Skip to content

Commit 458a915

Browse files
feat(devnet): ensure eth execution layer is auto-mining (#8)
1 parent 10bee1f commit 458a915

File tree

6 files changed

+57
-19
lines changed

6 files changed

+57
-19
lines changed

flake.nix

+8-2
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,21 @@
6767
{
6868
_module = {
6969
args = {
70-
7170
inherit crane;
7271
pkgs = import nixpkgs {
7372
inherit system;
7473
overlays = with inputs; [
7574
rust-overlay.overlays.default
7675
];
7776
};
78-
devnetConfig = { validatorCount = 4; };
77+
devnetConfig = {
78+
validatorCount = 4;
79+
ethereum = {
80+
beacon = {
81+
validatorCount = 64;
82+
};
83+
};
84+
};
7985
proto = {
8086
uniond = builtins.path {
8187
name = "uniond-proto";

networks/devnet.nix

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
};
3232
prysm-validator = import ./services/prysm-validator.nix {
3333
inherit pkgs;
34+
validatorCount = devnetConfig.ethereum.beacon.validatorCount;
3435
prysm-validator = self'.packages.prysm-validator;
3536
config = self'.packages.devnet-prysm-config;
3637
};

networks/genesis/devnet-evm/genesis.json

+35-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"arrowGlacierBlock": 0,
1818
"grayGlacierBlock": 0,
1919
"shanghaiTime": 1681499865,
20-
"terminalTotalDifficulty": 0,
20+
"terminalTotalDifficulty": 0,
2121
"clique": {
2222
"period": 5,
2323
"epoch": 30000
@@ -26,11 +26,44 @@
2626
"nonce": "0x0",
2727
"timestamp": "0x6439a649",
2828
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000123463a4b065722e99115d6c222f267d9cabb5240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
29-
"gasLimit": "0x1c9c380",
29+
"gasLimit": "0x1c9c380",
3030
"difficulty": "0x1",
3131
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
3232
"coinbase": "0x0000000000000000000000000000000000000000",
3333
"alloc": {
34+
"ceaBb9dE7Bdf6F20A42c7ffBBc722Eee776B3684": {
35+
"balance": "100000000000000000000"
36+
},
37+
"Be68fC2d8249eb60bfCf0e71D5A0d2F2e292c4eD": {
38+
"balance": "100000000000000000000"
39+
},
40+
"89b4AB1eF20763630df9743ACF155865600daFF2": {
41+
"balance": "100000000000000000000"
42+
},
43+
"04E00e6D2e9Ea1E2AF553De02A5172120BFA5c3e": {
44+
"balance": "100000000000000000000"
45+
},
46+
"a255dC78C1510e2c1332fBAC2de848058f479CEE": {
47+
"balance": "100000000000000000000"
48+
},
49+
"ACbd24742b87c34dED607FB87b22401B2Ede167E": {
50+
"balance": "100000000000000000000"
51+
},
52+
"01F6749035e02205768f97e6f1d394Fb6769EC20": {
53+
"balance": "100000000000000000000"
54+
},
55+
"8b66D5499F52D6F1857084A61743dFCB9a712859": {
56+
"balance": "100000000000000000000"
57+
},
58+
"13e16C4e5787f878f98a610EB321170512b134D4": {
59+
"balance": "100000000000000000000"
60+
},
61+
"eEBFA6B9242A19f91a0463291A937a20e3355681": {
62+
"balance": "100000000000000000000"
63+
},
64+
"87D987206180B8f3807Dd90455606eEa85cdB87a": {
65+
"balance": "100000000000000000000"
66+
},
3467
"123463a4b065722e99115d6c222f267d9cabb524": {
3568
"balance": "0x43c33c1937564800000"
3669
},

networks/genesis/devnet.nix

+7-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
mkHome = { genesisAccounts }:
1414
pkgs.runCommand "genesis-home" { } ''
1515
mkdir -p $out
16-
16+
1717
# Generate the wasm client genesis state
1818
base64 -w0 ${self'.packages.wasm-ethereum-lc}/lib/union_ethereum_lc.wasm > $out/encoded.txt
1919
${uniond} init testnet bn254 --chain-id ${chainId} --home $out
@@ -26,11 +26,11 @@
2626
cat $out/config/genesis.json | \
2727
${pkgs.jq}/bin/jq --arg code_id $CODE_ID --rawfile encoded_file $out/encoded.txt '.app_state."08-wasm".contracts'='[ { "code_id_key": $code_id, "contract_code": $encoded_file } ]' \
2828
> $out/tmp-genesis.json
29-
29+
3030
# TODO(aeryz): This can be enabled with `CODE_ID_B64` line if we want to add the client at the genesis.
3131
# | ${pkgs.jq}/bin/jq --arg code_id $CODE_ID_B64 .app_state.ibc.client_genesis.clients='[{"client_id":"08-wasm-0","client_state":{"@type":"/ibc.lightclients.wasm.v1.ClientState","code_id":$code_id,"data":"e30=","latest_height":{"revision_height":"2","revision_number":"0"}}}]' | ${pkgs.jq}/bin/jq .app_state.ibc.client_genesis.clients_consensus='[{"client_id":"08-wasm-0","consensus_states":[{"consensus_state":{"@type":"/ibc.lightclients.wasm.v1.ConsensusState","data":"e30=","timestamp":"1678732260023000000"},"height":{"revision_height":"1","revision_number":"0"}}]}]' \
3232
mv $out/tmp-genesis.json $out/config/genesis.json
33-
33+
3434
# Add the dev account
3535
ADDRESS=`echo 'wine parrot nominee girl exchange element pudding grow area twenty next junior come render shadow evidence sentence start rough debate feed all limb real' | ${uniond} keys add --recover testkey --keyring-backend test --home $out --output json | ${pkgs.jq}/bin/jq -r .address`
3636
${uniond} add-genesis-account $ADDRESS 10000000000000000000000000stake --keyring-backend test --home $out
@@ -65,12 +65,11 @@
6565
mkGethPrysmGenesis = {}:
6666
pkgs.runCommand "geth-prysm-genesis" { } ''
6767
mkdir -p $out
68-
cp ${./devnet-evm/genesis.json} "./genesis.json"
69-
70-
${prysmctl} \
71-
testnet generate-genesis \
68+
cp ${./devnet-evm/genesis.json} ./genesis.json
69+
70+
${prysmctl} testnet generate-genesis \
7271
--fork=bellatrix \
73-
--num-validators=64 \
72+
--num-validators=${toString devnetConfig.ethereum.beacon.validatorCount} \
7473
--output-ssz=$out/genesis.ssz \
7574
--chain-config-file=${./devnet-evm/beacon-config.yml} \
7675
--geth-genesis-json-in=./genesis.json \
@@ -128,7 +127,6 @@
128127
};
129128

130129
packages.devnet-geth-config = pkgs.linkFarm "devnet-geth-config" [
131-
{ name = "genesis.json"; path = "${./devnet-evm/genesis.json}"; }
132130
{ name = "beacon-config.yml"; path = "${./devnet-evm/beacon-config.yml}"; }
133131
{ name = "dev-key0.prv"; path = "${./devnet-evm/dev-key0.prv}"; }
134132
{ name = "dev-key1.prv"; path = "${./devnet-evm/dev-key1.prv}"; }

networks/services/geth.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let
88
DATADIR=.
99
ETH_DATADIR=$DATADIR/geth
1010
cp ${genesis}/genesis.json "$DATADIR/genesis.json"
11-
11+
1212
geth init --datadir "$ETH_DATADIR" "$DATADIR/genesis.json"
1313
geth account import --datadir "$ETH_DATADIR" \
1414
--password /dev/null ${config}/dev-key0.prv
@@ -52,7 +52,7 @@ in
5252
];
5353
command = [ "${geth-init}/bin/geth-init" ];
5454
healthcheck = {
55-
start_period = "5s";
55+
start_period = "20s";
5656
interval = "10s";
5757
retries = 4;
5858
test = [

networks/services/prysm-validator.nix

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs, prysm-validator, config, ... }:
1+
{ pkgs, prysm-validator, config, validatorCount, ... }:
22
let
33
prysm-validator-init = pkgs.writeShellApplication {
44
name = "prysm-validator-init";
@@ -11,7 +11,7 @@ let
1111
--beacon-rpc-provider=prysm-beacon:4000 \
1212
--datadir=./validatordata \
1313
--accept-terms-of-use \
14-
--interop-num-validators=64 \
14+
--interop-num-validators=${toString validatorCount} \
1515
--interop-start-index=0 \
1616
--chain-config-file=${config}/beacon-config.yml
1717
'';
@@ -27,8 +27,8 @@ in
2727
networks = [ "union-devnet" ];
2828
command = [ (pkgs.lib.getExe prysm-validator-init) ];
2929
depends_on = {
30-
geth = {
31-
condition = "service_healthy";
30+
prysm-beacon = {
31+
condition = "service_started";
3232
};
3333
};
3434
};

0 commit comments

Comments
 (0)