Commit 338711c2 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into jg/txmgr_cleanup_pt3

parents 551aaee4 88099c17
...@@ -178,4 +178,4 @@ require ( ...@@ -178,4 +178,4 @@ require (
lukechampine.com/blake3 v1.1.7 // indirect lukechampine.com/blake3 v1.1.7 // indirect
) )
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468 replace github.com/ethereum/go-ethereum v1.10.26 => github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b
...@@ -203,8 +203,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m ...@@ -203,8 +203,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc= 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/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468 h1:7KgjBYDji5AKi42eRYI+n8Gs+ZJVilSASL3WBu82c3M= github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b h1:qpsJ9tFppQOwO0rHrggOrSXW5XIx4G3DBEV6jrf9gU0=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468/go.mod h1:p0Yox74PhYlq1HvijrCBCD9A3cI7rXco7hT6KrQr+rY= github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b/go.mod h1:p0Yox74PhYlq1HvijrCBCD9A3cI7rXco7hT6KrQr+rY=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/memsize v0.0.1 h1:+zhkb+dhUgx0/e+M8sF0QqiouvMQUiKR+QYvdxIOKcQ= github.com/fjl/memsize v0.0.1 h1:+zhkb+dhUgx0/e+M8sF0QqiouvMQUiKR+QYvdxIOKcQ=
github.com/fjl/memsize v0.0.1/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fjl/memsize v0.0.1/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
......
...@@ -2,7 +2,7 @@ module github.com/ethereum-optimism/optimism/indexer ...@@ -2,7 +2,7 @@ module github.com/ethereum-optimism/optimism/indexer
go 1.17 go 1.17
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468 replace github.com/ethereum/go-ethereum v1.10.26 => github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b
require ( require (
github.com/ethereum-optimism/optimism/op-bindings v0.10.14 github.com/ethereum-optimism/optimism/op-bindings v0.10.14
......
...@@ -266,8 +266,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m ...@@ -266,8 +266,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc= 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/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468 h1:7KgjBYDji5AKi42eRYI+n8Gs+ZJVilSASL3WBu82c3M= github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b h1:qpsJ9tFppQOwO0rHrggOrSXW5XIx4G3DBEV6jrf9gU0=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468/go.mod h1:p0Yox74PhYlq1HvijrCBCD9A3cI7rXco7hT6KrQr+rY= github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b/go.mod h1:p0Yox74PhYlq1HvijrCBCD9A3cI7rXco7hT6KrQr+rY=
github.com/ethereum-optimism/optimism/op-batcher v0.10.14 h1:4C8hR2ut4kfzY9Lk7IZ8Utyw3P5rgiSabfech57nHP8= github.com/ethereum-optimism/optimism/op-batcher v0.10.14 h1:4C8hR2ut4kfzY9Lk7IZ8Utyw3P5rgiSabfech57nHP8=
github.com/ethereum-optimism/optimism/op-batcher v0.10.14/go.mod h1:j+uvhHcyqifm+IjpIKMSrdGRVyjjdmtLnYazZGt+ti4= github.com/ethereum-optimism/optimism/op-batcher v0.10.14/go.mod h1:j+uvhHcyqifm+IjpIKMSrdGRVyjjdmtLnYazZGt+ti4=
github.com/ethereum-optimism/optimism/op-bindings v0.10.1/go.mod h1:UeTZlpZyhOL3y9Sogzvbn8Z3q1tDmZEv1VmGxMiZYCg= github.com/ethereum-optimism/optimism/op-bindings v0.10.1/go.mod h1:UeTZlpZyhOL3y9Sogzvbn8Z3q1tDmZEv1VmGxMiZYCg=
......
This diff is collapsed.
...@@ -22,7 +22,10 @@ import ( ...@@ -22,7 +22,10 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-node/rollup"
) )
var ErrInvalidDeployConfig = errors.New("invalid deploy config") var (
ErrInvalidDeployConfig = errors.New("invalid deploy config")
ErrInvalidImmutablesConfig = errors.New("invalid immutables config")
)
// DeployConfig represents the deployment configuration for Optimism // DeployConfig represents the deployment configuration for Optimism
type DeployConfig struct { type DeployConfig struct {
...@@ -344,12 +347,27 @@ func NewDeployConfigWithNetwork(network, path string) (*DeployConfig, error) { ...@@ -344,12 +347,27 @@ func NewDeployConfigWithNetwork(network, path string) (*DeployConfig, error) {
} }
// NewL2ImmutableConfig will create an ImmutableConfig given an instance of a // NewL2ImmutableConfig will create an ImmutableConfig given an instance of a
// Hardhat and a DeployConfig. // DeployConfig and a block.
func NewL2ImmutableConfig(config *DeployConfig, block *types.Block) (immutables.ImmutableConfig, error) { func NewL2ImmutableConfig(config *DeployConfig, block *types.Block) (immutables.ImmutableConfig, error) {
immutable := make(immutables.ImmutableConfig) immutable := make(immutables.ImmutableConfig)
if config.L1StandardBridgeProxy == (common.Address{}) {
return immutable, fmt.Errorf("L1StandardBridgeProxy cannot be address(0): %w", ErrInvalidImmutablesConfig)
}
if config.L1CrossDomainMessengerProxy == (common.Address{}) {
return immutable, fmt.Errorf("L1CrossDomainMessengerProxy cannot be address(0): %w", ErrInvalidImmutablesConfig)
}
if config.L1ERC721BridgeProxy == (common.Address{}) { if config.L1ERC721BridgeProxy == (common.Address{}) {
return immutable, errors.New("L1ERC721BridgeProxy cannot be address(0)") return immutable, fmt.Errorf("L1ERC721BridgeProxy cannot be address(0): %w", ErrInvalidImmutablesConfig)
}
if config.SequencerFeeVaultRecipient == (common.Address{}) {
return immutable, fmt.Errorf("SequencerFeeVaultRecipient cannot be address(0): %w", ErrInvalidImmutablesConfig)
}
if config.BaseFeeVaultRecipient == (common.Address{}) {
return immutable, fmt.Errorf("BaseFeeVaultRecipient cannot be address(0): %w", ErrInvalidImmutablesConfig)
}
if config.L1FeeVaultRecipient == (common.Address{}) {
return immutable, fmt.Errorf("L1FeeVaultRecipient cannot be address(0): %w", ErrInvalidImmutablesConfig)
} }
immutable["L2StandardBridge"] = immutables.ImmutableValues{ immutable["L2StandardBridge"] = immutables.ImmutableValues{
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
"l1FeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788", "l1FeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788",
"sequencerFeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788", "sequencerFeeVaultRecipient": "0x71bE63f3384f5fb98995898A86B02Fb2426c5788",
"l1ERC721BridgeProxy": "0xff000000000000000000000000000000000000ff", "l1ERC721BridgeProxy": "0xff000000000000000000000000000000000000ff",
"l1StandardBridgeProxy": "0xff000000000000000000000000000000000000fd",
"l1CrossDomainMessengerProxy": "0xff000000000000000000000000000000000000dd",
"deploymentWaitConfirmations": 1, "deploymentWaitConfirmations": 1,
"fundDevAccounts": true "fundDevAccounts": true
......
package immutables package immutables
import ( import (
"errors"
"fmt" "fmt"
"math/big" "math/big"
...@@ -24,6 +25,39 @@ type ImmutableValues map[string]any ...@@ -24,6 +25,39 @@ type ImmutableValues map[string]any
// contracts. // contracts.
type ImmutableConfig map[string]ImmutableValues type ImmutableConfig map[string]ImmutableValues
// Check does a sanity check that the specific values that
// Optimism uses are set inside of the ImmutableConfig.
func (i ImmutableConfig) Check() error {
if _, ok := i["L2CrossDomainMessenger"]["otherMessenger"]; !ok {
return errors.New("L2CrossDomainMessenger otherMessenger not set")
}
if _, ok := i["L2StandardBridge"]["otherBridge"]; !ok {
return errors.New("L2StandardBridge otherBridge not set")
}
if _, ok := i["L2ERC721Bridge"]["messenger"]; !ok {
return errors.New("L2ERC721Bridge messenger not set")
}
if _, ok := i["L2ERC721Bridge"]["otherBridge"]; !ok {
return errors.New("L2ERC721Bridge otherBridge not set")
}
if _, ok := i["OptimismMintableERC721Factory"]["bridge"]; !ok {
return errors.New("OptimismMintableERC20Factory bridge not set")
}
if _, ok := i["OptimismMintableERC721Factory"]["remoteChainId"]; !ok {
return errors.New("OptimismMintableERC20Factory remoteChainId not set")
}
if _, ok := i["SequencerFeeVault"]["recipient"]; !ok {
return errors.New("SequencerFeeVault recipient not set")
}
if _, ok := i["L1FeeVault"]["recipient"]; !ok {
return errors.New("L1FeeVault recipient not set")
}
if _, ok := i["BaseFeeVault"]["recipient"]; !ok {
return errors.New("BaseFeeVault recipient not set")
}
return nil
}
// DeploymentResults represents the output of deploying each of the // DeploymentResults represents the output of deploying each of the
// contracts so that the immutables can be set properly in the bytecode. // contracts so that the immutables can be set properly in the bytecode.
type DeploymentResults map[string]hexutil.Bytes type DeploymentResults map[string]hexutil.Bytes
...@@ -31,6 +65,10 @@ type DeploymentResults map[string]hexutil.Bytes ...@@ -31,6 +65,10 @@ type DeploymentResults map[string]hexutil.Bytes
// BuildOptimism will deploy the L2 predeploys so that their immutables are set // BuildOptimism will deploy the L2 predeploys so that their immutables are set
// correctly. // correctly.
func BuildOptimism(immutable ImmutableConfig) (DeploymentResults, error) { func BuildOptimism(immutable ImmutableConfig) (DeploymentResults, error) {
if err := immutable.Check(); err != nil {
return DeploymentResults{}, err
}
deployments := []deployer.Constructor{ deployments := []deployer.Constructor{
{ {
Name: "GasPriceOracle", Name: "GasPriceOracle",
......
...@@ -19,9 +19,11 @@ func TestBuildOptimism(t *testing.T) { ...@@ -19,9 +19,11 @@ func TestBuildOptimism(t *testing.T) {
}, },
"L2ERC721Bridge": { "L2ERC721Bridge": {
"otherBridge": common.HexToAddress("0x1234567890123456789012345678901234567890"), "otherBridge": common.HexToAddress("0x1234567890123456789012345678901234567890"),
"messenger": common.HexToAddress("0x1234567890123456789012345678901234567890"),
}, },
"OptimismMintableERC721Factory": { "OptimismMintableERC721Factory": {
"remoteChainId": big.NewInt(1), "remoteChainId": big.NewInt(1),
"bridge": common.HexToAddress("0x1234567890123456789012345678901234567890"),
}, },
"SequencerFeeVault": { "SequencerFeeVault": {
"recipient": common.HexToAddress("0x1234567890123456789012345678901234567890"), "recipient": common.HexToAddress("0x1234567890123456789012345678901234567890"),
......
...@@ -102,6 +102,10 @@ func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams { ...@@ -102,6 +102,10 @@ func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams {
GasPriceOracleScalar: 1000_000, GasPriceOracleScalar: 1000_000,
DeploymentWaitConfirmations: 1, DeploymentWaitConfirmations: 1,
SequencerFeeVaultRecipient: common.Address{19: 1},
BaseFeeVaultRecipient: common.Address{19: 2},
L1FeeVaultRecipient: common.Address{19: 3},
EIP1559Elasticity: 10, EIP1559Elasticity: 10,
EIP1559Denominator: 50, EIP1559Denominator: 50,
......
...@@ -92,6 +92,10 @@ func DefaultSystemConfig(t *testing.T) SystemConfig { ...@@ -92,6 +92,10 @@ func DefaultSystemConfig(t *testing.T) SystemConfig {
GasPriceOracleOverhead: 2100, GasPriceOracleOverhead: 2100,
GasPriceOracleScalar: 1_000_000, GasPriceOracleScalar: 1_000_000,
SequencerFeeVaultRecipient: common.Address{19: 1},
BaseFeeVaultRecipient: common.Address{19: 2},
L1FeeVaultRecipient: common.Address{19: 3},
DeploymentWaitConfirmations: 1, DeploymentWaitConfirmations: 1,
EIP1559Elasticity: 2, EIP1559Elasticity: 2,
......
...@@ -20,6 +20,7 @@ type BlockInfo interface { ...@@ -20,6 +20,7 @@ type BlockInfo interface {
MixDigest() common.Hash MixDigest() common.Hash
BaseFee() *big.Int BaseFee() *big.Int
ReceiptHash() common.Hash ReceiptHash() common.Hash
GasUsed() uint64
} }
func InfoToL1BlockRef(info BlockInfo) L1BlockRef { func InfoToL1BlockRef(info BlockInfo) L1BlockRef {
...@@ -79,6 +80,10 @@ func (h headerBlockInfo) ReceiptHash() common.Hash { ...@@ -79,6 +80,10 @@ func (h headerBlockInfo) ReceiptHash() common.Hash {
return h.Header.ReceiptHash return h.Header.ReceiptHash
} }
func (h headerBlockInfo) GasUsed() uint64 {
return h.Header.GasUsed
}
// HeaderBlockInfo returns h as a BlockInfo implementation. // HeaderBlockInfo returns h as a BlockInfo implementation.
func HeaderBlockInfo(h *types.Header) BlockInfo { func HeaderBlockInfo(h *types.Header) BlockInfo {
return headerBlockInfo{h} return headerBlockInfo{h}
......
...@@ -34,7 +34,8 @@ const ( ...@@ -34,7 +34,8 @@ const (
globalValidateThrottle = 512 globalValidateThrottle = 512
gossipHeartbeat = 500 * time.Millisecond gossipHeartbeat = 500 * time.Millisecond
// seenMessagesTTL limits the duration that message IDs are remembered for gossip deduplication purposes // seenMessagesTTL limits the duration that message IDs are remembered for gossip deduplication purposes
seenMessagesTTL = 80 * gossipHeartbeat // 130 * gossipHeartbeat
seenMessagesTTL = 130 * gossipHeartbeat
DefaultMeshD = 8 // topic stable mesh target count DefaultMeshD = 8 // topic stable mesh target count
DefaultMeshDlo = 6 // topic stable mesh low watermark DefaultMeshDlo = 6 // topic stable mesh low watermark
DefaultMeshDhi = 12 // topic stable mesh high watermark DefaultMeshDhi = 12 // topic stable mesh high watermark
...@@ -234,7 +235,7 @@ func BuildBlocksValidator(log log.Logger, cfg *rollup.Config, runCfg GossipRunti ...@@ -234,7 +235,7 @@ func BuildBlocksValidator(log log.Logger, cfg *rollup.Config, runCfg GossipRunti
// Seen block hashes per block height // Seen block hashes per block height
// uint64 -> *seenBlocks // uint64 -> *seenBlocks
blockHeightLRU, err := lru.New(100) blockHeightLRU, err := lru.New(1000)
if err != nil { if err != nil {
panic(fmt.Errorf("failed to set up block height LRU cache: %w", err)) panic(fmt.Errorf("failed to set up block height LRU cache: %w", err))
} }
...@@ -328,9 +329,9 @@ func BuildBlocksValidator(log log.Logger, cfg *rollup.Config, runCfg GossipRunti ...@@ -328,9 +329,9 @@ func BuildBlocksValidator(log log.Logger, cfg *rollup.Config, runCfg GossipRunti
} }
func verifyBlockSignature(log log.Logger, cfg *rollup.Config, runCfg GossipRuntimeConfig, id peer.ID, signatureBytes []byte, payloadBytes []byte) pubsub.ValidationResult { func verifyBlockSignature(log log.Logger, cfg *rollup.Config, runCfg GossipRuntimeConfig, id peer.ID, signatureBytes []byte, payloadBytes []byte) pubsub.ValidationResult {
result := verifyBlockSignatureWithHasher(log, cfg, runCfg, id, signatureBytes, payloadBytes, BlockSigningHash) result := verifyBlockSignatureWithHasher(nil, cfg, runCfg, id, signatureBytes, payloadBytes, LegacyBlockSigningHash)
if result != pubsub.ValidationAccept { if result != pubsub.ValidationAccept {
return verifyBlockSignatureWithHasher(log, cfg, runCfg, id, signatureBytes, payloadBytes, LegacyBlockSigningHash) return verifyBlockSignatureWithHasher(log, cfg, runCfg, id, signatureBytes, payloadBytes, BlockSigningHash)
} }
return result return result
} }
...@@ -338,13 +339,17 @@ func verifyBlockSignature(log log.Logger, cfg *rollup.Config, runCfg GossipRunti ...@@ -338,13 +339,17 @@ func verifyBlockSignature(log log.Logger, cfg *rollup.Config, runCfg GossipRunti
func verifyBlockSignatureWithHasher(log log.Logger, cfg *rollup.Config, runCfg GossipRuntimeConfig, id peer.ID, signatureBytes []byte, payloadBytes []byte, hasher func(cfg *rollup.Config, payloadBytes []byte) (common.Hash, error)) pubsub.ValidationResult { func verifyBlockSignatureWithHasher(log log.Logger, cfg *rollup.Config, runCfg GossipRuntimeConfig, id peer.ID, signatureBytes []byte, payloadBytes []byte, hasher func(cfg *rollup.Config, payloadBytes []byte) (common.Hash, error)) pubsub.ValidationResult {
signingHash, err := hasher(cfg, payloadBytes) signingHash, err := hasher(cfg, payloadBytes)
if err != nil { if err != nil {
log.Warn("failed to compute block signing hash", "err", err, "peer", id) if log != nil {
log.Warn("failed to compute block signing hash", "err", err, "peer", id)
}
return pubsub.ValidationReject return pubsub.ValidationReject
} }
pub, err := crypto.SigToPub(signingHash[:], signatureBytes) pub, err := crypto.SigToPub(signingHash[:], signatureBytes)
if err != nil { if err != nil {
log.Warn("invalid block signature", "err", err, "peer", id) if log != nil {
log.Warn("invalid block signature", "err", err, "peer", id)
}
return pubsub.ValidationReject return pubsub.ValidationReject
} }
addr := crypto.PubkeyToAddress(*pub) addr := crypto.PubkeyToAddress(*pub)
...@@ -355,10 +360,14 @@ func verifyBlockSignatureWithHasher(log log.Logger, cfg *rollup.Config, runCfg G ...@@ -355,10 +360,14 @@ func verifyBlockSignatureWithHasher(log log.Logger, cfg *rollup.Config, runCfg G
// This means we may drop old payloads upon key rotation, // This means we may drop old payloads upon key rotation,
// but this can be recovered from like any other missed unsafe payload. // but this can be recovered from like any other missed unsafe payload.
if expected := runCfg.P2PSequencerAddress(); expected == (common.Address{}) { if expected := runCfg.P2PSequencerAddress(); expected == (common.Address{}) {
log.Warn("no configured p2p sequencer address, ignoring gossiped block", "peer", id, "addr", addr) if log != nil {
log.Warn("no configured p2p sequencer address, ignoring gossiped block", "peer", id, "addr", addr)
}
return pubsub.ValidationIgnore return pubsub.ValidationIgnore
} else if addr != expected { } else if addr != expected {
log.Warn("unexpected block author", "err", err, "peer", id, "addr", addr, "expected", expected) if log != nil {
log.Warn("unexpected block author", "err", err, "peer", id, "addr", addr, "expected", expected)
}
return pubsub.ValidationReject return pubsub.ValidationReject
} }
return pubsub.ValidationAccept return pubsub.ValidationAccept
......
...@@ -12,6 +12,27 @@ import ( ...@@ -12,6 +12,27 @@ import (
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
) )
var (
ErrBlockTimeZero = errors.New("block time cannot be 0")
ErrMissingChannelTimeout = errors.New("channel timeout must be set, this should cover at least a L1 block time")
ErrInvalidSeqWindowSize = errors.New("sequencing window size must at least be 2")
ErrMissingGenesisL1Hash = errors.New("genesis L1 hash cannot be empty")
ErrMissingGenesisL2Hash = errors.New("genesis L2 hash cannot be empty")
ErrGenesisHashesSame = errors.New("achievement get! rollup inception: L1 and L2 genesis cannot be the same")
ErrMissingGenesisL2Time = errors.New("missing L2 genesis time")
ErrMissingBatcherAddr = errors.New("missing genesis system config batcher address")
ErrMissingOverhead = errors.New("missing genesis system config overhead")
ErrMissingScalar = errors.New("missing genesis system config scalar")
ErrMissingGasLimit = errors.New("missing genesis system config gas limit")
ErrMissingBatchInboxAddress = errors.New("missing batch inbox address")
ErrMissingDepositContractAddress = errors.New("missing deposit contract address")
ErrMissingL1ChainID = errors.New("L1 chain ID must not be nil")
ErrMissingL2ChainID = errors.New("L2 chain ID must not be nil")
ErrChainIDsSame = errors.New("L1 and L2 chain IDs must be different")
ErrL1ChainIDNotPositive = errors.New("L1 chain ID must be non-zero and positive")
ErrL2ChainIDNotPositive = errors.New("L2 chain ID must be non-zero and positive")
)
type Genesis struct { type Genesis struct {
// The L1 block that the rollup starts *after* (no derived transactions) // The L1 block that the rollup starts *after* (no derived transactions)
L1 eth.BlockID `json:"l1"` L1 eth.BlockID `json:"l1"`
...@@ -147,52 +168,58 @@ func (cfg *Config) CheckL2GenesisBlockHash(ctx context.Context, client L2Client) ...@@ -147,52 +168,58 @@ func (cfg *Config) CheckL2GenesisBlockHash(ctx context.Context, client L2Client)
// Check verifies that the given configuration makes sense // Check verifies that the given configuration makes sense
func (cfg *Config) Check() error { func (cfg *Config) Check() error {
if cfg.BlockTime == 0 { if cfg.BlockTime == 0 {
return fmt.Errorf("block time cannot be 0, got %d", cfg.BlockTime) return ErrBlockTimeZero
} }
if cfg.ChannelTimeout == 0 { if cfg.ChannelTimeout == 0 {
return fmt.Errorf("channel timeout must be set, this should cover at least a L1 block time") return ErrMissingChannelTimeout
} }
if cfg.SeqWindowSize < 2 { if cfg.SeqWindowSize < 2 {
return fmt.Errorf("sequencing window size must at least be 2, got %d", cfg.SeqWindowSize) return ErrInvalidSeqWindowSize
} }
if cfg.Genesis.L1.Hash == (common.Hash{}) { if cfg.Genesis.L1.Hash == (common.Hash{}) {
return errors.New("genesis l1 hash cannot be empty") return ErrMissingGenesisL1Hash
} }
if cfg.Genesis.L2.Hash == (common.Hash{}) { if cfg.Genesis.L2.Hash == (common.Hash{}) {
return errors.New("genesis l2 hash cannot be empty") return ErrMissingGenesisL2Hash
} }
if cfg.Genesis.L2.Hash == cfg.Genesis.L1.Hash { if cfg.Genesis.L2.Hash == cfg.Genesis.L1.Hash {
return errors.New("achievement get! rollup inception: L1 and L2 genesis cannot be the same") return ErrGenesisHashesSame
} }
if cfg.Genesis.L2Time == 0 { if cfg.Genesis.L2Time == 0 {
return errors.New("missing L2 genesis time") return ErrMissingGenesisL2Time
} }
if cfg.Genesis.SystemConfig.BatcherAddr == (common.Address{}) { if cfg.Genesis.SystemConfig.BatcherAddr == (common.Address{}) {
return errors.New("missing genesis system config batcher address") return ErrMissingBatcherAddr
} }
if cfg.Genesis.SystemConfig.Overhead == (eth.Bytes32{}) { if cfg.Genesis.SystemConfig.Overhead == (eth.Bytes32{}) {
return errors.New("missing genesis system config overhead") return ErrMissingOverhead
} }
if cfg.Genesis.SystemConfig.Scalar == (eth.Bytes32{}) { if cfg.Genesis.SystemConfig.Scalar == (eth.Bytes32{}) {
return errors.New("missing genesis system config scalar") return ErrMissingScalar
} }
if cfg.Genesis.SystemConfig.GasLimit == 0 { if cfg.Genesis.SystemConfig.GasLimit == 0 {
return errors.New("missing genesis system config gas limit") return ErrMissingGasLimit
} }
if cfg.BatchInboxAddress == (common.Address{}) { if cfg.BatchInboxAddress == (common.Address{}) {
return errors.New("missing batch inbox address") return ErrMissingBatchInboxAddress
} }
if cfg.DepositContractAddress == (common.Address{}) { if cfg.DepositContractAddress == (common.Address{}) {
return errors.New("missing deposit contract address") return ErrMissingDepositContractAddress
} }
if cfg.L1ChainID == nil { if cfg.L1ChainID == nil {
return errors.New("l1 chain ID must not be nil") return ErrMissingL1ChainID
} }
if cfg.L2ChainID == nil { if cfg.L2ChainID == nil {
return errors.New("l2 chain ID must not be nil") return ErrMissingL2ChainID
} }
if cfg.L1ChainID.Cmp(cfg.L2ChainID) == 0 { if cfg.L1ChainID.Cmp(cfg.L2ChainID) == 0 {
return errors.New("l1 and l2 chain IDs must be different") return ErrChainIDsSame
}
if cfg.L1ChainID.Sign() < 1 {
return ErrL1ChainIDNotPositive
}
if cfg.L2ChainID.Sign() < 1 {
return ErrL2ChainIDNotPositive
} }
return nil return nil
} }
......
...@@ -212,3 +212,125 @@ func TestCheckL2BlockRefByNumber(t *testing.T) { ...@@ -212,3 +212,125 @@ func TestCheckL2BlockRefByNumber(t *testing.T) {
err = config.CheckL2GenesisBlockHash(context.TODO(), &mockClient) err = config.CheckL2GenesisBlockHash(context.TODO(), &mockClient)
assert.Error(t, err) assert.Error(t, err)
} }
func TestConfig_Check(t *testing.T) {
tests := []struct {
name string
modifier func(cfg *Config)
expectedErr error
}{
{
name: "BlockTimeZero",
modifier: func(cfg *Config) { cfg.BlockTime = 0 },
expectedErr: ErrBlockTimeZero,
},
{
name: "ChannelTimeoutZero",
modifier: func(cfg *Config) { cfg.ChannelTimeout = 0 },
expectedErr: ErrMissingChannelTimeout,
},
{
name: "SeqWindowSizeZero",
modifier: func(cfg *Config) { cfg.SeqWindowSize = 0 },
expectedErr: ErrInvalidSeqWindowSize,
},
{
name: "SeqWindowSizeOne",
modifier: func(cfg *Config) { cfg.SeqWindowSize = 1 },
expectedErr: ErrInvalidSeqWindowSize,
},
{
name: "NoL1Genesis",
modifier: func(cfg *Config) { cfg.Genesis.L1.Hash = common.Hash{} },
expectedErr: ErrMissingGenesisL1Hash,
},
{
name: "NoL2Genesis",
modifier: func(cfg *Config) { cfg.Genesis.L2.Hash = common.Hash{} },
expectedErr: ErrMissingGenesisL2Hash,
},
{
name: "GenesisHashesEqual",
modifier: func(cfg *Config) { cfg.Genesis.L2.Hash = cfg.Genesis.L1.Hash },
expectedErr: ErrGenesisHashesSame,
},
{
name: "GenesisL2TimeZero",
modifier: func(cfg *Config) { cfg.Genesis.L2Time = 0 },
expectedErr: ErrMissingGenesisL2Time,
},
{
name: "NoBatcherAddr",
modifier: func(cfg *Config) { cfg.Genesis.SystemConfig.BatcherAddr = common.Address{} },
expectedErr: ErrMissingBatcherAddr,
},
{
name: "NoOverhead",
modifier: func(cfg *Config) { cfg.Genesis.SystemConfig.Overhead = eth.Bytes32{} },
expectedErr: ErrMissingOverhead,
},
{
name: "NoScalar",
modifier: func(cfg *Config) { cfg.Genesis.SystemConfig.Scalar = eth.Bytes32{} },
expectedErr: ErrMissingScalar,
},
{
name: "NoGasLimit",
modifier: func(cfg *Config) { cfg.Genesis.SystemConfig.GasLimit = 0 },
expectedErr: ErrMissingGasLimit,
},
{
name: "NoBatchInboxAddress",
modifier: func(cfg *Config) { cfg.BatchInboxAddress = common.Address{} },
expectedErr: ErrMissingBatchInboxAddress,
},
{
name: "NoDepositContractAddress",
modifier: func(cfg *Config) { cfg.DepositContractAddress = common.Address{} },
expectedErr: ErrMissingDepositContractAddress,
},
{
name: "NoL1ChainId",
modifier: func(cfg *Config) { cfg.L1ChainID = nil },
expectedErr: ErrMissingL1ChainID,
},
{
name: "NoL2ChainId",
modifier: func(cfg *Config) { cfg.L2ChainID = nil },
expectedErr: ErrMissingL2ChainID,
},
{
name: "ChainIDsEqual",
modifier: func(cfg *Config) { cfg.L2ChainID = cfg.L1ChainID },
expectedErr: ErrChainIDsSame,
},
{
name: "L1ChainIdNegative",
modifier: func(cfg *Config) { cfg.L1ChainID = big.NewInt(-1) },
expectedErr: ErrL1ChainIDNotPositive,
},
{
name: "L1ChainIdZero",
modifier: func(cfg *Config) { cfg.L1ChainID = big.NewInt(0) },
expectedErr: ErrL1ChainIDNotPositive,
},
{
name: "L2ChainIdNegative",
modifier: func(cfg *Config) { cfg.L2ChainID = big.NewInt(-1) },
expectedErr: ErrL2ChainIDNotPositive,
},
{
name: "L2ChainIdZero",
modifier: func(cfg *Config) { cfg.L2ChainID = big.NewInt(0) },
expectedErr: ErrL2ChainIDNotPositive,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
cfg := randConfig()
test.modifier(cfg)
err := cfg.Check()
assert.Same(t, err, test.expectedErr)
})
}
}
...@@ -46,6 +46,7 @@ type HeaderInfo struct { ...@@ -46,6 +46,7 @@ type HeaderInfo struct {
baseFee *big.Int baseFee *big.Int
txHash common.Hash txHash common.Hash
receiptHash common.Hash receiptHash common.Hash
gasUsed uint64
} }
var _ eth.BlockInfo = (*HeaderInfo)(nil) var _ eth.BlockInfo = (*HeaderInfo)(nil)
...@@ -90,6 +91,10 @@ func (info *HeaderInfo) ReceiptHash() common.Hash { ...@@ -90,6 +91,10 @@ func (info *HeaderInfo) ReceiptHash() common.Hash {
return info.receiptHash return info.receiptHash
} }
func (info *HeaderInfo) GasUsed() uint64 {
return info.gasUsed
}
type rpcHeader struct { type rpcHeader struct {
ParentHash common.Hash `json:"parentHash"` ParentHash common.Hash `json:"parentHash"`
UncleHash common.Hash `json:"sha3Uncles"` UncleHash common.Hash `json:"sha3Uncles"`
...@@ -182,6 +187,7 @@ func (hdr *rpcHeader) Info(trustCache bool, mustBePostMerge bool) (*HeaderInfo, ...@@ -182,6 +187,7 @@ func (hdr *rpcHeader) Info(trustCache bool, mustBePostMerge bool) (*HeaderInfo,
baseFee: (*big.Int)(hdr.BaseFee), baseFee: (*big.Int)(hdr.BaseFee),
txHash: hdr.TxHash, txHash: hdr.TxHash,
receiptHash: hdr.ReceiptHash, receiptHash: hdr.ReceiptHash,
gasUsed: uint64(hdr.GasUsed),
} }
return &info, nil return &info, nil
} }
......
...@@ -21,6 +21,7 @@ type MockBlockInfo struct { ...@@ -21,6 +21,7 @@ type MockBlockInfo struct {
InfoMixDigest [32]byte InfoMixDigest [32]byte
InfoBaseFee *big.Int InfoBaseFee *big.Int
InfoReceiptRoot common.Hash InfoReceiptRoot common.Hash
InfoGasUsed uint64
} }
func (l *MockBlockInfo) Hash() common.Hash { func (l *MockBlockInfo) Hash() common.Hash {
...@@ -59,6 +60,10 @@ func (l *MockBlockInfo) ReceiptHash() common.Hash { ...@@ -59,6 +60,10 @@ func (l *MockBlockInfo) ReceiptHash() common.Hash {
return l.InfoReceiptRoot return l.InfoReceiptRoot
} }
func (l *MockBlockInfo) GasUsed() uint64 {
return l.InfoGasUsed
}
func (l *MockBlockInfo) ID() eth.BlockID { func (l *MockBlockInfo) ID() eth.BlockID {
return eth.BlockID{Hash: l.InfoHash, Number: l.InfoNum} return eth.BlockID{Hash: l.InfoHash, Number: l.InfoNum}
} }
...@@ -81,6 +86,7 @@ func RandomBlockInfo(rng *rand.Rand) *MockBlockInfo { ...@@ -81,6 +86,7 @@ func RandomBlockInfo(rng *rand.Rand) *MockBlockInfo {
InfoBaseFee: big.NewInt(rng.Int63n(1000_000 * 1e9)), // a million GWEI InfoBaseFee: big.NewInt(rng.Int63n(1000_000 * 1e9)), // a million GWEI
InfoReceiptRoot: types.EmptyRootHash, InfoReceiptRoot: types.EmptyRootHash,
InfoRoot: RandomHash(rng), InfoRoot: RandomHash(rng),
InfoGasUsed: rng.Uint64(),
} }
} }
......
...@@ -85,4 +85,4 @@ require ( ...@@ -85,4 +85,4 @@ require (
lukechampine.com/blake3 v1.1.7 // indirect lukechampine.com/blake3 v1.1.7 // indirect
) )
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468 replace github.com/ethereum/go-ethereum v1.10.26 => github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b
...@@ -81,8 +81,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF ...@@ -81,8 +81,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468 h1:7KgjBYDji5AKi42eRYI+n8Gs+ZJVilSASL3WBu82c3M= github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b h1:qpsJ9tFppQOwO0rHrggOrSXW5XIx4G3DBEV6jrf9gU0=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468/go.mod h1:p0Yox74PhYlq1HvijrCBCD9A3cI7rXco7hT6KrQr+rY= github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b/go.mod h1:p0Yox74PhYlq1HvijrCBCD9A3cI7rXco7hT6KrQr+rY=
github.com/ethereum-optimism/optimism/op-node v0.10.3 h1:96KbEtbfJTg5GXtNqLnrDPnXMbeynIy1G8iSc47whrA= github.com/ethereum-optimism/optimism/op-node v0.10.3 h1:96KbEtbfJTg5GXtNqLnrDPnXMbeynIy1G8iSc47whrA=
github.com/ethereum-optimism/optimism/op-node v0.10.3/go.mod h1:fsRLXH68xaLhjfr67MPEtjCocCzSXGhZIre536QccIw= github.com/ethereum-optimism/optimism/op-node v0.10.3/go.mod h1:fsRLXH68xaLhjfr67MPEtjCocCzSXGhZIre536QccIw=
github.com/ethereum-optimism/optimism/op-service v0.10.3 h1:gr+eVq6CzxMFqo0/9n6EoUkpumtYZEzO84gti6ekj/s= github.com/ethereum-optimism/optimism/op-service v0.10.3 h1:gr+eVq6CzxMFqo0/9n6EoUkpumtYZEzO84gti6ekj/s=
......
#!/usr/bin/env python3 #!/usr/bin/env python3
import urllib3
import json import json
import subprocess import subprocess
import os import os
...@@ -11,34 +10,10 @@ GETH_VERSION='v1.10.26' ...@@ -11,34 +10,10 @@ GETH_VERSION='v1.10.26'
def main(): def main():
for project in ('op-service', 'op-node', 'op-proposer', 'op-batcher', 'op-bindings', 'op-chain-ops', 'op-e2e', 'op-wheel'): for project in ('.', 'op-wheel', 'indexer'):
print(f'Updating {project}...') print(f'Updating {project}...')
update_mod(project) update_mod(project)
# pull the replacer from one of the modules above, since
# go work edit -replace does not resolve the branch name
# into a pseudo-version.
pv = None
with open('./op-service/go.mod') as f:
for line in f:
if line.startswith(f'replace github.com/ethereum/go-ethereum {GETH_VERSION}'):
splits = line.split(' => ')
pv = splits[1].strip()
pv = pv.split(' ')[1]
break
if pv is None:
raise Exception('Pseudo version not found.')
print('Updating go.work...')
subprocess.run([
'go',
'work',
'edit',
'-replace',
f'github.com/ethereum/go-ethereum@{GETH_VERSION}=github.com/ethereum-optimism/op-geth@{pv}'
], cwd=os.path.join(project), check=True)
def update_mod(project): def update_mod(project):
print('Replacing...') print('Replacing...')
......
...@@ -139,29 +139,30 @@ L2ERC721Bridge_Test:test_finalizeBridgeERC721_notFromRemoteMessenger_reverts() ( ...@@ -139,29 +139,30 @@ L2ERC721Bridge_Test:test_finalizeBridgeERC721_notFromRemoteMessenger_reverts() (
L2ERC721Bridge_Test:test_finalizeBridgeERC721_notViaLocalMessenger_reverts() (gas: 16148) L2ERC721Bridge_Test:test_finalizeBridgeERC721_notViaLocalMessenger_reverts() (gas: 16148)
L2ERC721Bridge_Test:test_finalizeBridgeERC721_selfToken_reverts() (gas: 17637) L2ERC721Bridge_Test:test_finalizeBridgeERC721_selfToken_reverts() (gas: 17637)
L2ERC721Bridge_Test:test_finalizeBridgeERC721_succeeds() (gas: 168905) L2ERC721Bridge_Test:test_finalizeBridgeERC721_succeeds() (gas: 168905)
L2OutputOracleTest:test_computeL2Timestamp_succeeds() (gas: 37184) L2OutputOracleTest:test_computeL2Timestamp_succeeds() (gas: 37206)
L2OutputOracleTest:test_constructor_badTimestamp_reverts() (gas: 70717) L2OutputOracleTest:test_constructor_badTimestamp_reverts() (gas: 70767)
L2OutputOracleTest:test_constructor_succeeds() (gas: 33760) L2OutputOracleTest:test_constructor_l2BlockTimeZero_reverts() (gas: 45786)
L2OutputOracleTest:test_deleteL2Outputs_afterLatest_reverts() (gas: 211900) L2OutputOracleTest:test_constructor_succeeds() (gas: 33695)
L2OutputOracleTest:test_deleteL2Outputs_afterLatest_reverts() (gas: 211855)
L2OutputOracleTest:test_deleteL2Outputs_ifNotChallenger_reverts() (gas: 18883) L2OutputOracleTest:test_deleteL2Outputs_ifNotChallenger_reverts() (gas: 18883)
L2OutputOracleTest:test_deleteL2Outputs_nonExistent_reverts() (gas: 107292) L2OutputOracleTest:test_deleteL2Outputs_nonExistent_reverts() (gas: 107292)
L2OutputOracleTest:test_deleteOutputs_multipleOutputs_succeeds() (gas: 302121) L2OutputOracleTest:test_deleteOutputs_multipleOutputs_succeeds() (gas: 302143)
L2OutputOracleTest:test_deleteOutputs_singleOutput_succeeds() (gas: 180656) L2OutputOracleTest:test_deleteOutputs_singleOutput_succeeds() (gas: 180700)
L2OutputOracleTest:test_getL2OutputIndexAfter_multipleOutputsExist_succeeds() (gas: 267182) L2OutputOracleTest:test_getL2OutputIndexAfter_multipleOutputsExist_succeeds() (gas: 267226)
L2OutputOracleTest:test_getL2OutputIndexAfter_noOutputsExis_reverts() (gas: 17914) L2OutputOracleTest:test_getL2OutputIndexAfter_noOutputsExis_reverts() (gas: 17936)
L2OutputOracleTest:test_getL2OutputIndexAfter_previousBlock_succeeds() (gas: 96086) L2OutputOracleTest:test_getL2OutputIndexAfter_previousBlock_succeeds() (gas: 96042)
L2OutputOracleTest:test_getL2OutputIndexAfter_sameBlock_succeeds() (gas: 95994) L2OutputOracleTest:test_getL2OutputIndexAfter_sameBlock_succeeds() (gas: 96016)
L2OutputOracleTest:test_getL2Output_succeeds() (gas: 101699) L2OutputOracleTest:test_getL2Output_succeeds() (gas: 101721)
L2OutputOracleTest:test_latestBlockNumber_succeeds() (gas: 96983) L2OutputOracleTest:test_latestBlockNumber_succeeds() (gas: 96960)
L2OutputOracleTest:test_nextBlockNumber_succeeds() (gas: 17468) L2OutputOracleTest:test_nextBlockNumber_succeeds() (gas: 17490)
L2OutputOracleTest:test_proposeL2Output_emptyOutput_reverts() (gas: 26688) L2OutputOracleTest:test_proposeL2Output_emptyOutput_reverts() (gas: 26710)
L2OutputOracleTest:test_proposeL2Output_futureTimetamp_reverts() (gas: 28646) L2OutputOracleTest:test_proposeL2Output_futureTimetamp_reverts() (gas: 28690)
L2OutputOracleTest:test_proposeL2Output_notProposer_reverts() (gas: 25782) L2OutputOracleTest:test_proposeL2Output_notProposer_reverts() (gas: 25826)
L2OutputOracleTest:test_proposeL2Output_proposeAnotherOutput_succeeds() (gas: 101027) L2OutputOracleTest:test_proposeL2Output_proposeAnotherOutput_succeeds() (gas: 101049)
L2OutputOracleTest:test_proposeL2Output_unexpectedBlockNumber_reverts() (gas: 28402) L2OutputOracleTest:test_proposeL2Output_unexpectedBlockNumber_reverts() (gas: 28402)
L2OutputOracleTest:test_proposeL2Output_unmatchedBlockhash_reverts() (gas: 29446) L2OutputOracleTest:test_proposeL2Output_unmatchedBlockhash_reverts() (gas: 29402)
L2OutputOracleTest:test_proposeL2Output_wrongFork_reverts() (gas: 29005) L2OutputOracleTest:test_proposeL2Output_wrongFork_reverts() (gas: 29005)
L2OutputOracleTest:test_proposeWithBlockhashAndHeight_succeeds() (gas: 95296) L2OutputOracleTest:test_proposeWithBlockhashAndHeight_succeeds() (gas: 95318)
L2OutputOracleUpgradeable_Test:test_initValuesOnProxy_succeeds() (gas: 26093) L2OutputOracleUpgradeable_Test:test_initValuesOnProxy_succeeds() (gas: 26093)
L2OutputOracleUpgradeable_Test:test_initializeImpl_alreadyInitialized_reverts() (gas: 15149) L2OutputOracleUpgradeable_Test:test_initializeImpl_alreadyInitialized_reverts() (gas: 15149)
L2OutputOracleUpgradeable_Test:test_initializeProxy_alreadyInitialized_reverts() (gas: 20131) L2OutputOracleUpgradeable_Test:test_initializeProxy_alreadyInitialized_reverts() (gas: 20131)
......
...@@ -73,7 +73,7 @@ contract L2OutputOracle is Initializable, Semver { ...@@ -73,7 +73,7 @@ contract L2OutputOracle is Initializable, Semver {
event OutputsDeleted(uint256 indexed prevNextOutputIndex, uint256 indexed newNextOutputIndex); event OutputsDeleted(uint256 indexed prevNextOutputIndex, uint256 indexed newNextOutputIndex);
/** /**
* @custom:semver 1.0.0 * @custom:semver 1.1.0
* *
* @param _submissionInterval Interval in blocks at which checkpoints must be submitted. * @param _submissionInterval Interval in blocks at which checkpoints must be submitted.
* @param _l2BlockTime The time per L2 block, in seconds. * @param _l2BlockTime The time per L2 block, in seconds.
...@@ -89,7 +89,13 @@ contract L2OutputOracle is Initializable, Semver { ...@@ -89,7 +89,13 @@ contract L2OutputOracle is Initializable, Semver {
uint256 _startingTimestamp, uint256 _startingTimestamp,
address _proposer, address _proposer,
address _challenger address _challenger
) Semver(1, 0, 0) { ) Semver(1, 1, 0) {
require(_l2BlockTime > 0, "L2OutputOracle: L2 block time must be greater than 0");
require(
_submissionInterval > _l2BlockTime,
"L2OutputOracle: submission interval must be greater than L2 block time"
);
SUBMISSION_INTERVAL = _submissionInterval; SUBMISSION_INTERVAL = _submissionInterval;
L2_BLOCK_TIME = _l2BlockTime; L2_BLOCK_TIME = _l2BlockTime;
PROPOSER = _proposer; PROPOSER = _proposer;
......
...@@ -104,4 +104,9 @@ library Predeploys { ...@@ -104,4 +104,9 @@ library Predeploys {
* @notice Address of the L1FeeVault predeploy. * @notice Address of the L1FeeVault predeploy.
*/ */
address internal constant L1_FEE_VAULT = 0x420000000000000000000000000000000000001A; address internal constant L1_FEE_VAULT = 0x420000000000000000000000000000000000001A;
/**
* @notice Address of the GovernanceToken predeploy.
*/
address internal constant GOVERNANCE_TOKEN = 0x4200000000000000000000000000000000000042;
} }
...@@ -44,6 +44,40 @@ contract L2OutputOracleTest is L2OutputOracle_Initializer { ...@@ -44,6 +44,40 @@ contract L2OutputOracleTest is L2OutputOracle_Initializer {
); );
} }
function test_constructor_l2BlockTimeZero_reverts() external {
vm.expectRevert("L2OutputOracle: L2 block time must be greater than 0");
new L2OutputOracle(
submissionInterval,
0,
startingBlockNumber,
block.timestamp,
proposer,
owner
);
}
function testFuzz_constructor_submissionIntervalLteL2BlockTime_reverts(
uint256 _submissionInterval,
uint256 _l2BlockTime
) external {
// Bound the _l2blockTime to be in the range of [1, type(uint256).max]
_l2BlockTime = bound(_l2BlockTime, 1, type(uint256).max);
// Roll the block number to _l2blockTime (the starting L2 timestamp must be less than or equal to the current time)
vm.roll(_l2BlockTime);
// Bound _submissionInterval to be less than or equal to _l2BlockTime
_submissionInterval = bound(_submissionInterval, 0, _l2BlockTime);
vm.expectRevert("L2OutputOracle: submission interval must be greater than L2 block time");
new L2OutputOracle(
_submissionInterval,
_l2BlockTime,
startingBlockNumber,
block.timestamp,
proposer,
owner
);
}
/**************** /****************
* Getter Tests * * Getter Tests *
****************/ ****************/
......
{
"numDeployConfirmations": 1,
"finalSystemOwner": "ADMIN",
"controller": "ADMIN",
"l1StartingBlockTag": "BLOCKHASH",
"l1ChainID": 5,
"l2ChainID": 42069,
"l2BlockTime": 2,
"maxSequencerDrift": 600,
"sequencerWindowSize": 3600,
"channelTimeout": 300,
"p2pSequencerAddress": "SEQUENCER",
"batchInboxAddress": "0xff00000000000000000000000000000000042069",
"batchSenderAddress": "BATCHER",
"l2OutputOracleSubmissionInterval": 120,
"l2OutputOracleStartingBlockNumber": 0,
"l2OutputOracleStartingTimestamp": "TIMESTAMP",
"l2OutputOracleProposer": "PROPOSER",
"l2OutputOracleChallenger": "ADMIN",
"finalizationPeriodSeconds": 12,
"proxyAdminOwner": "ADMIN",
"baseFeeVaultRecipient": "ADMIN",
"l1FeeVaultRecipient": "ADMIN",
"sequencerFeeVaultRecipient": "ADMIN",
"gasPriceOracleOverhead": 2100,
"gasPriceOracleScalar": 1000000,
"governanceTokenSymbol": "OP",
"governanceTokenName": "Optimism",
"governanceTokenOwner": "ADMIN",
"l2GenesisBlockGasLimit": "0x17D7840",
"l2GenesisBlockBaseFeePerGas": "0x3b9aca00",
"eip1559Denominator": 50,
"eip1559Elasticity": 10
}
import { DeployConfig } from '../src/deploy-config'
import config from './getting-started.json'
export default config satisfies DeployConfig
...@@ -5,6 +5,19 @@ import '@nomiclabs/hardhat-ethers' ...@@ -5,6 +5,19 @@ import '@nomiclabs/hardhat-ethers'
import { assertContractVariable, deploy } from '../src/deploy-utils' import { assertContractVariable, deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
if (hre.deployConfig.l2BlockTime === 0) {
throw new Error(
'L2OutputOracle deployment: l2BlockTime must be greater than 0'
)
} else if (
hre.deployConfig.l2OutputOracleSubmissionInterval <=
hre.deployConfig.l2BlockTime
) {
throw new Error(
'L2OutputOracle deployment: submissionInterval must be greater than the l2BlockTime'
)
}
await deploy({ await deploy({
hre, hre,
name: 'L2OutputOracle', name: 'L2OutputOracle',
......
...@@ -84,6 +84,12 @@ const config: HardhatUserConfig = { ...@@ -84,6 +84,12 @@ const config: HardhatUserConfig = {
accounts: [process.env.PRIVATE_KEY_DEPLOYER || ethers.constants.HashZero], accounts: [process.env.PRIVATE_KEY_DEPLOYER || ethers.constants.HashZero],
live: true, live: true,
}, },
'getting-started': {
chainId: 5,
url: process.env.L1_RPC || '',
accounts: [process.env.PRIVATE_KEY_DEPLOYER || ethers.constants.HashZero],
live: true,
},
}, },
foundry: { foundry: {
buildInfo: true, buildInfo: true,
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"build:forge": "forge build", "build:forge": "forge build",
"build:with-metadata": "FOUNDRY_PROFILE=echidna yarn build:forge", "build:with-metadata": "FOUNDRY_PROFILE=echidna yarn build:forge",
"build:differential": "tsc scripts/differential-testing.ts --outDir dist --moduleResolution node --esModuleInterop", "build:differential": "tsc scripts/differential-testing.ts --outDir dist --moduleResolution node --esModuleInterop",
"build:fuzz": "go build -o test-case-generator test-case-generator/cmd/fuzz.go", "build:fuzz": "(cd test-case-generator && go build ./cmd/fuzz.go)",
"prebuild": "yarn ts-node scripts/verify-foundry-install.ts", "prebuild": "yarn ts-node scripts/verify-foundry-install.ts",
"build": "hardhat compile && yarn autogen:artifacts && yarn build:ts && yarn typechain", "build": "hardhat compile && yarn autogen:artifacts && yarn build:ts && yarn typechain",
"build:ts": "tsc -p tsconfig.build.json", "build:ts": "tsc -p tsconfig.build.json",
......
...@@ -211,7 +211,7 @@ GossipSub [parameters][gossip-parameters]: ...@@ -211,7 +211,7 @@ GossipSub [parameters][gossip-parameters]:
- `fanout_ttl` (ttl for fanout maps for topics we are not subscribed to but have published to, in seconds): 24 - `fanout_ttl` (ttl for fanout maps for topics we are not subscribed to but have published to, in seconds): 24
- `mcache_len` (number of windows to retain full messages in cache for `IWANT` responses): 12 - `mcache_len` (number of windows to retain full messages in cache for `IWANT` responses): 12
- `mcache_gossip` (number of windows to gossip about): 3 - `mcache_gossip` (number of windows to gossip about): 3
- `seen_ttl` (number of heartbeat intervals to retain message IDs): 80 (= 40 seconds) - `seen_ttl` (number of heartbeat intervals to retain message IDs): 130 (= 65 seconds)
Notable differences from L1 consensus (Eth2): Notable differences from L1 consensus (Eth2):
......
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