mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
core/state: do not annotate logs in statedb
This commit is contained in:
parent
4979d85ea3
commit
d4e6a9f76e
4 changed files with 7 additions and 12 deletions
|
|
@ -448,7 +448,6 @@ func (ch addLogChange) revert(s *StateDB) {
|
|||
} else {
|
||||
s.logs[ch.txhash] = logs[:len(logs)-1]
|
||||
}
|
||||
s.logSize--
|
||||
}
|
||||
|
||||
func (ch addLogChange) dirtied() *common.Address {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ type StateDB struct {
|
|||
thash common.Hash
|
||||
txIndex int
|
||||
logs map[common.Hash][]*types.Log
|
||||
logSize uint
|
||||
|
||||
// Preimages occurred seen by VM in the scope of block.
|
||||
preimages map[common.Hash][]byte
|
||||
|
|
@ -243,11 +242,7 @@ func (s *StateDB) Error() error {
|
|||
func (s *StateDB) AddLog(log *types.Log) {
|
||||
s.journal.logChange(s.thash)
|
||||
|
||||
log.TxHash = s.thash
|
||||
log.TxIndex = uint(s.txIndex)
|
||||
log.Index = s.logSize
|
||||
s.logs[s.thash] = append(s.logs[s.thash], log)
|
||||
s.logSize++
|
||||
}
|
||||
|
||||
// GetLogs returns the logs matching the specified transaction hash.
|
||||
|
|
@ -669,7 +664,6 @@ func (s *StateDB) Copy() *StateDB {
|
|||
thash: s.thash,
|
||||
txIndex: s.txIndex,
|
||||
logs: make(map[common.Hash][]*types.Log, len(s.logs)),
|
||||
logSize: s.logSize,
|
||||
preimages: maps.Clone(s.preimages),
|
||||
|
||||
// Do we need to copy the access list and transient storage?
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ func TestBurn(t *testing.T) {
|
|||
// TestHooks is a basic sanity-check of all hooks
|
||||
func TestHooks(t *testing.T) {
|
||||
inner, _ := New(types.EmptyRootHash, NewDatabaseForTesting())
|
||||
inner.SetTxContext(common.Hash{0x11}, 100) // For the log
|
||||
var result []string
|
||||
var wants = []string{
|
||||
"0xaa00000000000000000000000000000000000000.balance: 0->100 (Unspecified)",
|
||||
|
|
@ -89,7 +88,7 @@ func TestHooks(t *testing.T) {
|
|||
"0xaa00000000000000000000000000000000000000.code: (0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470) ->0x1325 (0xa12ae05590de0c93a00bc7ac773c2fdb621e44f814985e72194f921c0050f728)",
|
||||
"0xaa00000000000000000000000000000000000000.storage slot 0x0000000000000000000000000000000000000000000000000000000000000001: 0x0000000000000000000000000000000000000000000000000000000000000000 ->0x0000000000000000000000000000000000000000000000000000000000000011",
|
||||
"0xaa00000000000000000000000000000000000000.storage slot 0x0000000000000000000000000000000000000000000000000000000000000001: 0x0000000000000000000000000000000000000000000000000000000000000011 ->0x0000000000000000000000000000000000000000000000000000000000000022",
|
||||
"log 100",
|
||||
"log 0xbb00000000000000000000000000000000000000",
|
||||
}
|
||||
emitF := func(format string, a ...any) {
|
||||
result = append(result, fmt.Sprintf(format, a...))
|
||||
|
|
@ -108,7 +107,7 @@ func TestHooks(t *testing.T) {
|
|||
emitF("%v.storage slot %v: %v ->%v", addr, slot, prev, new)
|
||||
},
|
||||
OnLog: func(log *types.Log) {
|
||||
emitF("log %v", log.TxIndex)
|
||||
emitF("log %v", log.Address)
|
||||
},
|
||||
})
|
||||
sdb.AddBalance(common.Address{0xaa}, uint256.NewInt(100), tracing.BalanceChangeUnspecified)
|
||||
|
|
|
|||
|
|
@ -206,8 +206,11 @@ func deriveFullReceipt(receipt *types.Receipt, evm *vm.EVM, result *ExecutionRes
|
|||
receipt.ContractAddress = crypto.CreateAddress(evm.TxContext.Origin, tx.Nonce())
|
||||
}
|
||||
|
||||
// Annotate the logs with blockhash and blocknumber.
|
||||
for _, log := range receipt.Logs {
|
||||
// Annotate the logs
|
||||
for index, log := range receipt.Logs {
|
||||
log.TxHash = tx.Hash()
|
||||
log.TxIndex = uint(statedb.TxIndex())
|
||||
log.Index = uint(index)
|
||||
log.BlockHash = blockHash
|
||||
log.BlockNumber = blockNumber.Uint64()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue