Commit 49010623 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

op-chain-ops: bindings decouple (#10493)

* op-chain-ops: bindings decouple

More small bindings decoupling. After this PR is merged,
it should be possible to move `op-bindings/bindings` into
`op-e2e/bindings`

* dead-code: cleanup

* build: fix
parent 2c63288b
This diff is collapsed.
......@@ -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"
......@@ -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)
}
......
......@@ -27,6 +27,24 @@ import (
var (
ErrInvalidDeployConfig = errors.New("invalid deploy config")
ErrInvalidImmutablesConfig = errors.New("invalid immutables config")
// MaximumBaseFee represents the max base fee for deposits, since
// there is an on chain EIP-1559 curve for deposits purchasing L2 gas.
// It is type(uint128).max in solidity.
MaximumBaseFee, _ = new(big.Int).SetString("ffffffffffffffffffffffffffffffff", 16)
)
const (
// MaxResourceLimit represents the maximum amount of L2 gas that a single deposit can use.
MaxResourceLimit = 20_000_000
// ElasticityMultiplier represents the elasticity of the deposit EIP-1559 fee market.
ElasticityMultiplier = 10
// BaseFeeMaxChangeDenominator represents the maximum change in base fee per block.
BaseFeeMaxChangeDenominator = 8
// MinimumBaseFee represents the minimum base fee for deposits.
MinimumBaseFee = params.GWei
// SystemTxMaxGas represents the maximum gas that a system transaction can use
// when it is included with user deposits.
SystemTxMaxGas = 1_000_000
)
// DeployConfig represents the deployment configuration for an OP Stack chain.
......@@ -391,7 +409,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(MaxResourceLimit+SystemTxMaxGas) {
return fmt.Errorf("%w: L2 genesis block gas limit is too small", ErrInvalidDeployConfig)
}
if d.L2GenesisBlockBaseFeePerGas == nil {
......
......@@ -7,9 +7,6 @@ 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
......@@ -17,30 +14,6 @@ import (
// 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
......
......@@ -5,6 +5,7 @@ import (
"fmt"
"strings"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-chain-ops/upgrades/bindings"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
......@@ -12,6 +13,19 @@ import (
"github.com/ethereum-optimism/superchain-registry/superchain"
)
var (
// The default values for the ResourceConfig, used as part of
// an EIP-1559 curve for deposit gas.
DefaultResourceConfig = bindings.ResourceMeteringResourceConfig{
MaxResourceLimit: genesis.MaxResourceLimit,
ElasticityMultiplier: genesis.ElasticityMultiplier,
BaseFeeMaxChangeDenominator: genesis.BaseFeeMaxChangeDenominator,
MinimumBaseFee: genesis.MinimumBaseFee,
SystemTxMaxGas: genesis.SystemTxMaxGas,
MaximumBaseFee: genesis.MaximumBaseFee,
}
)
// 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 {
......
......@@ -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")
}
......@@ -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),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment