Skip to content

Commit f8f7503

Browse files
authored
Update EIP-7910 implementation (#3571)
* Update EIP-7910 implementation There are a few different things going on in this pull request. 1. Implementing the Name() function for precompiles. 2. Adding a system test for calling the new eth_config RPC method. Fixes: NIT-3679 * Remove system contracts which aren't needed for Arbitrum These contracts are related to Ethereum's consensus and beacon chain functionality.
1 parent e1012c9 commit f8f7503

File tree

5 files changed

+124
-2
lines changed

5 files changed

+124
-2
lines changed

gethhook/geth-hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (p ArbosPrecompileWrapper) Run(input []byte) ([]byte, error) {
3030
}
3131

3232
func (p ArbosPrecompileWrapper) Name() string {
33-
panic("Non-advanced precompile method called")
33+
return p.inner.Name()
3434
}
3535

3636
func (p ArbosPrecompileWrapper) RunAdvanced(

go-ethereum

precompiles/precompile.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type ArbosPrecompile interface {
4848
) (output []byte, gasLeft uint64, err error)
4949

5050
Precompile() *Precompile
51+
Name() string
5152
}
5253

5354
type purity uint8
@@ -847,6 +848,11 @@ func (p *Precompile) Precompile() *Precompile {
847848
return p
848849
}
849850

851+
// Name returns the name of the precompile.
852+
func (p *Precompile) Name() string {
853+
return p.name
854+
}
855+
850856
// Get4ByteMethodSignatures is needed for the fuzzing harness
851857
func (p *Precompile) Get4ByteMethodSignatures() [][4]byte {
852858
ret := make([][4]byte, 0, len(p.methods))

precompiles/wrapper.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ func (wrapper *DebugPrecompile) Precompile() *Precompile {
5151
return wrapper.precompile.Precompile()
5252
}
5353

54+
func (wrapper *DebugPrecompile) Name() string {
55+
return wrapper.precompile.Name()
56+
}
57+
5458
// OwnerPrecompile is a precompile wrapper for those only chain owners may use
5559
type OwnerPrecompile struct {
5660
precompile ArbosPrecompile
@@ -117,3 +121,7 @@ func (wrapper *OwnerPrecompile) Precompile() *Precompile {
117121
con := wrapper.precompile
118122
return con.Precompile()
119123
}
124+
125+
func (wrapper *OwnerPrecompile) Name() string {
126+
return wrapper.precompile.Name()
127+
}

system_tests/eth_config_test.go

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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

Comments
 (0)