diff --git a/core/types/l2trace_block.go b/core/types/l2trace_block.go index 1f45e437fd..71a5d8c10e 100644 --- a/core/types/l2trace_block.go +++ b/core/types/l2trace_block.go @@ -4,13 +4,25 @@ import ( "math/big" "github.com/scroll-tech/go-ethereum/common" + "github.com/scroll-tech/go-ethereum/common/hexutil" "github.com/scroll-tech/go-ethereum/params" ) type TransactionData struct { - IsCreate bool `json:"isCreate"` - From common.Address `json:"from"` - Transaction + Type uint8 `json:"type"` + Nonce uint64 `json:"nonce"` + TxHash string `json:"txHash"` + Gas uint64 `json:"gas"` + GasPrice *hexutil.Big `json:"gasPrice"` + From common.Address `json:"from"` + To *common.Address `json:"to"` + ChainId *hexutil.Big `json:"chainId"` + Value *hexutil.Big `json:"value"` + Data string `json:"data"` + IsCreate bool `json:"isCreate"` + V *hexutil.Big `json:"v"` + R *hexutil.Big `json:"r"` + S *hexutil.Big `json:"s"` } // NewTraceTransaction returns a transaction that will serialize to the trace @@ -18,9 +30,22 @@ type TransactionData struct { func NewTraceTransaction(tx *Transaction, blockNumber uint64, config *params.ChainConfig) *TransactionData { signer := MakeSigner(config, big.NewInt(0).SetUint64(blockNumber)) from, _ := Sender(signer, tx) - return &TransactionData{ - From: from, - IsCreate: tx.To() == nil, - Transaction: *tx, + v, r, s := tx.RawSignatureValues() + result := &TransactionData{ + Type: tx.Type(), + TxHash: tx.Hash().String(), + Nonce: tx.Nonce(), + ChainId: (*hexutil.Big)(tx.ChainId()), + From: from, + Gas: tx.Gas(), + GasPrice: (*hexutil.Big)(tx.GasPrice()), + To: tx.To(), + Value: (*hexutil.Big)(tx.Value()), + Data: hexutil.Encode(tx.Data()), + IsCreate: tx.To() == nil, + V: (*hexutil.Big)(v), + R: (*hexutil.Big)(r), + S: (*hexutil.Big)(s), } + return result } diff --git a/eth/tracers/api_blocktrace_test.go b/eth/tracers/api_blocktrace_test.go index aeb39e1d6c..85532b6076 100644 --- a/eth/tracers/api_blocktrace_test.go +++ b/eth/tracers/api_blocktrace_test.go @@ -131,7 +131,7 @@ func checkChainAndProof(t *testing.T, b *testBackend, parent *types.Block, block storageProof := blockTrace.StorageTrace.StorageProofs for _, tx := range blockTrace.Transactions { - for _, addr := range []common.Address{tx.From, *tx.To()} { + for _, addr := range []common.Address{tx.From, *tx.To} { // verify proofs if data2, ok := storgeTrace.Proofs[addr.String()]; ok { data1, err := statedb.GetProof(addr) @@ -154,8 +154,8 @@ func checkTxs(t *testing.T, expect []*types.Transaction, actual []*types.Transac assert.Equal(t, len(expect), len(actual)) for i := range expect { eTx, aTx := expect[i], actual[i] - assert.Equal(t, eTx.Hash().String(), aTx.Hash()) - assert.Equal(t, eTx.Gas(), aTx.Gas()) + assert.Equal(t, eTx.Hash().String(), aTx.TxHash) + assert.Equal(t, eTx.Gas(), aTx.Gas) } }