mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
fix(trace): fix incorrect sender state info. (#71)
This commit is contained in:
parent
40e8f088b6
commit
2329d32409
3 changed files with 15 additions and 12 deletions
|
|
@ -1370,16 +1370,9 @@ func (bc *BlockChain) writeBlockResult(state *state.StateDB, block *types.Block,
|
|||
blockResult.BlockTrace = types.NewTraceBlock(bc.chainConfig, block, &coinbase)
|
||||
for i, tx := range block.Transactions() {
|
||||
evmTrace := blockResult.ExecutionResults[i]
|
||||
from := evmTrace.Sender.Address
|
||||
|
||||
// Get sender's address.
|
||||
from, _ := types.Sender(types.MakeSigner(bc.chainConfig, block.Number()), tx)
|
||||
evmTrace.Sender = &types.AccountProofWrapper{
|
||||
Address: from,
|
||||
Nonce: state.GetNonce(from),
|
||||
Balance: state.GetBalance(from),
|
||||
CodeHash: state.GetCodeHash(from),
|
||||
}
|
||||
// Get sender's account proof.
|
||||
// Get proof
|
||||
proof, err := state.GetProof(from)
|
||||
if err != nil {
|
||||
log.Error("Failed to get proof", "blockNumber", block.NumberU64(), "address", from.String(), "err", err)
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ type ExtraData struct {
|
|||
}
|
||||
|
||||
type AccountProofWrapper struct {
|
||||
Address common.Address `json:"address,omitempty"`
|
||||
Nonce uint64 `json:"nonce,omitempty"`
|
||||
Balance *big.Int `json:"balance,omitempty"`
|
||||
Address common.Address `json:"address"`
|
||||
Nonce uint64 `json:"nonce"`
|
||||
Balance *big.Int `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
|
||||
|
|
|
|||
|
|
@ -785,16 +785,26 @@ func (w *worker) commitTransaction(tx *types.Transaction, coinbase common.Addres
|
|||
// reset tracer.
|
||||
tracer := w.chain.GetVMConfig().Tracer.(*vm.StructLogger)
|
||||
tracer.Reset()
|
||||
// Get sender's address.
|
||||
from, _ := types.Sender(w.current.signer, tx)
|
||||
sender := &types.AccountProofWrapper{
|
||||
Address: from,
|
||||
Nonce: w.current.state.GetNonce(from),
|
||||
Balance: w.current.state.GetBalance(from),
|
||||
CodeHash: w.current.state.GetCodeHash(from),
|
||||
}
|
||||
|
||||
receipt, err := core.ApplyTransaction(w.chainConfig, w.chain, &coinbase, w.current.gasPool, w.current.state, w.current.header, tx, &w.current.header.GasUsed, *w.chain.GetVMConfig())
|
||||
if err != nil {
|
||||
w.current.state.RevertToSnapshot(snap)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
w.current.txs = append(w.current.txs, tx)
|
||||
w.current.receipts = append(w.current.receipts, receipt)
|
||||
w.current.executionResults = append(w.current.executionResults, &types.ExecutionResult{
|
||||
Gas: receipt.GasUsed,
|
||||
Sender: sender,
|
||||
Failed: receipt.Status != types.ReceiptStatusSuccessful,
|
||||
ReturnValue: fmt.Sprintf("%x", receipt.ReturnValue),
|
||||
StructLogs: vm.FormatLogs(tracer.StructLogs()),
|
||||
|
|
|
|||
Loading…
Reference in a new issue