ethereum.nix icon indicating copy to clipboard operation
ethereum.nix copied to clipboard

reth: 0.2.0-beta.6 -> 1.0.1

Open scottbot95 opened this issue 1 year ago • 14 comments
trafficstars

Reth recently had their 1.0, production-read release. This PR updates reth to the latest 1.0.1 release.

Considerations

I had to make several potentially controversial changes in order to get reth to build. Specifically two new flake inputs where added, rust-overlay and crane

rust-overlay

Reth requires Rust 1.79.0, this required pulling in the rust-overlay flake as even nixpkgs-unstable only has 1.78.0.

crane

The nixpkgs native rustPlatform.buildRustPackage is fairly rudimentary and doesn't play nicely with Rusts incremental compilation (it will re-download and rebuild your ENTIRE dependency closure every time the nix derivation is built). This is partially Rust's fault (since a package can change how it's dependencies are compiled), however the crane flake was designed to help improve this situation and reduce re-compile times. Crane also turned out to be required for testing as described below.

Testing

Reth has an extensive testing suite. These tests don't require nextest, however we only want to run the unit tests which is difficult to do with cargo test (would require a significant number of --skip args), but can easily be accomplished by providing -E '!kind(test)' to the nextest invocation. Additionally some "unit" tests require I/O access that is not compatible with the nix sandbox requiring us to skip several specific tests. In nextest this looks like -E '!kind(test) - test(tests::test_exex)'.

Unfortunately, when passing arguments via rustPlatform.buildRustPackage, nix tries to be "help" and will shell escape all arguments passed in. This completely breaks the -E args because it contains special characters that need to be included as-is to the actual call to cargo nextest run. There would be a workaround for this, simply have preCheck script that directly modifies cargoTestFlags, however unfortunately there is a bug in nixpkgs here where despite cargoTestFlags being an array, only the first element of that array is included in the final call (${cargoTestFlags} instead of the correct ${cargoTestFlags[@}}.

I have opted to use nextest since that is the officially supported testing platform with Reth and also executes >x3 faster than cargo test. This forced me to use crane due to the inability to properly pass in args to the cargo nextest run call with rustPlatform.buildRustPackage

scottbot95 avatar Jul 11 '24 16:07 scottbot95

If we don't like the the addition of the crane dependency, I think once https://github.com/NixOS/nixpkgs/pull/326365 is merged I should be able to refactor this to use buildRustPackage instead.

scottbot95 avatar Jul 13 '24 01:07 scottbot95

@scottbot95 I would prefer to wait instead to use buildRustPackage if possible rather than adding more external inputs (and it seems it's going to be merged soon).

aldoborrero avatar Jul 15 '24 08:07 aldoborrero

Sure that sounds reasonable to me. I will update once my change has been merged to nixpkgs.

That will also require I update the nixpkgs-unstable input. Would it be preferrable to update that as a separate PR or just include it in this one?

scottbot95 avatar Jul 15 '24 16:07 scottbot95

That will also require I update the nixpkgs-unstable input. Would it be preferrable to update that as a separate PR or just include it in this one?

@scottbot95 just include it on this one as it's tied to this specific work.

aldoborrero avatar Jul 19 '24 09:07 aldoborrero

@scottbot95 given the upstream PR for nixpkgs is taking more time than expected to be merged. Let's proceed and merge this work into master. We can refactor it on a separate PR and remove the extra inputs.

aldoborrero avatar Aug 09 '24 08:08 aldoborrero

Unfortunate, but that sounds reasonable to me. FWIW I have a local branch where I'm targeting my fork of nixpkgs and I have confirmed that it builds cleanly using buildRustPackage after my changes to nixpkgs

scottbot95 avatar Aug 09 '24 16:08 scottbot95

@scottbot95 is there anything else to account for or can I proceed with merging the PR?

aldoborrero avatar Aug 14 '24 14:08 aldoborrero

@aldoborrero I successfully used this commit to sync a holesky node so I think we should be good unless you care about bottoming out whatever the darwin issues are. Those might just go away when we switch back to buildRustPackage though. I don't have any darwin machines so it's rather difficult for me to test.

scottbot95 avatar Aug 15 '24 03:08 scottbot95

@scottbot95 would you mind fixing the conflict?

aldoborrero avatar Aug 15 '24 09:08 aldoborrero

Rebased against main

scottbot95 avatar Aug 18 '24 18:08 scottbot95

@scottbot95 thanks! Have a look at the following error.

aldoborrero avatar Aug 19 '24 12:08 aldoborrero

Sorry for taking a while to look at this. I think the issue is the rustPlatform.bindgenHook needs to be in commonArgs. I have pushed a potential fix but don't have a darwin machine so I have no easy to way test it locally.

scottbot95 avatar Sep 07 '24 23:09 scottbot95

Hmm still failing... I think this will require someone who actually understands darwin at all to resolve.

scottbot95 avatar Sep 07 '24 23:09 scottbot95

@brianmcgee would you be kind to test it on your Mac?

aldoborrero avatar Sep 10 '24 08:09 aldoborrero

Can we consider dropping darwin support for now for reth? If someone actually needs it, maybe they can also figure out what is wrong with the build command.

jhvst avatar Nov 01 '24 00:11 jhvst

Can we consider dropping darwin support for now for reth? If someone actually needs it, maybe they can also figure out what is wrong with the build command.

I think this makes sense, @aldoborrero @selfuryon ?

brianmcgee avatar Nov 04 '24 10:11 brianmcgee

It does. Let's proceed without darwin support.

aldoborrero avatar Nov 04 '24 10:11 aldoborrero

I'm closing this PR in favor of #560

aldoborrero avatar Jan 08 '25 09:01 aldoborrero