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
|
|
|
|
2021-05-06 17:37:38 +00:00
|
|
|
jsoniter "github.com/json-iterator/go"
|
2021-05-20 18:25:53 +00:00
|
|
|
"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"
|
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)
|
2021-06-26 12:27:29 +00:00
|
|
|
ReplayBlockTransactions(ctx context.Context, blockNr rpc.BlockNumberOrHash, traceTypes []string) ([]*TraceCallResult, error)
|
|
|
|
ReplayTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) (*TraceCallResult, 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)
|
2021-05-06 17:37:38 +00:00
|
|
|
Filter(ctx context.Context, req TraceFilterRequest, stream *jsoniter.Stream) 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-06-16 17:24:56 +00:00
|
|
|
kv ethdb.RoKV
|
|
|
|
maxTraces uint64
|
|
|
|
gasCap uint64
|
|
|
|
compatibility bool // Bug for bug compatiblity with OpenEthereum
|
2020-08-29 15:50:24 +00:00
|
|
|
}
|
|
|
|
|
2020-09-25 12:12:36 +00:00
|
|
|
// NewTraceAPI returns NewTraceAPI instance
|
2021-05-17 12:15:19 +00:00
|
|
|
func NewTraceAPI(base *BaseAPI, kv ethdb.RoKV, cfg *cli.Flags) *TraceAPIImpl {
|
2020-08-29 15:50:24 +00:00
|
|
|
return &TraceAPIImpl{
|
2021-06-16 17:24:56 +00:00
|
|
|
BaseAPI: base,
|
|
|
|
kv: kv,
|
|
|
|
maxTraces: cfg.MaxTraces,
|
|
|
|
gasCap: cfg.Gascap,
|
|
|
|
compatibility: cfg.TraceCompatibility,
|
2020-08-29 15:50:24 +00:00
|
|
|
}
|
|
|
|
}
|