diff --git a/go.mod b/go.mod index ed3594ba5004..da8d806374c7 100644 --- a/go.mod +++ b/go.mod @@ -228,7 +228,7 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect ) -replace github.com/ethereum/go-ethereum v1.13.15 => github.com/blockchaindevsh/op-geth v0.0.0-20240711035602-dfbe1492069c +replace github.com/ethereum/go-ethereum v1.13.15 => github.com/ethstorage/op-geth v0.0.0-20240918005936-a18d1c99aecb //replace github.com/ethereum/go-ethereum v1.13.9 => ../op-geth diff --git a/go.sum b/go.sum index 7cd4c72362f4..4c050b77abbf 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,6 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= -github.com/blockchaindevsh/op-geth v0.0.0-20240711035602-dfbe1492069c h1:uSibLxYF1JVhapdx6xszr5f/Bzm2RU3l66mag3KdZoY= -github.com/blockchaindevsh/op-geth v0.0.0-20240711035602-dfbe1492069c/go.mod h1:8tQ6r0e1NNJbSVHzYKafQqf62gV9BzZR+SKkXRckjLM= github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= @@ -183,6 +181,8 @@ github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethstorage/da-server v0.0.0-20240628094857-ed2ee4ff52d9 h1:yRJRj81rP83R5dZEsYitAFcqRagK/e+UxhiSSK4/Wds= github.com/ethstorage/da-server v0.0.0-20240628094857-ed2ee4ff52d9/go.mod h1:YeveZNzQFdseeqS0mQavqfyMI+U9l1GQu0CEwezTZA8= +github.com/ethstorage/op-geth v0.0.0-20240918005936-a18d1c99aecb h1:f076fgZk2/vUmrpHewhKOJgLXjQqfzsRlU/gKVPiKbg= +github.com/ethstorage/op-geth v0.0.0-20240918005936-a18d1c99aecb/go.mod h1:8tQ6r0e1NNJbSVHzYKafQqf62gV9BzZR+SKkXRckjLM= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= diff --git a/op-chain-ops/genesis/config.go b/op-chain-ops/genesis/config.go index bfc7bb9a08a7..6138b467f135 100644 --- a/op-chain-ops/genesis/config.go +++ b/op-chain-ops/genesis/config.go @@ -289,9 +289,10 @@ type DeployConfig struct { // UseInterop is a flag that indicates if the system is using interop UseInterop bool `json:"useInterop,omitempty"` - // l2 blob related configs - EnableL2Blob bool `json:"enable_l2_blob,omitempty"` - DACURLS []string `json:"dac_urls,omitempty"` + // L2GenesisBlobTimeOffset is the number of seconds after genesis block that the L2Blob hard fork activates. + // Set it to 0 to activate at genesis. Nil to disable L2Blob. + L2GenesisBlobTimeOffset *hexutil.Uint64 `json:"l2GenesisBlobTimeOffset,omitempty"` + DACURLS []string `json:"dac_urls,omitempty"` // UseSoulGasToken is a flag that indicates if the system is using SoulGasToken UseSoulGasToken bool `json:"useSoulGasToken"` @@ -612,6 +613,17 @@ func (d *DeployConfig) InteropTime(genesisTime uint64) *uint64 { return &v } +func (d *DeployConfig) L2BlobTime(genesisTime uint64) *uint64 { + if d.L2GenesisBlobTimeOffset == nil { + return nil + } + v := uint64(0) + if offset := *d.L2GenesisBlobTimeOffset; offset > 0 { + v = genesisTime + uint64(offset) + } + return &v +} + // RollupConfig converts a DeployConfig to a rollup.Config. If Ecotone is active at genesis, the // Overhead value is considered a noop. func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2GenesisBlockHash common.Hash, l2GenesisBlockNumber uint64) (*rollup.Config, error) { @@ -631,9 +643,9 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2GenesisBlockHas } var l2BlobConfig *rollup.L2BlobConfig - if d.EnableL2Blob { + if d.L2GenesisBlobTimeOffset != nil { l2BlobConfig = &rollup.L2BlobConfig{ - EnableL2Blob: true, + L2BlobTime: d.L2BlobTime(l1StartBlock.Time()), } if len(d.DACURLS) > 0 { l2BlobConfig.DACConfig = &rollup.DACConfig{URLS: d.DACURLS} diff --git a/op-chain-ops/genesis/genesis.go b/op-chain-ops/genesis/genesis.go index 5b32f561910b..fc5c94387073 100644 --- a/op-chain-ops/genesis/genesis.go +++ b/op-chain-ops/genesis/genesis.go @@ -68,11 +68,11 @@ func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, erro EcotoneTime: config.EcotoneTime(block.Time()), FjordTime: config.FjordTime(block.Time()), InteropTime: config.InteropTime(block.Time()), + L2BlobTime: config.L2BlobTime(block.Time()), Optimism: ¶ms.OptimismConfig{ EIP1559Denominator: eip1559Denom, EIP1559Elasticity: eip1559Elasticity, EIP1559DenominatorCanyon: eip1559DenomCanyon, - EnableL2Blob: config.EnableL2Blob, IsSoulBackedByNative: config.IsSoulBackedByNative, UseSoulGasToken: config.UseSoulGasToken, }, diff --git a/op-node/p2p/gossip.go b/op-node/p2p/gossip.go index 6c6bdd6cf53d..a2f2443bb589 100644 --- a/op-node/p2p/gossip.go +++ b/op-node/p2p/gossip.go @@ -313,7 +313,7 @@ func BuildBlocksValidator(log log.Logger, cfg *rollup.Config, runCfg GossipRunti now := uint64(time.Now().Unix()) // [REJECT] if the `payload.timestamp` is older than 60 seconds in the past - if uint64(payload.Timestamp) < now-60 { + if uint64(payload.Timestamp) < now-60 || uint64(payload.Timestamp) < cfg.BlockTime /* ensure timestamp>=BlockTime since we'll do subtraction below */ { log.Warn("payload is too old", "timestamp", uint64(payload.Timestamp)) return pubsub.ValidationReject } @@ -362,13 +362,13 @@ func BuildBlocksValidator(log log.Logger, cfg *rollup.Config, runCfg GossipRunti if blockVersion.HasBlobProperties() { // [REJECT] if the block is on a topic >= V3 and has a blob gas used value that is not zero - if payload.BlobGasUsed == nil || (!cfg.IsL2BlobEnabled() && *payload.BlobGasUsed != 0) { + if payload.BlobGasUsed == nil || (!cfg.IsL2Blob(uint64(payload.Timestamp)-cfg.BlockTime) && *payload.BlobGasUsed != 0) { log.Warn("payload is on v3 topic, but has non-zero blob gas used", "bad_hash", payload.BlockHash.String(), "blob_gas_used", payload.BlobGasUsed) return pubsub.ValidationReject } // [REJECT] if the block is on a topic >= V3 and has an excess blob gas value that is not zero - if payload.ExcessBlobGas == nil || (!cfg.IsL2BlobEnabled() && *payload.ExcessBlobGas != 0) { + if payload.ExcessBlobGas == nil || (!cfg.IsL2Blob(uint64(payload.Timestamp)-cfg.BlockTime) && *payload.ExcessBlobGas != 0) { log.Warn("payload is on v3 topic, but has non-zero excess blob gas", "bad_hash", payload.BlockHash.String(), "excess_blob_gas", payload.ExcessBlobGas) return pubsub.ValidationReject } diff --git a/op-node/rollup/types.go b/op-node/rollup/types.go index 5d020c94ae38..6f9ebfc171aa 100644 --- a/op-node/rollup/types.go +++ b/op-node/rollup/types.go @@ -149,8 +149,8 @@ type Config struct { } type L2BlobConfig struct { - DACConfig *DACConfig `json:"dac_config,omitempty"` - EnableL2Blob bool `json:"enable_l2_blob,omitempty"` + DACConfig *DACConfig `json:"dac_config,omitempty"` + L2BlobTime *uint64 `json:"l2BlobTime,omitempty"` } type DACConfig struct { URLS []string `json:"urls,omitempty"` @@ -165,8 +165,9 @@ func (dacConfig *DACConfig) Client() DACClient { return client.New(dacConfig.URLS) } -func (cfg *Config) IsL2BlobEnabled() bool { - return cfg.L2BlobConfig != nil && cfg.L2BlobConfig.EnableL2Blob +// IsL2Blob returns whether l2 blob is enabled +func (cfg *Config) IsL2Blob(parentTime uint64) bool { + return cfg.L2BlobConfig != nil && *cfg.L2BlobConfig.L2BlobTime <= parentTime } func (cfg *Config) DACConfig() *DACConfig {