mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
parent
b714e22893
commit
3d3c9d3edf
5 changed files with 25 additions and 30 deletions
|
|
@ -1353,7 +1353,7 @@ func (bc *BlockChain) writeBlockResult(state *state.StateDB, block *types.Block,
|
|||
coinbase := types.AccountProofWrapper{
|
||||
Address: block.Coinbase(),
|
||||
Nonce: state.GetNonce(block.Coinbase()),
|
||||
Balance: state.GetBalance(block.Coinbase()).String(),
|
||||
Balance: (*hexutil.Big)(state.GetBalance(block.Coinbase())),
|
||||
CodeHash: state.GetCodeHash(block.Coinbase()),
|
||||
}
|
||||
// Get coinbase address's account proof.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package types
|
|||
|
||||
import (
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
||||
)
|
||||
|
||||
// BlockResult contains block execution traces and results required for rollers.
|
||||
|
|
@ -57,7 +58,7 @@ type ExtraData struct {
|
|||
type AccountProofWrapper struct {
|
||||
Address common.Address `json:"address"`
|
||||
Nonce uint64 `json:"nonce"`
|
||||
Balance string `json:"balance"` // balance big.Int string
|
||||
Balance *hexutil.Big `json:"balance"`
|
||||
CodeHash common.Hash `json:"codeHash,omitempty"`
|
||||
Proof []string `json:"proof,omitempty"`
|
||||
Storage *StorageProofWrapper `json:"storage,omitempty"` // StorageProofWrapper can be empty if irrelated to storage operation
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ import (
|
|||
)
|
||||
|
||||
type BlockTrace struct {
|
||||
Number string `json:"number"` // big.Int string
|
||||
Number *hexutil.Big `json:"number"`
|
||||
Hash common.Hash `json:"hash"`
|
||||
GasLimit uint64 `json:"gasLimit"`
|
||||
Difficulty string `json:"difficulty"` // big.Int string
|
||||
BaseFee string `json:"baseFee"` // big.Int string
|
||||
Difficulty *hexutil.Big `json:"difficulty"`
|
||||
BaseFee *hexutil.Big `json:"baseFee"`
|
||||
Coinbase *AccountProofWrapper `json:"coinbase"`
|
||||
Time uint64 `json:"time"`
|
||||
Transactions []*TransactionTrace `json:"transactions"`
|
||||
|
|
@ -23,16 +23,16 @@ type TransactionTrace struct {
|
|||
Type uint8 `json:"type"`
|
||||
Nonce uint64 `json:"nonce"`
|
||||
Gas uint64 `json:"gas"`
|
||||
GasPrice string `json:"gasPrice"` // big.Int string
|
||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||
From common.Address `json:"from"`
|
||||
To *common.Address `json:"to"`
|
||||
ChainId string `json:"chainId"` // big.Int string
|
||||
Value string `json:"value"` // big.Int string
|
||||
ChainId *hexutil.Big `json:"chainId"`
|
||||
Value *hexutil.Big `json:"value"`
|
||||
Data string `json:"data"`
|
||||
IsCreate bool `json:"isCreate"`
|
||||
V string `json:"v"` // big.Int string
|
||||
R string `json:"r"` // big.Int string
|
||||
S string `json:"s"` // big.Int string
|
||||
V *hexutil.Big `json:"v"`
|
||||
R *hexutil.Big `json:"r"`
|
||||
S *hexutil.Big `json:"s"`
|
||||
}
|
||||
|
||||
// NewTraceBlock supports necessary fields for roller.
|
||||
|
|
@ -42,19 +42,12 @@ func NewTraceBlock(config *params.ChainConfig, block *Block, coinbase *AccountPr
|
|||
txs[i] = newTraceTransaction(tx, block.NumberU64(), config)
|
||||
}
|
||||
|
||||
baseFee := block.BaseFee()
|
||||
// due to the special logic of `baseFee`, if `baseFee` is a nil
|
||||
// we would like to use new(big.Int) to replace it so that `baseFee.String()` would return "0"
|
||||
if baseFee == nil {
|
||||
baseFee = new(big.Int)
|
||||
}
|
||||
|
||||
return &BlockTrace{
|
||||
Number: block.Number().String(),
|
||||
Number: (*hexutil.Big)(block.Number()),
|
||||
Hash: block.Hash(),
|
||||
GasLimit: block.GasLimit(),
|
||||
Difficulty: block.Difficulty().String(),
|
||||
BaseFee: baseFee.String(),
|
||||
Difficulty: (*hexutil.Big)(block.Difficulty()),
|
||||
BaseFee: (*hexutil.Big)(block.BaseFee()),
|
||||
Coinbase: coinbase,
|
||||
Time: block.Time(),
|
||||
Transactions: txs,
|
||||
|
|
@ -70,17 +63,17 @@ func newTraceTransaction(tx *Transaction, blockNumber uint64, config *params.Cha
|
|||
result := &TransactionTrace{
|
||||
Type: tx.Type(),
|
||||
Nonce: tx.Nonce(),
|
||||
ChainId: tx.ChainId().String(),
|
||||
ChainId: (*hexutil.Big)(tx.ChainId()),
|
||||
From: from,
|
||||
Gas: tx.Gas(),
|
||||
GasPrice: tx.GasPrice().String(),
|
||||
GasPrice: (*hexutil.Big)(tx.GasPrice()),
|
||||
To: tx.To(),
|
||||
Value: tx.Value().String(),
|
||||
Value: (*hexutil.Big)(tx.Value()),
|
||||
Data: hexutil.Encode(tx.Data()),
|
||||
IsCreate: tx.To() == nil,
|
||||
V: v.String(),
|
||||
R: r.String(),
|
||||
S: s.String(),
|
||||
V: (*hexutil.Big)(v),
|
||||
R: (*hexutil.Big)(r),
|
||||
S: (*hexutil.Big)(s),
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ func getWrappedProofForAddr(l *StructLogger, address common.Address) (*types.Acc
|
|||
return &types.AccountProofWrapper{
|
||||
Address: address,
|
||||
Nonce: l.env.StateDB.GetNonce(address),
|
||||
Balance: l.env.StateDB.GetBalance(address).String(),
|
||||
Balance: (*hexutil.Big)(l.env.StateDB.GetBalance(address)),
|
||||
CodeHash: l.env.StateDB.GetCodeHash(address),
|
||||
Proof: encodeProof(proof),
|
||||
}, nil
|
||||
|
|
@ -150,7 +150,7 @@ func getWrappedProofForStorage(l *StructLogger, address common.Address, key comm
|
|||
return &types.AccountProofWrapper{
|
||||
Address: address,
|
||||
Nonce: l.env.StateDB.GetNonce(address),
|
||||
Balance: l.env.StateDB.GetBalance(address).String(),
|
||||
Balance: (*hexutil.Big)(l.env.StateDB.GetBalance(address)),
|
||||
CodeHash: l.env.StateDB.GetCodeHash(address),
|
||||
Proof: encodeProof(proof),
|
||||
Storage: &types.StorageProofWrapper{
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import (
|
|||
mapset "github.com/deckarep/golang-set"
|
||||
|
||||
"github.com/scroll-tech/go-ethereum/common"
|
||||
"github.com/scroll-tech/go-ethereum/common/hexutil"
|
||||
"github.com/scroll-tech/go-ethereum/consensus"
|
||||
"github.com/scroll-tech/go-ethereum/consensus/misc"
|
||||
"github.com/scroll-tech/go-ethereum/core"
|
||||
|
|
@ -790,7 +791,7 @@ func (w *worker) commitTransaction(tx *types.Transaction, coinbase common.Addres
|
|||
sender := &types.AccountProofWrapper{
|
||||
Address: from,
|
||||
Nonce: w.current.state.GetNonce(from),
|
||||
Balance: w.current.state.GetBalance(from).String(),
|
||||
Balance: (*hexutil.Big)(w.current.state.GetBalance(from)),
|
||||
CodeHash: w.current.state.GetCodeHash(from),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue