mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-09 21:43:47 +00:00
fix(trace): use string for big.Int (#72)
This commit is contained in:
parent
2329d32409
commit
33fcd2bf6d
5 changed files with 23 additions and 25 deletions
|
|
@ -1353,7 +1353,7 @@ func (bc *BlockChain) writeBlockResult(state *state.StateDB, block *types.Block,
|
||||||
coinbase := types.AccountProofWrapper{
|
coinbase := types.AccountProofWrapper{
|
||||||
Address: block.Coinbase(),
|
Address: block.Coinbase(),
|
||||||
Nonce: state.GetNonce(block.Coinbase()),
|
Nonce: state.GetNonce(block.Coinbase()),
|
||||||
Balance: state.GetBalance(block.Coinbase()),
|
Balance: state.GetBalance(block.Coinbase()).String(),
|
||||||
CodeHash: state.GetCodeHash(block.Coinbase()),
|
CodeHash: state.GetCodeHash(block.Coinbase()),
|
||||||
}
|
}
|
||||||
// Get coinbase address's account proof.
|
// Get coinbase address's account proof.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/big"
|
|
||||||
|
|
||||||
"github.com/scroll-tech/go-ethereum/common"
|
"github.com/scroll-tech/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -59,7 +57,7 @@ type ExtraData struct {
|
||||||
type AccountProofWrapper struct {
|
type AccountProofWrapper struct {
|
||||||
Address common.Address `json:"address"`
|
Address common.Address `json:"address"`
|
||||||
Nonce uint64 `json:"nonce"`
|
Nonce uint64 `json:"nonce"`
|
||||||
Balance *big.Int `json:"balance"`
|
Balance string `json:"balance"` // balance big.Int string
|
||||||
CodeHash common.Hash `json:"codeHash,omitempty"`
|
CodeHash common.Hash `json:"codeHash,omitempty"`
|
||||||
Proof []string `json:"proof,omitempty"`
|
Proof []string `json:"proof,omitempty"`
|
||||||
Storage *StorageProofWrapper `json:"storage,omitempty"` // StorageProofWrapper can be empty if irrelated to storage operation
|
Storage *StorageProofWrapper `json:"storage,omitempty"` // StorageProofWrapper can be empty if irrelated to storage operation
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type BlockTrace struct {
|
type BlockTrace struct {
|
||||||
Number *big.Int `json:"number"`
|
Number string `json:"number"` // big.Int string
|
||||||
Hash common.Hash `json:"hash"`
|
Hash common.Hash `json:"hash"`
|
||||||
GasLimit uint64 `json:"gasLimit"`
|
GasLimit uint64 `json:"gasLimit"`
|
||||||
Difficulty *big.Int `json:"difficulty"`
|
Difficulty string `json:"difficulty"` // big.Int string
|
||||||
BaseFee *big.Int `json:"baseFee"`
|
BaseFee string `json:"baseFee"` // big.Int string
|
||||||
Coinbase *AccountProofWrapper `json:"coinbase"`
|
Coinbase *AccountProofWrapper `json:"coinbase"`
|
||||||
Time uint64 `json:"time"`
|
Time uint64 `json:"time"`
|
||||||
Transactions []*TransactionTrace `json:"transactions"`
|
Transactions []*TransactionTrace `json:"transactions"`
|
||||||
|
|
@ -23,16 +23,16 @@ type TransactionTrace struct {
|
||||||
Type uint8 `json:"type"`
|
Type uint8 `json:"type"`
|
||||||
Nonce uint64 `json:"nonce"`
|
Nonce uint64 `json:"nonce"`
|
||||||
Gas uint64 `json:"gas"`
|
Gas uint64 `json:"gas"`
|
||||||
GasPrice *big.Int `json:"gasPrice"`
|
GasPrice string `json:"gasPrice"` // big.Int string
|
||||||
From common.Address `json:"from"`
|
From common.Address `json:"from"`
|
||||||
To *common.Address `json:"to"`
|
To *common.Address `json:"to"`
|
||||||
ChainId *big.Int `json:"chainId"`
|
ChainId string `json:"chainId"` // big.Int string
|
||||||
Value *big.Int `json:"value"`
|
Value string `json:"value"` // big.Int string
|
||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
IsCreate bool `json:"isCreate"`
|
IsCreate bool `json:"isCreate"`
|
||||||
V *big.Int `json:"v"`
|
V string `json:"v"` // big.Int string
|
||||||
R *big.Int `json:"r"`
|
R string `json:"r"` // big.Int string
|
||||||
S *big.Int `json:"s"`
|
S string `json:"s"` // big.Int string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTraceBlock supports necessary fields for roller.
|
// NewTraceBlock supports necessary fields for roller.
|
||||||
|
|
@ -42,11 +42,11 @@ func NewTraceBlock(config *params.ChainConfig, block *Block, coinbase *AccountPr
|
||||||
txs[i] = newTraceTransaction(tx, block.NumberU64(), config)
|
txs[i] = newTraceTransaction(tx, block.NumberU64(), config)
|
||||||
}
|
}
|
||||||
return &BlockTrace{
|
return &BlockTrace{
|
||||||
Number: block.Number(),
|
Number: block.Number().String(),
|
||||||
Hash: block.Hash(),
|
Hash: block.Hash(),
|
||||||
GasLimit: block.GasLimit(),
|
GasLimit: block.GasLimit(),
|
||||||
Difficulty: block.Difficulty(),
|
Difficulty: block.Difficulty().String(),
|
||||||
BaseFee: block.BaseFee(),
|
BaseFee: block.BaseFee().String(),
|
||||||
Coinbase: coinbase,
|
Coinbase: coinbase,
|
||||||
Time: block.Time(),
|
Time: block.Time(),
|
||||||
Transactions: txs,
|
Transactions: txs,
|
||||||
|
|
@ -62,17 +62,17 @@ func newTraceTransaction(tx *Transaction, blockNumber uint64, config *params.Cha
|
||||||
result := &TransactionTrace{
|
result := &TransactionTrace{
|
||||||
Type: tx.Type(),
|
Type: tx.Type(),
|
||||||
Nonce: tx.Nonce(),
|
Nonce: tx.Nonce(),
|
||||||
ChainId: tx.ChainId(),
|
ChainId: tx.ChainId().String(),
|
||||||
From: from,
|
From: from,
|
||||||
Gas: tx.Gas(),
|
Gas: tx.Gas(),
|
||||||
GasPrice: tx.GasPrice(),
|
GasPrice: tx.GasPrice().String(),
|
||||||
To: tx.To(),
|
To: tx.To(),
|
||||||
Value: tx.Value(),
|
Value: tx.Value().String(),
|
||||||
Data: hexutil.Encode(tx.Data()),
|
Data: hexutil.Encode(tx.Data()),
|
||||||
IsCreate: tx.To() == nil,
|
IsCreate: tx.To() == nil,
|
||||||
V: v,
|
V: v.String(),
|
||||||
R: r,
|
R: r.String(),
|
||||||
S: s,
|
S: s.String(),
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ func getWrappedProofForAddr(l *StructLogger, address common.Address) (*types.Acc
|
||||||
return &types.AccountProofWrapper{
|
return &types.AccountProofWrapper{
|
||||||
Address: address,
|
Address: address,
|
||||||
Nonce: l.env.StateDB.GetNonce(address),
|
Nonce: l.env.StateDB.GetNonce(address),
|
||||||
Balance: l.env.StateDB.GetBalance(address),
|
Balance: l.env.StateDB.GetBalance(address).String(),
|
||||||
CodeHash: l.env.StateDB.GetCodeHash(address),
|
CodeHash: l.env.StateDB.GetCodeHash(address),
|
||||||
Proof: encodeProof(proof),
|
Proof: encodeProof(proof),
|
||||||
}, nil
|
}, nil
|
||||||
|
|
@ -150,7 +150,7 @@ func getWrappedProofForStorage(l *StructLogger, address common.Address, key comm
|
||||||
return &types.AccountProofWrapper{
|
return &types.AccountProofWrapper{
|
||||||
Address: address,
|
Address: address,
|
||||||
Nonce: l.env.StateDB.GetNonce(address),
|
Nonce: l.env.StateDB.GetNonce(address),
|
||||||
Balance: l.env.StateDB.GetBalance(address),
|
Balance: l.env.StateDB.GetBalance(address).String(),
|
||||||
CodeHash: l.env.StateDB.GetCodeHash(address),
|
CodeHash: l.env.StateDB.GetCodeHash(address),
|
||||||
Proof: encodeProof(proof),
|
Proof: encodeProof(proof),
|
||||||
Storage: &types.StorageProofWrapper{
|
Storage: &types.StorageProofWrapper{
|
||||||
|
|
|
||||||
|
|
@ -790,7 +790,7 @@ func (w *worker) commitTransaction(tx *types.Transaction, coinbase common.Addres
|
||||||
sender := &types.AccountProofWrapper{
|
sender := &types.AccountProofWrapper{
|
||||||
Address: from,
|
Address: from,
|
||||||
Nonce: w.current.state.GetNonce(from),
|
Nonce: w.current.state.GetNonce(from),
|
||||||
Balance: w.current.state.GetBalance(from),
|
Balance: w.current.state.GetBalance(from).String(),
|
||||||
CodeHash: w.current.state.GetCodeHash(from),
|
CodeHash: w.current.state.GetCodeHash(from),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue