test(e2e): repro reth-ahead-of-consensus cross-store desync (audit #703/#704)#745
test(e2e): repro reth-ahead-of-consensus cross-store desync (audit #703/#704)#745keanji-x wants to merge 1 commit into
Conversation
#704) Adds a single-node e2e suite that deterministically reproduces the non-atomic cross-store commit bug (reth execution rocksdb ahead of the aptos consensus DB) and the recovery-path panic it triggers. Repro (no power-loss race needed): 1. bring node live, commit past H, node.stop() cleanly 2. gravity_cli unwind the CONSENSUS DB back to ~H/2, leaving reth at H (NOTE: --consensus-db-path must be the parent <data> dir, the tool joins "consensus_db" internally; passing <data>/consensus_db no-ops) 3. node.start(): recovery anchors on reth's height (recover_block_number), the unwound consensus index lacks it, RecoveryData::new -> find_root fails "unable to find root" -> persistent_liveness_storage.rs:550 panic!("") and the node CRASHES (no PartialRecoveryData/state-sync fallback; recovery_manager.rs:104 is todo!()). Observed evidence captured by the test: ERROR persistent_liveness_storage.rs:549 Failed to construct recovery data {"error":"unable to find root: ..."} ; panicked at persistent_liveness_storage.rs:550 ; node process dead. The sibling silent-stall path (block_buffer_manager.rs:343 early-return leaving the buffer Uninitialized -> get_ordered_blocks awaits ready_notifier forever) is also asserted as a recovery failure. The test asserts the CORRECT post-fix behaviour (node reconciles reth_height > consensus_index and resumes), so it is xfail(strict) on current code. Remove the xfail once startup auto-reconciles instead of panicking/stalling. Test-only; no production code changed. Refs Galxe/gravity-audit#703, Galxe/gravity-audit#704 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for adding the repro test. I think the premise of this test does not match the actual commit ordering, so this case is probably not something we need to cover. In the real commit path, consensus is committed before reth. Therefore the crash window should not leave us with That latter case is expected and already recoverable: on restart, the node can replay / recover the missing reth side from consensus. So intentionally unwinding only the consensus DB creates an artificial state that should not be produced by the normal system failure model. Because of that, I don’t think this e2e test is necessary as-is. If we want to keep a test around recovery ordering, it should model the realistic direction instead: consensus ahead of reth, not reth ahead of consensus. But since that scenario already recovers normally, there may not be much value in adding a new xfail test here. |
Summary
Adds a deterministic single-node e2e suite (
gravity_e2e/cluster_test_cases/cross_store_desync_703_704/) that reproduces the non-atomic cross-store commit bug and the recovery-path crash it triggers — findings F1/F2 ingalxe/RESTART_RECOVERY_FINDINGS.md.reth (execution rocksdb) and the aptos consensus DB persist on independent stores with no write-ordering barrier. A crash in the commit window can leave reth at block N while consensus is at N-1. On restart, recovery anchors on reth's height (
bin/gravity_node/src/main.rs:123recover_block_number) but the consensus index no longer contains it, so recovery cannot find the root and the node dies — there is no reconcile / state-sync fallback.Reproduction (no power-loss race needed)
node.stop()cleanly.gravity_cli unwindthe consensus DB back to ~H/2, leaving reth at H.--consensus-db-pathmust be the parent<data>dir, becauseConsensusDB::newjoinsconsensus_dbinternally (aptos-core/consensus/src/consensusdb/mod.rs:112). Passing<data>/consensus_dboperates on an empty nested DB and silently no-ops.node.start()and observe recovery.Observed failure (current code)
This is F1 (#703): the
PartialRecoveryData/ state-sync fallback at:551is commented out andrecovery_manager.rs:104istodo!(), so any inconsistent recovery data is apanic!(""). The sibling F2 (#704) silent-stall path (crates/block-buffer-manager/src/block_buffer_manager.rs:343early-return leaving the bufferUninitialized→get_ordered_blocksawaitsready_notifierforever) is also asserted as a recovery failure.Test status
The test asserts the correct post-fix behaviour (node detects
reth_height > consensus_index, reconciles, and resumes producing blocks), so it is@pytest.mark.xfail(strict=True)on current code:Remove the xfail once startup auto-reconciles instead of panicking/stalling.
Notes
base_dir=/tmp/gravity-cluster-desyncand unique ports (rpc 8945, validator 6480, vfn 6490, authrpc 8953, reth_p2p 12324, metrics 9050, inspection 10300) — no collision with existing suites.🤖 Generated with Claude Code