Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reth: 0.2.0-beta.6 -> 1.0.1 #530

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

scottbot95
Copy link
Contributor

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

buildInputs = lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];
cargoExtraArgs = "--no-default-features" + (if stdenv.system != "x86_64-darwin" then " --features jemalloc" else "");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There has been >1000 commits since 0.2.0-beta.6. It is entirely possible this is no longer required, however I have no way to test x86_64-darwin.

@scottbot95
Copy link
Contributor Author

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

@aldoborrero
Copy link
Collaborator

@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).

@scottbot95
Copy link
Contributor Author

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?

@aldoborrero
Copy link
Collaborator

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
Copy link
Collaborator

@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.

@scottbot95
Copy link
Contributor Author

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

@aldoborrero
Copy link
Collaborator

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

@scottbot95
Copy link
Contributor Author

@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.

@aldoborrero
Copy link
Collaborator

@scottbot95 would you mind fixing the conflict?

@scottbot95
Copy link
Contributor Author

Rebased against main

@aldoborrero
Copy link
Collaborator

@scottbot95
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@aldoborrero
Copy link
Collaborator

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

@jhvst
Copy link
Contributor

jhvst commented Nov 1, 2024

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.

@brianmcgee
Copy link
Collaborator

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 ?

@aldoborrero
Copy link
Collaborator

It does. Let's proceed without darwin support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants