From 459a0c33457bfaca6cb9d74924c32ceb855a597b 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 | 96 ++++++++++++++++++++++++------------------- 4 files changed, 108 insertions(+), 47 deletions(-) diff --git a/flake.lock b/flake.lock index 3349a883..20e181b8 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": { @@ -182,11 +202,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1710608262, - "narHash": "sha256-Tf2zqUWgU1iofcECQ+xj7HJVtoCz6yWG/oEIDmXxwXg=", + "lastModified": 1720498663, + "narHash": "sha256-juqJkkdAt44mOfA43q1qUHn7iWoK++81lR8Mh7N/EF8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d211b80d2944a41899a6ab24009d9729cca05e49", + "rev": "106e145e1d4583d1e2bb20e54947d15ad55e75e1", "type": "github" }, "original": { @@ -198,6 +218,7 @@ }, "root": { "inputs": { + "crane": "crane", "devour-flake": "devour-flake", "devshell": "devshell", "flake-compat": "flake-compat", @@ -207,10 +228,31 @@ "lib-extras": "lib-extras", "nixpkgs": "nixpkgs", "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 a5755afd..a1c4db66 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,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 @ { @@ -93,6 +101,7 @@ pkgsUnstable = lib.extras.nix.mkNixpkgs { inherit system; nixpkgs = inputs.nixpkgs-unstable; + overlays = [(import inputs.rust-overlay)]; }; }; diff --git a/pkgs/default.nix b/pkgs/default.nix index 8409533a..1e11ef87 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -56,7 +56,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 {}; rotki-bin = callPackage ./rotki-bin {}; sedge = callPackage ./sedge {inherit bls mcl;}; diff --git a/pkgs/reth/default.nix b/pkgs/reth/default.nix index 3c6299e0..9e8de944 100644 --- a/pkgs/reth/default.nix +++ b/pkgs/reth/default.nix @@ -4,53 +4,63 @@ lib, rustPlatform, stdenv, -}: -rustPlatform.buildRustPackage rec { - pname = "reth"; - version = "0.2.0-beta.6"; + 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"; - src = fetchFromGitHub { - owner = "paradigmxyz"; - repo = pname; - rev = "v${version}"; - hash = "sha256-ZcQ29AwlTU6rDiknlJbOo8JubXQOJg1UVMSlRb1l8Yk="; - }; - - 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 - ]; + buildInputs = lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + ]; + }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; +in + craneLib.buildPackage (commonArgs + // { + inherit cargoArtifacts; - # `x86_64-darwin` seems to have issues with jemalloc - buildNoDefaultFeatures = true; - buildFeatures = lib.optional (stdenv.system != "x86_64-darwin") "jemalloc"; + nativeBuildInputs = [ + cargo-nextest + # Doesn't actually depend on rust version, so using this hook from nixpkgs is fine + rustPlatform.bindgenHook + ]; - buildInputs = lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.Security - ]; + # `x86_64-darwin` seems to have issues with jemalloc + cargoExtraArgs = + "--no-default-features" + + ( + if stdenv.system != "x86_64-darwin" + then " --features jemalloc" + else "" + ); - # 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" - ]; + 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)'" + ]; - 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"]; - }; -} + 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"]; + }; + })