mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
parent
0bdd2e0575
commit
4ea77a7577
2 changed files with 35 additions and 10 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue