|
| 1 | +// Copyright 2025, Offchain Labs, Inc. |
| 2 | +// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md |
| 3 | +package arbtest |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "encoding/json" |
| 8 | + "testing" |
| 9 | + |
| 10 | + "github.com/google/go-cmp/cmp" |
| 11 | + |
| 12 | + "github.com/ethereum/go-ethereum/common" |
| 13 | + "github.com/ethereum/go-ethereum/common/hexutil" |
| 14 | + "github.com/ethereum/go-ethereum/params" |
| 15 | +) |
| 16 | + |
| 17 | +func TestEthConfig(t *testing.T) { |
| 18 | + ctx, cancel := context.WithCancel(context.Background()) |
| 19 | + defer cancel() |
| 20 | + |
| 21 | + builder := NewNodeBuilder(ctx).DefaultConfig(t, false) |
| 22 | + cleanup := builder.Build(t) |
| 23 | + defer cleanup() |
| 24 | + |
| 25 | + var result json.RawMessage |
| 26 | + |
| 27 | + l2rpc := builder.L2.Stack.Attach() |
| 28 | + err := l2rpc.CallContext(ctx, &result, "eth_config") |
| 29 | + Require(t, err) |
| 30 | + |
| 31 | + // Types are duplicated from go-ethereum/internal/ethapi/api.go |
| 32 | + type config struct { |
| 33 | + ActivationTime uint64 `json:"activationTime"` |
| 34 | + BlobSchedule *params.BlobConfig `json:"blobSchedule"` |
| 35 | + ChainId *hexutil.Big `json:"chainId"` |
| 36 | + ForkId hexutil.Bytes `json:"forkId"` |
| 37 | + Precompiles map[string]common.Address `json:"precompiles"` |
| 38 | + SystemContracts map[string]common.Address `json:"systemContracts"` |
| 39 | + } |
| 40 | + |
| 41 | + type configResponse struct { |
| 42 | + Current *config `json:"current"` |
| 43 | + Next *config `json:"next"` |
| 44 | + Last *config `json:"last"` |
| 45 | + } |
| 46 | + |
| 47 | + want := &configResponse{ |
| 48 | + Current: &config{ |
| 49 | + ActivationTime: 0, |
| 50 | + BlobSchedule: nil, |
| 51 | + ChainId: (*hexutil.Big)(hexutil.MustDecodeBig("0x64aba")), |
| 52 | + ForkId: (hexutil.Bytes)(hexutil.MustDecode("0x5cf0a7a3")), |
| 53 | + Precompiles: map[string]common.Address{ |
| 54 | + "ArbAddressTable": common.HexToAddress("0x0000000000000000000000000000000000000066"), |
| 55 | + "ArbAggregator": common.HexToAddress("0x000000000000000000000000000000000000006d"), |
| 56 | + "ArbBLS": common.HexToAddress("0x0000000000000000000000000000000000000067"), |
| 57 | + "ArbDebug": common.HexToAddress("0x00000000000000000000000000000000000000ff"), |
| 58 | + "ArbFunctionTable": common.HexToAddress("0x0000000000000000000000000000000000000068"), |
| 59 | + "ArbGasInfo": common.HexToAddress("0x000000000000000000000000000000000000006c"), |
| 60 | + "ArbInfo": common.HexToAddress("0x0000000000000000000000000000000000000065"), |
| 61 | + "ArbNativeTokenManager": common.HexToAddress("0x0000000000000000000000000000000000000073"), |
| 62 | + "ArbOwner": common.HexToAddress("0x0000000000000000000000000000000000000070"), |
| 63 | + "ArbOwnerPublic": common.HexToAddress("0x000000000000000000000000000000000000006b"), |
| 64 | + "ArbRetryableTx": common.HexToAddress("0x000000000000000000000000000000000000006e"), |
| 65 | + "ArbStatistics": common.HexToAddress("0x000000000000000000000000000000000000006f"), |
| 66 | + "ArbSys": common.HexToAddress("0x0000000000000000000000000000000000000064"), |
| 67 | + "ArbWasm": common.HexToAddress("0x0000000000000000000000000000000000000071"), |
| 68 | + "ArbWasmCache": common.HexToAddress("0x0000000000000000000000000000000000000072"), |
| 69 | + "ArbosActs": common.HexToAddress("0x00000000000000000000000000000000000a4b05"), |
| 70 | + "ArbosTest": common.HexToAddress("0x0000000000000000000000000000000000000069"), |
| 71 | + "BLAKE2F": common.HexToAddress("0x0000000000000000000000000000000000000009"), |
| 72 | + "BLS12_G1ADD": common.HexToAddress("0x000000000000000000000000000000000000000b"), |
| 73 | + "BLS12_G1MSM": common.HexToAddress("0x000000000000000000000000000000000000000c"), |
| 74 | + "BLS12_G2ADD": common.HexToAddress("0x000000000000000000000000000000000000000d"), |
| 75 | + "BLS12_G2MSM": common.HexToAddress("0x000000000000000000000000000000000000000e"), |
| 76 | + "BLS12_MAP_FP2_TO_G2": common.HexToAddress("0x0000000000000000000000000000000000000011"), |
| 77 | + "BLS12_MAP_FP_TO_G1": common.HexToAddress("0x0000000000000000000000000000000000000010"), |
| 78 | + "BLS12_PAIRING_CHECK": common.HexToAddress("0x000000000000000000000000000000000000000f"), |
| 79 | + "BN254_ADD": common.HexToAddress("0x0000000000000000000000000000000000000006"), |
| 80 | + "BN254_MUL": common.HexToAddress("0x0000000000000000000000000000000000000007"), |
| 81 | + "BN254_PAIRING": common.HexToAddress("0x0000000000000000000000000000000000000008"), |
| 82 | + "ECREC": common.HexToAddress("0x0000000000000000000000000000000000000001"), |
| 83 | + "ID": common.HexToAddress("0x0000000000000000000000000000000000000004"), |
| 84 | + "KZG_POINT_EVALUATION": common.HexToAddress("0x000000000000000000000000000000000000000a"), |
| 85 | + "MODEXP": common.HexToAddress("0x0000000000000000000000000000000000000005"), |
| 86 | + "P256VERIFY": common.HexToAddress("0x0000000000000000000000000000000000000100"), |
| 87 | + "RIPEMD160": common.HexToAddress("0x0000000000000000000000000000000000000003"), |
| 88 | + "SHA256": common.HexToAddress("0x0000000000000000000000000000000000000002"), |
| 89 | + }, |
| 90 | + SystemContracts: map[string]common.Address{ |
| 91 | + "HISTORY_STORAGE_ADDRESS": common.HexToAddress("0x0000f90827f1c53a10cb7a02335b175320002935"), |
| 92 | + }, |
| 93 | + }, |
| 94 | + Next: nil, |
| 95 | + Last: nil, |
| 96 | + } |
| 97 | + |
| 98 | + got := &configResponse{} |
| 99 | + Require(t, json.Unmarshal(result, got)) |
| 100 | + |
| 101 | + // Use go-cmp to show a readable structural diff on failure, and |
| 102 | + // also include pretty-printed JSON for both expected and actual. |
| 103 | + if diff := cmp.Diff(want, got, cmp.Transformer("hex", func(in *hexutil.Big) string { |
| 104 | + return in.String() |
| 105 | + })); diff != "" { |
| 106 | + t.Fatalf("config mismatch (-want +got):\n%s\n", diff) |
| 107 | + } |
| 108 | +} |
0 commit comments