Skip to content

Commit

Permalink
validation: add fault game param checks (ethereum-optimism#636)
Browse files Browse the repository at this point in the history
* utils: make CastCall helper more flexible

* validation: add fault game checks

* validation: lint

* validation: move CastCall helper from superchain to validation package

* validation: move testFaultGameParams into standard checks

* validation: update fault game output root hash check to query l2

* validation: fix isPermissionless check

* go: update monorepo import

* validation: read op-program prestates from monorepo import

* go: tidy-all

* validation: remove anchorState check

* validation: update to use reformatted version of op-program import

* go: just tidy-all

* go: update monorepo import to point at latest main commit

* go: just tidy-all
  • Loading branch information
bitwiseguy authored Oct 21, 2024
1 parent aab3b8d commit 689eba7
Show file tree
Hide file tree
Showing 13 changed files with 283 additions and 178 deletions.
43 changes: 22 additions & 21 deletions add-chain/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/BurntSushi/toml"
"github.com/ethereum-optimism/superchain-registry/superchain"
"github.com/ethereum-optimism/superchain-registry/validation"
)

type AddressData struct {
Expand All @@ -17,78 +18,78 @@ type AddressData struct {

func readAddressesFromChain(addresses *superchain.AddressList, l1RpcUrl string, isFaultProofs bool) error {
// SuperchainConfig
address, err := castCall(addresses.OptimismPortalProxy, "superchainConfig()(address)", l1RpcUrl)
address, err := validation.CastCall(addresses.OptimismPortalProxy, "superchainConfig()(address)", nil, l1RpcUrl)
if err == nil {
addresses.SuperchainConfig = superchain.MustHexToAddress(address)
addresses.SuperchainConfig = superchain.MustHexToAddress(address[0])
}

// Guardian
address, err = castCall(addresses.SuperchainConfig, "guardian()(address)", l1RpcUrl)
address, err = validation.CastCall(addresses.SuperchainConfig, "guardian()(address)", nil, l1RpcUrl)
if err != nil {
address, err = castCall(addresses.OptimismPortalProxy, "guardian()(address)", l1RpcUrl)
address, err = validation.CastCall(addresses.OptimismPortalProxy, "guardian()(address)", nil, l1RpcUrl)
if err != nil {
return fmt.Errorf("could not retrieve address for Guardian %w", err)
}
}
addresses.Guardian = superchain.MustHexToAddress(address)
addresses.Guardian = superchain.MustHexToAddress(address[0])

// ProxyAdminOwner
address, err = castCall(addresses.ProxyAdmin, "owner()(address)", l1RpcUrl)
address, err = validation.CastCall(addresses.ProxyAdmin, "owner()(address)", nil, l1RpcUrl)
if err != nil {
return fmt.Errorf("could not retrieve address for ProxyAdminOwner")
}
addresses.ProxyAdminOwner = superchain.MustHexToAddress(address)
addresses.ProxyAdminOwner = superchain.MustHexToAddress(address[0])

// SystemConfigOwner
address, err = castCall(addresses.SystemConfigProxy, "owner()(address)", l1RpcUrl)
address, err = validation.CastCall(addresses.SystemConfigProxy, "owner()(address)", nil, l1RpcUrl)
if err != nil {
return fmt.Errorf("could not retrieve address for SystemConfigOwner")
}
addresses.SystemConfigOwner = superchain.MustHexToAddress(address)
addresses.SystemConfigOwner = superchain.MustHexToAddress(address[0])

// UnsafeBlockSigner
address, err = castCall(addresses.SystemConfigProxy, "unsafeBlockSigner()(address)", l1RpcUrl)
address, err = validation.CastCall(addresses.SystemConfigProxy, "unsafeBlockSigner()(address)", nil, l1RpcUrl)
if err != nil {
return fmt.Errorf("could not retrieve address for UnsafeBlockSigner")
}
addresses.UnsafeBlockSigner = superchain.MustHexToAddress(address)
addresses.UnsafeBlockSigner = superchain.MustHexToAddress(address[0])

// BatchSubmitter
hash, err := castCall(addresses.SystemConfigProxy, "batcherHash()(bytes32)", l1RpcUrl)
hash, err := validation.CastCall(addresses.SystemConfigProxy, "batcherHash()(bytes32)", nil, l1RpcUrl)
if err != nil {
return fmt.Errorf("could not retrieve batcherHash")
}
batchSubmitter := "0x" + hash[26:66]
batchSubmitter := "0x" + hash[0][26:66]
addresses.BatchSubmitter = superchain.MustHexToAddress(batchSubmitter)

if isFaultProofs {
// Proposer
address, err = castCall(addresses.PermissionedDisputeGame, "proposer()(address)", l1RpcUrl)
address, err = validation.CastCall(addresses.PermissionedDisputeGame, "proposer()(address)", nil, l1RpcUrl)
if err != nil {
return fmt.Errorf("could not retrieve address for Proposer")
}
addresses.Proposer = superchain.MustHexToAddress(address)
addresses.Proposer = superchain.MustHexToAddress(address[0])

// Challenger
address, err = castCall(addresses.PermissionedDisputeGame, "challenger()(address)", l1RpcUrl)
address, err = validation.CastCall(addresses.PermissionedDisputeGame, "challenger()(address)", nil, l1RpcUrl)
if err != nil {
return fmt.Errorf("could not retrieve address for Challenger")
}
addresses.Challenger = superchain.MustHexToAddress(address)
addresses.Challenger = superchain.MustHexToAddress(address[0])
} else {
// Proposer
address, err = castCall(addresses.L2OutputOracleProxy, "PROPOSER()(address)", l1RpcUrl)
address, err = validation.CastCall(addresses.L2OutputOracleProxy, "PROPOSER()(address)", nil, l1RpcUrl)
if err != nil {
return fmt.Errorf("could not retrieve address for Proposer")
}
addresses.Proposer = superchain.MustHexToAddress(address)
addresses.Proposer = superchain.MustHexToAddress(address[0])

// Challenger
address, err = castCall(addresses.L2OutputOracleProxy, "CHALLENGER()(address)", l1RpcUrl)
address, err = validation.CastCall(addresses.L2OutputOracleProxy, "CHALLENGER()(address)", nil, l1RpcUrl)
if err != nil {
return fmt.Errorf("could not retrieve address for Challenger")
}
addresses.Challenger = superchain.MustHexToAddress(address)
addresses.Challenger = superchain.MustHexToAddress(address[0])
}
return nil
}
Expand Down
28 changes: 14 additions & 14 deletions add-chain/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth

require (
github.com/BurntSushi/toml v1.4.0
github.com/ethereum-optimism/optimism v1.9.2-0.20240917150108-e7758b25fe3c
github.com/ethereum-optimism/optimism v1.9.5-0.20241021150032-1e59d08322f8
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240910145426-b3905c89e8ac
github.com/ethereum-optimism/superchain-registry/validation v0.0.0-20240910145426-b3905c89e8ac
github.com/ethereum/go-ethereum v1.14.8
github.com/ethereum/go-ethereum v1.14.11
github.com/google/go-cmp v0.6.0
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.27.4
github.com/urfave/cli/v2 v2.27.5
)

require (
github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
Expand All @@ -34,14 +34,14 @@ require (
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
Expand All @@ -56,7 +56,7 @@ require (
github.com/holiman/uint256 v1.3.1 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand All @@ -69,7 +69,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.20.3 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
Expand All @@ -78,20 +78,20 @@ require (
github.com/rs/cors v1.11.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 689eba7

Please sign in to comment.