-
Notifications
You must be signed in to change notification settings - Fork 182
fix: prefer Tipset::persist over Block::persist
#6083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughRemoved Block::persist and its Blockstore dependency. Refactored FullTipset::persist to persist header and messages directly. Updated chain follower and RPC finalize handlers to call FullTipset::persist instead of per-block persistence. Validation logic remains unchanged. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller as ChainFollower/RPC
participant FTS as FullTipset
participant Validator as TipsetValidator
participant Store as Blockstore
Caller->>FTS: persist(db)
note right of FTS: New flow: persist components directly
FTS->>Validator: validate_msg_root(db, block)
Validator-->>FTS: ok or error
alt validation ok
FTS->>Store: persist_objects([header])
Store-->>FTS: ok
FTS->>Store: persist_objects([BLS messages])
Store-->>FTS: ok
FTS->>Store: persist_objects([Secp messages])
Store-->>FTS: ok
FTS-->>Caller: ok
else validation error
FTS-->>Caller: error
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/chain_sync/chain_follower.rs (1)
470-472: Bulk persist per-tipset — LGTM.Tiny nit: avoid repeated blockstore() calls.
- for tipset in tipsets.iter() { - tipset.persist(chain_store.blockstore())?; - } + let db = chain_store.blockstore(); + for tipset in &tipsets { + tipset.persist(db)?; + }src/blocks/tipset.rs (1)
555-557: Avoid double-reference to db; persist messages before header to reduce transient dangling refs.Passing &db makes it &&DB; compile‑time OK but noisy. Also, persisting messages first minimizes a window where headers point to not‑yet‑stored data. If validate_msg_root already persists TxMeta, this ordering is even safer.
- crate::chain::persist_objects(&db, std::iter::once(block.header()))?; - crate::chain::persist_objects(&db, block.bls_msgs().iter())?; - crate::chain::persist_objects(&db, block.secp_msgs().iter())?; + // Persist message objects first, then header. + crate::chain::persist_objects(db, block.bls_msgs().iter())?; + crate::chain::persist_objects(db, block.secp_msgs().iter())?; + crate::chain::persist_objects(db, std::iter::once(block.header()))?;Can you confirm TipsetValidator::validate_msg_root persists the TxMeta (and AMT nodes) to the blockstore? If not, we should add an explicit persist for TxMeta here or in validate_msg_root.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/blocks/block.rs(0 hunks)src/blocks/tipset.rs(1 hunks)src/chain_sync/chain_follower.rs(1 hunks)src/rpc/methods/f3.rs(1 hunks)
💤 Files with no reviewable changes (1)
- src/blocks/block.rs
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: hanabi1224
PR: ChainSafe/forest#5930
File: build.rs:64-77
Timestamp: 2025-08-13T09:43:20.301Z
Learning: hanabi1224 prefers hard compile-time errors in build scripts rather than runtime safeguards or collision detection, believing it's better to fail fast and fix root causes of issues like malformed snapshot names.
🧬 Code graph analysis (3)
src/rpc/methods/f3.rs (3)
src/tool/subcommands/api_cmd/test_snapshot.rs (1)
ctx(127-178)src/tool/subcommands/api_cmd/generate_test_snapshot.rs (1)
ctx(106-159)src/rpc/methods/sync.rs (1)
ctx(177-252)
src/chain_sync/chain_follower.rs (2)
src/state_manager/mod.rs (1)
chain_store(296-298)src/rpc/mod.rs (1)
chain_store(466-468)
src/blocks/tipset.rs (1)
src/chain/store/chain_store.rs (2)
persist_objects(516-528)db(502-502)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: tests-release
- GitHub Check: tests
- GitHub Check: Build forest binaries on Linux AMD64
- GitHub Check: All lint checks
- GitHub Check: cargo-publish-dry-run
- GitHub Check: Build MacOS
- GitHub Check: Build Ubuntu
🔇 Additional comments (1)
src/rpc/methods/f3.rs (1)
597-597: Switch to FullTipset::persist — confirm no remaining Block::persist usagesGood call. Sandbox ripgrep skipped files ("No files were searched"); run locally: rg -n --hidden -uu 'Block::persist|\bblock\s*.persist\s*(' and confirm there are no hits.
LesnyRumcajs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix anything in particular?
No |
Summary of changes
Changes introduced in this pull request:
Tipset::persistoverBlock::persistto ensure message root of every block is persistedReference issue to close (if applicable)
Closes
Other information and links
Change checklist
Summary by CodeRabbit
Refactor
Chores
Impact