core/state: reduce allocation in updateStateObject (#31861)
Some checks are pending
i386 linux tests / Lint (push) Waiting to run
i386 linux tests / build (push) Waiting to run

Optimize updateStateObject to reduce an allocation.
This commit is contained in:
Marius van der Wijden 2025-05-20 18:31:01 +02:00 committed by GitHub
parent 62aa6b2621
commit 63740b7aca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -562,9 +562,8 @@ func (s *StateDB) GetTransientState(addr common.Address, key common.Hash) common
// updateStateObject writes the given object to the trie.
func (s *StateDB) updateStateObject(obj *stateObject) {
// Encode the account and update the account trie
addr := obj.Address()
if err := s.trie.UpdateAccount(addr, &obj.data, len(obj.code)); err != nil {
s.setError(fmt.Errorf("updateStateObject (%x) error: %v", addr[:], err))
if err := s.trie.UpdateAccount(obj.Address(), &obj.data, len(obj.code)); err != nil {
s.setError(fmt.Errorf("updateStateObject (%x) error: %v", obj.Address(), err))
}
if obj.dirtyCode {
s.trie.UpdateContractCode(obj.Address(), common.BytesToHash(obj.CodeHash()), obj.code)