Skip to content

Commit f9d376c

Browse files
eth/tracers: handle madhugiri fork in trace apis (#1925)
* eth/tracers: handle madhugiri fork in trace api * eth/tracers: avoid using block.transactions() * params: version bump to v2.5.4 --------- Co-authored-by: Pratik Patil <pratikspatil024@gmail.com>
1 parent 4c7bce2 commit f9d376c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

eth/tracers/api.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,20 @@ func (api *API) blockByNumberAndHash(ctx context.Context, number rpc.BlockNumber
176176
// getAllBlockTransactions returns all blocks transactions including state-sync transaction if present
177177
// along with a flag and it's hash (which is calculated differently than regular transactions)
178178
func (api *API) getAllBlockTransactions(ctx context.Context, block *types.Block) (types.Transactions, bool, common.Hash) {
179-
txs := block.Transactions()
179+
var (
180+
txs types.Transactions = block.Transactions()
181+
stateSyncPresent bool
182+
stateSyncHash common.Hash
183+
)
180184

181-
stateSyncPresent := false
182-
stateSyncHash := common.Hash{}
185+
isMadhugiri := api.backend.ChainConfig().Bor != nil && api.backend.ChainConfig().Bor.IsMadhugiri(block.Number())
186+
if isMadhugiri {
187+
if len(txs) > 0 && txs[len(txs)-1].Type() == types.StateSyncTxType {
188+
stateSyncPresent = true
189+
stateSyncHash = txs[len(txs)-1].Hash()
190+
}
191+
return txs, stateSyncPresent, stateSyncHash
192+
}
183193

184194
borReceipt := rawdb.ReadBorReceipt(api.backend.ChainDb(), block.Hash(), block.NumberU64(), api.backend.ChainConfig())
185195
if borReceipt != nil {
@@ -1088,7 +1098,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
10881098
if chainConfig.IsPrague(block.Number()) {
10891099
core.ProcessParentBlockHash(block.ParentHash(), evm)
10901100
}
1091-
for i, tx := range block.Transactions() {
1101+
for i, tx := range txs {
10921102
// Prepare the transaction for un-traced execution
10931103
var (
10941104
msg, _ = core.TransactionToMessage(tx, signer, block.BaseFee())

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
const (
2626
VersionMajor = 2 // Major version component of the current release
2727
VersionMinor = 5 // Minor version component of the current release
28-
VersionPatch = 3 // Patch version component of the current release
28+
VersionPatch = 4 // Patch version component of the current release
2929
VersionMeta = "" // Version metadata to append to the version string
3030
)
3131

0 commit comments

Comments
 (0)