From fc2d55dd58984585ac7107a5935c41542a4eeb58 Mon Sep 17 00:00:00 2001 From: CPerezz Date: Wed, 18 Feb 2026 15:16:16 +0100 Subject: [PATCH] core/state/partial: only write modified accounts to trie Match upstream BALStateTransition behavior: only call UpdateAccount for accounts that were actually modified (balance, nonce, code, or storage changes). Previously, all accounts in the BAL (including read-only ones) were written back to the trie, which could cause root mismatches if the re-encoded RLP differed from the original encoding. Co-Authored-By: Claude Opus 4.6 --- core/state/partial/state.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/state/partial/state.go b/core/state/partial/state.go index 44c5b67393..9b9261ef0e 100644 --- a/core/state/partial/state.go +++ b/core/state/partial/state.go @@ -287,6 +287,11 @@ func (s *PartialState) ApplyBALAndComputeRoot(parentRoot common.Hash, expectedRo continue } + // Only write accounts that were actually modified to the trie. + // Upstream BALStateTransition only processes ModifiedAccounts(). + if !state.modified { + continue + } if err := tr.UpdateAccount(state.addr, state.account, 0); err != nil { return common.Hash{}, 0, fmt.Errorf("failed to update account %s: %w", state.addr.Hex(), err)