Skip to content

fix: migrate trees ix preserve work#2320

Merged
ananas-block merged 2 commits intomainfrom
jorrit/fix-migrate-trees-preserve-work
Mar 2, 2026
Merged

fix: migrate trees ix preserve work#2320
ananas-block merged 2 commits intomainfrom
jorrit/fix-migrate-trees-preserve-work

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Mar 1, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced validation mechanisms for forester and network fee configurations across initialization and migration operations, ensuring stricter protocol compliance and preventing invalid setup combinations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

📝 Walkthrough

Walkthrough

These changes tighten validation rules for forester eligibility and network fee handling across registry initialization and migration paths. The modifications replace direct forester checks with ForesterEpochPda-based validation and enforce stricter constraints on forester definition relative to protocol network fees.

Changes

Cohort / File(s) Summary
Forester and Network Fee Validation
programs/registry/src/lib.rs
Replaced check_forester invocations with ForesterEpochPda::check_forester_in_program calls. Added enforcement preventing forester definition when network_fee matches protocol config. Introduced non-zero network_fee validation in rollover scenarios. Modified initialization logic in both initialize_state_merkle_tree and initialize_batched_state_merkle_tree to enforce forester/network_fee constraint combinations (e.g., require forester when no custom network_fee is provided).
Test Configuration Handling
sdk-libs/program-test/src/indexer/test_indexer.rs
Updated add_state_merkle_tree to conditionally construct StateMerkleTreeConfig based on whether a forester is defined—setting network_fee: None when forester is present, otherwise using defaults. This aligns test configuration with the new validation rules.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • chore: pre release #2014: Modifies forester eligibility checks and network_fee validation across registry code by replacing older check_forester patterns with ForesterEpochPda-based checks.

Suggested labels

ai-review

Suggested reviewers

  • sergeytimoshin

Poem

🌲 Foresters stand guard with stricter rules,
No double-dipping at protocol pools,
Network fees now verified with care,
Validation checks everywhere! ✨
Constraints tightened, logic squared,
Safe migrations ensured and prepared. 🔐

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 70.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references 'migrate trees ix' (instruction) and 'preserve work,' which aligns with the core changes around forester validation and network fee checks during tree migration, though it's quite terse.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jorrit/fix-migrate-trees-preserve-work

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Entire-Checkpoint: c994844a3394
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@programs/registry/src/lib.rs`:
- Around line 684-693: The code currently loads metadata and calls
ForesterEpochPda::check_forester_in_program(...) directly, which bypasses the
wrapper flow; change this to follow the wrapper pattern: load metadata (metadata
= ctx.accounts.merkle_tree.load()?.metadata), keep the network_fee non-zero
check, determine work units (use DEFAULT_WORK_V1), call check_forester(...) (the
wrapper) instead of ForesterEpochPda::check_forester_in_program so the
designated-forester fallback for private trees is preserved, and then proceed to
call the processing function; reference the symbols metadata, DEFAULT_WORK_V1,
check_forester, and ForesterEpochPda::check_forester_in_program when updating
the call.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5f7f10 and 6a2e0ad.

⛔ Files ignored due to path filters (1)
  • program-tests/registry-test/tests/tests.rs is excluded by none and included by none
📒 Files selected for processing (2)
  • programs/registry/src/lib.rs
  • sdk-libs/program-test/src/indexer/test_indexer.rs

@ananas-block ananas-block merged commit be9fa48 into main Mar 2, 2026
31 checks passed
@ananas-block ananas-block deleted the jorrit/fix-migrate-trees-preserve-work branch March 2, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants