Skip to content

Commit

Permalink
interop: interopgen v2 using OPSM (#11702)
Browse files Browse the repository at this point in the history
* op-chain-ops/interopgen: OPSM powered interop genesis

* ci: make forge scripts available to op-e2e

* op-chain-ops: address interopgen review comments
  • Loading branch information
protolambda authored Sep 13, 2024
1 parent 3ba35fa commit 3056348
Show file tree
Hide file tree
Showing 19 changed files with 1,281 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1591,8 +1591,8 @@ workflows:
- contracts-bedrock-build:
name: contracts-bedrock-build
build_command: |
forge build --skip test --skip scripts
forge build ./scripts/deploy/Deploy.s.sol
# Note: scripts are included, to be available to op-e2e
forge build --skip test
- contracts-bedrock-tests:
# Test everything except PreimageOracle.t.sol since it's slow.
name: contracts-bedrock-tests
Expand Down
12 changes: 6 additions & 6 deletions op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ type GasPriceOracleDeployConfig struct {
// Deprecated: Since Ecotone, this field is superseded by GasPriceOracleBaseFeeScalar and GasPriceOracleBlobBaseFeeScalar.
GasPriceOracleScalar uint64 `json:"gasPriceOracleScalar"`
// GasPriceOracleBaseFeeScalar represents the value of the base fee scalar used for fee calculations.
GasPriceOracleBaseFeeScalar uint32 `json:"gasPriceOracleBaseFeeScalar"`
GasPriceOracleBaseFeeScalar uint32 `json:"gasPriceOracleBaseFeeScalar" evm:"basefeeScalar"`
// GasPriceOracleBlobBaseFeeScalar represents the value of the blob base fee scalar used for fee calculations.
GasPriceOracleBlobBaseFeeScalar uint32 `json:"gasPriceOracleBlobBaseFeeScalar"`
GasPriceOracleBlobBaseFeeScalar uint32 `json:"gasPriceOracleBlobBaseFeeScalar" evm:"blobbasefeeScalar"`
}

var _ ConfigChecker = (*GasPriceOracleDeployConfig)(nil)
Expand Down Expand Up @@ -282,7 +282,7 @@ func (d *GasTokenDeployConfig) Check(log log.Logger) error {
// OperatorDeployConfig configures the hot-key addresses for operations such as sequencing and batch-submission.
type OperatorDeployConfig struct {
// P2PSequencerAddress is the address of the key the sequencer uses to sign blocks on the P2P layer.
P2PSequencerAddress common.Address `json:"p2pSequencerAddress"`
P2PSequencerAddress common.Address `json:"p2pSequencerAddress" evm:"p2pSequencerAddress"`
// BatchSenderAddress represents the initial sequencer account that authorizes batches.
// Transactions sent from this account to the batch inbox address are considered valid.
BatchSenderAddress common.Address `json:"batchSenderAddress"`
Expand Down Expand Up @@ -627,7 +627,7 @@ type OutputOracleDeployConfig struct {
L2OutputOracleSubmissionInterval uint64 `json:"l2OutputOracleSubmissionInterval"`
// L2OutputOracleStartingTimestamp is the starting timestamp for the L2OutputOracle.
// MUST be the same as the timestamp of the L2OO start block.
L2OutputOracleStartingTimestamp int `json:"l2OutputOracleStartingTimestamp"`
L2OutputOracleStartingTimestamp int64 `json:"l2OutputOracleStartingTimestamp"`
// L2OutputOracleStartingBlockNumber is the starting block number for the L2OutputOracle.
// Must be greater than or equal to the first Bedrock block. The first L2 output will correspond
// to this value plus the submission interval.
Expand Down Expand Up @@ -808,7 +808,7 @@ type DeployConfig struct {
// The L2 genesis timestamp does not affect the initial L2 account state:
// the storage of the L1Block contract at genesis is zeroed, since the adoption of
// the L2-genesis allocs-generation through solidity script.
L1StartingBlockTag *MarshalableRPCBlockNumberOrHash `json:"l1StartingBlockTag"`
L1StartingBlockTag *MarshalableRPCBlockNumberOrHash `json:"l1StartingBlockTag" evm:"-"`

// L1 contracts configuration.
// The deployer of the contracts chooses which sub-systems to deploy.
Expand All @@ -820,7 +820,7 @@ type DeployConfig struct {
L1DependenciesConfig

// Legacy, ignored, here for strict-JSON decoding to be accepted.
LegacyDeployConfig
LegacyDeployConfig `evm:"-"`
}

// Copy will deeply copy the DeployConfig. This does a JSON roundtrip to copy
Expand Down
7 changes: 7 additions & 0 deletions op-chain-ops/genesis/withdrawal_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"encoding/json"
"fmt"
"strconv"

"github.com/holiman/uint256"
)

// WithdrawalNetwork represents the network that withdrawals are sent to.
Expand Down Expand Up @@ -32,6 +34,11 @@ func (w *WithdrawalNetwork) ToUint8() uint8 {
}
}

func (w WithdrawalNetwork) ToABI() []byte {
out := uint256.NewInt(uint64(w.ToUint8())).Bytes32()
return out[:]
}

// FromUint8 converts a uint8 to a WithdrawalNetwork.
func FromUint8(i uint8) WithdrawalNetwork {
switch i {
Expand Down
108 changes: 108 additions & 0 deletions op-chain-ops/interopgen/configs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package interopgen

import (
"errors"
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
)

type L1Config struct {
ChainID *big.Int
genesis.DevL1DeployConfig
Prefund map[common.Address]*big.Int
}

func (c *L1Config) Check(log log.Logger) error {
if c.ChainID == nil {
return errors.New("missing L1 chain ID")
}
// nothing to check on c.DevL1DeployConfig
return nil
}

type SuperFaultProofConfig struct {
WithdrawalDelaySeconds *big.Int
MinProposalSizeBytes *big.Int
ChallengePeriodSeconds *big.Int
ProofMaturityDelaySeconds *big.Int
DisputeGameFinalityDelaySeconds *big.Int
}

type OPSMImplementationsConfig struct {
Release string

FaultProof SuperFaultProofConfig

UseInterop bool // to deploy Interop implementation contracts, instead of the regular ones.
}

type SuperchainConfig struct {
Deployer common.Address

ProxyAdminOwner common.Address
ProtocolVersionsOwner common.Address

Paused bool

Implementations OPSMImplementationsConfig

genesis.SuperchainL1DeployConfig
}

func (c *SuperchainConfig) Check(log log.Logger) error {
if c.Deployer == (common.Address{}) {
return errors.New("missing superchain deployer address")
}
if c.ProxyAdminOwner == (common.Address{}) {
return errors.New("missing superchain ProxyAdminOwner address")
}
if err := c.SuperchainL1DeployConfig.Check(log); err != nil {
return err
}
return nil
}

type L2Config struct {
Deployer common.Address // account used to deploy contracts to L2
Proposer common.Address
Challenger common.Address
SystemConfigOwner common.Address
genesis.L2InitializationConfig
Prefund map[common.Address]*big.Int
}

func (c *L2Config) Check(log log.Logger) error {
if c.Deployer == (common.Address{}) {
return errors.New("missing L2 deployer address")
}
if err := c.L2InitializationConfig.Check(log); err != nil {
return err
}
return nil
}

type WorldConfig struct {
L1 *L1Config
Superchain *SuperchainConfig
L2s map[string]*L2Config
}

func (c *WorldConfig) Check(log log.Logger) error {
if err := c.L1.Check(log); err != nil {
return fmt.Errorf("invalid L1 config: %w", err)
}
if err := c.Superchain.Check(log); err != nil {
return fmt.Errorf("invalid Superchain config: %w", err)
}
for l2ChainID, l2Cfg := range c.L2s {
if err := l2Cfg.Check(log.New("l2", &l2ChainID)); err != nil {
return fmt.Errorf("invalid L2 (chain ID %s) config: %w", l2ChainID, err)
}
}
return nil
}
Loading

0 comments on commit 3056348

Please sign in to comment.