Skip to content

Commit

Permalink
op-geth: update to support new precompile-overrides function (#11443)
Browse files Browse the repository at this point in the history
* op-geth: update to support new precompile-overrides function

* op-program: ensure no accidental precompile overrides

* go.mod: update op-geth for new precompile override functionality
  • Loading branch information
protolambda authored Aug 12, 2024
1 parent 998b8de commit 97aac00
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/crate-crypto/go-kzg-4844 v1.0.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240812010938-34a43d577f74
github.com/ethereum/go-ethereum v1.14.7
github.com/fsnotify/fsnotify v1.7.0
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb
Expand Down Expand Up @@ -233,7 +233,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum v1.14.7 => github.com/ethereum-optimism/op-geth v1.101407.0-rc.1
replace github.com/ethereum/go-ethereum v1.14.7 => github.com/ethereum-optimism/op-geth v1.101407.0-rc.1.0.20240812224053-8d99ca68bb1a

//replace github.com/ethereum/go-ethereum v1.13.9 => ../op-geth

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/
github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v1.101407.0-rc.1 h1:bE6V8GG46s7IX2s7prH26sKcVwW0/FbId3CEe5GYulQ=
github.com/ethereum-optimism/op-geth v1.101407.0-rc.1/go.mod h1:Zn0xPY3I/xX3Bm51kjXz9VSd+2ai7bEslVEAFTdVcpM=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2 h1:ySJykDUyb8RbcfLL3pz0Cs5Ji6NMVT7kmAY634DOCoE=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2/go.mod h1:zy9f3TNPS7pwW4msMitF83fp0Wf452tZ6+Fg6d4JyXM=
github.com/ethereum-optimism/op-geth v1.101407.0-rc.1.0.20240812224053-8d99ca68bb1a h1:OK3wB7HbdhCneSowC1XZusHaLIVdXoRLuCWgXp5Tjuc=
github.com/ethereum-optimism/op-geth v1.101407.0-rc.1.0.20240812224053-8d99ca68bb1a/go.mod h1:9pT+bF20XwCBE7WkjfRSsCg6RN6Njdbr924DtQ3+geY=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240812010938-34a43d577f74 h1:HQZQalpPUXs9qnJgDmEDzpPO70Z1p8Le2l0bZ9eJjCk=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240812010938-34a43d577f74/go.mod h1:zy9f3TNPS7pwW4msMitF83fp0Wf452tZ6+Fg6d4JyXM=
github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA=
github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeVvf7C1tm8elRjj4BdscTYzz/WAbYyf/JI4=
Expand Down
6 changes: 3 additions & 3 deletions op-e2e/actions/l1_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ func (s *L1Miner) ActL1StartBlock(timeDelta uint64) Action {
context := core.NewEVMBlockContext(header, s.l1Chain, nil, s.l1Chain.Config(), statedb)
// NOTE: Unlikely to be needed for the beacon block root, but we setup any precompile overrides anyways for forwards-compatibility
var precompileOverrides vm.PrecompileOverrides
if vmConfig := s.l1Chain.GetVMConfig(); vmConfig != nil && vmConfig.OptimismPrecompileOverrides != nil {
precompileOverrides = vmConfig.OptimismPrecompileOverrides
if vmConfig := s.l1Chain.GetVMConfig(); vmConfig != nil && vmConfig.PrecompileOverrides != nil {
precompileOverrides = vmConfig.PrecompileOverrides
}
vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, s.l1Chain.Config(), vm.Config{OptimismPrecompileOverrides: precompileOverrides})
vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, s.l1Chain.Config(), vm.Config{PrecompileOverrides: precompileOverrides})
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, statedb)
}

Expand Down
2 changes: 1 addition & 1 deletion op-program/client/l2/engine_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewOracleBackedL2Chain(logger log.Logger, oracle Oracle, precompileOracle e
blocks: make(map[common.Hash]*types.Block),
db: NewOracleBackedDB(oracle),
vmCfg: vm.Config{
OptimismPrecompileOverrides: engineapi.CreatePrecompileOverrides(precompileOracle),
PrecompileOverrides: engineapi.CreatePrecompileOverrides(precompileOracle),
},
}, nil
}
Expand Down
6 changes: 3 additions & 3 deletions op-program/client/l2/engineapi/block_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func NewBlockProcessorFromHeader(provider BlockDataProvider, h *types.Header) (*
context := core.NewEVMBlockContext(header, provider, nil, provider.Config(), statedb)
// NOTE: Unlikely to be needed for the beacon block root, but we setup any precompile overrides anyways for forwards-compatibility
var precompileOverrides vm.PrecompileOverrides
if vmConfig := provider.GetVMConfig(); vmConfig != nil && vmConfig.OptimismPrecompileOverrides != nil {
precompileOverrides = vmConfig.OptimismPrecompileOverrides
if vmConfig := provider.GetVMConfig(); vmConfig != nil && vmConfig.PrecompileOverrides != nil {
precompileOverrides = vmConfig.PrecompileOverrides
}
vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, provider.Config(), vm.Config{OptimismPrecompileOverrides: precompileOverrides})
vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, provider.Config(), vm.Config{PrecompileOverrides: precompileOverrides})
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, statedb)
}
return &BlockProcessor{
Expand Down
13 changes: 8 additions & 5 deletions op-program/client/l2/engineapi/precompiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,20 @@ type PrecompileOracle interface {
}

func CreatePrecompileOverrides(precompileOracle PrecompileOracle) vm.PrecompileOverrides {
return func(rules params.Rules, orig vm.PrecompiledContract, address common.Address) (vm.PrecompiledContract, bool) {
return func(rules params.Rules, orig vm.PrecompiledContract, address common.Address) vm.PrecompiledContract {
if orig == nil { // Only override existing contracts. Never introduce a precompile that is not there.
return nil
}
// NOTE: Ignoring chain rules for now. We assume that precompile behavior won't change for the foreseeable future
switch address {
case ecrecoverPrecompileAddress:
return &ecrecoverOracle{Orig: orig, Oracle: precompileOracle}, true
return &ecrecoverOracle{Orig: orig, Oracle: precompileOracle}
case bn256PairingPrecompileAddress:
return &bn256PairingOracle{Orig: orig, Oracle: precompileOracle}, true
return &bn256PairingOracle{Orig: orig, Oracle: precompileOracle}
case kzgPointEvaluationPrecompileAddress:
return &kzgPointEvaluationOracle{Orig: orig, Oracle: precompileOracle}, true
return &kzgPointEvaluationOracle{Orig: orig, Oracle: precompileOracle}
default:
return nil, false
return orig
}
}
}
Expand Down

0 comments on commit 97aac00

Please sign in to comment.