2020-08-29 15:50:24 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-02-10 17:04:47 +00:00
|
|
|
"encoding/json"
|
2020-08-29 15:50:24 +00:00
|
|
|
|
2020-09-25 12:12:36 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/cli"
|
2020-08-29 15:50:24 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common/hexutil"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
2020-09-25 12:12:36 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/rpc"
|
2021-03-30 07:09:00 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/turbo/rpchelper"
|
2020-08-29 15:50:24 +00:00
|
|
|
)
|
|
|
|
|
2020-09-25 12:12:36 +00:00
|
|
|
// TraceAPI RPC interface into tracing API
|
2020-08-29 15:50:24 +00:00
|
|
|
type TraceAPI interface {
|
2020-10-20 21:16:28 +00:00
|
|
|
// Ad-hoc (see ./trace_adhoc.go)
|
2020-09-26 06:41:34 +00:00
|
|
|
ReplayBlockTransactions(ctx context.Context, blockNr rpc.BlockNumber, traceTypes []string) ([]interface{}, error)
|
|
|
|
ReplayTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)
|
2020-12-14 11:27:52 +00:00
|
|
|
Call(ctx context.Context, call TraceCallParam, types []string, blockNr *rpc.BlockNumberOrHash) (*TraceCallResult, error)
|
2021-02-10 17:04:47 +00:00
|
|
|
CallMany(ctx context.Context, calls json.RawMessage, blockNr *rpc.BlockNumberOrHash) ([]*TraceCallResult, error)
|
2020-09-26 06:41:34 +00:00
|
|
|
RawTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)
|
2020-09-25 12:12:36 +00:00
|
|
|
|
2020-10-20 21:16:28 +00:00
|
|
|
// Filtering (see ./trace_filtering.go)
|
2020-09-25 12:12:36 +00:00
|
|
|
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) (ParityTraces, error)
|
2020-08-29 15:50:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TraceAPIImpl is implementation of the TraceAPI interface based on remote Db access
|
|
|
|
type TraceAPIImpl struct {
|
2021-01-02 19:28:22 +00:00
|
|
|
*BaseAPI
|
2021-03-30 09:53:54 +00:00
|
|
|
kv ethdb.RoKV
|
2020-10-03 08:07:49 +00:00
|
|
|
maxTraces uint64
|
|
|
|
traceType string
|
2020-12-14 11:27:52 +00:00
|
|
|
gasCap uint64
|
2021-03-30 07:09:00 +00:00
|
|
|
pending *rpchelper.Pending
|
2020-08-29 15:50:24 +00:00
|
|
|
}
|
|
|
|
|
2020-09-25 12:12:36 +00:00
|
|
|
// NewTraceAPI returns NewTraceAPI instance
|
2021-03-30 09:53:54 +00:00
|
|
|
func NewTraceAPI(kv ethdb.RoKV, pending *rpchelper.Pending, cfg *cli.Flags) *TraceAPIImpl {
|
2020-08-29 15:50:24 +00:00
|
|
|
return &TraceAPIImpl{
|
2021-01-02 19:28:22 +00:00
|
|
|
BaseAPI: &BaseAPI{},
|
2021-03-30 09:53:54 +00:00
|
|
|
kv: kv,
|
2020-10-03 08:07:49 +00:00
|
|
|
maxTraces: cfg.MaxTraces,
|
|
|
|
traceType: cfg.TraceType,
|
2020-12-14 11:27:52 +00:00
|
|
|
gasCap: cfg.Gascap,
|
2021-03-30 07:09:00 +00:00
|
|
|
pending: pending,
|
2020-08-29 15:50:24 +00:00
|
|
|
}
|
|
|
|
}
|