Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,13 @@ func (s *StateDB) GetRefund() uint64 {
// Finalise finalises the state by removing the destructed objects and clears
// the journal as well as the refunds. Finalise, however, will not push any updates
// into the tries just yet. Only IntermediateRoot or Commit will do that.
func (s *StateDB) Finalise(deleteEmptyObjects bool) {
func (s *StateDB) Finalise(deleteEmptyObjects bool) error {
addressesToPrefetch := make([]common.Address, 0, len(s.journal.dirties))
for addr := range s.journal.dirties {
if slices.Contains(types.NanoBlackList, addr) {
return fmt.Errorf("block contains blacklisted address: %s", addr.Hex())
}
}
for addr := range s.journal.dirties {
obj, exist := s.stateObjects[addr]
if !exist {
Expand Down Expand Up @@ -935,6 +940,7 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) {
}
// Invalidate journal because reverting across transactions is not allowed.
s.clearJournalAndRefund()
return nil
}

// IntermediateRoot computes the current root hash of the state trie.
Expand Down
5 changes: 3 additions & 2 deletions core/state/statedb_hooked.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ func (s *hookedStateDB) GetLogs(hash common.Hash, blockNumber uint64, blockHash
return s.inner.GetLogs(hash, blockNumber, blockHash, blockTime)
}

func (s *hookedStateDB) Finalise(deleteEmptyObjects bool) {
func (s *hookedStateDB) Finalise(deleteEmptyObjects bool) error {
defer s.inner.Finalise(deleteEmptyObjects)
if s.hooks.OnBalanceChange == nil {
return
return nil
}
for addr := range s.inner.journal.dirties {
obj := s.inner.stateObjects[addr]
Expand All @@ -299,6 +299,7 @@ func (s *hookedStateDB) Finalise(deleteEmptyObjects bool) {
}
}
}
return nil
}

func (s *hookedStateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
Expand Down
2 changes: 1 addition & 1 deletion core/vm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ type StateDB interface {
AccessEvents() *state.AccessEvents

// Finalise must be invoked at the end of a transaction
Finalise(bool)
Finalise(bool) error
IntermediateRoot(deleteEmptyObjects bool) common.Hash
}