diff --git a/ethclient/gethclient/gethclient.go b/ethclient/gethclient/gethclient.go index 6ddffbcd07..3fe84c9970 100644 --- a/ethclient/gethclient/gethclient.go +++ b/ethclient/gethclient/gethclient.go @@ -30,7 +30,6 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/tracers" - "github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/rpc" ) @@ -89,9 +88,9 @@ type TxTraceResult struct { // BlockTraceResult is the result of TraceChain type BlockTraceResult struct { - Block hexutil.Uint64 `json:"block"` // Block number corresponding to this trace - Hash common.Hash `json:"hash"` // Block hash corresponding to this trace - Traces []interface{} `json:"traces"` // Trace results produced by the task + Block hexutil.Uint64 `json:"block"` // Block number corresponding to this trace + Hash common.Hash `json:"hash"` // Block hash corresponding to this trace + Traces []*TxTraceResult `json:"traces"` // Trace results produced by the task } // GetProof returns the account and storage values of the specified account including the Merkle-proof. @@ -221,9 +220,9 @@ func (ec *Client) SubscribePendingTransactions(ctx context.Context, ch chan<- co } // TraceCall lets you trace a given eth_call -func (ec *Client) TraceCall(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, config *tracers.TraceCallConfig) (interface{}, error) { +func (ec *Client) TraceCall(ctx context.Context, msg ethereum.CallMsg, blockNrOrHash rpc.BlockNumberOrHash, config *tracers.TraceCallConfig) (interface{}, error) { var result interface{} - err := ec.c.CallContext(ctx, &result, "debug_traceCall", args, blockNrOrHash, config) + err := ec.c.CallContext(ctx, &result, "debug_traceCall", toCallArg(msg), blockNrOrHash, config) return result, err } @@ -235,14 +234,14 @@ func (ec *Client) TraceTransaction(ctx context.Context, hash common.Hash, config } // TraceChain subscribes to chain, receiving results from channel BlockTraceResult -func (ec *Client) TraceChain(ctx context.Context, ch chan<- *BlockTraceResult, start, end rpc.BlockNumber, config *tracers.TraceConfig) (*rpc.ClientSubscription, error) { - return ec.c.Subscribe(ctx, "debug", ch, "traceChain", start, end, config) +func (ec *Client) TraceChain(ctx context.Context, ch chan<- *BlockTraceResult, start, end *big.Int, config *tracers.TraceConfig) (*rpc.ClientSubscription, error) { + return ec.c.Subscribe(ctx, "debug", ch, "traceChain", toBlockNumArg(start), toBlockNumArg(end), config) } // TraceBlock returns the structured logs created during the execution of EVM -func (ec *Client) TraceBlock(ctx context.Context, blob hexutil.Bytes, config *tracers.TraceConfig) ([]*TxTraceResult, error) { +func (ec *Client) TraceBlock(ctx context.Context, blob []byte, config *tracers.TraceConfig) ([]*TxTraceResult, error) { var result []*TxTraceResult - err := ec.c.CallContext(ctx, &result, "debug_traceBlock", blob, config) + err := ec.c.CallContext(ctx, &result, "debug_traceBlock", hexutil.Bytes(blob), config) return result, err } diff --git a/ethclient/gethclient/gethclient_test.go b/ethclient/gethclient/gethclient_test.go index 31dcf53aac..3aed246b2a 100644 --- a/ethclient/gethclient/gethclient_test.go +++ b/ethclient/gethclient/gethclient_test.go @@ -24,24 +24,22 @@ import ( "reflect" "testing" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/eth/filters" - "github.com/ethereum/go-ethereum/eth/tracers" - "github.com/ethereum/go-ethereum/eth/tracers/logger" - "github.com/ethereum/go-ethereum/internal/ethapi" - "github.com/ethereum/go-ethereum/rlp" - "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth/ethconfig" + "github.com/ethereum/go-ethereum/eth/filters" + "github.com/ethereum/go-ethereum/eth/tracers" + "github.com/ethereum/go-ethereum/eth/tracers/logger" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" ) @@ -639,14 +637,14 @@ func testTraceCall(t *testing.T, client *rpc.Client) { var testSuite = []struct { blockNumber rpc.BlockNumber - call ethapi.TransactionArgs + call ethereum.CallMsg config *tracers.TraceCallConfig expectErr error expect interface{} }{ { - call: ethapi.TransactionArgs{ - From: &testAddr, + call: ethereum.CallMsg{ + From: testAddr, To: &testAddr, }, config: nil, @@ -660,8 +658,8 @@ func testTraceCall(t *testing.T, client *rpc.Client) { }, // with config { - call: ethapi.TransactionArgs{ - From: &testAddr, + call: ethereum.CallMsg{ + From: testAddr, To: &testAddr, }, config: &tracers.TraceCallConfig{ @@ -705,13 +703,13 @@ func testTraceChain(t *testing.T, client *rpc.Client) { ec := New(client) ch := make(chan *BlockTraceResult) - _, err := ec.TraceChain(context.Background(), ch, 0, 1, nil) + _, err := ec.TraceChain(context.Background(), ch, big.NewInt(0), big.NewInt(1), nil) if err != nil { t.Fatalf("testTraceChain error: %v", err) } traceBlock := <-ch - traceTxHash := common.HexToHash(traceBlock.Traces[0].(map[string]interface{})["txHash"].(string)) + traceTxHash := traceBlock.Traces[0].TxHash if traceTxHash != testTransactionHash { t.Errorf("result mismatch, want %v, get %v", testTransactionHash, traceTxHash) }