Skip to content

Commit

Permalink
fix debug call (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Apr 25, 2022
1 parent d46e1f2 commit f5b5d86
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions modelsc/cblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/eth/tracers"
"github.com/ava-labs/coreth/ethclient"
"github.com/ava-labs/coreth/interfaces"
"github.com/ava-labs/coreth/rpc"
Expand Down Expand Up @@ -123,11 +124,6 @@ func (c *Client) Close() {
c.rpcClient.Close()
}

type TracerParam struct {
Tracer string `json:"tracer"`
Timeout string `json:"timeout"`
}

type BlockContainer struct {
Block *types.Block
Traces []*TransactionTrace
Expand All @@ -146,16 +142,23 @@ func (c *Client) ReadBlock(blockNumber *big.Int, rpcTimeout time.Duration) (*Blo
return nil, err
}

var (
tracer = "callTracer"
tracerTimeout = "180s"
)

txTraces := make([]*TransactionTrace, 0, len(bl.Transactions()))
for _, tx := range bl.Transactions() {
txh := tx.Hash().Hex()
if !strings.HasPrefix(txh, "0x") {
txh = "0x" + txh
}
var results []interface{}
err = c.rpcClient.CallContext(ctx, &results, "debug_traceTransaction",
txh, TracerParam{Tracer: "callTracer", Timeout: "1m"})
if err != nil {
args := []interface{}{txh, &tracers.TraceConfig{
Timeout: &tracerTimeout,
Tracer: &tracer,
}}
if err := c.rpcClient.CallContext(ctx, &results, "debug_traceTransaction", args); err != nil {
return nil, err
}

Expand Down

0 comments on commit f5b5d86

Please sign in to comment.