From 68d390d518c627752877a0c894d4a922f7475669 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Thu, 2 Apr 2026 23:41:50 +0200 Subject: [PATCH 1/4] core/state: fix setError in BAL ST --- core/state/bal_state_transition.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state/bal_state_transition.go b/core/state/bal_state_transition.go index 0dccefd7c370..1d463db1971a 100644 --- a/core/state/bal_state_transition.go +++ b/core/state/bal_state_transition.go @@ -102,7 +102,7 @@ func (s *BALStateTransition) Error() error { } func (s *BALStateTransition) setError(err error) { - if s.err != nil { + if s.err == nil { s.err = err } } From c698661f7feb907796944768108a40266d8a00a8 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Fri, 3 Apr 2026 00:15:49 +0200 Subject: [PATCH 2/4] Fix balance change txindex check --- core/types/bal/bal_encoding.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/types/bal/bal_encoding.go b/core/types/bal/bal_encoding.go index 0029d5d66852..6f1c6187ed2a 100644 --- a/core/types/bal/bal_encoding.go +++ b/core/types/bal/bal_encoding.go @@ -367,7 +367,7 @@ func (e *AccountAccess) validate(blockTxCount int) error { return errors.New("balance changes not in ascending order by tx index") } - if len(e.BalanceChanges) > 0 && int(e.BalanceChanges[len(e.BalanceChanges)-1].TxIdx) > blockTxCount+2 { + if len(e.BalanceChanges) > 0 && int(e.BalanceChanges[len(e.BalanceChanges)-1].TxIdx) >= blockTxCount+2 { return errors.New("highest balance change index beyond what is allowed") } // check that the balance values are set and there are no duplicate index entries From a5aee0d2a8f03a56d2d9f5bbd5447e0ec518d76c Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Fri, 3 Apr 2026 00:16:06 +0200 Subject: [PATCH 3/4] fix origin code hash --- core/state/bal_state_transition.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/state/bal_state_transition.go b/core/state/bal_state_transition.go index 1d463db1971a..a2307fc8875b 100644 --- a/core/state/bal_state_transition.go +++ b/core/state/bal_state_transition.go @@ -169,10 +169,11 @@ func (s *BALStateTransition) commitAccount(addr common.Address) (*accountUpdate, ) op := &accountUpdate{ address: addr, - data: types.SlimAccountRLP(*s.postStates[addr]), // TODO: cache the updated state acocunt somewhere + data: types.SlimAccountRLP(*s.postStates[addr]), // TODO: cache the updated state account somewhere } - if prestate, exist := s.prestates.Load(addr); exist { - prestate := prestate.(*types.StateAccount) + var prestate *types.StateAccount + if ps, exist := s.prestates.Load(addr); exist { + prestate = ps.(*types.StateAccount) op.origin = types.SlimAccountRLP(*prestate) } @@ -181,10 +182,10 @@ func (s *BALStateTransition) commitAccount(addr common.Address) (*accountUpdate, hash: crypto.Keccak256Hash(s.diffs[addr].Code), blob: s.diffs[addr].Code, } - if op.origin == nil { + if prestate == nil { code.originHash = types.EmptyCodeHash } else { - code.originHash = crypto.Keccak256Hash(op.origin) + code.originHash = common.BytesToHash(prestate.CodeHash) } op.code = &code } From d834cd640241289b62a05276cfa4a0b25cf544a4 Mon Sep 17 00:00:00 2001 From: jwasinger Date: Fri, 3 Apr 2026 12:40:15 -0400 Subject: [PATCH 4/4] Apply suggestion from @jwasinger --- core/types/bal/bal_encoding.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/types/bal/bal_encoding.go b/core/types/bal/bal_encoding.go index 6f1c6187ed2a..fc1d36007ef6 100644 --- a/core/types/bal/bal_encoding.go +++ b/core/types/bal/bal_encoding.go @@ -367,7 +367,7 @@ func (e *AccountAccess) validate(blockTxCount int) error { return errors.New("balance changes not in ascending order by tx index") } - if len(e.BalanceChanges) > 0 && int(e.BalanceChanges[len(e.BalanceChanges)-1].TxIdx) >= blockTxCount+2 { + if len(e.BalanceChanges) > 0 && int(e.BalanceChanges[len(e.BalanceChanges)-1].TxIdx) > blockTxCount+1 { return errors.New("highest balance change index beyond what is allowed") } // check that the balance values are set and there are no duplicate index entries