Skip to content

Commit

Permalink
op-chain-ops: bindings decouple
Browse files Browse the repository at this point in the history
More small bindings decoupling. After this PR is merged,
it should be possible to move `op-bindings/bindings` into
`op-e2e/bindings`
  • Loading branch information
tynes committed May 13, 2024
1 parent 45e1bd2 commit e2c2068
Show file tree
Hide file tree
Showing 6 changed files with 695 additions and 37 deletions.
657 changes: 657 additions & 0 deletions op-chain-ops/cmd/check-ecotone/bindings/gaspriceoracle.go

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions op-chain-ops/cmd/check-ecotone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"

"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-chain-ops/cmd/check-ecotone/bindings"
nbindings "github.com/ethereum-optimism/optimism/op-node/bindings"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
op_service "github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
Expand Down Expand Up @@ -702,7 +703,7 @@ func checkUpgradeTxs(ctx context.Context, env *actionEnv) error {
}

func checkL1Block(ctx context.Context, env *actionEnv) error {
cl, err := bindings.NewL1Block(predeploys.L1BlockAddr, env.l2)
cl, err := nbindings.NewL1Block(predeploys.L1BlockAddr, env.l2)
if err != nil {
return fmt.Errorf("failed to create bindings around L1Block contract: %w", err)
}
Expand Down
3 changes: 2 additions & 1 deletion op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"

"github.com/ethereum-optimism/optimism/op-chain-ops/upgrades"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/eth"
)
Expand Down Expand Up @@ -391,7 +392,7 @@ func (d *DeployConfig) Check() error {
}
// When the initial resource config is made to be configurable by the DeployConfig, ensure
// that this check is updated to use the values from the DeployConfig instead of the defaults.
if uint64(d.L2GenesisBlockGasLimit) < uint64(DefaultResourceConfig.MaxResourceLimit+DefaultResourceConfig.SystemTxMaxGas) {
if uint64(d.L2GenesisBlockGasLimit) < uint64(upgrades.DefaultResourceConfig.MaxResourceLimit+upgrades.DefaultResourceConfig.SystemTxMaxGas) {
return fmt.Errorf("%w: L2 genesis block gas limit is too small", ErrInvalidDeployConfig)
}
if d.L2GenesisBlockBaseFeePerGas == nil {
Expand Down
27 changes: 0 additions & 27 deletions op-chain-ops/genesis/layer_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,13 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"

"github.com/ethereum-optimism/optimism/op-bindings/bindings"
)

// PrecompileCount represents the number of precompile addresses
// starting from `address(0)` to PrecompileCount that are funded
// with a single wei in the genesis state.
const PrecompileCount = 256

var (
// uint128Max is type(uint128).max and is set in the init function.
uint128Max = new(big.Int)
// The default values for the ResourceConfig, used as part of
// an EIP-1559 curve for deposit gas.
DefaultResourceConfig = bindings.ResourceMeteringResourceConfig{
MaxResourceLimit: 20_000_000,
ElasticityMultiplier: 10,
BaseFeeMaxChangeDenominator: 8,
MinimumBaseFee: params.GWei,
SystemTxMaxGas: 1_000_000,
}
)

func init() {
var ok bool
uint128Max, ok = new(big.Int).SetString("ffffffffffffffffffffffffffffffff", 16)
if !ok {
panic("bad uint128Max")
}
// Set the maximum base fee on the default config.
DefaultResourceConfig.MaximumBaseFee = uint128Max
}

// BuildL1DeveloperGenesis will create a L1 genesis block after creating
// all of the state required for an Optimism network to function.
// It is expected that the dump contains all of the required state to bootstrap
Expand Down
26 changes: 26 additions & 0 deletions op-chain-ops/upgrades/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,41 @@ package upgrades
import (
"context"
"fmt"
"math/big"
"strings"

"github.com/ethereum-optimism/optimism/op-chain-ops/upgrades/bindings"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"

"github.com/ethereum-optimism/superchain-registry/superchain"
)

var (
// uint128Max is type(uint128).max and is set in the init function.
uint128Max = new(big.Int)
// The default values for the ResourceConfig, used as part of
// an EIP-1559 curve for deposit gas.
DefaultResourceConfig = bindings.ResourceMeteringResourceConfig{
MaxResourceLimit: 20_000_000,
ElasticityMultiplier: 10,
BaseFeeMaxChangeDenominator: 8,
MinimumBaseFee: params.GWei,
SystemTxMaxGas: 1_000_000,
}
)

func init() {
var ok bool
uint128Max, ok = new(big.Int).SetString("ffffffffffffffffffffffffffffffff", 16)
if !ok {
panic("bad uint128Max")
}
// Set the maximum base fee on the default config.
DefaultResourceConfig.MaximumBaseFee = uint128Max
}

// CheckL1 will check that the versions of the contracts on L1 match the versions
// in the superchain registry.
func CheckL1(ctx context.Context, list *superchain.ImplementationList, backend bind.ContractBackend) error {
Expand Down
14 changes: 7 additions & 7 deletions op-chain-ops/upgrades/l1.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,22 +725,22 @@ func SystemConfig(batch *safe.Batch, implementations superchain.ImplementationLi
return err
}

if resourceConfig.MaxResourceLimit != genesis.DefaultResourceConfig.MaxResourceLimit {
if resourceConfig.MaxResourceLimit != DefaultResourceConfig.MaxResourceLimit {
return fmt.Errorf("DefaultResourceConfig MaxResourceLimit doesn't match contract MaxResourceLimit")
}
if resourceConfig.ElasticityMultiplier != genesis.DefaultResourceConfig.ElasticityMultiplier {
if resourceConfig.ElasticityMultiplier != DefaultResourceConfig.ElasticityMultiplier {
return fmt.Errorf("DefaultResourceConfig ElasticityMultiplier doesn't match contract ElasticityMultiplier")
}
if resourceConfig.BaseFeeMaxChangeDenominator != genesis.DefaultResourceConfig.BaseFeeMaxChangeDenominator {
if resourceConfig.BaseFeeMaxChangeDenominator != DefaultResourceConfig.BaseFeeMaxChangeDenominator {
return fmt.Errorf("DefaultResourceConfig BaseFeeMaxChangeDenominator doesn't match contract BaseFeeMaxChangeDenominator")
}
if resourceConfig.MinimumBaseFee != genesis.DefaultResourceConfig.MinimumBaseFee {
if resourceConfig.MinimumBaseFee != DefaultResourceConfig.MinimumBaseFee {
return fmt.Errorf("DefaultResourceConfig MinimumBaseFee doesn't match contract MinimumBaseFee")
}
if resourceConfig.SystemTxMaxGas != genesis.DefaultResourceConfig.SystemTxMaxGas {
if resourceConfig.SystemTxMaxGas != DefaultResourceConfig.SystemTxMaxGas {
return fmt.Errorf("DefaultResourceConfig SystemTxMaxGas doesn't match contract SystemTxMaxGas")
}
if resourceConfig.MaximumBaseFee.Cmp(genesis.DefaultResourceConfig.MaximumBaseFee) != 0 {
if resourceConfig.MaximumBaseFee.Cmp(DefaultResourceConfig.MaximumBaseFee) != 0 {
return fmt.Errorf("DefaultResourceConfig MaximumBaseFee doesn't match contract MaximumBaseFee")
}

Expand All @@ -756,7 +756,7 @@ func SystemConfig(batch *safe.Batch, implementations superchain.ImplementationLi
batcherHash,
l2GenesisBlockGasLimit,
p2pSequencerAddress,
genesis.DefaultResourceConfig,
DefaultResourceConfig,
chainConfig.BatchInboxAddr,
bindings.SystemConfigAddresses{
L1CrossDomainMessenger: common.Address(list.L1CrossDomainMessengerProxy),
Expand Down

0 comments on commit e2c2068

Please sign in to comment.