From 1139c94fefe0a7c2629423e4486c68d1abe408ee Mon Sep 17 00:00:00 2001 From: Scott Techau Date: Wed, 10 Jul 2024 22:46:47 +0000 Subject: [PATCH] reth: 0.2.0-beta.6 -> 1.0.1 --- flake.lock | 48 ++++++++++++++++-- flake.nix | 9 ++++ pkgs/default.nix | 2 +- pkgs/reth/default.nix | 110 ++++++++++++++++++++++++------------------ 4 files changed, 119 insertions(+), 50 deletions(-) diff --git a/flake.lock b/flake.lock index 9f74bf6c..a557fe79 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "crane": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720546058, + "narHash": "sha256-iU2yVaPIZm5vMGdlT0+57vdB/aPq/V5oZFBRwYw+HBM=", + "owner": "ipetkov", + "repo": "crane", + "rev": "2d83156f23c43598cf44e152c33a59d3892f8b29", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "devour-flake": { "flake": false, "locked": { @@ -198,11 +218,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1719317636, - "narHash": "sha256-bu0xbu2Z6DDzA9LGV81yJunIti6r7tjUImeR8orAL/I=", + "lastModified": 1720498663, + "narHash": "sha256-juqJkkdAt44mOfA43q1qUHn7iWoK++81lR8Mh7N/EF8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9c513fc6fb75142f6aec6b7545cb8af2236b80f5", + "rev": "d211b80d2944a41899a6ab24009d9729cca05e49", "type": "github" }, "original": { @@ -214,6 +234,7 @@ }, "root": { "inputs": { + "crane": "crane", "devour-flake": "devour-flake", "devshell": "devshell", "flake-compat": "flake-compat", @@ -224,10 +245,31 @@ "nixpkgs": "nixpkgs", "nixpkgs-2311": "nixpkgs-2311", "nixpkgs-unstable": "nixpkgs-unstable", + "rust-overlay": "rust-overlay", "systems": "systems", "treefmt-nix": "treefmt-nix" } }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs-unstable" + ] + }, + "locked": { + "lastModified": 1720491570, + "narHash": "sha256-PHS2BcQ9kxBpu9GKlDg3uAlrX/ahQOoAiVmwGl6BjD4=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "b970af40fdc4bd80fd764796c5f97c15e2b564eb", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 748a6cac..0a21421d 100644 --- a/flake.nix +++ b/flake.nix @@ -51,6 +51,14 @@ inputs.nixpkgs.follows = "nixpkgs"; inputs.treefmt-nix.follows = "treefmt-nix"; }; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; + crane = { + url = "github:ipetkov/crane"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs @ { @@ -95,6 +103,7 @@ pkgsUnstable = lib.extras.nix.mkNixpkgs { inherit system; nixpkgs = inputs.nixpkgs-unstable; + overlays = [(import inputs.rust-overlay)]; }; pkgs2311 = lib.extras.nix.mkNixpkgs { inherit system; diff --git a/pkgs/default.nix b/pkgs/default.nix index 1402c42b..5cccd66c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -59,7 +59,7 @@ nethermind = callPackageUnstable ./nethermind {}; nimbus = callPackageUnstable ./nimbus {}; prysm = callPackage ./prysm {inherit bls blst;}; - reth = callPackageUnstable ./reth {}; + reth = callPackageUnstable ./reth {inherit (inputs) crane;}; rocketpool = callPackage ./rocketpool {}; rocketpoold = callPackage ./rocketpoold {inherit bls blst;}; rotki-bin = callPackage2311 ./rotki-bin {}; diff --git a/pkgs/reth/default.nix b/pkgs/reth/default.nix index 3c6299e0..02538a08 100644 --- a/pkgs/reth/default.nix +++ b/pkgs/reth/default.nix @@ -4,53 +4,71 @@ lib, rustPlatform, stdenv, -}: -rustPlatform.buildRustPackage rec { - pname = "reth"; - version = "0.2.0-beta.6"; - - src = fetchFromGitHub { - owner = "paradigmxyz"; - repo = pname; - rev = "v${version}"; - hash = "sha256-ZcQ29AwlTU6rDiknlJbOo8JubXQOJg1UVMSlRb1l8Yk="; - }; + pkgs, + crane, + cargo-nextest, +}: let + craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default); + commonArgs = rec { + pname = "reth"; + version = "1.0.1"; - cargoLock = { - lockFile = "${src}/Cargo.lock"; - outputHashes = { - "alloy-consensus-0.1.0" = "sha256-2TZeQo0d+Yp0M46VNx3OZoyDT4F31cLdOpl1tk3syfg="; - "discv5-0.4.1" = "sha256-agrluN1C9/pS/IMFTVlPOuYl3ZuklnTYb46duVvTPio="; - "revm-inspectors-0.1.0" = "sha256-ZRlYNEHD+wewlttUcMuEoTYg9Hn89JVAr7+hIeMBXog="; + src = fetchFromGitHub { + owner = "paradigmxyz"; + repo = pname; + rev = "v${version}"; + hash = "sha256-GqBNyPeXIN7q2m3SkhP4BUYXyEQYlkP0JH/pKgEvf7k="; }; - }; + strictDeps = true; - nativeBuildInputs = [ - rustPlatform.bindgenHook - ]; - - # `x86_64-darwin` seems to have issues with jemalloc - buildNoDefaultFeatures = true; - buildFeatures = lib.optional (stdenv.system != "x86_64-darwin") "jemalloc"; - - buildInputs = lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.Security - ]; - - # Some tests fail due to I/O that is unfriendly with nix sandbox. - checkFlags = [ - "--skip=builder::tests::block_number_node_config_test" - "--skip=builder::tests::launch_multiple_nodes" - "--skip=builder::tests::rpc_handles_none_without_http" - "--skip=cli::tests::override_trusted_setup_file" - "--skip=cli::tests::parse_env_filter_directives" - ]; - - meta = with lib; { - description = "Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust"; - homepage = "https://github.com/paradigmxyz/reth"; - license = with licenses; [mit asl20]; - mainProgram = "reth"; - platforms = ["aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux"]; + buildInputs = lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + ]; + + nativeBuildInputs = [ + # Doesn't actually depend on rust version, so using this hook from nixpkgs is fine + rustPlatform.bindgenHook + ]; }; -} + cargoArtifacts = craneLib.buildDepsOnly commonArgs; +in + craneLib.buildPackage (commonArgs + // { + inherit cargoArtifacts; + + nativeBuildInputs = + commonArgs.nativeBuildInputs + ++ [ + cargo-nextest + ]; + + # `x86_64-darwin` seems to have issues with jemalloc + cargoExtraArgs = + "--no-default-features" + + ( + if stdenv.system != "x86_64-darwin" + then " --features jemalloc" + else "" + ); + + cargoTestCommand = "cargo nextest run"; + cargoTestExtraArgs = builtins.concatStringsSep " " [ + "--hide-progress-bar" + "--workspace" + "--exclude ef-tests" + "-E" + # Only run unit tests (`!kind(test)`) and skip several tests which can't run within the nix sandbox + "'!kind(test) - test(cli::tests::parse_env_filter_directives) - test(tests::test_exex) - test(auth_layer::tests::test_jwt_layer)'" + ]; + + # https://crane.dev/faq/rebuilds-bindgen.html + NIX_OUTPATH_USED_AS_RANDOM_SEED = "aaaaaaaaaa"; + + meta = with lib; { + description = "Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust"; + homepage = "https://github.com/paradigmxyz/reth"; + license = with licenses; [mit asl20]; + mainProgram = "reth"; + platforms = ["aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux"]; + }; + })