diff --git a/beacon/light/request/scheduler.go b/beacon/light/request/scheduler.go index e80daf805e86..242ed56d2840 100644 --- a/beacon/light/request/scheduler.go +++ b/beacon/light/request/scheduler.go @@ -269,7 +269,7 @@ func (s *Scheduler) addEvent(event Event) { s.Trigger() } -// filterEvent sorts each Event either as a request event or a server event, +// filterEvents sorts each Event either as a request event or a server event, // depending on its type. Request events are also sorted in a map based on the // module that originally initiated the request. It also ensures that no events // related to a server are returned before EvRegistered or after EvUnregistered. diff --git a/consensus/misc/eip1559/eip1559.go b/consensus/misc/eip1559/eip1559.go index a970bdcd31b3..98456a1653b1 100644 --- a/consensus/misc/eip1559/eip1559.go +++ b/consensus/misc/eip1559/eip1559.go @@ -57,7 +57,7 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade return nil } -// DecodeHolocene1599Params extracts the Holcene 1599 parameters from the encoded form defined here: +// DecodeHolocene1559Params extracts the Holcene 1599 parameters from the encoded form defined here: // https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/holocene/exec-engine.md#eip-1559-parameters-in-payloadattributesv3 // // Returns 0,0 if the format is invalid, though ValidateHolocene1559Params should be used instead of this function for diff --git a/consensus/misc/eip1559/eip1559_test.go b/consensus/misc/eip1559/eip1559_test.go index c69dc80f93ac..c48b540b74e6 100644 --- a/consensus/misc/eip1559/eip1559_test.go +++ b/consensus/misc/eip1559/eip1559_test.go @@ -187,7 +187,7 @@ func TestCalcBaseFeeOptimism(t *testing.T) { } } -// TestCalcBaseFeeHolocene assumes all blocks are Optimism blocks post-Holocene upgrade +// TestCalcBaseFeeOptimismHolocene assumes all blocks are Optimism blocks post-Holocene upgrade func TestCalcBaseFeeOptimismHolocene(t *testing.T) { parentBaseFee := int64(10_000_000) parentGasLimit := uint64(30_000_000) diff --git a/core/blockchain.go b/core/blockchain.go index bbf57c3ccb7a..b9fd783e625a 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -410,10 +410,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis } } } - // The first thing the node will do is reconstruct the verification data for - // the head block (ethash cache or clique voting snapshot). Might as well do - // it in advance. - bc.engine.VerifyHeader(bc, bc.CurrentHeader()) if bc.logger != nil && bc.logger.OnBlockchainInit != nil { bc.logger.OnBlockchainInit(chainConfig) @@ -467,6 +463,11 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis rawdb.WriteChainConfig(db, genesisHash, chainConfig) } + // The first thing the node will do is reconstruct the verification data for + // the head block (ethash cache or clique voting snapshot). Might as well do + // it in advance. + bc.engine.VerifyHeader(bc, bc.CurrentHeader()) + // Start tx indexer if it's enabled. if txLookupLimit != nil { bc.txIndexer = newTxIndexer(*txLookupLimit, bc) diff --git a/core/genesis.go b/core/genesis.go index 201ba049fe00..622e4f7924d7 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -381,6 +381,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g // Get the existing chain configuration. newcfg := genesis.configOrDefault(stored) applyOverrides(newcfg) + if err := newcfg.CheckConfigForkOrder(); err != nil { return newcfg, common.Hash{}, err } @@ -390,7 +391,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g rawdb.WriteChainConfig(db, stored, newcfg) return newcfg, stored, nil } + storedData, _ := json.Marshal(storedcfg) + log.Info("Stored config", "json", string(storedData)) // Special case: if a private network is being used (no genesis and also no // mainnet hash in the database), we must not apply the `configOrDefault` // chain config as that would be AllProtocolChanges (applying any new fork @@ -400,6 +403,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g newcfg = storedcfg applyOverrides(newcfg) } + newData, _ := json.Marshal(newcfg) + log.Info("New config", "json", string(newData), "genesis-nil", genesis == nil) + // Check config compatibility and write the config. Compatibility errors // are returned to the caller unless we're already at block zero. head := rawdb.ReadHeadHeader(db) @@ -414,9 +420,13 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g if compatErr != nil && ((head.Number.Uint64() != 0 && compatErr.RewindToBlock != 0) || (head.Time != 0 && compatErr.RewindToTime != 0)) { return newcfg, stored, compatErr } + // Don't overwrite if the old is identical to the new - if newData, _ := json.Marshal(newcfg); !bytes.Equal(storedData, newData) { + if !bytes.Equal(storedData, newData) { + log.Info("Configs differ") rawdb.WriteChainConfig(db, stored, newcfg) + } else { + log.Info("Configs equal") } return newcfg, stored, nil } diff --git a/core/state_transition.go b/core/state_transition.go index 2b8f22dc75de..ee63af70c3ff 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -157,6 +157,8 @@ type Message struct { Mint *big.Int // Mint is the amount to mint before EVM processing, or nil if there is no minting. RollupCostData types.RollupCostData // RollupCostData caches data to compute the fee we charge for data availability + // PostValidation is an optional check of the resulting post-state, if and when the message is + // applied fully to the EVM. This function may return an error to deny inclusion of the message. PostValidation func(evm *vm.EVM, result *ExecutionResult) error } @@ -452,7 +454,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { err = nil } - if st.msg.PostValidation != nil { + if err == nil && st.msg.PostValidation != nil { if err := st.msg.PostValidation(st.evm, result); err != nil { return nil, err } diff --git a/go.mod b/go.mod index 3c152bd5bdbb..2753cbc702ce 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/deckarep/golang-set/v2 v2.6.0 github.com/donovanhide/eventsource v0.0.0-20210830082556-c59027999da0 github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 - github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241119111730-bee358f6d6e6 + github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241213092551-33a63fce8214 github.com/ethereum/c-kzg-4844 v1.0.0 github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 github.com/fatih/color v1.16.0 diff --git a/go.sum b/go.sum index a63fc834cd02..b8799493464f 100644 --- a/go.sum +++ b/go.sum @@ -171,8 +171,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.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241119111730-bee358f6d6e6 h1:+AIYWDX7FeWRLnBVqPiwireTacLLGGww1slGyv+YN0o= -github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241119111730-bee358f6d6e6/go.mod h1:9feO8jcL5OZ1tvRjEfNAHz4Aggvd6373l+ZxmZZAyZs= +github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241213092551-33a63fce8214 h1:94dIMFDCafAQ3FCC1pryuhgfZc1jPoDwK4xSMOPshN8= +github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20241213092551-33a63fce8214/go.mod h1:9feO8jcL5OZ1tvRjEfNAHz4Aggvd6373l+ZxmZZAyZs= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= diff --git a/miner/miner.go b/miner/miner.go index 25229e50a9d4..447cf4ccbd2f 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -60,13 +60,12 @@ type Config struct { GasPrice *big.Int // Minimum gas price for mining a transaction Recommit time.Duration // The time interval for miner to re-create mining work. - RollupComputePendingBlock bool // Compute the pending block from tx-pool, instead of copying the latest-block - EffectiveGasCeil uint64 // if non-zero, a gas ceiling to apply independent of the header's gaslimit value + RollupComputePendingBlock bool // Compute the pending block from tx-pool, instead of copying the latest-block + RollupTransactionConditionalRateLimit int // Total number of conditional cost units allowed in a second - RollupTransactionConditionalRateLimit int // Total number of conditional cost units allowed in a second - - MaxDATxSize *big.Int // if non-nil, don't include any txs with data availability size larger than this in any built block - MaxDABlockSize *big.Int // if non-nil, then don't build a block requiring more than this amount of total data availability + EffectiveGasCeil uint64 // if non-zero, a gas ceiling to apply independent of the header's gaslimit value + MaxDATxSize *big.Int `toml:",omitempty"` // if non-nil, don't include any txs with data availability size larger than this in any built block + MaxDABlockSize *big.Int `toml:",omitempty"` // if non-nil, then don't build a block requiring more than this amount of total data availability } // DefaultConfig contains default settings for miner. diff --git a/miner/miner_test.go b/miner/miner_test.go index d365ee18ac12..e038b02f61b9 100644 --- a/miner/miner_test.go +++ b/miner/miner_test.go @@ -188,8 +188,8 @@ func TestRejectedConditionalTx(t *testing.T) { }) tx.SetConditional(&types.TransactionConditional{TimestampMax: uint64Ptr(timestamp - 1)}) - // 1 pending tx - miner.txpool.Add(types.Transactions{tx}, true, false) + // 1 pending tx (synchronously, it has to be there before it can be rejected) + miner.txpool.Add(types.Transactions{tx}, true, true) if !miner.txpool.Has(tx.Hash()) { t.Fatalf("conditional tx is not in the mempool") } diff --git a/miner/worker.go b/miner/worker.go index a4f297c6c6b4..c3bd100897b2 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -545,6 +545,12 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran log.Debug("adding tx would exceed block DA size limit", "hash", ltx.Hash, "txda", ltx.DABytes, "blockda", blockDABytes, "dalimit", miner.config.MaxDABlockSize) txs.Pop() + // If the number of remaining bytes is too few to hold even the minimum possible transaction size, + // then we can stop early. + daBytesRemaining := new(big.Int).Sub(miner.config.MaxDABlockSize, daBytesAfter) + if daBytesRemaining.Cmp(types.MinTransactionSize) < 0 { + break + } continue } } diff --git a/params/config.go b/params/config.go index 04cc43a84037..05c7c93bbaff 100644 --- a/params/config.go +++ b/params/config.go @@ -21,6 +21,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params/forks" ) @@ -709,6 +710,7 @@ func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height, time uint64, var lasterr *ConfigCompatError for { err := c.checkCompatible(newcfg, bhead, btime, genesisTimestamp) + log.Info("Checking compatibility", "height", bhead, "time", btime, "error", err) if err == nil || (lasterr != nil && err.RewindToBlock == lasterr.RewindToBlock && err.RewindToTime == lasterr.RewindToTime) { break } @@ -955,7 +957,7 @@ func configBlockEqual(x, y *big.Int) bool { // isForkTimestampIncompatible returns true if a fork scheduled at timestamp s1 // cannot be rescheduled to timestamp s2 because head is already past the fork. func isForkTimestampIncompatible(s1, s2 *uint64, head uint64, genesis *uint64) bool { - return (isTimestampForked(s1, head) || isTimestampForked(s2, head)) && !configTimestampEqual(s1, s2) && !isTimestampPreGenesis(s1, genesis) && !isTimestampPreGenesis(s2, genesis) + return (isTimestampForked(s1, head) || isTimestampForked(s2, head)) && !configTimestampEqual(s1, s2) && !(isTimestampPreGenesis(s1, genesis) && isTimestampPreGenesis(s2, genesis)) } func isTimestampPreGenesis(s, genesis *uint64) bool { diff --git a/params/config_test.go b/params/config_test.go index 4e5f3e5af416..a12cd6333748 100644 --- a/params/config_test.go +++ b/params/config_test.go @@ -144,6 +144,30 @@ func TestCheckCompatible(t *testing.T) { genesisTimestamp: newUint64(24), wantErr: nil, }, + { + stored: &ChainConfig{HoloceneTime: newUint64(10)}, + new: &ChainConfig{HoloceneTime: newUint64(20)}, + headTimestamp: 25, + genesisTimestamp: newUint64(15), + wantErr: &ConfigCompatError{ + What: "Holocene fork timestamp", + StoredTime: newUint64(10), + NewTime: newUint64(20), + RewindToTime: 9, + }, + }, + { + stored: &ChainConfig{HoloceneTime: newUint64(10)}, + new: &ChainConfig{HoloceneTime: newUint64(20)}, + headTimestamp: 15, + genesisTimestamp: newUint64(5), + wantErr: &ConfigCompatError{ + What: "Holocene fork timestamp", + StoredTime: newUint64(10), + NewTime: newUint64(20), + RewindToTime: 9, + }, + }, } for i, test := range tests { diff --git a/params/superchain.go b/params/superchain.go index bab6bec17e0b..110d7d98f5c7 100644 --- a/params/superchain.go +++ b/params/superchain.go @@ -11,7 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" ) -var OPStackSupport = ProtocolVersionV0{Build: [8]byte{}, Major: 9, Minor: 0, Patch: 0, PreRelease: 1}.Encode() +var OPStackSupport = ProtocolVersionV0{Build: [8]byte{}, Major: 9, Minor: 0, Patch: 0, PreRelease: 0}.Encode() func init() { for id, ch := range superchain.OPChains {