Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canyon Hard Fork #105

Merged
merged 36 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
92a36e8
Enable ci for tip/canyon branch
pcw109550 Nov 1, 2023
29b7bfb
Add Canyon network override flags
pcw109550 Nov 1, 2023
9dabedf
Update erigon-lib
pcw109550 Nov 2, 2023
9707654
Change EIP 1559 Denominator with Canyon
pcw109550 Nov 2, 2023
77b2209
Update erigon-lib
pcw109550 Nov 2, 2023
8b92f9f
Merge pull request #97 from testinprod-io/pcw109550/canyon/config-ove…
Nov 2, 2023
88a18c0
Merge pull request #98 from testinprod-io/pcw109550/canyon/eip1559-de…
Nov 6, 2023
aa17e2d
post-Canyon receipt-root deposit tx hashing fix
pcw109550 Nov 3, 2023
cb15a81
Add tests for post-Canyon receipt-root deposit tx hashing fix
pcw109550 Nov 3, 2023
f7c07d3
Remove unused method
pcw109550 Nov 3, 2023
dc4a7b6
Fix comment
pcw109550 Nov 4, 2023
87d1c83
Avoid null access for blockNumber while receipt copy
pcw109550 Nov 4, 2023
a183507
Deepcopy receipts while testing
pcw109550 Nov 4, 2023
2d70c29
Add deposit related field when receipt json marshal
pcw109550 Nov 4, 2023
a92dcc0
Run codecgen and gencodec for receipt
pcw109550 Nov 4, 2023
699ca44
Add receipt test for json sedes
pcw109550 Nov 4, 2023
3e319d2
Remove unnecessary conversion
pcw109550 Nov 6, 2023
a1b6e0b
Merge pull request #99 from testinprod-io/pcw109550/canyon/deposit-tx…
Nov 7, 2023
f794865
Add create2deployer precompile
pcw109550 Nov 7, 2023
d477f8d
Add tests for create2deployer precompile
pcw109550 Nov 7, 2023
8d65cc7
Deploy create2deployer in the next hardfork
pcw109550 Nov 7, 2023
0675f0f
Merge pull request #101 from testinprod-io/pcw109550/canyon/create2de…
Nov 7, 2023
a87c476
Activate shanghai with canyon
pcw109550 Nov 7, 2023
f0bfb99
Remove debug print
pcw109550 Nov 8, 2023
ca4ce28
Merge pull request #102 from testinprod-io/pcw109550/canyon/shanghai-…
Nov 8, 2023
64e3677
Update erigon-lib
pcw109550 Nov 8, 2023
44d3c46
Update field name
pcw109550 Nov 8, 2023
e221714
Add canyon time in op-goerli and devnet
pcw109550 Nov 8, 2023
1bc4858
Add test for ensuring canyon time is on block boundary
pcw109550 Nov 8, 2023
689a578
Ensure setting EIP1559DenominatorCanyon if canyon override is set
pcw109550 Nov 8, 2023
e41cc5c
Fall back for default canyon time
pcw109550 Nov 8, 2023
068f0db
Warn when canyonTime is not set
pcw109550 Nov 8, 2023
f48892f
Adjust canyonTime for devnet for avoid precompile deploy
pcw109550 Nov 8, 2023
4f7093d
Merge pull request #103 from testinprod-io/pcw109550/canyon/fix-eip15…
ImTei Nov 8, 2023
22c57fb
Merge pull request #104 from testinprod-io/pcw109550/canyon/chainspec
ImTei Nov 8, 2023
d076798
Update erigon-lib version
ImTei Nov 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on:
- alpha
- stable
- op-erigon
- tip/canyon
pull_request:
branches:
- devel
- alpha
- stable
- op-erigon
- tip/canyon
types:
- opened
- reopened
Expand Down
2 changes: 1 addition & 1 deletion cmd/erigon-el/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (
genesisSpec = nil
}
var genesisErr error
chainConfig, genesis, genesisErr = core.WriteGenesisBlock(tx, genesisSpec, config.OverrideShanghaiTime, tmpdir, logger)
chainConfig, genesis, genesisErr = core.WriteGenesisBlock(tx, genesisSpec, config.OverrideShanghaiTime, config.OverrideOptimismCanyonTime, tmpdir, logger)
if _, ok := genesisErr.(*chain.ConfigCompatError); genesisErr != nil && !ok {
return genesisErr
}
Expand Down
10 changes: 10 additions & 0 deletions cmd/integration/commands/state_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,16 @@ func (b *blockProcessor) applyBlock(
}
}

