From 0a04487cd8c308a864f81d4e663b820f6ee8acc1 Mon Sep 17 00:00:00 2001 From: binary-mesh Date: Thu, 16 Apr 2026 11:47:34 +0300 Subject: [PATCH] core/overlay: prevent silent transition state restart on decode failure When gob.Decode fails in LoadTransitionState, the function previously returned nil, which triggered the fallback path that creates a fresh TransitionState{Ended: isVerkle}. On a verkle-enabled node, this would incorrectly mark the transition as complete, potentially causing the node to use BinaryTrie for a partially-transitioned state. Instead of returning nil, return a non-nil TransitionState with both Started and Ended set to false. This ensures: - InTransition() returns false (no partial transition in progress) - Transitioned() returns false (transition has not completed) - The fallback path is not triggered, preventing incorrect state The root hash is also logged in the error message to aid debugging corruption incidents. --- core/overlay/state_transition.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/overlay/state_transition.go b/core/overlay/state_transition.go index a52d9139c9..8a7e46ad29 100644 --- a/core/overlay/state_transition.go +++ b/core/overlay/state_transition.go @@ -86,8 +86,14 @@ func LoadTransitionState(db ethdb.KeyValueReader, root common.Hash, isVerkle boo // Decode transition state err := dec.Decode(&newts) if err != nil { - log.Error("failed to decode transition state", "err", err) - return nil + log.Error("failed to decode transition state", "root", root, "err", err) + // Corrupted transition state data must not silently restart + // the transition via the fallback path. Return an ended state + // rather than nil to avoid triggering the fresh-start fallback, + // which would incorrectly mark the transition as complete when + // the on-disk data was merely corrupted. + ts = &TransitionState{Ended: false, Started: false} + return ts } ts = &newts }