Skip to content

Commit cdca791

Browse files
authored
fix(taiko): decode basefeeSharingPctg from extradata for ontake blocks (#370)
1 parent 3b30523 commit cdca791

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

eth/state_accessor.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block,
259259
}
260260
// Assemble the transaction call message and return if the requested offset
261261
msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee())
262+
263+
// CHANGE(taiko): decode the basefeeSharingPctg config from the extradata, and
264+
// add it to the Message, if its an ontake block.
265+
if eth.blockchain.Config().IsOntake(block.Number()) {
266+
msg.BasefeeSharingPctg = core.DecodeOntakeExtraData(block.Header().Extra)
267+
}
262268
txContext := core.NewEVMTxContext(msg)
263269
context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil)
264270
if idx == txIndex {

eth/tracers/api.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
279279
}
280280
}
281281
msg, _ := core.TransactionToMessage(tx, signer, task.block.BaseFee())
282+
// CHANGE(taiko): decode the basefeeSharingPctg config from the extradata, and
283+
// add it to the Message, if its an ontake block.
284+
if api.backend.ChainConfig().IsOntake(task.block.Number()) {
285+
msg.BasefeeSharingPctg = core.DecodeOntakeExtraData(task.block.Header().Extra)
286+
}
282287
txctx := &Context{
283288
BlockHash: task.block.Hash(),
284289
BlockNumber: task.block.Number(),
@@ -565,6 +570,11 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
565570
txContext = core.NewEVMTxContext(msg)
566571
vmenv = vm.NewEVM(vmctx, txContext, statedb, chainConfig, vm.Config{})
567572
)
573+
// CHANGE(taiko): decode the basefeeSharingPctg config from the extradata, and
574+
// add it to the Message, if its an ontake block.
575+
if api.backend.ChainConfig().IsOntake(block.Number()) {
576+
msg.BasefeeSharingPctg = core.DecodeOntakeExtraData(block.Header().Extra)
577+
}
568578
statedb.SetTxContext(tx.Hash(), i)
569579
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit)); err != nil {
570580
log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err)
@@ -647,6 +657,11 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
647657
}
648658
// Generate the next state snapshot fast without tracing
649659
msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee())
660+
// CHANGE(taiko): decode the basefeeSharingPctg config from the extradata, and
661+
// add it to the Message, if its an ontake block.
662+
if api.backend.ChainConfig().IsOntake(block.Number()) {
663+
msg.BasefeeSharingPctg = core.DecodeOntakeExtraData(block.Header().Extra)
664+
}
650665
txctx := &Context{
651666
BlockHash: blockHash,
652667
BlockNumber: block.Number(),
@@ -694,6 +709,11 @@ func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, stat
694709
// Fetch and execute the next transaction trace tasks
695710
for task := range jobs {
696711
msg, _ := core.TransactionToMessage(txs[task.index], signer, block.BaseFee())
712+
// CHANGE(taiko): decode the basefeeSharingPctg config from the extradata, and
713+
// add it to the Message, if its an ontake block.
714+
if api.backend.ChainConfig().IsOntake(block.Number()) {
715+
msg.BasefeeSharingPctg = core.DecodeOntakeExtraData(block.Header().Extra)
716+
}
697717
txctx := &Context{
698718
BlockHash: blockHash,
699719
BlockNumber: block.Number(),
@@ -829,6 +849,11 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
829849
writer *bufio.Writer
830850
err error
831851
)
852+
// CHANGE(taiko): decode the basefeeSharingPctg config from the extradata, and
853+
// add it to the Message, if its an ontake block.
854+
if api.backend.ChainConfig().IsOntake(block.Number()) {
855+
msg.BasefeeSharingPctg = core.DecodeOntakeExtraData(block.Header().Extra)
856+
}
832857
// If the transaction needs tracing, swap out the configs
833858
if tx.Hash() == txHash || txHash == (common.Hash{}) {
834859
// Generate a unique temporary file to dump it into

0 commit comments

Comments
 (0)