From 2654296f5f13731ee890f5e59b8e98e3587b2146 Mon Sep 17 00:00:00 2001 From: TucksonDev Date: Thu, 20 Nov 2025 16:42:56 +0000 Subject: [PATCH 1/2] Clean generated chain config --- genesis/genesis.json | 4 +--- script/Predeploys.s.sol | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/genesis/genesis.json b/genesis/genesis.json index ef291f4..26b7302 100644 --- a/genesis/genesis.json +++ b/genesis/genesis.json @@ -262,9 +262,7 @@ "DataAvailabilityCommittee": false, "InitialArbOSVersion": 40, "InitialChainOwner": "0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E", - "GenesisBlockNum": 0, - "MaxCodeSize": 24576, - "MaxInitCodeSize": 49152 + "GenesisBlockNum": 0 } }, "difficulty": "0x1", diff --git a/script/Predeploys.s.sol b/script/Predeploys.s.sol index b3f9198..9f8e937 100644 --- a/script/Predeploys.s.sol +++ b/script/Predeploys.s.sol @@ -803,7 +803,7 @@ contract Predeploys is Script { vm.toString(arbOSVersion), ',"InitialChainOwner":"', vm.toString(chainOwner), - '","GenesisBlockNum":0,"MaxCodeSize":24576,"MaxInitCodeSize":49152}}' + '","GenesisBlockNum":0}}' ) ); vm.serializeString(genesisJson, "nonce", "0x0"); From 0547853516294303eedc8d4df35420cf9f339c53 Mon Sep 17 00:00:00 2001 From: TucksonDev Date: Fri, 21 Nov 2025 12:25:19 +0000 Subject: [PATCH 2/2] Minify chain config before printing the genesis json file contents --- Dockerfile | 6 ++++++ generate.sh | 18 ++++++++++++++++++ genesis/genesis.json | 32 ++------------------------------ 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/Dockerfile b/Dockerfile index 42b22cb..6919914 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,12 @@ # syntax=docker/dockerfile:1 FROM ghcr.io/foundry-rs/foundry:v1.4.2 +# Install dependencies (jq) +USER root +RUN apt-get update && \ + apt-get install -y jq +USER foundry + # Copy code into container WORKDIR /app COPY . . diff --git a/generate.sh b/generate.sh index 5ed2b17..5a6bbfd 100755 --- a/generate.sh +++ b/generate.sh @@ -23,5 +23,23 @@ forge script script/Predeploys.s.sol:Predeploys \ --chain-id $CHAIN_ID \ > /dev/null +# Minify the chainConfig property in the generated genesis file +# NOTE: we need to minify the chainConfig because nitro will use it to obtain the genesis blockhash, +# and if there are any unnecessary whitespaces, the blockhash will be different from what is found on-chain. +PLACEHOLDER="__CONFIG_MINIFIED__" +GENESIS_FILE="genesis/genesis.json" +config_minified=$(jq -c '.config' "$GENESIS_FILE") + +# Set the placeholder in the chainConfig property and save the result +tmp=$(mktemp) +jq --arg ph "$PLACEHOLDER" '.config = $ph' "$GENESIS_FILE" | jq '.' > "$tmp" + +# Replace the placeholder with the minified config +awk -v ph="\"$PLACEHOLDER\"" -v rep="$config_minified" ' + { sub(ph, rep); print } +' "$tmp" > "$GENESIS_FILE" + +rm "$tmp" + # Output the generated genesis file cat genesis/genesis.json \ No newline at end of file diff --git a/genesis/genesis.json b/genesis/genesis.json index 26b7302..82463d7 100644 --- a/genesis/genesis.json +++ b/genesis/genesis.json @@ -236,39 +236,11 @@ } }, "coinbase": "0x0000000000000000000000000000000000000000", - "config": { - "chainId": 31337, - "homesteadBlock": 0, - "daoForkBlock": null, - "daoForkSupport": true, - "eip150Block": 0, - "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "muirGlacierBlock": 0, - "berlinBlock": 0, - "londonBlock": 0, - "clique": { - "period": 0, - "epoch": 0 - }, - "arbitrum": { - "EnableArbOS": true, - "AllowDebugPrecompiles": false, - "DataAvailabilityCommittee": false, - "InitialArbOSVersion": 40, - "InitialChainOwner": "0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E", - "GenesisBlockNum": 0 - } - }, + "config": {"chainId":31337,"homesteadBlock":0,"daoForkBlock":null,"daoForkSupport":true,"eip150Block":0,"eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000","eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"berlinBlock":0,"londonBlock":0,"clique":{"period":0,"epoch":0},"arbitrum":{"EnableArbOS":true,"AllowDebugPrecompiles":false,"DataAvailabilityCommittee":false,"InitialArbOSVersion":40,"InitialChainOwner":"0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E","GenesisBlockNum":0}}, "difficulty": "0x1", "extraData": "0x", "gasLimit": "0x1C9C380", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0", "timestamp": "0x0" -} \ No newline at end of file +}