resolve reviews

This commit is contained in:
bnovil 2023-10-04 20:23:10 +08:00
parent e270b23766
commit 605623a58a
2 changed files with 21 additions and 24 deletions

View file

@ -30,7 +30,6 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/tracers" "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/p2p"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
) )
@ -91,7 +90,7 @@ type TxTraceResult struct {
type BlockTraceResult struct { type BlockTraceResult struct {
Block hexutil.Uint64 `json:"block"` // Block number corresponding to this trace Block hexutil.Uint64 `json:"block"` // Block number corresponding to this trace
Hash common.Hash `json:"hash"` // Block hash 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 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. // 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 // 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{} 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 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 // 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) { 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", start, end, config) return ec.c.Subscribe(ctx, "debug", ch, "traceChain", toBlockNumArg(start), toBlockNumArg(end), config)
} }
// TraceBlock returns the structured logs created during the execution of EVM // 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 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 return result, err
} }

View file

@ -24,24 +24,22 @@ import (
"reflect" "reflect"
"testing" "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"
"github.com/ethereum/go-ethereum/common" "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/consensus/ethash"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/ethconfig" "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/ethclient"
"github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
) )
@ -639,14 +637,14 @@ func testTraceCall(t *testing.T, client *rpc.Client) {
var testSuite = []struct { var testSuite = []struct {
blockNumber rpc.BlockNumber blockNumber rpc.BlockNumber
call ethapi.TransactionArgs call ethereum.CallMsg
config *tracers.TraceCallConfig config *tracers.TraceCallConfig
expectErr error expectErr error
expect interface{} expect interface{}
}{ }{
{ {
call: ethapi.TransactionArgs{ call: ethereum.CallMsg{
From: &testAddr, From: testAddr,
To: &testAddr, To: &testAddr,
}, },
config: nil, config: nil,
@ -660,8 +658,8 @@ func testTraceCall(t *testing.T, client *rpc.Client) {
}, },
// with config // with config
{ {
call: ethapi.TransactionArgs{ call: ethereum.CallMsg{
From: &testAddr, From: testAddr,
To: &testAddr, To: &testAddr,
}, },
config: &tracers.TraceCallConfig{ config: &tracers.TraceCallConfig{
@ -705,13 +703,13 @@ func testTraceChain(t *testing.T, client *rpc.Client) {
ec := New(client) ec := New(client)
ch := make(chan *BlockTraceResult) 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 { if err != nil {
t.Fatalf("testTraceChain error: %v", err) t.Fatalf("testTraceChain error: %v", err)
} }
traceBlock := <-ch traceBlock := <-ch
traceTxHash := common.HexToHash(traceBlock.Traces[0].(map[string]interface{})["txHash"].(string)) traceTxHash := traceBlock.Traces[0].TxHash
if traceTxHash != testTransactionHash { if traceTxHash != testTransactionHash {
t.Errorf("result mismatch, want %v, get %v", testTransactionHash, traceTxHash) t.Errorf("result mismatch, want %v, get %v", testTransactionHash, traceTxHash)
} }