mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 16:03:45 +00:00
parent
0bdd2e0575
commit
4ea77a7577
2 changed files with 35 additions and 10 deletions
|
|
@ -4,13 +4,25 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/scroll-tech/go-ethereum/common"
|
"github.com/scroll-tech/go-ethereum/common"
|
||||||
|
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
||||||
"github.com/scroll-tech/go-ethereum/params"
|
"github.com/scroll-tech/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TransactionData struct {
|
type TransactionData struct {
|
||||||
IsCreate bool `json:"isCreate"`
|
Type uint8 `json:"type"`
|
||||||
From common.Address `json:"from"`
|
Nonce uint64 `json:"nonce"`
|
||||||
Transaction
|
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
|
// 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 {
|
func NewTraceTransaction(tx *Transaction, blockNumber uint64, config *params.ChainConfig) *TransactionData {
|
||||||
signer := MakeSigner(config, big.NewInt(0).SetUint64(blockNumber))
|
signer := MakeSigner(config, big.NewInt(0).SetUint64(blockNumber))
|
||||||
from, _ := Sender(signer, tx)
|
from, _ := Sender(signer, tx)
|
||||||
return &TransactionData{
|
v, r, s := tx.RawSignatureValues()
|
||||||
From: from,
|
result := &TransactionData{
|
||||||
IsCreate: tx.To() == nil,
|
Type: tx.Type(),
|
||||||
Transaction: *tx,
|
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
|
storageProof := blockTrace.StorageTrace.StorageProofs
|
||||||
for _, tx := range blockTrace.Transactions {
|
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
|
// verify proofs
|
||||||
if data2, ok := storgeTrace.Proofs[addr.String()]; ok {
|
if data2, ok := storgeTrace.Proofs[addr.String()]; ok {
|
||||||
data1, err := statedb.GetProof(addr)
|
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))
|
assert.Equal(t, len(expect), len(actual))
|
||||||
for i := range expect {
|
for i := range expect {
|
||||||
eTx, aTx := expect[i], actual[i]
|
eTx, aTx := expect[i], actual[i]
|
||||||
assert.Equal(t, eTx.Hash().String(), aTx.Hash())
|
assert.Equal(t, eTx.Hash().String(), aTx.TxHash)
|
||||||
assert.Equal(t, eTx.Gas(), aTx.Gas())
|
assert.Equal(t, eTx.Gas(), aTx.Gas)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue