fix: traceTx function

This commit is contained in:
anshalshukla 2024-08-22 17:21:22 +05:30
parent f88af20009
commit ab2db597d9
No known key found for this signature in database
GPG key ID: 84BE5474523D8CBC
2 changed files with 4 additions and 8 deletions

View file

@ -1392,11 +1392,6 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor
config.BorTx = newBoolPtr(false)
}
_, err = core.ApplyTransactionWithEVM(message, api.backend.ChainConfig(), new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, vmenv, context.Background())
if err != nil {
return nil, fmt.Errorf("tracing failed: %w", err)
}
if *config.BorTx {
callmsg := prepareCallMessage(*message)
// nolint : contextcheck
@ -1404,8 +1399,10 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor
return nil, fmt.Errorf("tracing failed: %w", err)
}
} else {
// nolint : contextcheck
if _, err = core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.GasLimit), context.Background()); err != nil {
// Call Prepare to clear out the statedb access list
statedb.SetTxContext(txctx.TxHash, txctx.TxIndex)
_, err = core.ApplyTransactionWithEVM(message, api.backend.ChainConfig(), new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, vmenv, context.Background())
if err != nil {
return nil, fmt.Errorf("tracing failed: %w", err)
}
}

View file

@ -469,7 +469,6 @@ func TestTraceTransaction(t *testing.T) {
api := NewAPI(backend)
result, err := api.TraceTransaction(context.Background(), target, nil)
fmt.Println("Anshal trace txn - ", result)
if err != nil {
t.Errorf("Failed to trace transaction %v", err)
}