Skip to content

revert giga snapshot journal rollback changes#3536

Merged
codchen merged 8 commits into
mainfrom
codex/fix-giga-sstore-snapshot-rollback
Jun 10, 2026
Merged

revert giga snapshot journal rollback changes#3536
codchen merged 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 10, 2026, 2:30 AM

@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.31%. Comparing base (7b5b01a) to head (146a1f3).

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.20%   58.31%   -0.89%     
==========================================
  Files        2226     2152      -74     
  Lines      183684   175014    -8670     
==========================================
- Hits       108749   102065    -6684     
+ Misses      65147    63869    -1278     
+ Partials     9788     9080     -708     
Flag Coverage Δ
sei-chain-pr 74.90% <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.61% <95.65%> (-1.14%) ⬇️
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 core EVM transaction snapshot/revert and finalize flush semantics for persistent state; incorrect behavior could break contract reverts or state commits.

Overview
Reverts Giga xevm/state from journal-based snapshot rollback to the CacheMultiStore context stack model (aligned with x/evm/state).

Snapshot / revert: Snapshot pushes the current sdk.Context and switches to a new cached multistore + event manager; RevertToSnapshot restores that context stack and only uses journal watermarks to unwind in-memory journal entries (transient storage, access lists, surplus, etc.). Persistent KV changes (balance, storage, code, nonce, address mappings) are rolled back by discarding cache layers, not per-entry journal revert.

Removed: Journal types and revert logic for balanceChange, storageChange, codeChange, nonceChange, createAccountChange, deleteMappingChange, plus clearAccountStateJournaled, SetAddressMapping on the state keeper interface, and auth keeper global account number byte get/set helpers used by mapping rollback.

Finalize / lifecycle: DBImpl again keeps snapshottedCtxs, flushes nested caches on Finalize/CleanupForTracer, and reads GetCommittedState from the base snapshot context. CreateAccount calls non-journaled clearAccountState again.

Tests: Drops the large Giga snapshot/integration suite tied to journal rollback; adds OnNonceChangeV2 nonce tracing tests in Giga and x/evm/state.

Reviewed by Cursor Bugbot for commit 146a1f3. 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.

Comment thread giga/deps/xevm/state/state.go
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
@codchen codchen force-pushed the codex/fix-giga-sstore-snapshot-rollback branch from 15c64f6 to 146a1f3 Compare June 10, 2026 02:29
@codchen codchen added this pull request to the merge queue Jun 10, 2026
Merged via the queue into main with commit ba465c7 Jun 10, 2026
82 of 84 checks passed
@codchen codchen deleted the codex/fix-giga-sstore-snapshot-rollback branch June 10, 2026 03:45
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