Skip to content

revert giga snapshot journal rollback changes#3536

Open
codchen wants to merge 8 commits into
mainfrom
codex/fix-giga-sstore-snapshot-rollback
Open

revert giga snapshot journal rollback changes#3536
codchen wants to merge 8 commits into
mainfrom
codex/fix-giga-sstore-snapshot-rollback

Conversation

@codchen

@codchen codchen commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Why

The desired fix is to undo the journal-based Giga snapshot/rollback changes and return to the pre-#3295 / pre-#3414 behavior. This restores Giga StateDB snapshot handling to the CacheMultiStore stack model instead of the journal rollback approach introduced and adjusted by those PRs.

Cursor review notes

  • RevertToSnapshot(0) / snapshottedCtxs[0]: left unchanged because the rebased Giga implementation matches x/evm/state.
  • nonce hook guard: left unchanged because the rebased Giga implementation matches x/evm/state (OnNonceChange guard with OnNonceChangeV2 callback).

Validation

  • rebased onto origin/main at b8473e713
  • go test ./giga/deps/xevm/state -count=1
  • go test ./giga/deps/xevm/... -count=1
  • go test ./sei-cosmos/x/auth/keeper -count=1

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 9, 2026, 12:47 PM

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.02469% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.29%. Comparing base (1f52187) to head (15c64f6).

Files with missing lines Patch % Lines
giga/deps/xevm/state/statedb.go 40.00% 32 Missing and 1 partial ⚠️
giga/deps/xevm/state/state.go 95.65% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3536      +/-   ##
==========================================
- Coverage   59.18%   58.29%   -0.89%     
==========================================
  Files        2225     2151      -74     
  Lines      183625   174955    -8670     
==========================================
- Hits       108677   101998    -6679     
+ Misses      65154    63871    -1283     
+ Partials     9794     9086     -708     
Flag Coverage Δ
sei-chain-pr 74.81% <58.02%> (?)
sei-db 70.41% <ø> (ø)
sei-db-state-db ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
giga/deps/xevm/state/balance.go 60.67% <ø> (-0.87%) ⬇️
giga/deps/xevm/state/code.go 76.92% <ø> (-10.04%) ⬇️
giga/deps/xevm/state/journal.go 85.71% <100.00%> (-4.20%) ⬇️
giga/deps/xevm/state/nonce.go 100.00% <100.00%> (ø)
sei-cosmos/x/auth/keeper/keeper.go 83.13% <ø> (+1.61%) ⬆️
x/evm/state/nonce.go 100.00% <100.00%> (+25.00%) ⬆️
giga/deps/xevm/state/state.go 97.52% <95.65%> (-1.20%) ⬇️
giga/deps/xevm/state/statedb.go 58.22% <40.00%> (-20.49%) ⬇️

... and 75 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codchen codchen changed the title [codex] fix giga snapshot storage rollback fix giga snapshot storage rollback Jun 8, 2026
@codchen codchen changed the title fix giga snapshot storage rollback fix giga snapshot cache journal rollback Jun 8, 2026
@codchen codchen marked this pull request as ready for review June 8, 2026 02:29
@cursor

cursor Bot commented Jun 8, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes how EVM transaction reverts apply to balances, storage, code, and mappings in the Giga path—core correctness for failed/reverted execution.

Overview
Reverts Giga xevm StateDB snapshot/rollback from the journal-based model back to the CacheMultiStore context stack used by x/evm/state.

Snapshot / revert: Snapshot pushes a cached sdk.Context onto snapshottedCtxs and swaps in a fresh cache layer; RevertToSnapshot restores that context and drops newer layers. The journal now only rolls back in-memory effects (transient storage, access lists, surplus, account flags, etc.) via watermark entries—not persisted KV, bank balance, code, nonce, or address mappings.

Removed: Per-mutation journal types and revert paths for storage, code, nonce, balances, CreateAccount clearing, and self-destruct mapping restore; clearAccountStateJournaled; committedCtx / revision bookkeeping; SetAddressMapping on the Giga state keeper interface; auth keeper global account number byte get/set helpers tied to mapping rollback. Large snapshot_test.go / internal statedb tests for journal rollback are deleted.

Finalize / reads: Finalize flushes nested cache writes and merges events into the base snapshot context; GetCommittedState reads from snapshottedCtxs[0].

Tracing: Giga and main x/evm SetNonce use the OnNonceChangeV2 hook with a small test added on both paths.

Reviewed by Cursor Bugbot for commit 15c64f6. Bugbot is set up for automated code reviews on this repo. Configure here.

@codchen codchen changed the title fix giga snapshot cache journal rollback fix giga snapshot storage rollback Jun 8, 2026
@codchen codchen changed the title fix giga snapshot storage rollback revert giga snapshot journal rollback changes Jun 8, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit df9ff92. Configure here.

}
s.journal = s.journal[:snapshot.journalIndex]
s.ctx = s.snapshottedCtxs[rev]
s.snapshottedCtxs = s.snapshottedCtxs[:rev]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty base after revert zero

High Severity

RevertToSnapshot(0) sets snapshottedCtxs to an empty slice while GetCommittedState and flushEvents still read snapshottedCtxs[0]. After a revert to the initial revision, those paths can panic even though s.ctx already holds the base context that replaced the removed committedCtx field.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit df9ff92. Configure here.

Comment thread giga/deps/xevm/state/nonce.go
@codchen codchen force-pushed the codex/fix-giga-sstore-snapshot-rollback branch from df9ff92 to 747638c Compare June 8, 2026 09:09

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a large, app-hash-breaking revert of journal-based snapshot/rollback logic in the EVM StateDB — worth a human look given the scope and consensus implications, even though no bugs were found by the bug hunter.

Extended reasoning...

Overview

This PR reverts two prior PRs (#3414 and #3295) that introduced journal-based Giga StateDB snapshot/rollback, returning the implementation to the CacheMultiStore stack model. It also touches sei-cosmos/x/auth/keeper/keeper.go (removes GetGlobalAccountNumberBytes/SetGlobalAccountNumberBytes), modifies the expected_keepers interface (removes SetAddressMapping), deletes large snapshot integration test suites, and simplifies docker/localnode/Dockerfile (ubuntu:24.04ubuntu:latest, retry logic loosened).

Security risks

The PR is labeled app-hash-breaking, meaning it changes consensus behavior. The semantics of snapshot/revert during EVM execution directly affect state root computation; any divergence from the prior implementation could fork the network. The Dockerfile change to ubuntu:latest reduces reproducibility but is dev-environment scoped.

Level of scrutiny

High. This touches consensus-critical EVM state handling and is explicitly app-hash-breaking. The Cursor bot raised two concerns (panic risk on RevertToSnapshot(0) reading snapshottedCtxs[0], and a nonce hook guard checking V1 while calling V2) which the author acknowledged in the PR description as intentionally matching x/evm/state. A human should validate that intent and confirm the rebased Giga semantics are correct.

Other factors

Coverage dropped on the touched files (patch coverage 55.55%, statedb.go at 40%, nonce.go at 0%). Significant test suites were deleted (snapshot_test.go, statedb_internal_test.go) as they tested the journal model being removed. The author validated with go test ./giga/deps/xevm/... but the loss of integration coverage on the new (restored) snapshot model is worth weighing.

@codchen codchen force-pushed the codex/fix-giga-sstore-snapshot-rollback branch from 6317aa4 to df6bfea Compare June 9, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants