From a1198fba816fb1dffdc373ad586f4ff3be0b83c9 Mon Sep 17 00:00:00 2001 From: blockchaindevsh Date: Tue, 17 Sep 2024 20:55:33 +0800 Subject: [PATCH] replace "enable_l2_blob" with "l2BlobTime" --- go.mod | 2 +- go.sum | 4 ++-- op-chain-ops/genesis/config.go | 8 ++++---- op-chain-ops/genesis/genesis.go | 2 +- op-node/p2p/gossip.go | 6 +++--- op-node/rollup/types.go | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index ed3594ba50048..7fac6b4123c79 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-20240917122918-64a6306fa986 //replace github.com/ethereum/go-ethereum v1.13.9 => ../op-geth diff --git a/go.sum b/go.sum index 7cd4c72362f4b..dc7a164026a08 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-20240917122918-64a6306fa986 h1:VOG50dsZCNOBBBg6yoKWn3/eWMtfFLXoOnvT23t68nI= +github.com/ethstorage/op-geth v0.0.0-20240917122918-64a6306fa986/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 bfc7bb9a08a7d..ed85e550494ea 100644 --- a/op-chain-ops/genesis/config.go +++ b/op-chain-ops/genesis/config.go @@ -290,8 +290,8 @@ 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"` + L2BlobTime *uint64 `json:"l2BlobTime,omitempty"` + DACURLS []string `json:"dac_urls,omitempty"` // UseSoulGasToken is a flag that indicates if the system is using SoulGasToken UseSoulGasToken bool `json:"useSoulGasToken"` @@ -631,9 +631,9 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2GenesisBlockHas } var l2BlobConfig *rollup.L2BlobConfig - if d.EnableL2Blob { + if d.L2BlobTime != nil { l2BlobConfig = &rollup.L2BlobConfig{ - EnableL2Blob: true, + L2BlobTime: d.L2BlobTime, } 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 5b32f561910b5..b0a72388effbe 100644 --- a/op-chain-ops/genesis/genesis.go +++ b/op-chain-ops/genesis/genesis.go @@ -72,7 +72,7 @@ func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, erro EIP1559Denominator: eip1559Denom, EIP1559Elasticity: eip1559Elasticity, EIP1559DenominatorCanyon: eip1559DenomCanyon, - EnableL2Blob: config.EnableL2Blob, + L2BlobTime: config.L2BlobTime, IsSoulBackedByNative: config.IsSoulBackedByNative, UseSoulGasToken: config.UseSoulGasToken, }, diff --git a/op-node/p2p/gossip.go b/op-node/p2p/gossip.go index 6c6bdd6cf53d9..925b59958c0b8 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.IsL2BlobEnabled(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.IsL2BlobEnabled(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 5d020c94ae38c..260e925aa6852 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,8 @@ func (dacConfig *DACConfig) Client() DACClient { return client.New(dacConfig.URLS) } -func (cfg *Config) IsL2BlobEnabled() bool { - return cfg.L2BlobConfig != nil && cfg.L2BlobConfig.EnableL2Blob +func (cfg *Config) IsL2BlobEnabled(parentTime uint64) bool { + return cfg.L2BlobConfig != nil && *cfg.L2BlobConfig.L2BlobTime <= parentTime } func (cfg *Config) DACConfig() *DACConfig {