diff --git a/core/blockchain.go b/core/blockchain.go index 8c7fb7a177..d71809bab0 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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) diff --git a/core/types/l2trace.go b/core/types/l2trace.go index 287f846e8f..ab3736f7b0 100644 --- a/core/types/l2trace.go +++ b/core/types/l2trace.go @@ -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 diff --git a/miner/worker.go b/miner/worker.go index da67107a70..bd68aeb9b1 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -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()),