Skip to content

Commit

Permalink
Merge tag 'v1.101411.4' into release/optimism-1.x-fh3.0
Browse files Browse the repository at this point in the history
Tag created with op-workbench.
  • Loading branch information
Eduard-Voiculescu committed Dec 20, 2024
2 parents 43f1a6f + efa05b1 commit 2c588d0
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 22 deletions.
2 changes: 1 addition & 1 deletion beacon/light/request/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion consensus/misc/eip1559/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion consensus/misc/eip1559/eip1559_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
11 changes: 5 additions & 6 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions miner/miner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
6 changes: 6 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
4 changes: 3 additions & 1 deletion params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions params/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion params/superchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2c588d0

Please sign in to comment.