mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 07:53:47 +00:00
feat(trace): add coinbase account_proof (#58)
This commit is contained in:
parent
5128154925
commit
8ccc10541d
2 changed files with 20 additions and 4 deletions
|
|
@ -1346,7 +1346,23 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
||||||
|
|
||||||
// Fill blockResult content
|
// Fill blockResult content
|
||||||
func (bc *BlockChain) writeBlockResult(state *state.StateDB, block *types.Block, blockResult *types.BlockResult) {
|
func (bc *BlockChain) writeBlockResult(state *state.StateDB, block *types.Block, blockResult *types.BlockResult) {
|
||||||
blockResult.BlockTrace = types.NewTraceBlock(bc.chainConfig, block)
|
coinbase := types.AccountProofWrapper{
|
||||||
|
Address: block.Coinbase(),
|
||||||
|
Nonce: state.GetNonce(block.Coinbase()),
|
||||||
|
Balance: state.GetBalance(block.Coinbase()),
|
||||||
|
}
|
||||||
|
// Get coinbase address's account proof.
|
||||||
|
proof, err := state.GetProof(block.Coinbase())
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Failed to get proof", "blockNumber", block.NumberU64(), "address", block.Coinbase().String(), "err", err)
|
||||||
|
} else {
|
||||||
|
coinbase.Proof = make([]string, len(proof))
|
||||||
|
for i := range proof {
|
||||||
|
coinbase.Proof[i] = hexutil.Encode(proof[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
blockResult.BlockTrace = types.NewTraceBlock(bc.chainConfig, block, coinbase)
|
||||||
for i, tx := range block.Transactions() {
|
for i, tx := range block.Transactions() {
|
||||||
evmTrace := blockResult.ExecutionResults[i]
|
evmTrace := blockResult.ExecutionResults[i]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ type BlockTrace struct {
|
||||||
GasLimit uint64 `json:"gasLimit"`
|
GasLimit uint64 `json:"gasLimit"`
|
||||||
Difficulty *big.Int `json:"difficulty"`
|
Difficulty *big.Int `json:"difficulty"`
|
||||||
BaseFee *big.Int `json:"baseFee"`
|
BaseFee *big.Int `json:"baseFee"`
|
||||||
Coinbase common.Address `json:"coinbase"`
|
Coinbase AccountProofWrapper `json:"coinbase"`
|
||||||
Time uint64 `json:"time"`
|
Time uint64 `json:"time"`
|
||||||
Transactions []*TransactionTrace `json:"transactions"`
|
Transactions []*TransactionTrace `json:"transactions"`
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +36,7 @@ type TransactionTrace struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTraceBlock supports necessary fields for roller.
|
// NewTraceBlock supports necessary fields for roller.
|
||||||
func NewTraceBlock(config *params.ChainConfig, block *Block) *BlockTrace {
|
func NewTraceBlock(config *params.ChainConfig, block *Block, coinbase AccountProofWrapper) *BlockTrace {
|
||||||
txs := make([]*TransactionTrace, block.Transactions().Len())
|
txs := make([]*TransactionTrace, block.Transactions().Len())
|
||||||
for i, tx := range block.Transactions() {
|
for i, tx := range block.Transactions() {
|
||||||
txs[i] = newTraceTransaction(tx, block.NumberU64(), config)
|
txs[i] = newTraceTransaction(tx, block.NumberU64(), config)
|
||||||
|
|
@ -47,7 +47,7 @@ func NewTraceBlock(config *params.ChainConfig, block *Block) *BlockTrace {
|
||||||
GasLimit: block.GasLimit(),
|
GasLimit: block.GasLimit(),
|
||||||
Difficulty: block.Difficulty(),
|
Difficulty: block.Difficulty(),
|
||||||
BaseFee: block.BaseFee(),
|
BaseFee: block.BaseFee(),
|
||||||
Coinbase: block.Coinbase(),
|
Coinbase: coinbase,
|
||||||
Time: block.Time(),
|
Time: block.Time(),
|
||||||
Transactions: txs,
|
Transactions: txs,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue