diff --git a/validation/genesis/genesis-allocs_test.go b/validation/genesis/genesis-allocs_test.go index 045a75a00..61cd0e096 100644 --- a/validation/genesis/genesis-allocs_test.go +++ b/validation/genesis/genesis-allocs_test.go @@ -159,6 +159,8 @@ func testGenesisAllocs(t *testing.T, chain *ChainConfig) { require.NoError(t, err) allocs := types.GenesisAlloc{} err = json.Unmarshal(expectedData, &allocs) + removeEmptyStorageSlots(allocs, t) + require.NoError(t, err) expectedData, err = json.MarshalIndent(allocs, "", " ") require.NoError(t, err) @@ -167,12 +169,14 @@ func testGenesisAllocs(t *testing.T, chain *ChainConfig) { require.NoError(t, err) gen := core.Genesis{} err = json.Unmarshal(expectedData, &gen) + removeEmptyStorageSlots(gen.Alloc, t) require.NoError(t, err) expectedData, err = json.MarshalIndent(gen.Alloc, "", " ") require.NoError(t, err) } g, err := core.LoadOPStackGenesis(chainId) + removeEmptyStorageSlots(g.Alloc, t) require.NoError(t, err) if chainId == uint64(1301) { @@ -214,6 +218,18 @@ func testGenesisAllocs(t *testing.T, chain *ChainConfig) { require.Equal(t, string(expectedData), string(gotData)) } +// This function removes empty storage slots as we know declaring empty slots is functionally equivalent to not declaring them. +func removeEmptyStorageSlots(allocs types.GenesisAlloc, t *testing.T) { + for _, account := range allocs { + for slot, value := range account.Storage { + if value == (common.Hash{}) { + delete(account.Storage, slot) + t.Log("Removed empty storage slot: ", slot.Hex()) + } + } + } +} + // trim the CBOR octets from the bytecode of a weth9 contract func trimWeth9BytecodeMetadataHash(data []byte) ([]byte, error) { var weth9Data map[string]interface{}