Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / blockchains / lighthouse / default.nix
blob2500ec5c28571db2b6136dadd5ef0e612fa73398
1 { clang
2 , cmake
3 , CoreFoundation
4 , fetchFromGitHub
5 , fetchurl
6 , lib
7 , lighthouse
8 , nix-update-script
9 , nodePackages
10 , perl
11 , pkg-config
12 , postgresql
13 , protobuf
14 , rustPlatform
15 , Security
16 , sqlite
17 , rust-jemalloc-sys
18 , stdenv
19 , SystemConfiguration
20 , testers
21 , unzip
24 rustPlatform.buildRustPackage rec {
25   pname = "lighthouse";
26   version = "4.5.0";
28   # lighthouse/common/deposit_contract/build.rs
29   depositContractSpecVersion = "0.12.1";
30   testnetDepositContractSpecVersion = "0.9.2.1";
32   src = fetchFromGitHub {
33     owner = "sigp";
34     repo = "lighthouse";
35     rev = "v${version}";
36     hash = "sha256-UUOvTxOQXT1zfhDYEL/J6moHAyejZn7GyGS/XBmXxRQ=";
37   };
39   patches = [
40     ./use-system-sqlite.patch
41   ];
43   postPatch = ''
44     cp ${./Cargo.lock} Cargo.lock
45   '';
47   cargoLock = {
48     lockFile = ./Cargo.lock;
49     outputHashes = {
50       "amcl-0.3.0" = "sha256-kc8k/ls4W0TwFBsRcyyotyz8ZBEjsZXHeJnJtsnW/LM=";
51       "anvil-rpc-0.1.0" = "sha256-L38OioxnWEn94g3GJT4j3U1cJZ8jQDHp8d1QOHaVEuU=";
52       "beacon-api-client-0.1.0" = "sha256-Z0CoPxZzl2bjb8vgmHWxq2orMawhMMs7beKGopilKjE=";
53       "ethereum-consensus-0.1.1" = "sha256-biTrw3yMJUo9+56QK5RGWXLCoPPZEWp18SCs+Y9QWg4=";
54       "libmdbx-0.1.4" = "sha256-NMsR/Wl1JIj+YFPyeMMkrJFfoS07iEAKEQawO89a+/Q=";
55       "lmdb-rkv-0.14.0" = "sha256-sxmguwqqcyOlfXOZogVz1OLxfJPo+Q0+UjkROkbbOCk=";
56       "mev-rs-0.3.0" = "sha256-LCO0GTvWTLcbPt7qaSlLwlKmAjt3CIHVYTT/JRXpMEo=";
57       "testcontainers-0.14.0" = "sha256-mSsp21G7MLEtFROWy88Et5s07PO0tjezovCGIMh+/oQ=";
58       "warp-0.3.5" = "sha256-d5e6ASdL7+Dl3KsTNOb9B5RHpStrupOKsbGWsdu9Jfk=";
59     };
60   };
62   buildFeatures = [ "modern" "gnosis" ];
64   nativeBuildInputs = [
65     rustPlatform.bindgenHook
66     cmake
67     perl
68     pkg-config
69     protobuf
70   ];
72   buildInputs = [
73     sqlite
74     rust-jemalloc-sys
75   ] ++ lib.optionals stdenv.isDarwin [
76     CoreFoundation
77     Security
78     SystemConfiguration
79   ];
81   depositContractSpec = fetchurl {
82     url = "https://raw.githubusercontent.com/ethereum/eth2.0-specs/v${depositContractSpecVersion}/deposit_contract/contracts/validator_registration.json";
83     hash = "sha256-ZslAe1wkmkg8Tua/AmmEfBmjqMVcGIiYHwi+WssEwa8=";
84   };
86   testnetDepositContractSpec = fetchurl {
87     url = "https://raw.githubusercontent.com/sigp/unsafe-eth2-deposit-contract/v${testnetDepositContractSpecVersion}/unsafe_validator_registration.json";
88     hash = "sha256-aeTeHRT3QtxBRSNMCITIWmx89vGtox2OzSff8vZ+RYY=";
89   };
91   LIGHTHOUSE_DEPOSIT_CONTRACT_SPEC_URL = "file://${depositContractSpec}";
92   LIGHTHOUSE_DEPOSIT_CONTRACT_TESTNET_URL = "file://${testnetDepositContractSpec}";
94   cargoBuildFlags = [
95     "--package lighthouse"
96   ];
98   __darwinAllowLocalNetworking = true;
100   checkFeatures = [ ];
102   # All of these tests require network access and/or docker
103   cargoTestFlags = [
104     "--workspace"
105     "--exclude beacon_node"
106     "--exclude beacon_chain"
107     "--exclude http_api"
108     "--exclude lighthouse"
109     "--exclude lighthouse_network"
110     "--exclude slashing_protection"
111     "--exclude watch"
112     "--exclude web3signer_tests"
113   ];
115   # All of these tests require network access
116   checkFlags = [
117     "--skip basic"
118     "--skip deposit_tree::cache_consistency"
119     "--skip deposit_tree::double_update"
120     "--skip deposit_tree::updating"
121     "--skip eth1_cache::big_skip"
122     "--skip eth1_cache::double_update"
123     "--skip eth1_cache::pruning"
124     "--skip eth1_cache::simple_scenario"
125     "--skip fast::deposit_cache_query"
126     "--skip http::incrementing_deposits"
127     "--skip persist::test_persist_caches"
128     "--skip service::tests::tests::test_dht_persistence"
129     "--skip time::test::test_reinsertion_updates_timeout"
130   ] ++ lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [
131     "--skip subnet_service::tests::attestation_service::test_subscribe_same_subnet_several_slots_apart"
132     "--skip subnet_service::tests::sync_committee_service::same_subscription_with_lower_until_epoch"
133     "--skip subnet_service::tests::sync_committee_service::subscribe_and_unsubscribe"
134   ];
136   nativeCheckInputs = [
137     nodePackages.ganache
138     postgresql
139   ];
141   passthru = {
142     tests.version = testers.testVersion {
143       package = lighthouse;
144       command = "lighthouse --version";
145       version = "v${lighthouse.version}";
146     };
147     updateScript = nix-update-script { };
148   };
150   meta = with lib; {
151     description = "Ethereum consensus client in Rust";
152     homepage = "https://lighthouse.sigmaprime.io/";
153     license = licenses.asl20;
154     maintainers = with maintainers; [ centromere pmw ];
155   };