// Optimism Canyon
ibs := state.New(b.reader)
misc.EnsureCreate2Deployer(b.chainConfig, header.Time, ibs)
if err := ibs.FinalizeTx(rules, b.writer); err != nil {
return nil, err
}
if err := b.writer.w.FinishTx(); err != nil {
return nil, fmt.Errorf("finish create2Deployer failed: %w", err)
}

b.txNum++ // Pre-block transaction
b.writer.w.SetTxNum(b.txNum)
if err := b.writer.w.FinishTx(); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/rpcdaemon/commands/erigon_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ func buildBlockResponse(br services.FullBlockReader, db kv.Tx, blockNum uint64,
additionalFields["totalDifficulty"] = (*hexutil.Big)(td)
}

depositNonces := rawdb.ReadDepositNonces(db, blockNum)
response, err := ethapi.RPCMarshalBlockEx(block, true, fullTx, nil, common.Hash{}, additionalFields, depositNonces)
receipts := rawdb.ReadRawReceipts(db, blockNum)
response, err := ethapi.RPCMarshalBlockEx(block, true, fullTx, nil, common.Hash{}, additionalFields, receipts)

if err == nil && rpc.BlockNumber(block.NumberU64()) == rpc.PendingBlockNumber {
// Pending blocks need to nil out a few fields
Expand Down
14 changes: 10 additions & 4 deletions cmd/rpcdaemon/commands/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,14 @@ type RPCTransaction struct {
SourceHash *common.Hash `json:"sourceHash,omitempty"`
Mint *hexutil.Big `json:"mint,omitempty"`
IsSystemTx *bool `json:"isSystemTx,omitempty"`
// deposit-tx post-Canyon only
DepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"`
}

// newRPCTransaction returns a transaction that will serialize to the RPC
// representation, with the given location metadata set (if available).
func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int,
depositNonce *uint64) *RPCTransaction {
receipt *types.Receipt) *RPCTransaction {
// Determine the signer. For replay-protected transactions, use the most permissive
// signer, because we assume that signers are backwards-compatible with old
// transactions. For non-protected transactions, the homestead signer signer is used
Expand Down Expand Up @@ -464,8 +466,12 @@ func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber
if t.IsSystemTransaction {
result.IsSystemTx = &t.IsSystemTransaction
}
if depositNonce != nil {
result.Nonce = hexutil.Uint64(*depositNonce)
if receipt != nil && receipt.DepositNonce != nil {
result.Nonce = hexutil.Uint64(*receipt.DepositNonce)
if receipt.DepositReceiptVersion != nil {
result.DepositReceiptVersion = new(hexutil.Uint64)
*result.DepositReceiptVersion = hexutil.Uint64(*receipt.DepositReceiptVersion)
}
}
result.GasPrice = (*hexutil.Big)(common.Big0)
// must contain v, r, s values for backwards compatibility.
Expand Down Expand Up @@ -537,7 +543,7 @@ func newRPCBorTransaction(opaqueTx types.Transaction, txHash common.Hash, blockH
func newRPCPendingTransaction(tx types.Transaction, current *types.Header, config *chain.Config) *RPCTransaction {
var baseFee *big.Int
if current != nil {
baseFee = misc.CalcBaseFee(config, current)
baseFee = misc.CalcBaseFee(config, current, current.Time+1)
}
return newRPCTransaction(tx, common.Hash{}, 0, 0, baseFee, nil)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/rpcdaemon/commands/eth_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ func (api *APIImpl) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber
}
}

depositNonces := rawdb.ReadDepositNonces(tx, b.NumberU64())
response, err := ethapi.RPCMarshalBlockEx(b, true, fullTx, borTx, borTxHash, additionalFields, depositNonces)
receipts := rawdb.ReadRawReceipts(tx, b.NumberU64())
response, err := ethapi.RPCMarshalBlockEx(b, true, fullTx, borTx, borTxHash, additionalFields, receipts)
if err == nil && number == rpc.PendingBlockNumber {
// Pending blocks need to nil out a few fields
for _, field := range []string{"hash", "nonce", "miner"} {
Expand Down Expand Up @@ -291,8 +291,8 @@ func (api *APIImpl) GetBlockByHash(ctx context.Context, numberOrHash rpc.BlockNu
}
}

depositNonces := rawdb.ReadDepositNonces(tx, number)
response, err := ethapi.RPCMarshalBlockEx(block, true, fullTx, borTx, borTxHash, additionalFields, depositNonces)
receipts := rawdb.ReadRawReceipts(tx, number)
response, err := ethapi.RPCMarshalBlockEx(block, true, fullTx, borTx, borTxHash, additionalFields, receipts)

if chainConfig.Bor != nil {
response["miner"], _ = ecrecover(block.Header(), chainConfig.Bor)
Expand Down
9 changes: 7 additions & 2 deletions cmd/rpcdaemon/commands/eth_receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,13 @@ func marshalReceipt(receipt *types.Receipt, txn types.Transaction, chainConfig *
fields["l1GasUsed"] = hexutil.Big(*receipt.L1GasUsed)
fields["l1Fee"] = hexutil.Big(*receipt.L1Fee)
fields["l1FeeScalar"] = receipt.FeeScalar
} else if receipt.DepositNonce != nil {
fields["depositNonce"] = hexutil.Uint64(*receipt.DepositNonce)
} else {
if receipt.DepositNonce != nil {
fields["depositNonce"] = hexutil.Uint64(*receipt.DepositNonce)
}
if receipt.DepositReceiptVersion != nil {
fields["depositReceiptVersion"] = hexutil.Uint64(*receipt.DepositReceiptVersion)
}
}
}

Expand Down
27 changes: 12 additions & 15 deletions cmd/rpcdaemon/commands/eth_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ func (api *APIImpl) GetTransactionByHash(ctx context.Context, txnHash common.Has
}

if chainConfig.IsOptimism() {
depositNonces := rawdb.ReadDepositNonces(tx, block.NumberU64())
if txnIndex >= uint64(len(depositNonces)) {
return nil, fmt.Errorf("depositNonce for tx %x not found", txnHash)
} else {
return newRPCTransaction(txn, blockHash, blockNum, txnIndex, baseFee, depositNonces[txnIndex]), nil
receipts := rawdb.ReadRawReceipts(tx, block.NumberU64())
if len(receipts) <= int(txnIndex) {
return nil, fmt.Errorf("block has less receipts than expected: %d <= %d, block: %d", len(receipts), int(txnIndex), blockNum)
}
return newRPCTransaction(txn, blockHash, blockNum, txnIndex, baseFee, receipts[txnIndex]), nil
}
return newRPCTransaction(txn, blockHash, blockNum, txnIndex, baseFee, nil), nil
}
Expand Down Expand Up @@ -209,12 +208,11 @@ func (api *APIImpl) GetTransactionByBlockHashAndIndex(ctx context.Context, block
}

if chainConfig.IsOptimism() {
depositNonces := rawdb.ReadDepositNonces(tx, block.NumberU64())
if uint64(txIndex) >= uint64(len(depositNonces)) {
return nil, fmt.Errorf("depositNonce for tx %x not found", txs[txIndex].Hash())
} else {
return newRPCTransaction(txs[txIndex], block.Hash(), block.NumberU64(), uint64(txIndex), block.BaseFee(), depositNonces[txIndex]), nil
receipts := rawdb.ReadRawReceipts(tx, block.NumberU64())
if len(receipts) <= int(txIndex) {
return nil, fmt.Errorf("block has less receipts than expected: %d <= %d, block: %d", len(receipts), int(txIndex), block.NumberU64())
}
return newRPCTransaction(txs[txIndex], block.Hash(), block.NumberU64(), uint64(txIndex), block.BaseFee(), receipts[txIndex]), nil
}
return newRPCTransaction(txs[txIndex], block.Hash(), block.NumberU64(), uint64(txIndex), block.BaseFee(), nil), nil
}
Expand Down Expand Up @@ -280,12 +278,11 @@ func (api *APIImpl) GetTransactionByBlockNumberAndIndex(ctx context.Context, blo
return newRPCBorTransaction(borTx, derivedBorTxHash, block.Hash(), block.NumberU64(), uint64(txIndex), block.BaseFee(), chainConfig.ChainID), nil
}
if chainConfig.IsOptimism() {
depositNonces := rawdb.ReadDepositNonces(tx, blockNum)
if uint64(txIndex) >= uint64(len(depositNonces)) {
return nil, fmt.Errorf("depositNonce for tx %x not found", txs[txIndex].Hash())
} else {
return newRPCTransaction(txs[txIndex], block.Hash(), blockNum, uint64(txIndex), block.BaseFee(), depositNonces[txIndex]), nil
receipts := rawdb.ReadRawReceipts(tx, block.NumberU64())
if len(receipts) <= int(txIndex) {
return nil, fmt.Errorf("block has less receipts than expected: %d <= %d, block: %d", len(receipts), int(txIndex), block.NumberU64())
}
return newRPCTransaction(txs[txIndex], block.Hash(), block.NumberU64(), uint64(txIndex), block.BaseFee(), receipts[txIndex]), nil
}
return newRPCTransaction(txs[txIndex], block.Hash(), block.NumberU64(), uint64(txIndex), block.BaseFee(), nil), nil
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/rpcdaemon/commands/eth_uncles.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func (api *APIImpl) GetUncleByBlockNumberAndIndex(ctx context.Context, number rp
return nil, nil
}
uncle := types.NewBlockWithHeader(uncles[index])
depositNonces := rawdb.ReadDepositNonces(tx, blockNum)
return ethapi.RPCMarshalBlock(uncle, false, false, additionalFields, depositNonces)
receipts := rawdb.ReadRawReceipts(tx, blockNum)
return ethapi.RPCMarshalBlock(uncle, false, false, additionalFields, receipts)
}

// GetUncleByBlockHashAndIndex implements eth_getUncleByBlockHashAndIndex. Returns information about an uncle given a block's hash and the index of the uncle.
Expand Down Expand Up @@ -79,8 +79,8 @@ func (api *APIImpl) GetUncleByBlockHashAndIndex(ctx context.Context, hash common
return nil, nil
}
uncle := types.NewBlockWithHeader(uncles[index])
depositNonces := rawdb.ReadDepositNonces(tx, number)
return ethapi.RPCMarshalBlock(uncle, false, false, additionalFields, depositNonces)
receipts := rawdb.ReadRawReceipts(tx, number)
return ethapi.RPCMarshalBlock(uncle, false, false, additionalFields, receipts)
}

// GetUncleCountByBlockNumber implements eth_getUncleCountByBlockNumber. Returns the number of uncles in the block, if any.
Expand Down
4 changes: 2 additions & 2 deletions cmd/rpcdaemon/commands/graphql_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ func (api *GraphQLAPIImpl) delegateGetBlockByNumber(tx kv.Tx, b *types.Block, nu
return nil, err
}
additionalFields := make(map[string]interface{})
depositNonces := rawdb.ReadDepositNonces(tx, uint64(number.Int64()))
response, err := ethapi.RPCMarshalBlock(b, inclTx, inclTx, additionalFields, depositNonces)
receipts := rawdb.ReadRawReceipts(tx, uint64(number.Int64()))
response, err := ethapi.RPCMarshalBlock(b, inclTx, inclTx, additionalFields, receipts)
if !inclTx {
delete(response, "transactions") // workaround for https://github.com/ledgerwatch/erigon/issues/4989#issuecomment-1218415666
}
Expand Down
19 changes: 9 additions & 10 deletions cmd/rpcdaemon/commands/otterscan_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,17 @@ func (api *OtterscanAPIImpl) searchTransactionsBeforeV3(tx kv.TemporalTx, ctx co
return nil, err
}
var rpcTx *RPCTransaction
var receipt *types.Receipt
if chainConfig.IsOptimism() {
depositNonces := rawdb.ReadDepositNonces(tx, blockNum)
if txIndex >= len(depositNonces) {
return nil, fmt.Errorf("depositNonce for tx %x not found", txn.Hash())
} else {
rpcTx = newRPCTransaction(txn, blockHash, blockNum, uint64(txIndex), header.BaseFee, depositNonces[txIndex])
receipts := rawdb.ReadRawReceipts(tx, blockNum)
if len(receipts) <= txIndex {
return nil, fmt.Errorf("block has less receipts than expected: %d <= %d, block: %d", len(receipts), txIndex, blockNum)
}
} else {
rpcTx = newRPCTransaction(txn, blockHash, blockNum, uint64(txIndex), header.BaseFee, nil)
receipt = receipts[txIndex]
}
rpcTx = newRPCTransaction(txn, blockHash, blockNum, uint64(txIndex), header.BaseFee, receipt)
txs = append(txs, rpcTx)
receipt := &types.Receipt{
receipt = &types.Receipt{
Type: txn.Type(), CumulativeGasUsed: res.UsedGas,
TransactionIndex: uint(txIndex),
BlockNumber: header.Number, BlockHash: blockHash, Logs: rawLogs,
Expand Down Expand Up @@ -677,8 +676,8 @@ func (api *OtterscanAPIImpl) delegateGetBlockByNumber(tx kv.Tx, b *types.Block,
return nil, err
}
additionalFields := make(map[string]interface{})
depositNonces := rawdb.ReadDepositNonces(tx, uint64(number.Int64()))
response, err := ethapi.RPCMarshalBlock(b, inclTx, inclTx, additionalFields, depositNonces)
receipts := rawdb.ReadRawReceipts(tx, uint64(number.Int64()))
response, err := ethapi.RPCMarshalBlock(b, inclTx, inclTx, additionalFields, receipts)
if !inclTx {
delete(response, "transactions") // workaround for https://github.com/ledgerwatch/erigon/issues/4989#issuecomment-1218415666
}
Expand Down
13 changes: 4 additions & 9 deletions cmd/rpcdaemon/commands/otterscan_search_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ func (api *OtterscanAPIImpl) traceBlock(dbtx kv.Tx, ctx context.Context, blockNu
header := block.Header()
rules := chainConfig.Rules(block.NumberU64(), header.Time)
found := false

var depositNonces []*uint64
if chainConfig.IsOptimism() {
depositNonces = rawdb.ReadDepositNonces(dbtx, blockNum)
}
for idx, tx := range block.Transactions() {
ibs.SetTxContext(tx.Hash(), block.Hash(), idx)

Expand All @@ -116,11 +111,11 @@ func (api *OtterscanAPIImpl) traceBlock(dbtx kv.Tx, ctx context.Context, blockNu
_ = ibs.FinalizeTx(rules, cachedWriter)

if tracer.Found {
var depositNonce *uint64
if chainConfig.IsOptimism() && idx < len(depositNonces) {
depositNonce = depositNonces[idx]
var receipt *types.Receipt
if chainConfig.IsOptimism() && idx < len(block.Transactions()) {
receipt = blockReceipts[idx]
}
rpcTx := newRPCTransaction(tx, block.Hash(), blockNum, uint64(idx), block.BaseFee(), depositNonce)
rpcTx := newRPCTransaction(tx, block.Hash(), blockNum, uint64(idx), block.BaseFee(), receipt)
mReceipt := marshalReceipt(blockReceipts[idx], tx, chainConfig, block.HeaderNoCopy(), tx.Hash(), true)
mReceipt["timestamp"] = block.Time()
rpcTxs = append(rpcTxs, rpcTx)
Expand Down
10 changes: 10 additions & 0 deletions cmd/state/commands/erigon4.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ func processBlock23(startTxNum uint64, trace bool, txNumStart uint64, rw *StateR
}
}

// Optimism Canyon
ibs := state.New(rw)
misc.EnsureCreate2Deployer(chainConfig, header.Time, ibs)
if err := ibs.FinalizeTx(rules, ww); err != nil {
return 0, nil, err
}
if err := ww.w.FinishTx(); err != nil {
return 0, nil, fmt.Errorf("finish create2Deployer failed: %w", err)
}

txNum++ // Pre-block transaction
ww.w.SetTxNum(txNum)
if err := ww.w.FinishTx(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions cmd/state/commands/opcode_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,10 @@ func runBlock(engine consensus.Engine, ibs *state.IntraBlockState, txnWriter sta
if chainConfig.DAOForkBlock != nil && chainConfig.DAOForkBlock.Cmp(block.Number()) == 0 {
misc.ApplyDAOHardFork(ibs)
}

// Optimism Canyon
misc.EnsureCreate2Deployer(chainConfig, header.Time, ibs)

systemcontracts.UpgradeBuildInSystemContract(chainConfig, header.Number, ibs, logger)
rules := chainConfig.Rules(block.NumberU64(), block.Time())
for i, tx := range block.Transactions() {
Expand Down
15 changes: 12 additions & 3 deletions cmd/state/exec3/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,22 @@ func (rw *Worker) RunTxTaskNoLock(txTask *exec22.TxTask) {

rules := txTask.Rules
daoForkTx := rw.chainConfig.DAOForkBlock != nil && rw.chainConfig.DAOForkBlock.Uint64() == txTask.BlockNum && txTask.TxIndex == -1
// Optimism Canyon
create2DeployerTx := txTask.TxIndex == -1

var err error
header := txTask.Header

switch {
case daoForkTx:
//fmt.Printf("txNum=%d, blockNum=%d, DAO fork\n", txTask.TxNum, txTask.BlockNum)
misc.ApplyDAOHardFork(ibs)
case daoForkTx || create2DeployerTx:
if daoForkTx {
//fmt.Printf("txNum=%d, blockNum=%d, DAO fork\n", txTask.TxNum, txTask.BlockNum)
misc.ApplyDAOHardFork(ibs)
}
if create2DeployerTx && header != nil {
// Optimism Canyon
misc.EnsureCreate2Deployer(rw.chainConfig, header.Time, ibs)
}
ibs.SoftFinalise()
case txTask.TxIndex == -1:
if txTask.BlockNum == 0 {
Expand Down
15 changes: 12 additions & 3 deletions cmd/state/exec3/state_recon.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ func (rw *ReconWorker) runTxTask(txTask *exec22.TxTask) error {
ibs := rw.ibs
rules := txTask.Rules
daoForkTx := rw.chainConfig.DAOForkBlock != nil && rw.chainConfig.DAOForkBlock.Uint64() == txTask.BlockNum && txTask.TxIndex == -1
// Optimism Canyon
create2DeployerTx := txTask.TxIndex == -1

var err error
if txTask.BlockNum == 0 && txTask.TxIndex == -1 {
//fmt.Printf("txNum=%d, blockNum=%d, Genesis\n", txTask.TxNum, txTask.BlockNum)
Expand All @@ -303,9 +306,15 @@ func (rw *ReconWorker) runTxTask(txTask *exec22.TxTask) error {
}
// For Genesis, rules should be empty, so that empty accounts can be included
rules = &chain.Rules{}
} else if daoForkTx {
//fmt.Printf("txNum=%d, blockNum=%d, DAO fork\n", txNum, blockNum)
misc.ApplyDAOHardFork(ibs)
} else if daoForkTx || create2DeployerTx {
if daoForkTx {
//fmt.Printf("txNum=%d, blockNum=%d, DAO fork\n", txNum, blockNum)
misc.ApplyDAOHardFork(ibs)
}
if create2DeployerTx && txTask.Header != nil {
// Optimism Canyon
misc.EnsureCreate2Deployer(rw.chainConfig, txTask.Header.Time, ibs)
}
ibs.SoftFinalise()
} else if txTask.Final {
if txTask.BlockNum > 0 {
Expand Down
Loading