Skip to content

Commit 410610c

Browse files
authored
Centralize all validation exclusions (#357)
* centralize most exclusions * move uniqueness exclusions to central location * move gpo exclusions to central location * move testL1SecurityConfig exclusions to central location * lint
1 parent 2e03300 commit 410610c

File tree

9 files changed

+90
-100
lines changed

9 files changed

+90
-100
lines changed

validation/chainid-rpc_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ import (
1010
)
1111

1212
func testChainIDFromRPC(t *testing.T, chain *ChainConfig) {
13-
isExcluded := map[uint64]bool{
14-
11155421: true, // sepolia-dev-0/oplabs-devnet-0 No Public RPC declared
15-
11763072: true, // sepolia-dev-0/base-devnet-0 No Public RPC declared
16-
}
17-
if isExcluded[chain.ChainID] {
18-
t.Skip("chain excluded from chain ID RPC check")
19-
}
13+
skipIfExcluded(t, chain.ChainID)
2014
// Create an ethclient connection to the specified RPC URL
2115
client, err := ethclient.Dial(chain.PublicRPC)
2216
require.NoError(t, err, "Failed to connect to the Ethereum client at RPC url %s", chain.PublicRPC)

validation/exclusions_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package validation
2+
3+
import (
4+
"regexp"
5+
"testing"
6+
)
7+
8+
func skipIfExcluded(t *testing.T, chainID uint64) {
9+
for pattern := range exclusions {
10+
matches, err := regexp.Match(pattern, []byte(t.Name()))
11+
if err != nil {
12+
panic(err)
13+
}
14+
if matches && exclusions[pattern][chainID] {
15+
t.Skip("Excluded!")
16+
}
17+
}
18+
}
19+
20+
var exclusions = map[string]map[uint64]bool{
21+
"ChainID_RPC_Check": {
22+
11155421: true, // sepolia-dev-0/oplabs-devnet-0 No Public RPC declared
23+
11763072: true, // sepolia-dev-0/base-devnet-0 No Public RPC declared
24+
},
25+
"GPO_Params": {
26+
11155421: true, // sepolia-dev-0/oplabs-devnet-0 (no public endpoint)
27+
11763072: true, // sepolia-dev-0/base-devnet-0 (no public endpoint)
28+
},
29+
"L2OO_Params": {
30+
10: true, // OP mainnet - Upgraded to fault proofs
31+
999999999: true, // sepolia/zora Incorrect finalizationPeriodSeconds, 604800 is not within bounds [12 12]
32+
1740: true, // sepolia/metal Incorrect finalizationPeriodSeconds, 604800 is not within bounds [12 12]
33+
919: true, // sepolia/mode Incorrect finalizationPeriodSeconds, 180 is not within bounds [12 12]
34+
11155420: true, // sepolia/op No L2OO because this chain uses Fault Proofs https://github.com/ethereum-optimism/superchain-registry/issues/219
35+
11155421: true, // oplabs-sepolia-devnet-0 No L2OO because this chain uses Fault Proofs https://github.com/ethereum-optimism/superchain-registry/issues/219
36+
},
37+
"L1_Security_Config": {
38+
8453: true, // base (incorrect challenger, incorrect guardian)
39+
11763072: true, // base-devnet-0 (incorrect challenger, incorrect guardian)
40+
90001: true, // race (incorrect challenger, incorrect guardian)
41+
84532: true, // base-sepolia (incorrect challenger)
42+
7777777: true, // zora (incorrect challenger)
43+
1750: true, // metal (incorrect challenger)
44+
919: true, // mode sepolia (incorrect challenger)
45+
999999999: true, // zora sepolia (incorrect challenger)
46+
34443: true, // mode (incorrect challenger)
47+
},
48+
"L2_Security_Config": {
49+
11155421: true, // sepolia-dev-0/oplabs-devnet-0 No Public RPC declared
50+
11763072: true, // sepolia-dev-0/base-devnet-0 No Public RPC declared
51+
},
52+
"Genesis_Hash_Check": {
53+
10: true, // OP Mainnet
54+
},
55+
"Genesis_RPC_Check": {
56+
11155421: true, // sepolia-dev-0/oplabs-devnet-0 No Public RPC declared
57+
11763072: true, // sepolia-dev-0/base-devnet-0 No Public RPC declared
58+
},
59+
"Standard_Contract_Versions": {
60+
8453: true, // mainnet/base
61+
11155421: true, // sepolia-dev-0/oplabs-devnet-0
62+
11763072: true, // sepolia-dev-0/base-devnet-0
63+
},
64+
"Uniqueness_Check": {
65+
11155421: true, // oplabs devnet 0, not in upstream repo
66+
11763072: true, // base devnet 0, not in upstream repo}
67+
},
68+
}

validation/gpo-params_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
)
2020

2121
func testGasPriceOracleParams(t *testing.T, chain *ChainConfig) {
22+
skipIfExcluded(t, chain.ChainID)
23+
2224
gasPriceOraclAddr := predeploys.GasPriceOracleAddr
2325

2426
checkPreEcotoneResourceConfig := func(t *testing.T, chain *ChainConfig, client *ethclient.Client) {
@@ -57,13 +59,6 @@ func testGasPriceOracleParams(t *testing.T, chain *ChainConfig) {
5759
}
5860
}
5961

60-
isExcluded := map[uint64]bool{
61-
11155421: true, // sepolia-dev-0/oplabs-devnet-0 (no public endpoint)
62-
11763072: true, // sepolia-dev-0/base-devnet-0 (no public endpoint)
63-
}
64-
if isExcluded[chain.ChainID] {
65-
t.Skip()
66-
}
6762
rpcEndpoint := chain.PublicRPC
6863
require.NotEmpty(t, rpcEndpoint, "no public endpoint for chain")
6964
client, err := ethclient.Dial(rpcEndpoint)

validation/l2oo_test.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,7 @@ type L2OOParams struct {
2424
}
2525

2626
func testL2OOParams(t *testing.T, chain *ChainConfig) {
27-
isExcluded := map[uint64]bool{
28-
10: true, // OP mainnet - Upgraded to fault proofs
29-
999999999: true, // sepolia/zora Incorrect finalizationPeriodSeconds, 604800 is not within bounds [12 12]
30-
1740: true, // sepolia/metal Incorrect finalizationPeriodSeconds, 604800 is not within bounds [12 12]
31-
919: true, // sepolia/mode Incorrect finalizationPeriodSeconds, 180 is not within bounds [12 12]
32-
11155420: true, // sepolia/op No L2OO because this chain uses Fault Proofs https://github.com/ethereum-optimism/superchain-registry/issues/219
33-
11155421: true, // oplabs-sepolia-devnet-0 No L2OO because this chain uses Fault Proofs https://github.com/ethereum-optimism/superchain-registry/issues/219
34-
}
35-
if isExcluded[chain.ChainID] {
36-
t.Skip()
37-
}
27+
skipIfExcluded(t, chain.ChainID)
3828

3929
rpcEndpoint := Superchains[chain.Superchain].Config.L1.PublicRPC
4030

validation/security-configs_test.go

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ var checkResolutions = func(t *testing.T, r standard.Resolutions, chainID uint64
5252
}
5353

5454
func testL1SecurityConfig(t *testing.T, chainID uint64) {
55+
skipIfExcluded(t, chainID)
56+
5557
rpcEndpoint := Superchains[OPChains[chainID].Superchain].Config.L1.PublicRPC
5658
require.NotEmpty(t, rpcEndpoint, "no rpc specified")
5759

@@ -72,20 +74,7 @@ func testL1SecurityConfig(t *testing.T, chainID uint64) {
7274

7375
checkResolutions(t, standard.Config.Roles.L1.GetResolutions(isFaultProofs), chainID, client)
7476

75-
isExcluded := map[uint64]bool{
76-
8453: true, // base (incorrect challenger, incorrect guardian)
77-
11763072: true, // base-devnet-0 (incorrect challenger, incorrect guardian)
78-
90001: true, // race (incorrect challenger, incorrect guardian)
79-
84532: true, // base-sepolia (incorrect challenger)
80-
7777777: true, // zora (incorrect challenger)
81-
1750: true, // metal (incorrect challenger)
82-
919: true, // mode sepolia (incorrect challenger)
83-
999999999: true, // zora sepolia (incorrect challenger)
84-
34443: true, // mode (incorrect challenger)
85-
}
86-
if !isExcluded[chainID] {
87-
checkResolutions(t, standard.Config.MultisigRoles[OPChains[chainID].Superchain].L1.GetResolutions(isFaultProofs), chainID, client)
88-
}
77+
checkResolutions(t, standard.Config.MultisigRoles[OPChains[chainID].Superchain].L1.GetResolutions(isFaultProofs), chainID, client)
8978

9079
// Perform an extra check on a mapping value of "L1CrossDomainMessengerProxy":
9180
// This is because L1CrossDomainMessenger's proxy is a ResolvedDelegateProxy, and
@@ -106,15 +95,7 @@ func testL1SecurityConfig(t *testing.T, chainID uint64) {
10695
}
10796

10897
func testL2SecurityConfig(t *testing.T, chain *ChainConfig) {
109-
isExcluded := map[uint64]bool{
110-
11155421: true, // sepolia-dev-0/oplabs-devnet-0 No Public RPC declared
111-
11763072: true, // sepolia-dev-0/base-devnet-0 No Public RPC declared
112-
}
113-
114-
if isExcluded[chain.ChainID] {
115-
t.Skip("chain excluded from check")
116-
}
117-
98+
skipIfExcluded(t, chain.ChainID)
11899
// Create an ethclient connection to the specified RPC URL
119100
client, err := ethclient.Dial(chain.PublicRPC)
120101
require.NoError(t, err, "Failed to connect to the Ethereum client at RPC url %s", chain.PublicRPC)

validation/superchain-genesis_test.go

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ import (
1515
)
1616

1717
func testGenesisHash(t *testing.T, chainID uint64) {
18-
if chainID == 10 {
19-
t.Skipf("chain %d: EXCLUDED from Genesis block hash validation", chainID)
20-
}
21-
18+
skipIfExcluded(t, chainID)
2219
chainConfig, ok := OPChains[chainID]
2320
if !ok {
2421
t.Fatalf("no chain with ID %d found", chainID)
@@ -40,34 +37,11 @@ func testGenesisHash(t *testing.T, chainID uint64) {
4037
require.Equal(t, common.Hash(declaredGenesisHash), computedGenesisHash, "chain %d: Genesis block hash must match computed value", chainID)
4138
}
4239

43-
// This check should apply to ALL chains in the registry, as it protects downstream code (op-geth)
44-
func TestGenesisHash(t *testing.T) {
45-
isExcluded := map[uint64]bool{
46-
10: true, // OP Mainnet, requires override (see https://github.com/ethereum-optimism/op-geth/blob/daade41d463b4ff332c6ed955603e47dcd25528b/core/superchain.go#L83-L94)
47-
}
48-
for chainID, chain := range OPChains {
49-
t.Run(perChainTestName(chain), func(t *testing.T) {
50-
if isExcluded[chain.ChainID] {
51-
t.Skipf("chain %d: EXCLUDED from Genesis block hash validation", chainID)
52-
}
53-
testGenesisHash(t, chainID)
54-
})
55-
}
56-
}
57-
5840
func testGenesisHashAgainstRPC(t *testing.T, chain *ChainConfig) {
59-
isExcluded := map[uint64]bool{
60-
11155421: true, // sepolia-dev-0/oplabs-devnet-0 (no public endpoint)
61-
11763072: true, // sepolia-dev-0/base-devnet-0 (no public endpoint)
62-
}
63-
64-
if isExcluded[chain.ChainID] {
65-
t.Skip("chain excluded from check")
66-
}
41+
skipIfExcluded(t, chain.ChainID)
6742

6843
declaredGenesisHash := chain.Genesis.L2.Hash
6944
rpcEndpoint := chain.PublicRPC
70-
require.NotEmpty(t, rpcEndpoint)
7145

7246
client, err := ethclient.Dial(rpcEndpoint)
7347
require.NoErrorf(t, err, "could not dial rpc endpoint %s", rpcEndpoint)

validation/superchain-version_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,7 @@ func TestSuperchainWideContractVersions(t *testing.T) {
5656
}
5757

5858
func testContractsMatchATag(t *testing.T, chain *ChainConfig) {
59-
isExcluded := map[uint64]bool{
60-
8453: true, // mainnet/base
61-
11155421: true, // sepolia-dev-0/oplabs-devnet-0
62-
11763072: true, // sepolia-dev-0/base-devnet-0
63-
}
64-
if isExcluded[chain.ChainID] {
65-
t.Skipf("chain %d: EXCLUDED from contract version validation", chain.ChainID)
66-
}
59+
skipIfExcluded(t, chain.ChainID)
6760

6861
rpcEndpoint := Superchains[chain.Superchain].Config.L1.PublicRPC
6962
require.NotEmpty(t, rpcEndpoint)

validation/uniqueness_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,8 @@ func init() {
118118
}
119119

120120
func testIsGloballyUnique(t *testing.T, chain *ChainConfig) {
121-
isExcluded := map[uint64]bool{
122-
11155421: true, // oplabs devnet 0, not in upstream repo
123-
11763072: true, // base devnet 0, not in upstream repo
124-
}
125-
if isExcluded[chain.ChainID] {
126-
t.Skip("excluded from global chain id check")
127-
}
121+
skipIfExcluded(t, chain.ChainID)
122+
128123
props := globalChainIds[uint(chain.ChainID)]
129124
require.NotNil(t, props, "chain ID is not listed at chainid.network")
130125
globalChainName := props.Name

validation/validation_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ func testValidation(t *testing.T, chain *ChainConfig) {
4545
// designed to protect downstream software or
4646
// sanity checking basic consistency conditions.
4747
func testUniversal(t *testing.T, chain *ChainConfig) {
48-
t.Run("Genesis Hash Check (op-geth)", func(t *testing.T) {
48+
t.Run("Genesis Hash Check", func(t *testing.T) {
4949
testGenesisHash(t, chain.ChainID)
5050
})
51-
t.Run("Genesis Check (RPC)", func(t *testing.T) {
51+
t.Run("Genesis RPC Check", func(t *testing.T) {
5252
testGenesisHashAgainstRPC(t, chain)
5353
})
5454
t.Run("Uniqueness Check", func(t *testing.T) {
@@ -63,15 +63,15 @@ func testUniversal(t *testing.T, chain *ChainConfig) {
6363
// i.e. not to a Standard Candidate Chain.
6464
func testStandardCandidate(t *testing.T, chain *ChainConfig) {
6565
t.Run("Standard Config Params", func(t *testing.T) {
66-
testDataAvailability(t, chain)
67-
testResourceConfig(t, chain)
68-
testL2OOParams(t, chain)
69-
testGasLimit(t, chain)
70-
testGasPriceOracleParams(t, chain)
66+
t.Run("Data Availability", func(t *testing.T) { testDataAvailability(t, chain) })
67+
t.Run("Resource Config", func(t *testing.T) { testResourceConfig(t, chain) })
68+
t.Run("L2OO Params", func(t *testing.T) { testL2OOParams(t, chain) })
69+
t.Run("Gas Limit", func(t *testing.T) { testGasLimit(t, chain) })
70+
t.Run("GPO Params", func(t *testing.T) { testGasPriceOracleParams(t, chain) })
7171
})
7272
t.Run("Standard Config Roles", func(t *testing.T) {
73-
testL1SecurityConfig(t, chain.ChainID)
74-
testL2SecurityConfig(t, chain)
73+
t.Run("L1 Security Config", func(t *testing.T) { testL1SecurityConfig(t, chain.ChainID) })
74+
t.Run("L2 Security Config", func(t *testing.T) { testL2SecurityConfig(t, chain) })
7575
})
7676
t.Run("Standard Contract Versions", func(t *testing.T) {
7777
testContractsMatchATag(t, chain)

0 commit comments

Comments
 (0)