erigon-pulse/cmd/rpcdaemon/commands/trace_api.go
Alex Sharov 0edac73451
RPC: trace_replayTransaction and trace_replayBlockTransactions methods (stateDiff only) (#2238)
* trace_replay

* trace_replay

* trace_replay

* trace_replay

* trace_replay
2021-06-26 13:27:29 +01:00

50 lines
1.9 KiB
Go

package commands
import (
"context"
"encoding/json"
jsoniter "github.com/json-iterator/go"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/hexutil"
"github.com/ledgerwatch/erigon/ethdb"
"github.com/ledgerwatch/erigon/rpc"
)
// TraceAPI RPC interface into tracing API
type TraceAPI interface {
// Ad-hoc (see ./trace_adhoc.go)
ReplayBlockTransactions(ctx context.Context, blockNr rpc.BlockNumberOrHash, traceTypes []string) ([]*TraceCallResult, error)
ReplayTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) (*TraceCallResult, error)
Call(ctx context.Context, call TraceCallParam, types []string, blockNr *rpc.BlockNumberOrHash) (*TraceCallResult, error)
CallMany(ctx context.Context, calls json.RawMessage, blockNr *rpc.BlockNumberOrHash) ([]*TraceCallResult, error)
RawTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)
// Filtering (see ./trace_filtering.go)
Transaction(ctx context.Context, txHash common.Hash) (ParityTraces, error)
Get(ctx context.Context, txHash common.Hash, txIndicies []hexutil.Uint64) (*ParityTrace, error)
Block(ctx context.Context, blockNr rpc.BlockNumber) (ParityTraces, error)
Filter(ctx context.Context, req TraceFilterRequest, stream *jsoniter.Stream) error
}
// TraceAPIImpl is implementation of the TraceAPI interface based on remote Db access
type TraceAPIImpl struct {
*BaseAPI
kv ethdb.RoKV
maxTraces uint64
gasCap uint64
compatibility bool // Bug for bug compatiblity with OpenEthereum
}
// NewTraceAPI returns NewTraceAPI instance
func NewTraceAPI(base *BaseAPI, kv ethdb.RoKV, cfg *cli.Flags) *TraceAPIImpl {
return &TraceAPIImpl{
BaseAPI: base,
kv: kv,
maxTraces: cfg.MaxTraces,
gasCap: cfg.Gascap,
compatibility: cfg.TraceCompatibility,
}
}