mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
eth/tracers: support traceCall with txIndex (#8736)
This is a similar PR of https://github.com/ethereum/go-ethereum/pull/28460, support traceCall in the middle of a block Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
4873502818
commit
32d05a3b40
@ -3,6 +3,7 @@ package tracers
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
||||
"github.com/ledgerwatch/erigon/eth/tracers/logger"
|
||||
"github.com/ledgerwatch/erigon/turbo/adapter/ethapi"
|
||||
)
|
||||
@ -19,4 +20,5 @@ type TraceConfig struct {
|
||||
|
||||
BorTraceEnabled *bool
|
||||
BorTx *bool
|
||||
TxIndex *hexutil.Uint
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package jsonrpc
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
|
@ -3,28 +3,27 @@ package jsonrpc
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
|
||||
"github.com/ledgerwatch/erigon/core/vm/evmtypes"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
||||
"github.com/ledgerwatch/erigon/common/math"
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||
"github.com/ledgerwatch/erigon/core/state"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
"github.com/ledgerwatch/erigon/core/vm"
|
||||
"github.com/ledgerwatch/erigon/core/vm/evmtypes"
|
||||
"github.com/ledgerwatch/erigon/eth/tracers"
|
||||
"github.com/ledgerwatch/erigon/rpc"
|
||||
"github.com/ledgerwatch/erigon/turbo/adapter/ethapi"
|
||||
"github.com/ledgerwatch/erigon/turbo/rpchelper"
|
||||
"github.com/ledgerwatch/erigon/turbo/transactions"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// TraceBlockByNumber implements debug_traceBlockByNumber. Returns Geth style block traces.
|
||||
@ -267,7 +266,7 @@ func (api *PrivateDebugAPIImpl) TraceCall(ctx context.Context, args ethapi.CallA
|
||||
}
|
||||
engine := api.engine()
|
||||
|
||||
blockNumber, hash, _, err := rpchelper.GetBlockNumber(blockNrOrHash, dbtx, api.filters)
|
||||
blockNumber, hash, isLatest, err := rpchelper.GetBlockNumber(blockNrOrHash, dbtx, api.filters)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get block number: %v", err)
|
||||
}
|
||||
@ -277,7 +276,12 @@ func (api *PrivateDebugAPIImpl) TraceCall(ctx context.Context, args ethapi.CallA
|
||||
return err
|
||||
}
|
||||
|
||||
stateReader, err := rpchelper.CreateStateReader(ctx, dbtx, blockNrOrHash, 0, api.filters, api.stateCache, api.historyV3(dbtx), chainConfig.ChainName)
|
||||
var stateReader state.StateReader
|
||||
if config.TxIndex == nil || isLatest {
|
||||
stateReader, err = rpchelper.CreateStateReader(ctx, dbtx, blockNrOrHash, 0, api.filters, api.stateCache, api.historyV3(dbtx), chainConfig.ChainName)
|
||||
} else {
|
||||
stateReader, err = rpchelper.CreateHistoryStateReader(dbtx, blockNumber, int(*config.TxIndex), api.historyV3(dbtx), chainConfig.ChainName)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("create state reader: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user