diff --git a/beacon/engine/types.go b/beacon/engine/types.go index 9a3ea8d077..aef01e7f5f 100644 --- a/beacon/engine/types.go +++ b/beacon/engine/types.go @@ -217,9 +217,11 @@ func ExecutableDataToBlock(params ExecutableData, versionedHashes []common.Hash, if err != nil { return nil, err } - if len(params.ExtraData) > 32 { - return nil, fmt.Errorf("invalid extradata length: %v", len(params.ExtraData)) - } + + // TODO(galaio): need hardfork, skip check + //if len(params.ExtraData) > 32 { + // return nil, fmt.Errorf("invalid extradata length: %v", len(params.ExtraData)) + //} if len(params.LogsBloom) != 256 { return nil, fmt.Errorf("invalid logsBloom length: %v", len(params.LogsBloom)) } diff --git a/core/blockchain.go b/core/blockchain.go index caba259bed..31511af72d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1887,7 +1887,15 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error) if err != nil { return it.index, err } - log.Info("Insert chain", "block", block.NumberU64(), "txDAG", txDAG) + log.Info("Insert chain", "block", block.NumberU64(), "txDAG", txDAG.Type()) + } + // TODO(galaio): need hardfork + if bc.chainConfig.Optimism != nil && len(block.Header().Extra) > 0 { + txDAG, err := types.DecodeTxDAG(block.Header().Extra) + if err != nil { + return it.index, err + } + log.Info("Insert chain", "block", block.NumberU64(), "txDAG", txDAG.Type()) } // Enable prefetching to pull in trie node paths while processing transactions diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go index e0338f28c9..9fe363f151 100644 --- a/core/parallel_state_processor.go +++ b/core/parallel_state_processor.go @@ -741,6 +741,14 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat return nil, nil, 0, err } } + // TODO(galaio): need hardfork + if p.bc.chainConfig.Optimism != nil && len(block.Header().Extra) > 0 { + txDAG, err = types.DecodeTxDAG(block.Header().Extra) + if err != nil { + return nil, nil, 0, err + } + log.Info("dispatch chain with", "block", block.NumberU64(), "txDAG", txDAG.Type()) + } // From now on, entering parallel execution. p.doStaticDispatchV2(p.allTxReqs, txDAG) // todo: put txReqs in unit? diff --git a/miner/worker.go b/miner/worker.go index f52d58085e..d0a1a31b64 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1337,6 +1337,25 @@ func (w *worker) generateWork(genParams *generateParams) *newPayloadResult { return &newPayloadResult{err: fmt.Errorf("empty block root")} } + // Because the TxDAG appends after sidecar, so we only enable after cancun + if w.chainConfig.IsCancun(block.Number(), block.Time()) && w.chainConfig.Optimism == nil { + txDAG, _ := work.state.MVStates2TxDAG() + rawTxDAG, err := types.EncodeTxDAG(txDAG) + if err != nil { + return &newPayloadResult{err: err} + } + block = block.WithTxDAG(rawTxDAG) + } + + // TODO(galaio): need hardfork + if w.chainConfig.Optimism != nil { + txDAG, _ := work.state.MVStates2TxDAG() + rawTxDAG, err := types.EncodeTxDAG(txDAG) + if err != nil { + return &newPayloadResult{err: err} + } + block.Header().Extra = rawTxDAG + } assembleBlockTimer.UpdateSince(start) log.Debug("assembleBlockTimer", "duration", common.PrettyDuration(time.Since(start)), "parentHash", genParams.parentHash) @@ -1444,7 +1463,7 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti } // Because the TxDAG appends after sidecar, so we only enable after cancun - if w.chainConfig.IsCancun(env.header.Number, env.header.Time) { + if w.chainConfig.IsCancun(env.header.Number, env.header.Time) && w.chainConfig.Optimism == nil { for i := len(env.txs); i < len(block.Transactions()); i++ { env.state.RecordSystemTxRWSet(i) } @@ -1456,6 +1475,16 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti block = block.WithTxDAG(rawTxDAG) } + // TODO(galaio): need hardfork + if w.chainConfig.Optimism != nil { + txDAG, _ := env.state.MVStates2TxDAG() + rawTxDAG, err := types.EncodeTxDAG(txDAG) + if err != nil { + return err + } + block.Header().Extra = rawTxDAG + } + // If we're post merge, just ignore if !w.isTTDReached(block.Header()) { select {