feat: Add support for CommitDiff to efficiently commit small changes in large delegated accounts#575
feat: Add support for CommitDiff to efficiently commit small changes in large delegated accounts#575
CommitDiff to efficiently commit small changes in large delegated accounts#575Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
249b1aa to
2f0555f
Compare
0151da0 to
5c25e73
Compare
MagicBlockInstruction::ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts
MagicBlockInstruction::ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accountsScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts
2ae750b to
725f72c
Compare
Manual Deploy AvailableYou can trigger a manual deploy of this PR branch to testnet: Alternative: Comment
Comment updated automatically when the PR is synchronized. |
725f72c to
e5c5e15
Compare
ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accountsScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts
ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accountsScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts
There was a problem hiding this comment.
Actionable comments posted: 29
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
magicblock-committor-service/src/tasks/args_task.rs (1)
229-237: reset_commit_id ignores CommitDiff—update both variants.Commit IDs must update for Commit and CommitDiff.
Apply:
- let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { - log::error!("reset_commit_id"); - return; - }; - - commit_task.commit_id = commit_id; + match &mut self.task_type { + ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + _ => {} + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (28)
Cargo.toml(1 hunks)magicblock-accounts/src/scheduled_commits_processor.rs(3 hunks)magicblock-committor-service/src/tasks/args_task.rs(6 hunks)magicblock-committor-service/src/tasks/mod.rs(1 hunks)magicblock-committor-service/src/tasks/task_builder.rs(3 hunks)magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs(1 hunks)magicblock-magic-program-api/src/instruction.rs(1 hunks)magicblock-rpc-client/src/lib.rs(1 hunks)programs/magicblock/src/magic_scheduled_base_intent.rs(7 hunks)programs/magicblock/src/magicblock_processor.rs(4 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(2 hunks)programs/magicblock/src/schedule_transactions/process_scheduled_commit_sent.rs(5 hunks)test-integration/Cargo.toml(2 hunks)test-integration/programs/schedulecommit-security/src/lib.rs(2 hunks)test-integration/programs/schedulecommit/src/api.rs(5 hunks)test-integration/programs/schedulecommit/src/lib.rs(9 hunks)test-integration/programs/schedulecommit/src/order_book.rs(1 hunks)test-integration/programs/schedulecommit/src/utils/mod.rs(3 hunks)test-integration/schedulecommit/client/src/schedule_commit_context.rs(6 hunks)test-integration/schedulecommit/client/src/verify.rs(2 hunks)test-integration/schedulecommit/test-scenarios/Cargo.toml(1 hunks)test-integration/schedulecommit/test-scenarios/tests/01_commits.rs(2 hunks)test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs(4 hunks)test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs(1 hunks)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs(1 hunks)test-integration/test-ledger-restore/tests/08_commit_update.rs(2 hunks)test-integration/test-tools/src/integration_test_context.rs(2 hunks)test-integration/test-tools/src/scheduled_commits.rs(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
PR: magicblock-labs/magicblock-validator#585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (15)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
test-integration/test-ledger-restore/src/lib.rs (1)
setup_validator_with_local_remote(97-119)
test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (3)
test-integration/programs/schedulecommit/src/api.rs (1)
schedule_commit_with_payer_cpi_instruction(214-232)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
assert_two_committees_were_committed(68-91)get_context_with_delegated_committees(16-35)assert_feepayer_was_committed(94-113)test-integration/schedulecommit/client/src/verify.rs (1)
fetch_and_verify_commit_result_from_logs(7-14)
test-integration/programs/schedulecommit-security/src/lib.rs (1)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
create_schedule_commit_ix(41-66)
magicblock-committor-service/src/tasks/args_task.rs (4)
magicblock-committor-service/src/tasks/mod.rs (2)
instruction(66-66)instruction(249-255)magicblock-committor-service/src/tasks/buffer_task.rs (2)
instruction(65-86)new(37-45)magicblock-committor-service/src/config.rs (1)
local(29-35)magicblock-accounts/src/scheduled_commits_processor.rs (2)
new(66-90)new(420-436)
programs/magicblock/src/magicblock_processor.rs (3)
magicblock-committor-service/src/tasks/args_task.rs (1)
instruction(58-160)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
process_schedule_commit(34-259)magicblock-committor-program/src/state/changeset.rs (1)
request_undelegation(230-232)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4)
test-integration/programs/schedulecommit/src/api.rs (4)
schedule_commit_and_undelegate_cpi_instruction(234-252)schedule_commit_and_undelegate_cpi_with_mod_after_instruction(287-311)schedule_commit_diff_instruction_for_order_book(193-212)update_order_book_instruction(175-191)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
get_context_with_delegated_committees(16-35)assert_one_committee_was_committed(41-65)assert_one_committee_account_was_undelegated_on_chain(190-196)test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
committees(205-209)ephem_blockhash(322-324)ephem_client(318-320)test-integration/schedulecommit/client/src/verify.rs (1)
fetch_and_verify_order_book_commit_result_from_logs(16-23)
test-integration/programs/schedulecommit/src/api.rs (2)
test-integration/programs/schedulecommit/src/order_book.rs (1)
new(85-94)test-integration/programs/flexi-counter/src/state.rs (1)
pda(32-35)
test-integration/schedulecommit/client/src/verify.rs (2)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
ctx(90-91)test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
ctx(145-146)
magicblock-committor-service/src/tasks/task_builder.rs (2)
magicblock-accounts/src/scheduled_commits_processor.rs (2)
new(66-90)new(420-436)magicblock-committor-service/src/tasks/args_task.rs (1)
new(49-54)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
assert_is_signer(30-44)assert_keys_equal(16-28)allocate_account_and_assign_owner(58-106)test-integration/programs/schedulecommit/src/order_book.rs (1)
new(85-94)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(153-156)test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
base_intent(544-549)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
test-integration/programs/schedulecommit/src/api.rs (3)
init_order_book_instruction(36-54)init_payer_escrow(77-98)init_account_instruction(16-34)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(153-156)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
ctx(90-91)test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
ctx(145-146)test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
try_new(72-74)ncommittees(102-121)try_new_random_keys(66-71)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
get_context_with_delegated_committees(16-35)
⏰ 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). (4)
- GitHub Check: run_make_ci_format
- GitHub Check: run_make_ci_test
- GitHub Check: run_make_ci_lint
- GitHub Check: run_make_ci_test
🔇 Additional comments (34)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
55-55: LGTM! Correctly updated to match new function signature.Both call sites properly destructure the new 3-tuple return value. The
_tmpdirbinding is necessary to keep theTempDiralive throughout the function scope, preventing premature cleanup of the temporary directory while the validator is still using it.Also applies to: 170-170
test-integration/programs/schedulecommit/src/utils/mod.rs (2)
53-53: LGTM: Type alignment with Solana API.Changing
sizetou64aligns with Solana'ssystem_instruction::allocateAPI, which expects au64parameter. This improves type consistency and eliminates the need for type conversions downstream.
70-90: LGTM: Clean implementation with helpful debugging.The changes correctly handle the type conversion:
- Line 71: The cast to
usizeis necessary forRent::minimum_balanceand is safe given Solana's practical account size limits.- Lines 75-80: The debug log provides useful visibility into lamport requirements during account allocation.
- Line 90: Passing
sizedirectly asu64tosystem_instruction::allocateis cleaner and aligns with the API signature.test-integration/programs/schedulecommit-security/src/lib.rs (2)
2-2: LGTM: Import addition is correct.The
CommitPolicyimport is necessary for the API change on line 149.
143-150: No action required—the two CPI paths use intentionally different APIs.The review comment's concern about consistency is based on a false premise. The code uses two fundamentally different functions from different modules:
- Path 1 (
schedule_commit_cpi_instruction): A local program API wrapper with a fixed, simplified interface- Path 2 (
create_schedule_commit_ix): An external SDK function with extended configuration options includingCommitPolicyThese are not parallel implementations requiring symmetry. The
schedule_commit_cpi_instructionfunction does not supportCommitPolicyby design—it wraps commit scheduling with hardcoded policy defaults. AddingCommitPolicy::UseFullBytestocreate_schedule_commit_ixis the correct change and requires no corresponding update toschedule_commit_cpi_instruction.Likely an incorrect or invalid review comment.
test-integration/test-tools/src/integration_test_context.rs (1)
167-171: Transaction version configuration is correct and environment-aware.The conditional logic properly handles two distinct RPC endpoints:
- Chain (Solana devnet):
max_supported_transaction_version: Some(0)with 50 retries to handle devnet's known quirk of sometimes returning version responses instead of transaction metadata (noted at line 160-161).- Ephemeral (local validator):
Noneto use default behavior on a controlled, local environment without such quirks.Git history confirms this change is part of the current PR (commit 4c75d78). The code is correctly differentiated for each environment. No changes needed.
test-integration/test-tools/src/scheduled_commits.rs (1)
182-213: LGTM! Clear hierarchical naming for log variables.The renaming from
ephem_logs/chain_logstoephem_logs_l1/ephem_logs_l2improves clarity by establishing a consistent naming convention that reflects the two-level log retrieval hierarchy.magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (1)
29-33: LGTM: CommitDiff included in strategy persistence.Cleanly broadens Commit to CommitDiff without changing strategy semantics.
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
224-230: Diff-aware commit routing is correct; keep logs concise.Choosing StandaloneDiff when request_diff is true is right. Consider demoting the "StandaloneDiff" ic_msg to debug in production builds to reduce log noise.
Also applies to: 233-238
29-32: All call sites properly initialize request_diff—no corrections needed.Verification confirms that every
process_schedule_commit()invocation explicitly sets bothrequest_undelegationandrequest_difffields. All three instruction paths (ScheduleCommit,ScheduleCommitAndUndelegate,ScheduleCommitDiffAndUndelegate) pass values forrequest_diff, withScheduleCommitDiffAndUndelegatecorrectly setting it totrueto trigger theCommitType::StandaloneDiffpath. No uninitialized defaults are used, and no silent routing to full-state commits can occur.programs/magicblock/src/schedule_transactions/process_scheduled_commit_sent.rs (1)
29-30: LGTM: commit_diff added end-to-end with safe logging.Field is carried into printable form and logged only as a flag. Tests initialize the new field.
Also applies to: 44-45, 71-73, 215-217, 254-255
magicblock-committor-service/src/tasks/args_task.rs (1)
197-205: Calibrate compute units for CommitDiff based on diff size.Fixed 65_000 may be inaccurate. Once diff is precomputed, scale CU by diff length/segments or add headroom to avoid CU errors.
Based on learnings
programs/magicblock/src/magicblock_processor.rs (3)
2-2: LGTM: import added is correct.
51-54: ScheduleCommit: explicit request_diff=false is correct.
90-99: New ScheduleCommitDiffAndUndelegate path correctly flips request_diff=true.magicblock-committor-service/src/tasks/task_builder.rs (1)
96-105: Per-account Commit vs CommitDiff task selection is correct.programs/magicblock/src/magic_scheduled_base_intent.rs (6)
104-107: ScheduledBaseIntent::is_commit_diff added — OK.
155-164: MagicBaseIntent::is_commit_diff added — OK.
448-454: CommitType::is_commit_diff implementation — OK.
456-463: Getters updated for StandaloneDiff — OK.Also applies to: 465-473
475-487: is_empty handles StandaloneDiff — OK.
317-323: StandaloneDiff variant already exists and is actively used in the codebase.The review's concern assumes
StandaloneDiffis a new addition that will shift bincode discriminants. However, the variant is already present inprocess_schedule_commit.rs(lines 225–226), indicating it exists before this PR or is not new.If
StandaloneDiffwas already committed to the codebase:
- The bincode discriminant shift already happened (or never was a concern).
- The review comment's warning is outdated or misguided.
If the snippet shows the final state (post-changes) and
StandaloneDiffwas genuinely added in this PR:
- Verify the diff shows it was inserted between existing variants (which would shift discriminants).
- If it was appended after existing variants, discriminants remain stable and no migration is needed.
Critical finding: No backwards compatibility tests, no versioning code, and no serde external tagging exist. If persisted state truly exists and the variant order changed, this is a risk. However, the evidence suggests
StandaloneDiffis not new.Action for developer: Confirm in the PR diff that you are not reordering existing enum variants. If appending new variants after existing ones, bincode compatibility is safe. If inserting between existing variants, migration is required.
test-integration/schedulecommit/test-scenarios/Cargo.toml (1)
19-20: LGTM!The addition of
randandborshas workspace dev-dependencies appropriately supports the new order-book test scenarios introduced in this PR.test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
30-31: LGTM!The addition of deterministic seed
b"magic_schedule_commit"improves test reproducibility by ensuring consistent PDA derivation across test runs.test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (2)
16-35: LGTM!The seed parameter enables deterministic test context initialization, and explicitly driving the
init_committeesanddelegate_committeesworkflow steps with debug logging improves test clarity and observability.
41-47: LGTM!Making
assert_one_committee_was_committedgeneric over typeTwith appropriate trait bounds enables reuse across different account types (MainAccount, OrderBookOwned, etc.) while maintaining type safety.test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (2)
23-80: LGTM!The test properly validates that attempting to commit a fee payer without escrowing lamports fails with the expected "DoesNotHaveEscrowAccount" error. The test structure and assertions are appropriate.
83-135: LGTM!The test correctly validates the happy path where fee payer commits succeed when lamports are properly escrowed. The verification flow and assertions comprehensively check that both committees and the fee payer were committed and synchronized.
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (3)
55-56: LGTM!The addition of deterministic seed
b"magic_schedule_commit"ensures reproducible test behavior across runs.
110-164: LGTM!The
commit_and_undelegate_order_book_accounthelper follows the established pattern of other commit helpers in this file, properly constructing the update and schedule-commit-diff instructions sequence.
244-312: Excellent reproducibility design for randomized testing.The test demonstrates best practices for randomized testing:
- Prints the RNG seed for reproducibility
- Includes the seed in assertion failure messages
- Uses seeded RNG (StdRng) for deterministic behavior given a seed
This allows failures to be reproduced by rerunning with the printed seed value.
One optional enhancement: consider adding a way to override the seed via environment variable for easier failure reproduction:
let rng_seed = std::env::var("TEST_RNG_SEED") .ok() .and_then(|s| s.parse::<u64>().ok()) .unwrap_or_else(|| OsRng.next_u64());test-integration/programs/schedulecommit/src/lib.rs (1)
561-571: Use commit_diff for undelegate path; this looks correct.The diff-based commit is invoked when
undelegateis true; good alignment with the new optimization.Please confirm tests cover both diff and full-commit paths (with/without
undelegate).test-integration/programs/schedulecommit/src/order_book.rs (1)
101-116: Bounds/capacity logic is good; but relies on header being valid.Once header init is fixed in
process_init_order_book, these helpers are fine for basic growth semantics.Ensure tests cover:
- Non-zero existing asks/bids followed by additional inserts (to exercise prefix/suffix behavior).
- Capacity exhaustion returning
None.Also applies to: 118-138, 163-184
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
260-267: Seed semantics are correct and consistently applied across the codebase.The verification shows that
delegate_account_cpi_instruction()explicitly branches on two supported canonical seeds:
b"magic_schedule_commit"→ScheduleCommitInstruction::DelegateCpib"order_book"→ScheduleCommitInstruction::DelegateOrderBookAll test utilities and callers supply only these supported seeds. The
delegate_committees()function at lines 260-267 correctly passes&self.user_seed, and all constructors receive only canonical seeds from test callers. PDA derivation and instruction creation use consistent seed semantics.
9c44347 to
693af7f
Compare
There was a problem hiding this comment.
Actionable comments posted: 9
♻️ Duplicate comments (22)
magicblock-rpc-client/src/lib.rs (1)
430-430: Redundant error prefix persists in log message.The
error!macro already includes ERROR level in its output. The explicit"> ERROR:"prefix creates redundancy and reduces log readability.Apply this diff to remove the redundant prefix:
- error!("> ERROR: {:?}", err); + error!("{:?}", err);Or add context instead:
- error!("> ERROR: {:?}", err); + error!("Transaction processed status failed: {:?}", err);test-integration/test-tools/src/scheduled_commits.rs (2)
198-210: Verbose debug output concern still applies.The past review comment regarding verbose debug output from
println!with{:#?}formatting remains applicable to these new debug statements. Consider making the debug output conditional or using a more compact format.
233-235: Unnecessary clone() on Copy type.The past review comment regarding the redundant
.clone()call onSignature(which implementsCopy) remains applicable. Use*siginstead ofsig.clone().test-integration/test-tools/src/integration_test_context.rs (1)
157-158: Format the panic message withlabel.The panic still prints the literal
rpc_client for [{}] does not exist, so the label never appears when this trips. Please injectlabelinto the message.- let rpc_client = - rpc_client.expect("rpc_client for [{}] does not exist"); + let rpc_client = rpc_client.unwrap_or_else(|| { + panic!("rpc_client for [{}] does not exist", label) + });test-integration/schedulecommit/client/src/verify.rs (1)
16-23: Code duplication: consider the generic implementation suggested in the previous review.This function duplicates
fetch_and_verify_commit_result_from_logsexcept for the type parameter. A generic implementation withT: borsh::BorshDeserializewould eliminate this duplication.test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
115-118: PDA derivation must match program-side seeds.The PDA is derived using an arbitrary
user_seed, which may not match the on-chain program's expected seeds (e.g.,[b"order_book", book_manager]or[b"magic_schedule_commit", player]). This mismatch will cause transaction failures.
170-203: Validate user_seed explicitly to prevent silent misconfiguration.The implicit
elsebranch will execute for anyuser_seedthat isn'tb"magic_schedule_commit", including invalid values. Add explicit validation to fail fast with a clear error when an unsupported seed is provided.test-integration/programs/schedulecommit/src/api.rs (1)
106-109: Derive delegated PDA with canonical seeds to match on-chain expectations.The PDA is derived using an arbitrary
user_seed, but the on-chain program expects fixed seeds like[b"magic_schedule_commit", player]or[b"order_book", book_manager]. This mismatch will cause thedelegated_accountto not match program-side expectations.Cargo.toml (1)
112-112: CI/CD will fail: local path dependency not available.The path
../delegation-programdoes not exist in the repository or CI environments, causing all builds to fail. Either:
- Revert to a git-based dependency (consistent with the learning about using git branch references)
- Make
delegation-programa workspace member at the correct path- Update CI workflows to checkout the dependency
Verify the intended dependency resolution strategy:
#!/bin/bash # Check if the delegation-program path exists if [ -d "../delegation-program" ]; then echo "✓ Path exists locally" ls -la ../delegation-program/ else echo "✗ Path ../delegation-program does not exist" fi # Check for any git submodule configuration echo "" echo "=== Git submodules ===" git submodule status 2>/dev/null || echo "No submodules configured" # Check recent commits for this dependency change echo "" echo "=== Recent changes to delegation-program dependency ===" git log -n 5 --oneline --all -- Cargo.toml | head -10test-integration/Cargo.toml (1)
40-40: Critical: Local path dependencies will break CI builds.This issue has already been flagged in previous review comments. The local paths
../../ephemeral-rollups-sdk/rust/sdkand../../delegation-programdo not exist in the CI environment and will cause build failures.Also applies to: 60-60
test-integration/programs/schedulecommit/src/lib.rs (4)
302-309: Zero the order-book header immediately after allocation.
OrderBook::newreadsbids_len/asks_lenstraight from account data. Leaving those bytes uninitialized means random counts, which makes the next borrow calculate bogus slices and can walk past the buffer. Please clear the header bytes right after allocation (e.g. borrow data, zero the firstsize_of::<OrderBookHeader>()bytes).Apply this diff:
allocate_account_and_assign_owner(AllocateAndAssignAccountArgs { payer_info: payer, account_info: order_book, owner: &crate::ID, signer_seeds: &[b"order_book", book_manager.key.as_ref(), &[bump]], size: 10 * 1024, })?; + { + let mut data = order_book.try_borrow_mut_data()?; + let header_len = core::mem::size_of::<OrderBookHeader>(); + if data.len() < header_len { + return Err(ProgramError::AccountDataTooSmall); + } + for byte in &mut data[..header_len] { + *byte = 0; + } + } + Ok(())
329-334: Fix the PDA assertion message.The diagnostic still prints
payer.key, so a failing check points at the wrong seed. Swap it forbook_manager.keyas previously requested.Apply this diff:
assert_keys_equal(order_book.key, &pda, || { format!( "PDA for the account ('{}') and for book_manager ('{}') is incorrect", - order_book.key, payer.key + order_book.key, book_manager.key ) })?;
398-403: Update the log label.This path is mutating an existing order book, not initializing one. Please change the
msg!to say “Update order book” (or equivalent) so logs stay accurate.
424-451: Use the right error kind and require the payer to sign.When the accounts slice is the wrong length you must emit
ProgramError::NotEnoughAccountKeys;MissingRequiredSignatureis misleading. More importantly, we still never verifypayer.is_signer, so the CPI can run with an unsigned funder. Addassert_is_signer(payer, "payer")?before the CPI.Apply this diff:
let [payer, order_book_account, magic_context, magic_program] = accounts else { - return Err(ProgramError::MissingRequiredSignature); + return Err(ProgramError::NotEnoughAccountKeys); }; + assert_is_signer(payer, "payer")?; + commit_diff_and_undelegate_accounts( payer, vec![order_book_account], magic_context, magic_program,test-integration/programs/schedulecommit/src/order_book.rs (3)
45-55:deserializestill aliases immutable data mutably (UB).
slice::from_raw_parts_mutonbook_bytesforges a&mut [u8]from shared data, violating Rust’s aliasing rules and instantly triggering undefined behaviour. Please replace this with a safe path—e.g. copy into an owned buffer or implement a parser that reads header/levels straight from the immutable slice.
85-93:OrderBook::newassumes alignment that account data does not guarantee.Casting
header_bytes.as_ptr()to*mut OrderBookHeader(and the level pointer to*mut OrderLevel) requires 4/8‑byte alignment, but Solana account data is byte-aligned. The moment you dereference those pointers you trigger UB. Rework this to treat the buffer as raw bytes and read/write fields withfrom_le_bytes/to_le_bytesinstead of typed references.
140-178: Typed slices over account data remain unsafe.
slice::from_raw_parts(_ as *mut OrderLevel, ...)for bids/asks/buffer helpers creates slices ofOrderLevelout of unaligned memory. That’s the same UB called out earlier. Please keep the backing store as[u8], then decode/encode eachOrderLevelby copying 16 bytes into a local array and usingu64::from_le_bytes/u64::to_le_bytes.magicblock-magic-program-api/src/instruction.rs (1)
111-111: Add documentation for ScheduleCommitDiffAndUndelegate.This issue was already identified in a previous review. The variant lacks documentation while all sibling variants include doc comments describing the instruction purpose and account references.
magicblock-committor-service/src/tasks/args_task.rs (3)
75-103: Stop hard-coding the RPC endpoint in CommitDiff.
ChainConfig::local(ComputeBudgetConfig::new(1_000_000))forces every CommitDiff task to dialhttp://localhost:7799with Processed commitment and re-create an RPC client each timeinstruction()is called. In production that URI does not exist, so we immediately fall back tocommit_stateand never ship a diff; plus every call repeats the network fetch we already warned about. Inject the realChainConfig/RpcClientfrom the service (or precompute/cache the diff during task construction) soinstruction()stays pure and uses the configured endpoint. Prior feedback on this remains unresolved.
115-116: Do not log raw diff payloads.Dumping the entire diff at warn level leaks account data and explodes log volume. Log only bounded metadata (e.g., commit_id, pubkey, diff length) instead.
- log::warn!("DIFF computed: {:?}", args.diff); + log::debug!( + "commit_diff computed: commit_id={} pubkey={} len={}", + value.commit_id, + value.committed_account.pubkey, + args.diff.len() + );
171-173: Remove the CommitDiff panic in optimize().
optimize()is part of the normal pipeline; panicking here will abort the worker whenever a CommitDiff task flows through. ReturnErr(self)(mirroring the other variants) so the caller can fall back cleanly.- ArgsTaskType::CommitDiff(_) => { - panic!("ArgsTaskType::CommitDiff not handled") - } + ArgsTaskType::CommitDiff(_) => Err(self),programs/magicblock/src/magicblock_processor.rs (1)
38-38: Avoid logging entire MagicBlockInstruction payloads.
ic_msg!(..., "{:?}", instruction)dumps the full enum—including the diff bytes you just added—on every invocation. That inflates CU cost and spams logs, an issue we already called out earlier. Drop the log or gate it behind a debug-only feature flag so mainnet builds don’t emit the payload.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (28)
Cargo.toml(1 hunks)magicblock-accounts/src/scheduled_commits_processor.rs(3 hunks)magicblock-committor-service/src/tasks/args_task.rs(6 hunks)magicblock-committor-service/src/tasks/mod.rs(1 hunks)magicblock-committor-service/src/tasks/task_builder.rs(3 hunks)magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs(1 hunks)magicblock-magic-program-api/src/instruction.rs(1 hunks)magicblock-rpc-client/src/lib.rs(1 hunks)programs/magicblock/src/magic_scheduled_base_intent.rs(7 hunks)programs/magicblock/src/magicblock_processor.rs(4 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(2 hunks)programs/magicblock/src/schedule_transactions/process_scheduled_commit_sent.rs(5 hunks)test-integration/Cargo.toml(2 hunks)test-integration/programs/schedulecommit-security/src/lib.rs(2 hunks)test-integration/programs/schedulecommit/src/api.rs(5 hunks)test-integration/programs/schedulecommit/src/lib.rs(9 hunks)test-integration/programs/schedulecommit/src/order_book.rs(1 hunks)test-integration/programs/schedulecommit/src/utils/mod.rs(3 hunks)test-integration/schedulecommit/client/src/schedule_commit_context.rs(6 hunks)test-integration/schedulecommit/client/src/verify.rs(2 hunks)test-integration/schedulecommit/test-scenarios/Cargo.toml(1 hunks)test-integration/schedulecommit/test-scenarios/tests/01_commits.rs(2 hunks)test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs(4 hunks)test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs(1 hunks)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs(1 hunks)test-integration/test-ledger-restore/tests/08_commit_update.rs(2 hunks)test-integration/test-tools/src/integration_test_context.rs(2 hunks)test-integration/test-tools/src/scheduled_commits.rs(3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
test-integration/test-tools/src/integration_test_context.rstest-integration/programs/schedulecommit/src/utils/mod.rstest-integration/test-ledger-restore/tests/08_commit_update.rstest-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/utils/mod.rsmagicblock-committor-service/src/tasks/args_task.rstest-integration/programs/schedulecommit/src/api.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.
Applied to files:
test-integration/Cargo.tomlCargo.toml
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (15)
test-integration/programs/schedulecommit-security/src/lib.rs (1)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
create_schedule_commit_ix(41-66)
magicblock-committor-service/src/tasks/task_builder.rs (2)
magicblock-committor-service/src/tasks/args_task.rs (1)
new(49-54)magicblock-accounts/src/scheduled_commits_processor.rs (2)
new(66-90)new(420-436)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(153-156)test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
base_intent(544-549)
test-integration/schedulecommit/client/src/verify.rs (2)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
ctx(90-91)test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
ctx(145-146)
programs/magicblock/src/magicblock_processor.rs (3)
magicblock-committor-service/src/tasks/args_task.rs (1)
instruction(58-160)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
process_schedule_commit(34-259)magicblock-committor-program/src/state/changeset.rs (1)
request_undelegation(230-232)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
get_context_with_delegated_committees(16-35)
magicblock-committor-service/src/tasks/args_task.rs (3)
magicblock-committor-service/src/tasks/mod.rs (2)
instruction(66-66)instruction(249-255)magicblock-committor-service/src/tasks/buffer_task.rs (1)
instruction(65-86)magicblock-committor-service/src/config.rs (1)
local(29-35)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
ctx(90-91)test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
ctx(145-146)test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
try_new(72-74)ncommittees(102-121)try_new_random_keys(66-71)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(153-156)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
test-integration/programs/schedulecommit/src/api.rs (3)
init_order_book_instruction(36-54)init_payer_escrow(77-98)init_account_instruction(16-34)test-integration/test-tools/src/integration_test_context.rs (1)
try_new(113-115)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
test-integration/test-ledger-restore/src/lib.rs (1)
setup_validator_with_local_remote(97-119)
test-integration/programs/schedulecommit/src/api.rs (2)
test-integration/programs/schedulecommit/src/order_book.rs (1)
new(85-94)test-integration/programs/flexi-counter/src/state.rs (1)
pda(32-35)
test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (4)
test-integration/test-runner/bin/run_tests.rs (1)
run_test(777-796)test-integration/programs/schedulecommit/src/api.rs (1)
schedule_commit_with_payer_cpi_instruction(214-232)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (4)
assert_two_committees_synchronized_count(139-169)assert_two_committees_were_committed(68-91)get_context_with_delegated_committees(16-35)assert_feepayer_was_committed(94-113)test-integration/schedulecommit/client/src/verify.rs (1)
fetch_and_verify_commit_result_from_logs(7-14)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
assert_is_signer(30-44)assert_keys_equal(16-28)allocate_account_and_assign_owner(58-106)test-integration/programs/schedulecommit/src/order_book.rs (1)
new(85-94)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4)
test-integration/programs/schedulecommit/src/api.rs (3)
schedule_commit_and_undelegate_cpi_with_mod_after_instruction(287-311)schedule_commit_diff_instruction_for_order_book(193-212)update_order_book_instruction(175-191)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
get_context_with_delegated_committees(16-35)assert_one_committee_was_committed(41-65)assert_one_committee_account_was_undelegated_on_chain(190-196)test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
committees(205-209)ephem_blockhash(322-324)ephem_client(318-320)test-integration/schedulecommit/client/src/verify.rs (1)
fetch_and_verify_order_book_commit_result_from_logs(16-23)
⏰ 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). (3)
- GitHub Check: run_make_ci_test
- GitHub Check: run_make_ci_lint
- GitHub Check: run_make_ci_test
🔇 Additional comments (20)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
49-55: LGTM: Type alignment with Solana API.Changing
sizefromusizetou64correctly aligns with Solana'ssystem_instruction::allocatesignature, which expectsspace: u64.
75-79: LGTM: Helpful debug logging.The added logging for lamport requirements and payer balance aids in troubleshooting account allocation issues during testing.
90-90: Critical fix: Correct system_instruction::allocate signature.The updated call now correctly provides both required arguments (
pubkeyandspace) tosystem_instruction::allocate. The previous implementation appears to have been missing the pubkey argument, which would not match the function signature:pub fn allocate(pubkey: &Pubkey, space: u64) -> Instruction.test-integration/test-tools/src/scheduled_commits.rs (1)
182-213: Variable renaming improves clarity.The renaming of log variables to
ephem_logs_l1andephem_logs_l2clearly distinguishes the two-level log fetching process, and the updated error context at line 206 now correctly references the first-level logs. These changes enhance code readability.test-integration/programs/schedulecommit-security/src/lib.rs (2)
2-2: LGTM!The
CommitPolicyimport is correctly added to support the new argument at line 149.
143-150: Ignore this review comment. The original comment incorrectly assumes thatschedule_commit_cpi_instructionandcreate_schedule_commit_ixshould be consistent, but they are two distinct functions from different crates with different purposes:
schedule_commit_cpi_instruction(fromprogram_schedulecommit::api) is a local CPI helper that does not accept aCommitPolicyparametercreate_schedule_commit_ix(fromephemeral_rollups_sdk::ephem) is an SDK function that acceptsCommitPolicyas a parameterThe two functions have intentionally different signatures. There is no test inconsistency to address.
Likely an incorrect or invalid review comment.
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
55-61: No issues found—code is correct as written.The
TempDirreturned bysetup_validator_with_local_remoteis created specifically for temporary config storage during validator initialization (written instart_magicblock_validator_with_config_structat line 225:fs::write(&config_path, config_toml)). After the validator process is spawned, this directory is no longer needed and is safely dropped. The actual ledger directory is managed separately by the main_tmpdirat line 42 of the test, which persists for the entire test duration. The binding to_tmpdirwith an underscore prefix correctly signals that this return value is intentionally unused beyond validator initialization.test-integration/programs/schedulecommit/src/api.rs (3)
36-54: LGTM!The
init_order_book_instructionfollows the standard instruction builder pattern with appropriate account metadata.
56-75: LGTM!The
grow_order_book_instructioncorrectly constructs the instruction with theadditional_spaceparameter.
175-212: LGTM!Both
update_order_book_instructionandschedule_commit_diff_instruction_for_order_bookfollow correct instruction builder patterns with appropriate account metadata.test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
30-31: LGTM! Deterministic seed ensures reproducible test contexts.The hard-coded seed
b"magic_schedule_commit"provides deterministic PDA derivation and context initialization, which improves test reliability and debugging.Also applies to: 84-85
test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (2)
82-135: LGTM! Fee payer escrow test properly verifies expected behavior.The test correctly verifies that with proper escrow setup, the fee payer commit succeeds and all expected assertions pass.
34-41: Fix struct field destructuring:payer_ephemfield andephem_blockhashretrieval.The code attempts to destructure non-existent struct fields:
- Line 35:
payerfield doesn't exist inScheduleCommitTestContextFields— should bepayer_ephem: payer- Line 39:
ephem_blockhashis not a struct field — must be fetched separately viaephem_client.get_latest_blockhash().unwrap()- Lines 58, 112: Remove dereference (
*) fromephem_blockhashonce correctedSee
01_commits.rs(lines 34, 54) for the correct pattern.Also applies to: 88-95, 112
⛔ Skipped due to learnings
Learnt from: bmuddha Repo: magicblock-labs/magicblock-validator PR: 578 File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27 Timestamp: 2025-10-21T14:00:54.642Z Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579programs/magicblock/src/magic_scheduled_base_intent.rs (3)
104-106: LGTM!The
is_commit_diff()method correctly delegates to the base intent, following the same pattern as the existingis_undelegate()method.
155-163: LGTM!The
is_commit_diff()method correctly handles allMagicBaseIntentvariants, properly delegating to the underlyingCommitTypefor bothCommitandCommitAndUndelegatecases.
458-458: LGTM!The accessor methods correctly handle the new
StandaloneDiffvariant, treating it identically toStandalonesince both containVec<CommittedAccount>.Also applies to: 468-468, 480-482
magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (2)
29-33: LGTM!The match correctly handles both
CommitandCommitDiffvariants identically, as both containCommitTaskand should be persisted the same way.
59-59: ****The review comment is incorrect.
BufferTaskTypeintentionally has only a singleCommitvariant because it represents buffer-based commit operations.CommitDiffis a separate task variant that belongs exclusively toArgsTaskTypeand is handled through a different code path.Evidence:
- ArgsTaskType includes CommitDiff(CommitTask), but BufferTaskType does not
- ArgsTaskType::CommitDiff explicitly panics with "ArgsTaskType::CommitDiff not handled" when attempting conversion, indicating CommitDiff is intentionally not converted to BufferTask
- The refutable pattern at line 59 is safe because BufferTaskType can only ever contain a single variant
No code changes are needed; the refutable pattern is correct as implemented.
Likely an incorrect or invalid review comment.
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
31-31: LGTM!The
request_difffield addition cleanly extends the options structure to control diff-based commit scheduling.
231-238: LGTM!The
commit_actionis correctly used in both the undelegation and non-undelegation paths, enabling diff-based commits for both scenarios while preserving existing semantics.
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs
Outdated
Show resolved
Hide resolved
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
Outdated
Show resolved
Hide resolved
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
Show resolved
Hide resolved
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
Outdated
Show resolved
Hide resolved
693af7f to
99f2e8f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (8)
test-integration/Cargo.toml (1)
40-40:⚠️ Path dependency concerns from prior review remain unresolved.The migration from git-based to local path dependencies for
ephemeral-rollups-sdkandmagicblock-delegation-programstill poses the same critical CI/CD risks flagged in the previous review: these paths do not exist in the repository, CI workflows do not clone them, and builds will fail in CI/CD and for contributors without manual setup.The prior review's recommendations still apply:
- Update CI to clone both external repositories, OR
- Switch back to git-based references, OR
- Add clear setup documentation with exact clone commands and relative paths
Also applies to: 60-60
magicblock-committor-service/src/tasks/args_task.rs (2)
228-234:reset_commit_idmust handleCommitDiffvariant.The current implementation only updates the
commit_idforCommittasks and silently returns forCommitDiff. When aCommitDifftask is recycled, the stalecommit_idwill remain, causing desynced submissions.Apply this fix to handle both variants:
fn reset_commit_id(&mut self, commit_id: u64) { - // TODO (snawaz): handle CommitDiff as well? what is it about? - let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { - return; - }; - - commit_task.commit_id = commit_id; + match &mut self.task_type { + ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + _ => { + // Only Commit and CommitDiff tasks have commit_id + } + } }
74-122: Network I/O insideinstruction()remains a major concern.The
instruction()method performs RPC calls and diff computation on every invocation, which is expensive and risky:
instruction()may be called multiple times (e.g., viainvolved_accounts), multiplying RPC calls- TOCTOU: base-chain account can change between diff calculation and transaction submission
- Coupling to network hinders testing and determinism
Per previous discussion, this is acknowledged as temporary and will be addressed in subsequent PRs. Consider tracking this technical debt.
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
224-228: Consider enhancing observability as previously suggested.The conditional logic correctly selects the commit type based on
request_diff. However, a past review comment suggests improving the log messages to include the number of committed accounts and the flag value for better operational visibility.test-integration/programs/schedulecommit/src/order_book.rs (2)
99-119: Unaligned typed reference toOrderBookHeaderremains a critical issue.Line 114 creates a typed reference
&mut OrderBookHeadervia raw pointer cast. While alignment is asserted at runtime (lines 102-110), Solana account data does not guarantee alignment for arbitrary types. This is undefined behavior if the account data is not aligned toalign_of::<OrderBookHeader>().The assertion will catch misalignment at runtime, but the proper fix is to avoid typed references entirely. Consider reading/writing the header fields as raw bytes using little-endian encoding.
165-178: Typed slices over potentially unaligned memory (OrderLevel).Lines 166 and 173-174 use
slice::from_raw_partsto create typed slices ofOrderLevel(which containsu64fields requiring 8-byte alignment). Account data alignment is not guaranteed by Solana, leading to undefined behavior on read.Per previous review: store levels as raw bytes and provide accessors that read/write fields via
u64::from_le_bytes/to_le_bytes, or use a packed representation without taking references to fields.test-integration/programs/schedulecommit/src/lib.rs (2)
280-311: Critical: OrderBook header is never initialized.After
allocate_account_and_assign_ownerreturns (line 308), the account data contains uninitialized memory. Subsequent calls toOrderBook::newwill read uninitializedbids_lenandasks_lenvalues, causing undefined behavior.Apply this fix immediately after allocation:
allocate_account_and_assign_owner(AllocateAndAssignAccountArgs { payer_info: payer, account_info: order_book, owner: &crate::ID, signer_seeds: &[b"order_book", book_manager.key.as_ref(), &[bump]], size: 10 * 1024, })?; + // Initialize header to zero + let mut data = order_book.try_borrow_mut_data()?; + let header_size = core::mem::size_of::<OrderBookHeader>(); + for b in &mut data[..header_size] { + *b = 0; + } Ok(())
329-334: Incorrect identifier in PDA assertion error message.Line 332 incorrectly references
payer.keyin the error message, which should bebook_manager.keyto accurately reflect the PDA derivation.Apply this fix:
assert_keys_equal(order_book.key, &pda, || { format!( "PDA for the account ('{}') and for book_manager ('{}') is incorrect", - order_book.key, payer.key + order_book.key, book_manager.key ) })?;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
magicblock-committor-service/src/tasks/args_task.rs(6 hunks)programs/magicblock/src/magic_scheduled_base_intent.rs(7 hunks)programs/magicblock/src/magicblock_processor.rs(2 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(2 hunks)test-integration/Cargo.toml(4 hunks)test-integration/programs/schedulecommit/Cargo.toml(1 hunks)test-integration/programs/schedulecommit/src/lib.rs(9 hunks)test-integration/programs/schedulecommit/src/order_book.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/args_task.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (5)
magicblock-committor-service/src/tasks/args_task.rs (3)
magicblock-committor-service/src/tasks/mod.rs (2)
instruction(66-66)instruction(249-255)magicblock-committor-service/src/tasks/buffer_task.rs (1)
instruction(65-86)magicblock-committor-service/src/config.rs (1)
local(29-35)
programs/magicblock/src/magicblock_processor.rs (1)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
process_schedule_commit(34-258)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(153-156)test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
base_intent(544-549)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(153-156)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
assert_is_signer(30-44)assert_keys_equal(16-28)allocate_account_and_assign_owner(58-106)test-integration/programs/schedulecommit/src/order_book.rs (1)
new(99-119)
🔇 Additional comments (11)
test-integration/Cargo.toml (1)
72-72: Now let me check the codebase for actual usage of these dependencies to confirm they are necessary:Based on my verification, I can now generate the rewritten review comment:
Both dependencies are compatible with Solana 2.2 and appropriate for this PR.
rkyv 0.7.45 supports no_std and no_alloc configurations, making it suitable for Solana on-chain programs. It supports no-std builds for targets without a standard library and no-alloc builds for targets where allocations cannot be made. The Solana VM guarantees that account data is byte-aligned to a multiple of 8, which enables rkyv's zero-copy deserialization to function safely on account data. static_assertions 1.1.0 is a stable, widely-adopted crate (225,914,390 downloads all time) providing compile-time assertion macros useful for validating account structure layouts and sizes—a common pattern in Solana programs.
No further verification needed.
test-integration/programs/schedulecommit/Cargo.toml (1)
11-12: LGTM! Dependencies properly support order book implementation.The additions of
rkyvandstatic_assertionsare well-utilized inorder_book.rsfor alignment guarantees and compile-time size/alignment checks.programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
31-31: LGTM! New field enables diff-based commit path.The
request_diffflag properly controls whether to useCommitType::StandaloneDifforCommitType::Standalone, enabling the optimization for large accounts with small changes.programs/magicblock/src/magicblock_processor.rs (2)
44-59: LGTM! Existing instructions properly default to non-diff path.Both
ScheduleCommitandScheduleCommitAndUndelegatecorrectly setrequest_diff: falseto maintain existing behavior.
85-92: LGTM! New instruction variant correctly enables diff-based commit with undelegation.The
ScheduleCommitDiffAndUndelegateinstruction properly sets bothrequest_undelegation: trueandrequest_diff: true, mirroringScheduleCommitAndUndelegatebehavior while enabling the diff optimization.test-integration/programs/schedulecommit/src/order_book.rs (1)
48-75: LGTM! Mutable aliasing UB resolved with aligned copy.The implementation now safely copies the input buffer into
rkyv::AlignedVecbefore creating mutable references, avoiding the undefined behavior from the previous approach. The comment clearly explains the rationale.magicblock-committor-service/src/tasks/args_task.rs (2)
171-172: LGTM! CommitDiff correctly returnsErr(self)in optimize().Returning
Err(self)forCommitDiffis correct since the diff is already optimized by design—it sends only the differences rather than full account data. Converting toBufferTaskwould be counterproductive.Per previous discussion, this is the correct semantic since CommitDiff is already using the most efficient data transfer strategy.
196-203: LGTM! Compute units appropriately set for CommitDiff.The 65,000 compute units for
CommitDiff(vs 70,000 forCommit) reflects the reduced work from transmitting only the diff. This aligns with the test observation showing lower CU usage.Based on learnings: these are compute units per task, and transactions may comprise multiple tasks.
test-integration/programs/schedulecommit/src/lib.rs (3)
203-203: LGTM! Type change tou64is appropriate.Changing
MainAccount::SIZEfromusizetou64aligns with thesizeparameter type inallocate_account_and_assign_owner(line 255) and Solana's account size conventions.
398-414: LGTM! Log message and signer check are correct.Line 402 now uses the accurate log message "Update orderbook", and line 407 properly validates that the payer is a signer before allowing the update.
419-439: LGTM! Handler correctly uses diff-based commit with undelegation.The implementation properly:
- Returns
NotEnoughAccountKeyswhen accounts are missing (line 426)- Validates payer is a signer (line 429)
- Invokes
commit_diff_and_undelegate_accountsfor the optimized diff path (line 431)
99f2e8f to
7eaaa13
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
magicblock-committor-service/src/tasks/args_task.rs (1)
228-235: Critical:reset_commit_idsilently ignores CommitDiff tasks.When a
CommitDifftask is recycled, the current code silently returns without updating itscommit_id(line 230-232), leaving stale IDs that will cause:
- Desynchronization with actual commit state
- Failed submissions with wrong nonce
- Data integrity issues
A past review correctly identified this issue.
Apply this fix to handle both
CommitandCommitDiff:fn reset_commit_id(&mut self, commit_id: u64) { - // TODO (snawaz): handle CommitDiff as well? what is it about? - let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { - return; - }; - - commit_task.commit_id = commit_id; + match &mut self.task_type { + ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + _ => { + // Other task types don't have commit_id + } + } }
♻️ Duplicate comments (7)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
389-446: CRITICAL: try_from_args cannot construct StandaloneDiff.The
try_from_argsmethod only handlesCommitTypeArgs::StandaloneandCommitTypeArgs::WithBaseActions, but does not handleCommitTypeArgs::StandaloneDiff. This means:
- Code paths using
try_from_args(e.g.,process_schedule_base_intent) cannot constructCommitType::StandaloneDiff- Only
process_schedule_commitcan create it programmatically- Any attempt to deserialize
CommitTypeArgs::StandaloneDifffrom instruction data will failThis creates a critical inconsistency where the
StandaloneDiffvariant cannot be fully utilized across all code paths.The method needs a new match arm similar to:
pub fn try_from_args( args: CommitTypeArgs, context: &ConstructionContext<'_, '_>, ) -> Result<CommitType, InstructionError> { match args { CommitTypeArgs::Standalone(accounts) => { // ... existing code ... Ok(CommitType::Standalone(committed_accounts)) } + CommitTypeArgs::StandaloneDiff(accounts) => { + let committed_accounts_ref = Self::extract_commit_accounts( + &accounts, + context.transaction_context, + )?; + Self::validate_accounts(&committed_accounts_ref, context)?; + let committed_accounts = committed_accounts_ref + .into_iter() + .map(|el| { + let mut committed_account: CommittedAccount = el.into(); + committed_account.account.owner = context + .parent_program_id + .unwrap_or(committed_account.account.owner); + committed_account + }) + .collect(); + Ok(CommitType::StandaloneDiff(committed_accounts)) + } CommitTypeArgs::WithBaseActions { ... } => { // ... existing code ... } } }Based on past review comment.
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
224-228: Add observability logging for commit type selection.The conditional logic correctly selects the commit type, but lacks logging to indicate which path was taken. This makes debugging and auditing more difficult.
Based on past review comment, consider adding:
let commit_action = if opts.request_diff { + ic_msg!( + invoke_context, + "ScheduleCommit: using StandaloneDiff for {} accounts", + committed_accounts.len() + ); CommitType::StandaloneDiff(committed_accounts) } else { + ic_msg!( + invoke_context, + "ScheduleCommit: using Standalone for {} accounts", + committed_accounts.len() + ); CommitType::Standalone(committed_accounts) };magicblock-committor-service/src/tasks/args_task.rs (1)
74-122: Network I/O in instruction() confirmed as unresolved; improve fallback logging.The RPC-in-instruction issue is genuine and remains present despite the past review claiming it was addressed in commit 99f2e8f (which does not exist in the repository).
Confirmed concerns:
instruction() called multiple times per task: The method is invoked from
delivery_preparator.rs(line 377, mapped over cleanup_tasks),tasks/utils.rs(line 58, mapped over tasks), andtask_strategist.rs(line 217, in optimization loop). Each call triggers RPC I/O on the base-chain, multiplying network overhead and creating TOCTOU race conditions.ChainConfig hardcoded locally (line 76): ChainConfig is properly injected into the service/processor but ArgsTask hardcodes
ChainConfig::local()instead of receiving injected config. This remains unresolved.Fallback log incomplete (line 90): The message contains a typo ("commmit_id" with 3 m's) and is missing the
pubkeycontext for debugging. Improve clarity:- log::warn!("Fallback to commit_state and send full-bytes, as rpc failed to fetch the delegated-account from base chain, commmit_id: {} , error: {}", value.commit_id, e); + log::warn!( + "Fallback to commit_state for account {}: RPC fetch failed, commit_id={} - {}", + value.committed_account.pubkey, + value.commit_id, + e + );The architectural concerns about performing RPC I/O during instruction building should be addressed, and the config injection pattern needs to be established.
test-integration/programs/schedulecommit/src/lib.rs (3)
280-311: Header remains uninitialized after allocation—subsequent reads are undefined.After
allocate_account_and_assign_owner, the header fields (bids_len,asks_len) are still uninitialized. Any call toOrderBook::newon this account will read garbage.Apply this fix to zero the header immediately after allocation:
allocate_account_and_assign_owner(AllocateAndAssignAccountArgs { payer_info: payer, account_info: order_book, owner: &crate::ID, signer_seeds: &[b"order_book", book_manager.key.as_ref(), &[bump]], size: 10 * 1024, })?; + // Initialize header to zero + let mut data = order_book.try_borrow_mut_data()?; + data[..core::mem::size_of::<OrderBookHeader>()].fill(0); Ok(())
329-334: Error message references wrong key.The PDA assertion message incorrectly shows
payer.keyinstead ofbook_manager.key, making debugging harder.assert_keys_equal(order_book.key, &pda, || { format!( "PDA for the account ('{}') and for book_manager ('{}') is incorrect", - order_book.key, payer.key + order_book.key, book_manager.key ) })?;
402-402: Inconsistent log message casing.Message says "Update orderbook" but other logs use "OrderBook" with capital letters and space for consistency.
- msg!("Update orderbook"); + msg!("Update order book");test-integration/Cargo.toml (1)
40-40: Local path dependencies will break CI/CD builds.These local path dependencies point to repositories outside the current codebase (
../../ephemeral-rollups-sdkand../../delegation-program) that are not cloned by the CI workflow. This will cause build failures for all contributors and in continuous integration.Choose one of the following solutions:
- Revert to git-based dependencies (recommended for now):
-ephemeral-rollups-sdk = { path = "../../ephemeral-rollups-sdk/rust/sdk"} +ephemeral-rollups-sdk = { git = "https://github.com/magicblock-labs/ephemeral-rollups-sdk.git", rev = "..." }
Update CI to clone required repositories before build steps in
.github/workflows/ci-test-integration.ymlDocument the local setup in README with explicit clone instructions if local paths are intended for development only
Based on learnings: This appears to be a transition to local development setup but lacks the corresponding CI infrastructure updates.
Also applies to: 60-60
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
magicblock-committor-service/src/tasks/args_task.rs(6 hunks)programs/magicblock/src/magic_scheduled_base_intent.rs(7 hunks)programs/magicblock/src/magicblock_processor.rs(2 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(2 hunks)test-integration/Cargo.toml(4 hunks)test-integration/programs/schedulecommit/Cargo.toml(1 hunks)test-integration/programs/schedulecommit/src/lib.rs(9 hunks)test-integration/programs/schedulecommit/src/order_book.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/args_task.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (5)
magicblock-committor-service/src/tasks/args_task.rs (4)
magicblock-committor-service/src/tasks/mod.rs (2)
instruction(66-66)instruction(249-255)magicblock-committor-service/src/tasks/buffer_task.rs (2)
instruction(65-86)new(37-45)magicblock-committor-service/src/config.rs (1)
local(29-35)magicblock-accounts/src/scheduled_commits_processor.rs (2)
new(66-90)new(420-436)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(153-156)
programs/magicblock/src/magicblock_processor.rs (1)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
process_schedule_commit(34-258)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
magicblock-committor-service/src/tasks/task_builder.rs (1)
committed_accounts(153-156)test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
base_intent(544-549)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
assert_is_signer(30-44)assert_keys_equal(16-28)allocate_account_and_assign_owner(58-106)test-integration/programs/schedulecommit/src/order_book.rs (1)
new(105-125)
⏰ 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). (3)
- GitHub Check: run_make_ci_format
- GitHub Check: run_make_ci_test
- GitHub Check: run_make_ci_test
🔇 Additional comments (14)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
29-32: Field addition looks correct.The new
request_difffield is properly scoped aspub(crate)and theDefaulttrait will initialize it tofalse, maintaining backward compatibility.programs/magicblock/src/magicblock_processor.rs (2)
44-51: ScheduleCommit handler correctly configured.The handler properly sets
request_diff: falseto maintain the existing full-commit behavior for standard commits.
85-92: New instruction handler correctly implemented.The
ScheduleCommitDiffAndUndelegatehandler properly enables both undelegation and diff-based commits by setting both flags totrue. The implementation follows the established pattern from the other handlers.programs/magicblock/src/magic_scheduled_base_intent.rs (4)
104-106: Delegation method correctly implemented.The
is_commit_diff()method appropriately delegates to the underlyingbase_intent, following the established pattern for other query methods in this struct.
155-163: Commit diff detection logic is correct.The method correctly returns
falseforBaseActionsand properly delegates to the commit-related variants to determine if differential commits are enabled.
317-327: StandaloneDiff variant added correctly.The new variant follows the same structure as
Standalone, holdingVec<CommittedAccount>. Note that full account data is stored here; the actual diff computation likely occurs downstream during commit processing.
448-484: Accessor methods properly handle StandaloneDiff.All match expressions are now exhaustive and correctly handle the new
StandaloneDiffvariant. Theis_commit_diff()method correctly returnstrueonly forStandaloneDiff, and the accessor methods treat it consistently withStandalone.magicblock-committor-service/src/tasks/args_task.rs (4)
1-24: LGTM: Imports support the CommitDiff feature.All new imports are necessary for the RPC client setup, diff computation, and configuration.
30-30: LGTM: CommitDiff variant added.Reusing
CommitTaskfor theCommitDiffvariant is appropriate since they share the same data requirements.
171-172: LGTM: ReturningErr(self)for CommitDiff is correct.The past review discussion thoroughly analyzed this and concluded that
CommitDiffshould returnErr(self)(no optimization) because:
CommitDiffis already optimized by design—it transmits only the diff (e.g., 286 bytes) vs. full account data (10,240 bytes per your test)- Converting
CommitDifftoBufferTaskwould be counterproductive and defeat its purposeErr(self)correctly signals "no further optimization possible"Suggestion: The TODO on line 171 can be resolved and removed based on the past review's analysis.
199-199: LGTM: Compute units appropriately reduced for CommitDiff.The 65,000 compute unit allocation (5k less than
Commit's 70k) aligns with your test observations and reflects the reduced data processing for diff-based commits.test-integration/programs/schedulecommit/src/lib.rs (1)
419-439: LGTM—signer validation and error handling are now correct.The function now properly returns
NotEnoughAccountKeyswhen the accounts array doesn't match, and validates thatpayeris a signer before proceeding with the CPI call.test-integration/programs/schedulecommit/Cargo.toml (1)
11-12: LGTM—dependencies appropriately support zero-copy OrderBook.The
rkyvcrate providesAlignedVecfor safe buffer allocation, andstatic_assertionsenables compile-time layout verification. Both are correctly utilized inorder_book.rs.test-integration/Cargo.toml (1)
72-72: LGTM—workspace dependencies properly declared.The
rkyvandstatic_assertionscrates are correctly added at the workspace level, enabling their use across integration test crates for zero-copy structures and compile-time assertions.Also applies to: 91-91
7eaaa13 to
c05f313
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
magicblock-committor-service/src/tasks/mod.rs (1)
324-345: NullTaskInfoFetcher prevents CommitDiff testing; full implementation incomplete.The test uses
NullTaskInfoFetcherwhich returnsOk(None)forget_base_account, so the 1024-byte account test falls back toCommitStateand skips theCommitDiffbranch entirely. However, note thatCommitDiffsupport is currently incomplete:BufferTaskpanics when encountering aCommitDiffTask(seebuffer_task.rs:72), andargs_task.rs:141-144contains a TODO indicating thatCommitDiffcannot yet execute as aBufferTask. Adding a mock fetcher that returnsSome(account)would trigger this panic and break tests. Consider revisiting this test gap once theCommitDiffpath is fully implemented.
♻️ Duplicate comments (11)
test-integration/programs/schedulecommit/src/api.rs (5)
133-148: Brittle user_seed dispatch routing.The
elsebranch (line 140) routes all non-"magic_schedule_commit"seeds toDelegateOrderBook. Since this is a public API, unknown seeds silently succeed with potentially incorrect behavior.Consider either:
- Explicit match on known seeds (
b"magic_schedule_commit",b"order_book") with error/panic for others- Add a doc comment stating supported seeds and that others are treated as order-book by convention
🔎 Proposed fix (explicit matching)
Instruction::new_with_borsh( program_id, - &if user_seed == b"magic_schedule_commit" { + &match user_seed { + b"magic_schedule_commit" => { ScheduleCommitInstruction::DelegateCpi(DelegateCpiArgs { valid_until: i64::MAX, commit_frequency_ms: 1_000_000_000, player: player_or_book_manager, validator, }) - } else { + } + b"order_book" => { ScheduleCommitInstruction::DelegateOrderBook( DelegateOrderBookArgs { commit_frequency_ms: 1_000_000_000, book_manager: player_or_book_manager, validator, }, ) - }, + } + _ => panic!("Unsupported user_seed: only b\"magic_schedule_commit\" and b\"order_book\" are supported"), + }, account_metas, )
56-75: Signer mismatch between init and grow operations.
init_order_book_instructionrequiresbook_manageras a signer (line 44:true), butgrow_order_book_instructiondoes not (line 65:false). This allows any payer to grow someone else's order book without authorization.If
book_managershould authorize growth (consistent with init), change line 65 totrueand addassert_is_signervalidation in the handler. If permissive growth is intentional, document this explicitly.🔎 Proposed fix (if authorization required)
let account_metas = vec![ AccountMeta::new(payer, true), - AccountMeta::new_readonly(book_manager, false), + AccountMeta::new_readonly(book_manager, true), AccountMeta::new(order_book, false), AccountMeta::new_readonly(system_program::id(), false), ];
113-117: Remove debug print statements.These
println!statements appear to be temporary debugging code and should be removed before merging.🔎 Proposed fix
let delegate_accounts = DelegateAccounts::new(pda, program_id); - println!("delegate_accounts: {:#?}", delegate_accounts); - println!( - "config: {:#?}", - dlp::pda::program_config_from_program_id(&crate::ID) - ); - let delegate_metas = DelegateAccountMetas::from(delegate_accounts);
184-200: Missing book_manager authorization in update operation.Unlike
init_order_book_instructionandgrow_order_book_instruction, this function omits thebook_manageraccount entirely. Since order books are PDAs derived from[b"order_book", book_manager.key], anyone can currently update any order book.
202-221: Missing book_manager authorization in schedule commit operation.Similar to
update_order_book_instruction, this function omitsbook_managervalidation, allowing anyone to schedule commits for any order book.test-integration/test-committor-service/tests/utils/transactions.rs (2)
238-239: Fix the copy-pasted comment.The doc comment incorrectly refers to "counter" instead of "order book".
🔎 Proposed fix
-/// This needs to be run for each test that required a new counter to be delegated +/// This needs to be run for each test that requires a new order book to be delegated #[allow(dead_code)]
249-249: Fix the debug message referencing wrong context.The debug message still references "counter auth" but this function deals with order book accounts.
🔎 Proposed fix
- debug!("Airdropped to counter auth: {} SOL", 777 * LAMPORTS_PER_SOL); + debug!("Airdropped to payer: {} SOL", 777 * LAMPORTS_PER_SOL);magicblock-committor-service/src/tasks/args_task.rs (1)
206-212: reset_commit_id doesn't handle CommitDiff tasks.When a
CommitDifftask needs its commit_id reset (e.g., during retry), this method silently returns without updating. This was flagged in a past review.🔎 Proposed fix
fn reset_commit_id(&mut self, commit_id: u64) { - let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { - return; - }; - - commit_task.commit_id = commit_id; + match &mut self.task_type { + ArgsTaskType::Commit(task) => { + task.commit_id = commit_id; + } + ArgsTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + _ => {} + } }magicblock-committor-service/src/tasks/task_builder.rs (3)
60-60: Downgrade or remove debug logging before merge.
log::warn!("create_commit_task entered")fires on every commit task creation, which will flood production logs. This was flagged in past reviews.🔎 Proposed fix
- log::warn!("create_commit_task entered"); + log::trace!("create_commit_task: pubkey={}", account.pubkey);
83-87: Remove verbose debug logging that dumps full account data.Logging full
base_accountandaccount.accountwith{:#?}will flood logs and potentially leak sensitive account data. This was flagged in past reviews.🔎 Proposed fix
- log::warn!( - "create_commit_task: base_account: {:#?}, {:#?}", - base_account, - account.account - ); + log::debug!( + "create_commit_task: using CommitDiff, pubkey={}, base_len={}, new_len={}", + account.pubkey, base_account.data.len(), account.account.data.len() + );
95-95: Same issue: verbose debug logging.🔎 Proposed fix
- log::warn!("create_commit_task: {:#?}", account.account); + log::debug!("create_commit_task: using CommitState, pubkey={}", account.pubkey);
🧹 Nitpick comments (1)
test-integration/test-committor-service/tests/utils/instructions.rs (1)
68-68: Remove debug print statement.This
println!appears to be leftover debugging code. Consider removing it or converting tolog::debug!if the information is valuable for test diagnostics.🔎 Proposed fix
- println!("schedulecommit ID: {}", ID); + // If logging is needed: + // log::debug!("schedulecommit ID: {}", ID);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.locktest-integration/schedulecommit/elfs/dlp.sois excluded by!**/*.so
📒 Files selected for processing (11)
Cargo.tomlmagicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/Cargo.tomltest-integration/programs/schedulecommit/src/api.rstest-integration/test-committor-service/Cargo.tomltest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/utils/instructions.rstest-integration/test-committor-service/tests/utils/transactions.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- test-integration/test-committor-service/Cargo.toml
- Cargo.toml
🧰 Additional context used
🧠 Learnings (19)
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
magicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/test_ix_commit_local.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/args_task.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/Cargo.toml
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/args_task.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/programs/schedulecommit/src/api.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/programs/schedulecommit/src/api.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/test_ix_commit_local.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/Cargo.toml
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
magicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/task_builder.rs
📚 Learning: 2025-11-12T09:46:27.553Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: magicblock-task-scheduler/src/db.rs:26-0
Timestamp: 2025-11-12T09:46:27.553Z
Learning: In magicblock-task-scheduler, task parameter validation (including ensuring iterations > 0 and enforcing minimum execution intervals) is performed in the Magic program (on-chain) before ScheduleTaskRequest instances reach the scheduler service. The From<&ScheduleTaskRequest> conversion in db.rs does not need additional validation because inputs are already validated at the program level.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-04T10:48:00.070Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/mod.rs:217-219
Timestamp: 2025-11-04T10:48:00.070Z
Learning: In magicblock-validator, the codebase uses a pattern where types containing non-Send/non-Sync fields (like Rc<RefCell<...>>) are marked with unsafe impl Send when they are guaranteed to be confined to a single thread through careful API design and thread spawning patterns.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-11-20T08:57:07.217Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 650
File: magicblock-chainlink/src/submux/subscription_task.rs:13-99
Timestamp: 2025-11-20T08:57:07.217Z
Learning: In the magicblock-validator repository, avoid posting review comments that merely confirm code is correct or matches intended behavior without providing actionable feedback, suggestions for improvement, or identifying potential issues. Such confirmatory comments are considered unhelpful noise by the maintainers.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-11-21T11:03:26.756Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 664
File: magicblock-chainlink/src/testing/mod.rs:342-370
Timestamp: 2025-11-21T11:03:26.756Z
Learning: In the magicblock-validator codebase, avoid leaving review comments that merely acknowledge code is correct or well-structured when there is no actionable suggestion, improvement, or issue to flag. Only comment when there is something specific to recommend, fix, or clarify.
Applied to files:
test-integration/Cargo.toml
🧬 Code graph analysis (6)
magicblock-committor-service/src/tasks/mod.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-103)
magicblock-committor-service/src/tasks/task_strategist.rs (3)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
get_base_account(43-46)get_base_account(275-280)magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
get_base_account(36-41)magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-103)
test-integration/test-committor-service/tests/utils/instructions.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
init_order_book_instruction(36-54)delegate_account_cpi_instruction(100-151)
magicblock-committor-service/src/tasks/task_builder.rs (1)
test-integration/test-committor-service/tests/common.rs (2)
create_commit_task(162-178)new(52-55)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (2)
init_account_and_delegate_ixs(21-52)init_order_book_account_and_delegate_ixs(61-94)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (2)
test-integration/test-committor-service/tests/utils/transactions.rs (2)
init_and_delegate_order_book_on_chain(240-300)fund_validator_auth_and_ensure_validator_fees_vault(303-344)test-integration/test-committor-service/tests/utils/mod.rs (1)
ensure_validator_authority(35-44)
⏰ 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). (2)
- GitHub Check: run_make_ci_test
- GitHub Check: run_make_ci_lint
🔇 Additional comments (20)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (4)
34-34: LGTM!The new import for
init_and_delegate_order_book_on_chainaligns with the added order-book test infrastructure.
98-121: Good test coverage for CommitDiff boundary conditions.The new order-book tests effectively cover the critical transition points:
- 100 and 679 bytes →
CommitStrategy::Args(fits in transaction)- 681 bytes →
CommitStrategy::FromBuffer(exceeds limit)- 10k bytes →
CommitStrategy::FromBufferThe comment at lines 110-113 clearly documents why 680 is skipped (both 679 and 680 produce 1644-byte encoded tx, but raw bytes for 680 exceed 1232 limit).
188-251: Well-structured test helper for order-book commit scenarios.The
commit_book_order_accountfunction properly:
- Sets up the validator authority and fees vault
- Initializes and delegates an order book on-chain
- Modifies data to produce a diff
- Constructs the appropriate intent based on undelegate flag
- Validates against expected strategy
The data modification loop (lines 214-216) using
wrapping_add(1)is a clean approach to guarantee a diff is produced.
320-324: Updated strategy expectations align with Args-centric commit flow.The multi-account tests now correctly expect
CommitStrategy::Argsfor scenarios where transaction size permits, reflecting the new CommitDiff optimization path.test-integration/test-committor-service/tests/utils/transactions.rs (3)
15-19: LGTM!The extended imports properly expose the new order-book instruction helpers needed for the test utilities.
124-134: Pragmatic handling of CommitState/CommitDiff log matching.The approach to also match "CommitDiff" when searching for "CommitState" is reasonable given that CommitDiff is an optimized variant of CommitState. The inline comment clearly explains the rationale.
240-300: Good parallel structure with existing account delegation flow.The
init_and_delegate_order_book_on_chainfunction mirrors the structure ofinit_and_delegate_account_on_chain, making the codebase consistent and maintainable. The implementation correctly:
- Airdrops SOL to the payer
- Builds init and delegate instructions via the helper
- Sends both transactions with appropriate signers (note:
book_managersigns the init tx)- Retrieves and returns the delegated account
test-integration/test-committor-service/tests/utils/instructions.rs (3)
2-3: LGTM!The new imports for
KeypairandSignerare required for the order-book instruction helper.
54-59: LGTM!The
InitOrderBookAndDelegateIxsstruct follows the established pattern fromInitAccountAndDelegateIxs, appropriately including thebook_managerkeypair needed for signing the init transaction.
70-86: LGTM!The PDA derivation and instruction construction correctly use:
- Seeds
[b"order_book", book_manager.pubkey().as_ref()]matching the on-chain derivationinit_order_book_instructionfor initializationdelegate_account_cpi_instructionwithb"order_book"seed for delegationThis aligns with the API in
api.rs.test-integration/programs/schedulecommit/src/api.rs (2)
11-14: LGTM!The updated imports correctly bring in the new types needed for order-book operations.
36-54: LGTM!The
init_order_book_instructioncorrectly marksbook_manageras a read-only signer (line 44), establishing proper authorization for order book creation.magicblock-committor-service/src/tasks/mod.rs (1)
111-118: LGTM! CommitDiffTask struct is well-structured.The struct correctly includes
CloneandDebugderives (addressing prior feedback) and contains all necessary fields for diff-based commits:commit_id,allow_undelegation,committed_account, andbase_account.magicblock-committor-service/src/tasks/task_strategist.rs (2)
433-438: LGTM! MockInfoFetcher correctly implements get_base_account.The mock returns
Ok(None)which is appropriate for testing the fallback path. The typo from past reviews has been fixed.Note: Like
NullTaskInfoFetcher, this mock doesn't exercise theCommitDiffhappy path. Consider adding a variant that returnsSome(account)to test diff generation.
442-462: Async test helper looks correct.The
create_test_commit_taskhelper properly delegates toTaskBuilderImpl::create_commit_taskwith anArc<NullTaskInfoFetcher>. The async pattern is correctly applied.magicblock-committor-service/src/tasks/task_builder.rs (2)
45-51: LGTM! Threshold constant is well-documented.The comment clearly explains why 256 bytes was chosen and the trade-off being made. This addresses prior feedback about documenting the rationale.
152-158: LGTM! Parallel task creation with join_all.The refactoring correctly parallelizes commit task creation using
join_all. Each account is processed independently withcreate_commit_task, allowing concurrent base-account fetches when applicable.magicblock-committor-service/src/tasks/args_task.rs (3)
67-91: LGTM! CommitDiff instruction building is correct.The implementation properly:
- Constructs
CommitDiffArgswith the diff computed viacompute_diff- Logs diff size vs original size at
infolevel (appropriate for observability)- Calls
dlp::instruction_builder::commit_diffwith correct parameters
140-152: Acknowledge: CommitDiff downgrade to BufferTask is documented.The TODO correctly documents that CommitDiff is currently downgraded to CommitTask when converting to BufferTask. This is acceptable as an interim solution while buffer-based CommitDiff support is developed.
194-194: Verify: CommitDiff maps to TaskType::Commit intentionally.
ArgsTaskType::CommitDiffmaps toTaskType::Commit. This means commit-diff tasks will be grouped/partitioned with regular commit tasks. Verify this is intentional, as past reviews questioned whetherCommitDiffshould have its ownTaskTypevariant for distinct metrics/routing.
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
magicblock-committor-service/src/tasks/args_task.rs (1)
131-156: CommitDiff tasks don't have their commit_id resetThe
reset_commit_idmethod inArgsTaskonly handlesArgsTaskType::Commit, ignoringCommitDifftasks:fn reset_commit_id(&mut self, commit_id: u64) { let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { return; }; commit_task.commit_id = commit_id; }Both
CommitTaskandCommitDiffTaskhavecommit_idfields and are logically equivalent commit operations (both map toTaskType::Commit). If aCommitDifftask is recycled during retry or repartitioning, itscommit_idremains stale while the pipeline expects a new nonce, causing desynchronization.Update this method to handle both variants:
fn reset_commit_id(&mut self, commit_id: u64) { - let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { - return; - }; - - commit_task.commit_id = commit_id; + match &mut self.task_type { + ArgsTaskType::Commit(task) => { + task.commit_id = commit_id; + } + ArgsTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + _ => { + // Non-commit tasks don't carry a commit_id; nothing to reset. + } + } }
♻️ Duplicate comments (7)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
137-150: Fix counter-vs–order-book wording in helper comment and debug logThe new order-book helper still uses “counter” terminology in the doc comment and debug message, which will confuse future readers.
Proposed wording fixes
-/// This needs to be run for each test that required a new counter to be delegated +/// This needs to be run for each test that requires a new order book to be delegated #[allow(dead_code)] pub async fn init_and_delegate_order_book_on_chain( @@ - debug!("Airdropped to counter auth: {} SOL", 777 * LAMPORTS_PER_SOL); + debug!("Airdropped to payer: {} SOL", 777 * LAMPORTS_PER_SOL);Also applies to: 238-250
test-integration/programs/schedulecommit/src/api.rs (6)
56-75: Authorization inconsistency:book_managershould be a signer.This issue was previously flagged. The
book_manageris marked as a non-signer (line 65), inconsistent withinit_order_book_instructionwhich requires the manager's signature. This allows any payer to grow another entity's order book without authorization.
107-110: PDA derivation uses arbitraryuser_seed.This concern was previously flagged. The arbitrary
user_seedparameter may not match on-chain program expectations for canonical seeds likeb"magic_schedule_commit"orb"order_book".
113-117: Remove debug print statements.This issue was previously flagged. These
println!statements should be removed before merging.
133-148: Permissiveuser_seedhandling routes unknown seeds toDelegateOrderBook.This concern was previously flagged. Any
user_seedother thanb"magic_schedule_commit"is treated as an order-book delegation, which is brittle for a public API.
184-200: Missingbook_managerauthorization.This issue was previously flagged. The instruction omits the
book_manageraccount, allowing any payer to update any order book. This is inconsistent withinit_order_book_instructionandgrow_order_book_instructionwhich validate the manager.
202-221: Missingbook_managerauthorization.This issue was previously flagged. Similar to
update_order_book_instruction, this function omits thebook_manageraccount, allowing anyone to schedule commits for any order book without authorization.
🧹 Nitpick comments (3)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (2)
98-121: Order-book commit helper/tests look correct but are threshold‑sensitiveThe
commit_book_order_accounthelper and the new order-book tests correctly:
- Initialize + delegate an order book on-chain
- Mutate only the first
changed_lenbytes (with bounds-assert)- Feed that into a single-account Commit/Finalize intent with the expected
CommitStrategy.The 679/681 byte tests are tightly coupled to current encoding/threshold behavior (comment explains why 681 is the flip point). That’s fine for now, but these tests will be brittle if the diff/Args vs buffer thresholds or encoding change; be prepared to revisit the magic sizes if the planner or DLP args evolve.
Also applies to: 188-251
260-447: Multi-account strategy expectations match Args‑first planner but may be brittleThe updated
expect_strategiesmaps (moreCommitStrategy::Args, adjustedFromBufferWithLookupTablecounts) are consistent with an Args/CommitDiff‑first planner that only falls back to buffers+ALTs when necessary. The patterns across the 2/3/4/5/6/8/20‑account tests look internally consistent.If planner thresholds continue to evolve, consider gradually relaxing some of these assertions (e.g., asserting “at least one Args” or bounds on buffer counts) to reduce future churn, especially for tests whose purpose is end‑to‑end commit success rather than exact internal strategy distribution.
test-integration/test-committor-service/tests/utils/instructions.rs (1)
54-94: Avoidprintln!in test helper; use logging or drop itThe new order-book helper cleanly assembles
InitOrderBookAndDelegateIxs, butprintln!("schedulecommit ID: {}", ID);will spam stdout for every call. Prefer either removing it or switching to alog::debug!(with appropriate logger init) so tests can control verbosity.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.locktest-integration/schedulecommit/elfs/dlp.sois excluded by!**/*.so
📒 Files selected for processing (11)
Cargo.tomlmagicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/Cargo.tomltest-integration/programs/schedulecommit/src/api.rstest-integration/test-committor-service/Cargo.tomltest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/utils/instructions.rstest-integration/test-committor-service/tests/utils/transactions.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- test-integration/test-committor-service/Cargo.toml
- test-integration/Cargo.toml
🧰 Additional context used
🧠 Learnings (15)
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
Cargo.toml
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.
Applied to files:
Cargo.toml
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/programs/schedulecommit/src/api.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/utils/transactions.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_ix_commit_local.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/utils/transactions.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_ix_commit_local.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/utils/transactions.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/programs/schedulecommit/src/api.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/utils/transactions.rsmagicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
test-integration/test-committor-service/tests/utils/transactions.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_ix_commit_local.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-12T09:46:27.553Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: magicblock-task-scheduler/src/db.rs:26-0
Timestamp: 2025-11-12T09:46:27.553Z
Learning: In magicblock-task-scheduler, task parameter validation (including ensuring iterations > 0 and enforcing minimum execution intervals) is performed in the Magic program (on-chain) before ScheduleTaskRequest instances reach the scheduler service. The From<&ScheduleTaskRequest> conversion in db.rs does not need additional validation because inputs are already validated at the program level.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-04T10:48:00.070Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/mod.rs:217-219
Timestamp: 2025-11-04T10:48:00.070Z
Learning: In magicblock-validator, the codebase uses a pattern where types containing non-Send/non-Sync fields (like Rc<RefCell<...>>) are marked with unsafe impl Send when they are guaranteed to be confined to a single thread through careful API design and thread spawning patterns.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
🧬 Code graph analysis (6)
magicblock-committor-service/src/tasks/task_strategist.rs (4)
test-integration/test-committor-service/tests/common.rs (3)
get_base_account(145-150)create_commit_task(162-178)new(52-55)magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
get_base_account(36-41)magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (3)
get_base_account(43-46)get_base_account(275-280)new(60-67)magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-103)
magicblock-committor-service/src/tasks/task_builder.rs (2)
test-integration/test-committor-service/tests/common.rs (2)
create_commit_task(162-178)new(52-55)magicblock-committor-service/src/tasks/args_task.rs (1)
new(42-47)
test-integration/test-committor-service/tests/utils/instructions.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
init_order_book_instruction(36-54)delegate_account_cpi_instruction(100-151)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (3)
init_account_and_delegate_ixs(21-52)init_order_book_account_and_delegate_ixs(61-94)init_validator_fees_vault_ix(5-11)
magicblock-committor-service/src/tasks/mod.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-103)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (2)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
init_and_delegate_order_book_on_chain(240-300)test-integration/test-committor-service/tests/utils/mod.rs (1)
ensure_validator_authority(35-44)
⏰ 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). (3)
- GitHub Check: Build Project
- GitHub Check: run_make_ci_lint
- GitHub Check: run_make_ci_test
🔇 Additional comments (9)
Cargo.toml (1)
98-100: Verify delegation-program rev and lock alignmentThe new
magicblock-delegation-programrev looks fine; just ensure this commit exists on the remote, matches the expected CommitDiff API, and thatCargo.lock(if committed) has been updated accordingly so CI builds reproducibly.test-integration/test-committor-service/tests/utils/transactions.rs (1)
124-135: tx_logs_contain correctly handles CommitState vs CommitDiff logsThe special-casing of
needle == "CommitState"to also accept"CommitDiff"aligns with the planner’s ability to choose either variant without forcing all tests to branch on that detail. The behavior is documented in-line and looks good.test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
68-96: Single-account tests now exercising Args path appropriatelySwitching the single-account commit tests (100 B up to 10 KB) to expect
CommitStrategy::Argsmatches the new CommitDiff/Args-first planner, while still keeping larger/bundled scenarios to cover buffer/ALT paths elsewhere in this file. This distribution of expectations looks coherent.magicblock-committor-service/src/tasks/mod.rs (1)
17-18: CommitDiffTask definition and serialization tests are wired correctlyIntroducing
CommitDiffTask { commit_id, allow_undelegation, committed_account, base_account }in this module and re‑exportingTaskBuilderImplprovides the necessary building blocks for the new CommitDiff flow. The updatedserialization_safety_testnow:
- Constructs commit tasks via
TaskBuilderImpl::create_commit_task(..., &Arc::new(NullTaskInfoFetcher)).await- Exercises all
ArgsTaskTypevariants, plusBufferTaskpreparation pathswhich is a good sanity check for instruction shape and (de)serialization. No issues from this module’s side.
Also applies to: 32-33, 104-117, 305-459
magicblock-committor-service/src/tasks/task_builder.rs (2)
45-52: Commit vs CommitDiff selection and async task creation look correct
COMMIT_STATE_SIZE_THRESHOLD = 256combined withget_base_accountto decide betweenCommitTaskandCommitDiffTaskis a reasonable first cut, and usingjoin_allto assemble commit tasks in parallel is a nice improvement over per-account awaits. The fallback behavior onOk(None)/Err(e)(log and use CommitState) keeps CommitDiff as a best‑effort optimization without risking commit failures.Also applies to: 53-103
152-158: join_all usage for commit task assembly is appropriateUsing
join_allover the committed accounts to callcreate_commit_task(...).awaitin parallel is a good fit here and keeps the API aligned with the asyncTaskInfoFetcher. Theexpectoncommit_ids.getis also reasonable given the invariant promised byfetch_next_commit_ids.magicblock-committor-service/src/tasks/task_strategist.rs (1)
383-439: Async strategist tests and use of NullTaskInfoFetcher look goodThe strategist tests now:
- Build commit tasks via
TaskBuilderImpl::create_commit_task(..., &Arc::new(NullTaskInfoFetcher)).await- Use
join_allto generate multiple large commit tasks- Assert buffer vs Args strategies and ALT usage across a range of scenarios
Given
NullTaskInfoFetcher::get_base_accountalways returnsOk(None), these tests intentionally exercise the Commit/Buffer path only, which is fine since CommitDiff behavior is covered elsewhere. No changes needed here.Also applies to: 441-463, 496-607, 609-685
magicblock-committor-service/src/tasks/args_task.rs (1)
1-7: CommitDiff ArgsTask wiring is coherent with existing Commit flowThe new
ArgsTaskType::CommitDiff(CommitDiffTask)variant,compute_diffcall usingReadableAccount::data(), and thecommit_diffinstruction builder integrate cleanly:
- No RPC in
instruction(), only in-memory diff againstbase_accountcompute_units/TaskType/LabelValuekeep Commit and CommitDiff in the same operational bucket while still distinguishing them in metrics ("args_commit_diff")This matches the PR’s goal of treating CommitDiff as an internal optimization without changing external task semantics.
Also applies to: 21-27, 50-91, 176-183, 191-199, 215-223
test-integration/programs/schedulecommit/src/api.rs (1)
36-54: LGTM!The initialization instruction correctly marks
book_manageras a signer, which is appropriate for account creation and establishes the authorization pattern for this order book.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
magicblock-committor-service/src/tasks/args_task.rs (1)
200-206: Fix reset_commit_id to handle CommitDiff tasks.The
reset_commit_idmethod only updatesCommittasks and silently ignoresCommitDifftasks. IfCommitDifftasks are recycled with new commit IDs, this will cause desynced submissions.🔎 Proposed fix
fn reset_commit_id(&mut self, commit_id: u64) { - let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { - return; - }; - - commit_task.commit_id = commit_id; + match &mut self.task_type { + ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + _ => { + // BaseAction, Finalize, Undelegate don't have commit_id + } + } }
♻️ Duplicate comments (1)
magicblock-committor-service/src/tasks/task_strategist.rs (1)
445-445: Inconsistent system program import usage.Line 445 uses
system_program::id()while line 505 usessystem_program_id(). Both resolve to the same value, but this is inconsistent within the test module.🔎 Proposed fix (use system_program_id consistently)
- owner: system_program::id(), + owner: system_program_id(),
🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/args_task.rs (1)
170-177: Verify compute unit allocation for CommitDiff.Both
CommitandCommitDiffare allocated 70,000 compute units. However, the PR objectives mention thatCommitDiffused 65k compute units in tests. SinceCommitDiffsends only the diff (not full state), it may warrant a lower allocation.Consider whether 65,000 or a more precise value would be more appropriate.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
magicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/buffer_task.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- magicblock-committor-service/src/tasks/task_builder.rs
🧰 Additional context used
🧠 Learnings (9)
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (1)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
magicblock-committor-service/src/tasks/args_task.rs (2)
from(36-38)value(210-218)
⏰ 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). (3)
- GitHub Check: Build Project
- GitHub Check: run_make_ci_test
- GitHub Check: run_make_ci_lint
🔇 Additional comments (7)
magicblock-committor-service/src/tasks/task_strategist.rs (6)
373-398: LGTM!The new imports properly support the async test patterns (
join_all), the extendedMockInfoFetcher(MagicBlockRpcClientResult), and the new diff threshold tests (COMMIT_STATE_SIZE_THRESHOLD,NullTaskInfoFetcher).
401-431: LGTM!The
MockInfoFetchernow holds aHashMap<Pubkey, Account>enabling diff-path testing by returning base accounts fromget_base_account. This addresses the previous concern about only testing direct commits.
569-632: Good addition of diff threshold tests.These tests properly exercise the diff-based commit optimization:
- Small diff on large account → Args strategy (efficient)
- Threshold boundary cases → Args strategy
- Large diff → Buffer strategy (fallback)
This addresses the prior concern about missing diff test coverage.
641-645: LGTM!The
join_allpattern for parallel task creation is correctly implemented and consistent across all similar test setups.
510-513: LGTM!The async test conversion is correctly applied with
#[tokio::test]and proper awaiting of thecreate_test_commit_taskhelper.
766-865: LGTM!The integration tests for
build_execution_strategycorrectly validate single-stage, two-stage, and ALT scenarios using the async patterns. The use ofMockInfoFetcher::default()(empty HashMap) is appropriate here since these tests focus on execution mode selection rather than diff behavior.magicblock-committor-service/src/tasks/args_task.rs (1)
185-192: Clarify TaskType mapping for CommitDiff.
CommitDiffcurrently maps toTaskType::Commit(line 188), but a previous review suggested adding a distinctTaskType::CommitDiffvariant to reflect the different execution models. The review was marked as addressed in commit 4916c85, yet the mapping remains unchanged.Given taco-paco's feedback about separating task responsibilities, please clarify whether:
- The decision was made to keep both under
TaskType::Commit, or- This distinction will be introduced in a subsequent PR (matching the pattern of the TODO at line 135)
|
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
238-238: Fix grammar in the comment.The comment contains a grammatical error: "required" should be "requires".
🔎 Proposed fix
-/// This needs to be run for each test that required a new order_book to be delegated +/// This needs to be run for each test that requires a new order_book to be delegatedmagicblock-committor-service/src/tasks/args_task.rs (1)
200-206: Critical: reset_commit_id must handle CommitDiff variant.When
CommitDifftasks are recycled,reset_commit_idsilently returns without updating the commit ID, leaving stale commit IDs in place. This will cause nonce mismatches and transaction failures when the recycled task is submitted.Both
CommitandCommitDiffvariants hold acommit_idfield that must be updated during recycling.🔎 Proposed fix
fn reset_commit_id(&mut self, commit_id: u64) { - let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { - return; - }; - - commit_task.commit_id = commit_id; + match &mut self.task_type { + ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + _ => { + // Other task types don't have commit_id + } + } }
🧹 Nitpick comments (4)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
238-298: Consider adding debug logs for consistency and debuggability.The function logic is correct and properly handles order book initialization and delegation. However, it lacks debug logging present in the analogous
init_and_delegate_account_on_chainfunction, which logs after airdrop, init, and delegate steps. Adding similar debug statements would improve consistency and help diagnose test failures.🔎 Suggested debug logs
rpc_client .request_airdrop(&payer.pubkey(), 777 * LAMPORTS_PER_SOL) .await .unwrap(); + debug!("Airdropped to payer: {} SOL", 777 * LAMPORTS_PER_SOL); let InitOrderBookAndDelegateIxs { init, delegate, book_manager, order_book, } = init_order_book_account_and_delegate_ixs(payer.pubkey()); let latest_block_hash = rpc_client.get_latest_blockhash().await.unwrap(); // Init account rpc_client .send_and_confirm_transaction_with_spinner_and_config( &Transaction::new_signed_with_payer( &[init], Some(&payer.pubkey()), &[payer, &book_manager], latest_block_hash, ), CommitmentConfig::confirmed(), RpcSendTransactionConfig { skip_preflight: true, ..Default::default() }, ) .await .expect("Failed to init account"); + debug!("Init order_book: {:?}", order_book); // Delegate account rpc_client .send_and_confirm_transaction_with_spinner_and_config( &Transaction::new_signed_with_payer( &[delegate], Some(&payer.pubkey()), &[&payer], latest_block_hash, ), CommitmentConfig::confirmed(), RpcSendTransactionConfig { skip_preflight: true, ..Default::default() }, ) .await .expect("Failed to delegate"); + debug!("Delegated order_book: {:?}", order_book); let order_book_acc = get_account!(rpc_client, order_book, "order_book"); (order_book, order_book_acc)magicblock-committor-service/src/tasks/args_task.rs (1)
67-85: Consider caching computed diff to avoid repeated computation.The
compute_diffcall executes on everyinstruction()invocation. Ifinstruction()is called multiple times (e.g., during transaction size calculation, optimization passes, or final assembly), the diff is recomputed each time, which is wasteful for large accounts.Consider computing and caching the diff once during task construction or on first call to
instruction(), then reusing the cached result.🔎 Example refactor to cache diff
Add a cached diff field to
CommitDiffTask:pub struct CommitDiffTask { pub commit_id: u64, pub allow_undelegation: bool, pub committed_account: CommittedAccount, pub base_account: Account, cached_diff: OnceCell<Vec<u8>>, // or Option<Vec<u8>> with interior mutability }Then in
instruction():ArgsTaskType::CommitDiff(value) => { let diff = value.cached_diff.get_or_init(|| { compute_diff( value.base_account.data(), value.committed_account.account.data(), ).to_vec() }); let args = CommitDiffArgs { nonce: value.commit_id, lamports: value.committed_account.account.lamports, diff: diff.clone(), allow_undelegation: value.allow_undelegation, }; // ... rest of the code }magicblock-committor-service/src/tasks/task_builder.rs (1)
54-96: Consider batching base account fetches for multiple tasks.The current implementation fetches base accounts individually for each commit task. When processing multiple accounts, this results in N sequential RPC calls (or N parallel calls with
join_allin the caller).Consider extending
TaskInfoFetcherwith a batch method likefetch_base_accounts(&[Pubkey])that can fetch multiple base accounts in a single RPC call (usinggetMultipleAccounts). This would significantly reduce RPC overhead when committing multiple accounts.Since this is an optimization that doesn't affect correctness and requires broader refactoring of the
TaskInfoFetchertrait, it's acceptable to defer to a future PR.magicblock-committor-service/src/tasks/task_strategist.rs (1)
435-866: Minor style inconsistency: Mixed system program imports.Line 446 uses
system_program::id()while line 505 usessystem_program_id(). Both resolve to the same value.For consistency, prefer using
system_program_id()throughout since it's already imported at line 381.This is a minor nitpick and doesn't affect correctness.
🔎 Suggested fix
let committed_account = CommittedAccount { pubkey: Pubkey::new_unique(), account: Account { lamports: 1000, data: vec![1; data_size], - owner: system_program::id(), + owner: system_program_id(), executable: false, rent_epoch: 0, }, };
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
magicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/buffer_task.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/utils/transactions.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- magicblock-committor-service/src/tasks/buffer_task.rs
🧰 Additional context used
🧠 Learnings (11)
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/utils/transactions.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/args_task.rstest-integration/test-committor-service/tests/utils/transactions.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/utils/transactions.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/utils/transactions.rs
📚 Learning: 2025-11-12T09:46:27.553Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: magicblock-task-scheduler/src/db.rs:26-0
Timestamp: 2025-11-12T09:46:27.553Z
Learning: In magicblock-task-scheduler, task parameter validation (including ensuring iterations > 0 and enforcing minimum execution intervals) is performed in the Magic program (on-chain) before ScheduleTaskRequest instances reach the scheduler service. The From<&ScheduleTaskRequest> conversion in db.rs does not need additional validation because inputs are already validated at the program level.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
test-integration/test-committor-service/tests/utils/transactions.rs
🧬 Code graph analysis (2)
magicblock-committor-service/src/tasks/task_strategist.rs (3)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
get_base_account(36-41)magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
get_base_account(43-46)get_base_account(275-280)magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-95)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (3)
init_account_and_delegate_ixs(21-52)init_order_book_account_and_delegate_ixs(61-94)init_validator_fees_vault_ix(5-11)
⏰ 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). (2)
- GitHub Check: run_make_ci_test
- GitHub Check: Build Project
🔇 Additional comments (10)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
16-18: LGTM! Necessary imports for order book support.The added imports correctly support the new order book delegation functionality introduced in this file.
magicblock-committor-service/src/tasks/args_task.rs (4)
134-146: LGTM: Temporary downgrade documented in TODO.The downgrade from
CommitDifftoCommitTaskbefore buffering is clearly documented as temporary. Per the PR objectives and reviewer feedback, this will be addressed in subsequent PRs whenBufferTaskgainsCommitDiffsupport.The current approach ensures correctness even if it sacrifices the diff optimization when buffering is needed.
170-178: Verify CommitDiff compute unit allocation.The code allocates 70,000 compute units for
CommitDiff, matchingCommit. However, the PR description states thatCommitDiffuses 65,000 compute units compared toCommit's 70,000.Confirm whether this allocation should be reduced to 65,000 to match the actual on-chain compute usage, or if 70,000 is intentionally conservative to provide headroom.
185-193: Verify TaskType mapping for CommitDiff.A previous review comment (marked as "✅ Addressed in commit 4916c85") recommended adding a separate
TaskType::CommitDiffvariant to distinguish commit-diff execution from regular commits. However, the current code still mapsCommitDifftoTaskType::Commit.Please confirm:
- Was the separate variant intentionally deferred to a future PR?
- Or should this mapping be updated to use
TaskType::CommitDiff?The distinction matters for metrics, task routing, and optimization decisions where
CommitDiffhas fundamentally different characteristics (RPC-based, non-bufferable, different compute profile).
209-219: LGTM: Appropriate label for metrics tracking.The distinct label
"args_commit_diff"enables separate metrics collection forCommitDifftasks, which is useful for monitoring the adoption and performance of the diff optimization.magicblock-committor-service/src/tasks/task_builder.rs (2)
45-51: LGTM: Well-documented threshold constant.The
COMMIT_STATE_SIZE_THRESHOLDis clearly documented with rationale. The 256-byte threshold appropriately targets small, frequently-updated accounts (like counters with a few integer fields) where diff encoding provides the most benefit.Public visibility enables testing code to reference this threshold when verifying commit type selection.
144-150: LGTM: Effective use of parallel async task creation.Using
join_allto parallelize task creation is an excellent optimization. Since each task creation may fetch a base account via RPC, parallelizing these fetches significantly reduces total latency when processing multiple accounts.The approach correctly shares the
task_info_fetcherreference across all parallel tasks, avoiding redundant RPC client instantiation.magicblock-committor-service/src/tasks/task_strategist.rs (3)
401-432: LGTM: MockInfoFetcher enables flexible test scenarios.The
MockInfoFetcherimplementation correctly provides test control over base account availability. TheHashMap-based approach allows tests to simulate various scenarios:
- Account present (returns
Some(account))- Account not found (returns
Nonewhen pubkey not in map)- Different base account data for testing various diff sizes
The
Defaultderivation enables concise test setup when no base accounts are needed.
435-476: LGTM: Test helper correctly simulates both commit types.The async
create_test_commit_taskhelper effectively simulates both commit scenarios:
diff_len == 0: UsesNullTaskInfoFetcher→ no base account → createsCommitStatetaskdiff_len > 0: UsesMockInfoFetcherwith modified base → createsCommitDifftask with controlled diff sizeThe modification logic (wrapping_add to change first N bytes) provides realistic diff scenarios for testing optimization behavior.
570-632: Excellent: CommitDiff test coverage addresses reviewer feedback.The new test functions comprehensively verify the CommitDiff behavior across multiple scenarios:
- Large account, small diff (lines 570-588): Verifies that
Argsstrategy is used (no buffering needed for small diff)- Large account, threshold-sized diff (lines 591-609): Verifies boundary behavior at
COMMIT_STATE_SIZE_THRESHOLD- Large account, large diff (lines 612-632): Verifies that
Bufferstrategy is used when diff exceeds thresholdThese tests directly address the reviewer feedback (taco-paco) about missing CommitDiff test coverage. The tests verify both task type selection (CommitDiff vs Commit) and strategy selection (Args vs Buffer).
Based on learnings: Tests in this codebase use
#[tokio::test]for async test functions and validate behavior through strategy assertions.
taco-paco
left a comment
There was a problem hiding this comment.
Looks good, left some comments that we need to address.
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
Show resolved
Hide resolved
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
Outdated
Show resolved
Hide resolved
test-integration/test-committor-service/tests/test_transaction_preparator.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (8)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
41-47: Remove unused trait bounds on generic parameter.The function body only inspects the structure of
ScheduledCommitResult<T>(checkingincluded.len(),excluded.len(), andsigs.len()) but never deserializes, formats, or compares values of typeT. The trait boundsstd::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eqare not used.🔎 Proposed fix
pub fn assert_one_committee_was_committed<T>( ctx: &ScheduleCommitTestContext, res: &ScheduledCommitResult<T>, is_single_stage: bool, -) where - T: std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq, -{ +) {test-integration/test-committor-service/tests/utils/instructions.rs (1)
3-3: Remove unused import.The
Signerimport is not used anywhere in this file and should be removed.🔎 Proposed fix
-use test_kit::Signer;test-integration/programs/schedulecommit/src/lib.rs (3)
307-341: Missing book_manager signer validation.The function derives the order book PDA from
book_manager.key(lines 320-323) and uses it insigner_seeds(line 336), but never validates thatbook_manageris a signer. The instruction builder inapi.rsmarksbook_manageras a signer, but the handler doesn't enforce this requirement.This creates an authorization gap where anyone can initialize an order book for any
book_managerwithout their signature.🔎 Proposed fix
assert_is_signer(payer, "payer")?; + assert_is_signer(book_manager, "book_manager")?; let (pda, bump) = Pubkey::find_program_address(
390-423: Missing payer signer validation before delegation CPI.The handler calls
delegate_account(which creates accounts and transfers lamports) without first validating thatpayeris a signer. If the payer flag is missing, the CPI will fail with a less clear error message.🔎 Proposed fix
}; + assert_is_signer(payer, "payer")?; + let seeds_no_bump = [b"order_book", args.book_manager.as_ref()]; delegate_account(
449-469: Missing PDA and ownership validation for order_book_account.The handler schedules commit and undelegate for
order_book_accountwithout verifying:
- The account is the expected PDA derived from
[b"order_book", book_manager.key]- The account is owned by this program
This allows committing arbitrary accounts via this instruction. While downstream checks in the delegation/magic program may enforce some constraints, explicit validation here would provide clearer error messages and prevent misuse.
Note: Full PDA validation requires
book_managerto be available (either as an additional account or in instruction data) to recompute and verify the PDA.test-integration/programs/schedulecommit/src/api.rs (3)
71-90: Authorization inconsistency: book_manager should be a signer.
init_order_book_instructionmarksbook_manageras a signer (line 59), butgrow_order_book_instructionmarks it as a non-signer (line 80). This means any payer can grow another entity's order book without authorization.If
book_managershould authorize growth (mirroring init semantics), update the account meta to require a signature and add corresponding on-chain validation inprocess_grow_order_book.🔎 Proposed fix
AccountMeta::new(payer, true), - AccountMeta::new_readonly(book_manager, false), + AccountMeta::new_readonly(book_manager, true), AccountMeta::new(order_book, false),Then add validation in
process_grow_order_book:assert_is_signer(payer, "payer")?; + assert_is_signer(book_manager, "book_manager")?;
197-213: Missing book_manager authorization for updates.The function only requires
payersignature and omits thebook_manageraccount entirely. This creates an inconsistent authorization model:
- Init and grow operations validate
book_managermatches the order book's PDA derivation- Update operation skips this check, allowing anyone to modify any order book
Since order books are PDAs derived from
[b"order_book", book_manager.key], thebook_manageris the conceptual owner. Include and validate this account to maintain consistent authorization.
215-234: Missing book_manager authorization for commit scheduling.Similar to
update_order_book_instruction, this function omits thebook_manageraccount. Without this validation, anyone can schedule commits for any order book without the owner's authorization.Include
book_managerin the account metas and validate authorization on-chain, consistent withinit_order_book_instructionandgrow_order_book_instruction.
🧹 Nitpick comments (2)
magicblock-committor-service/src/tasks/mod.rs (1)
307-447: Serialization tests are correctly structured.The updated tests properly validate serialization safety for all task variants:
- Tests are synchronous (appropriate for serialization validation per past feedback)
- Coverage includes all
ArgsTaskTypevariants (Commit, Finalize, Undelegate, BaseAction) andBufferTaskpreparation flows- Tests exercise
.into()conversions from task types to ArgsTask/BufferTaskOptional: Consider adding CommitDiffTask serialization test
If
CommitDiffTaskserialization isn't already covered inargs_task.rs(whereArgsTaskType::CommitDiffis presumably defined), you might add a dedicated test here to ensure the new variant serializes correctly. However, this is optional if coverage exists elsewhere.🔎 Optional test addition
#[test] fn test_commit_diff_task_serialization() { let validator = Pubkey::new_unique(); let commit_diff_task = CommitDiffTask { commit_id: 999, allow_undelegation: true, committed_account: CommittedAccount { pubkey: Pubkey::new_unique(), account: Account { lamports: 5000, data: vec![1; 512], owner: Pubkey::new_unique(), executable: false, rent_epoch: 0, }, }, base_account: Account { lamports: 5000, data: vec![2; 512], owner: Pubkey::new_unique(), executable: false, rent_epoch: 0, }, }; // Test that CommitDiffTask can be converted and serialized // This would require ArgsTaskType::CommitDiff to be available // let args_task: ArgsTask = ArgsTaskType::CommitDiff(commit_diff_task).into(); // assert_serializable(&args_task.instruction(&validator)); }test-integration/test-committor-service/tests/utils/instructions.rs (1)
68-68: Remove debug print statement.This
println!statement adds noise to test output. Either remove it entirely or convert it to conditional debug logging if the information is valuable during debugging.🔎 Proposed fix
- println!("schedulecommit ID: {}", ID);Or if logging is needed:
- println!("schedulecommit ID: {}", ID); + log::debug!("schedulecommit ID: {}", ID);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
magicblock-committor-service/src/intent_executor/mod.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/api.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/schedulecommit/test-security/tests/01_invocations.rstest-integration/test-committor-service/tests/utils/instructions.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- magicblock-committor-service/src/intent_executor/mod.rs
- test-integration/schedulecommit/test-security/tests/01_invocations.rs
🧰 Additional context used
🧠 Learnings (13)
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rsmagicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/api.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/client/src/schedule_commit_context.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/api.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/client/src/schedule_commit_context.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-04T10:48:00.070Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/mod.rs:217-219
Timestamp: 2025-11-04T10:48:00.070Z
Learning: In magicblock-validator, the codebase uses a pattern where types containing non-Send/non-Sync fields (like Rc<RefCell<...>>) are marked with unsafe impl Send when they are guaranteed to be confined to a single thread through careful API design and thread spawning patterns.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-12T09:46:27.553Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: magicblock-task-scheduler/src/db.rs:26-0
Timestamp: 2025-11-12T09:46:27.553Z
Learning: In magicblock-task-scheduler, task parameter validation (including ensuring iterations > 0 and enforcing minimum execution intervals) is performed in the Magic program (on-chain) before ScheduleTaskRequest instances reach the scheduler service. The From<&ScheduleTaskRequest> conversion in db.rs does not need additional validation because inputs are already validated at the program level.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.
Applied to files:
test-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
test-integration/programs/schedulecommit/src/lib.rs
🧬 Code graph analysis (4)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
ctx(148-149)test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
ctx(90-91)test-integration/schedulecommit/client/src/schedule_commit_context.rs (4)
try_new(72-74)ncommittees(102-121)try_new_random_keys(66-71)fmt(40-49)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (2)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
get_context_with_delegated_committees(16-35)assert_one_committee_was_committed(41-65)assert_one_committee_account_was_undelegated_on_chain(190-196)test-integration/schedulecommit/client/src/verify.rs (1)
fetch_and_verify_order_book_commit_result_from_logs(16-23)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
test-integration/programs/schedulecommit/src/order_book.rs (1)
try_new(109-143)test-integration/test-tools/src/integration_test_context.rs (1)
try_new(116-118)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
get_context_with_delegated_committees(16-35)
⏰ 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). (4)
- GitHub Check: run_make_ci_lint
- GitHub Check: run_make_ci_format
- GitHub Check: Build Project
- GitHub Check: run_make_ci_test
🔇 Additional comments (8)
magicblock-committor-service/src/tasks/mod.rs (3)
17-17: LGTM: Import is necessary for CommitDiffTask.The
Accountimport is correctly added to support the newCommitDiffTaskstruct'sbase_accountfield.
32-32: LGTM: TaskBuilderImpl re-export aligns with architecture.Exposing
TaskBuilderImplpublicly is consistent with the PR objective to centralize commit-variant decision logic in TaskBuilder rather than inside task constructors.
111-117: LGTM: CommitDiffTask struct is well-defined.The new
CommitDiffTaskstruct appropriately separates the commit-with-diff variant fromCommitTask. Thebase_accountfield will hold the base-chain state needed for diff computation, and theDebugderive (requested in earlier reviews) aids diagnostics.This addresses the architectural feedback to split task types rather than using optional fields or flags inside a single
CommitTaskstruct.test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
48-51: LGTM! Clean integration of UserSeeds enum.The changes consistently thread
UserSeeds::MagicScheduleCommitthrough test setup and delegation calls, replacing the previous hardcoded byte string approach. This is a cleaner, more maintainable solution.Also applies to: 104-107, 238-238
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)
300-362: Excellent test design with reproducible randomness.The order book test demonstrates best practices:
- Uses seeded randomness (
OsRng→StdRng) for reproducibility- Prints the seed for debugging test failures
- Generates realistic random order book data with controlled ranges
- Verifies complete data integrity after commit/undelegate operations
- Error messages reference the seed for investigation
The intentional
println!of the seed (line 309) aids debugging and is appropriate for test code.test-integration/programs/schedulecommit/src/lib.rs (1)
822-840: LGTM! Appropriate handling of multiple account types.The branching logic cleanly handles both
MainAccountandOrderBookdeserialization based on data length, with appropriate error logging that doesn't fail the undelegation operation. This is a good defensive coding pattern.test-integration/programs/schedulecommit/src/api.rs (1)
16-29: LGTM! Clean enum-based seed abstraction.The
UserSeedsenum with itsbytes()helper provides a type-safe alternative to raw byte slices for PDA derivation. This is a good refactoring that improves maintainability and reduces errors.test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
72-73: LGTM! Consistent UserSeeds integration throughout.The changes cleanly thread
UserSeedsthrough the client context:
- Constructors properly accept and store the seed
- PDA derivation uses
user_seed.bytes()for consistent seed handling- Init logic branches explicitly on seed variants with clear error handling
- Delegation propagates the seed correctly
The integration is well-structured and maintains consistency across all operations.
Also applies to: 115-118, 166-211, 275-275
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (9)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
41-47: Remove unused trait bounds.The trait bounds
std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eqon generic parameterTare not utilized by the function body. The function only inspects theScheduledCommitResultstructure and never deserializes or compares values of typeT.🔎 Proposed fix
-pub fn assert_one_committee_was_committed<T>( +pub fn assert_one_committee_was_committed<T>( ctx: &ScheduleCommitTestContext, res: &ScheduledCommitResult<T>, is_single_stage: bool, -) where - T: std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq, -{ +) {test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
166-169: Consider extracting compute budget values as named constants.The compute unit limit (1,400,000) and price (10,000) are hardcoded. Extracting these as named constants would improve maintainability.
Example
const INIT_COMPUTE_UNIT_LIMIT: u32 = 1_400_000; const INIT_COMPUTE_UNIT_PRICE: u64 = 10_000; let mut ixs = vec![ ComputeBudgetInstruction::set_compute_unit_limit(INIT_COMPUTE_UNIT_LIMIT), ComputeBudgetInstruction::set_compute_unit_price(INIT_COMPUTE_UNIT_PRICE), ];
193-206: Remove commented-out code block.The 14-line commented TODO about growing order books adds noise. Consider tracking the account size limitation as a GitHub issue and replacing this block with a brief comment referencing the issue.
test-integration/programs/schedulecommit/src/api.rs (3)
71-90: Authorization inconsistency: grow_order_book_instruction should require book_manager signature.
init_order_book_instructionmarksbook_manageras a signer (line 59), butgrow_order_book_instructionmarks it as a non-signer (line 80). This inconsistency allows any payer to grow another entity's order book without authorization.For consistent authorization semantics,
grow_order_book_instructionshould require the book_manager's signature, and the on-chain handler (process_grow_order_bookin lib.rs) should validate it.🔎 Recommended fix
AccountMeta::new(payer, true), - AccountMeta::new_readonly(book_manager, false), + AccountMeta::new_readonly(book_manager, true), AccountMeta::new(order_book, false),Also add
assert_is_signer(book_manager, "book_manager")?in the on-chain handler.
197-213: Missing book_manager authorization in update_order_book_instruction.The function only requires the
payersignature and omits thebook_manageraccount entirely. This is inconsistent withinit_order_book_instructionandgrow_order_book_instruction, which include and validate the book_manager.Since order books are PDAs derived from
[b"order_book", book_manager.key], the conceptual owner is the book_manager. Without this validation, anyone can modify any order book.🔎 Recommended fix
pub fn update_order_book_instruction( payer: Pubkey, + book_manager: Pubkey, order_book: Pubkey, update: BookUpdate, ) -> Instruction { let program_id = crate::id(); let account_metas = vec![ AccountMeta::new(payer, true), + AccountMeta::new_readonly(book_manager, true), AccountMeta::new(order_book, false), ];Also update the on-chain handler to validate the PDA derivation from book_manager.
215-234: Missing book_manager authorization in schedule_commit_diff_instruction_for_order_book.Similar to
update_order_book_instruction, this function omits thebook_manageraccount and only requires the payer's signature. This allows anyone to schedule commits for any order book.🔎 Recommended fix
pub fn schedule_commit_diff_instruction_for_order_book( payer: Pubkey, + book_manager: Pubkey, order_book: Pubkey, magic_program_id: Pubkey, magic_context_id: Pubkey, ) -> Instruction { let program_id = crate::id(); let account_metas = vec![ AccountMeta::new(payer, true), + AccountMeta::new_readonly(book_manager, true), AccountMeta::new(order_book, false), AccountMeta::new(magic_context_id, false), AccountMeta::new_readonly(magic_program_id, false), ];test-integration/programs/schedulecommit/src/lib.rs (3)
307-341: Missing book_manager signer validation in process_init_order_book.The function validates that
payeris a signer (line 318) but does not validatebook_manager. The instruction builder inapi.rsmarksbook_manageras a signer (line 59), but the handler never checks this.While the function will eventually fail in
allocate_account_and_assign_owner(line 332) when it tries to usebook_manager.keyinsigner_seeds, this produces a less clear error than validating up front.🔎 Recommended fix
assert_is_signer(payer, "payer")?; + assert_is_signer(book_manager, "book_manager")?; let (pda, bump) = Pubkey::find_program_address(
390-423: Missing payer signer validation before delegate_account CPI.The handler calls
delegate_account(line 404), which creates accounts and transfers lamports, without first validating thatpayeris a signer. If the payer flag is missing, the CPI will fail with a less clear error.🔎 Recommended fix
let [payer, order_book, owner_program, buffer, delegation_record, delegation_metadata, delegation_program, system_program] = accounts else { return Err(ProgramError::NotEnoughAccountKeys); }; + assert_is_signer(payer, "payer")?; + let seeds_no_bump = [b"order_book", args.book_manager.as_ref()];
449-469: Missing PDA and ownership validation for order_book_account.The handler schedules a commit and undelegate for
order_book_accountwithout verifying:
- The account is the expected PDA derived from
[b"order_book", book_manager.key]- The account is owned by this program
This allows committing arbitrary accounts via this instruction. While downstream checks in the delegation/magic program may enforce some constraints, explicit validation here would provide clearer error messages and prevent misuse.
Note: Full PDA validation requires
book_managerto be available (either as an additional account or in instruction data) to recompute and verify the PDA.
🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/mod.rs (1)
104-109: Optional: Add Debug derive to CommitTask for consistency.
CommitDiffTaskhasDebugderive (line 111) butCommitTaskdoes not. AddingDebugtoCommitTaskwould improve consistency and provide better error diagnostics during debugging and logging.🔎 Optional enhancement
-#[derive(Clone)] +#[derive(Clone, Debug)] pub struct CommitTask { pub commit_id: u64, pub allow_undelegation: bool, pub committed_account: CommittedAccount, }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
magicblock-committor-service/src/intent_executor/mod.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/api.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/utils/mod.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/schedulecommit/test-security/tests/01_invocations.rstest-integration/test-committor-service/tests/utils/instructions.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- test-integration/test-committor-service/tests/utils/instructions.rs
- test-integration/schedulecommit/test-security/tests/01_invocations.rs
🧰 Additional context used
🧠 Learnings (13)
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
magicblock-committor-service/src/intent_executor/mod.rsmagicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/intent_executor/mod.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/programs/schedulecommit/src/utils/mod.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rstest-integration/schedulecommit/client/src/schedule_commit_context.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/intent_executor/mod.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/programs/schedulecommit/src/utils/mod.rstest-integration/programs/schedulecommit/src/api.rstest-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-10-21T13:06:38.900Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/http/get_program_accounts.rs:17-25
Timestamp: 2025-10-21T13:06:38.900Z
Learning: The magicblock validator does not support ledger forking, so commitment-based state queries (processed/confirmed/finalized) are not applicable. RPC methods can safely ignore commitment and minContextSlot parameters from Solana RPC config objects.
Applied to files:
magicblock-committor-service/src/intent_executor/mod.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/utils/mod.rstest-integration/programs/schedulecommit/src/api.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/client/src/schedule_commit_context.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/client/src/schedule_commit_context.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/utils/mod.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/programs/schedulecommit/src/utils/mod.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-04T10:48:00.070Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/mod.rs:217-219
Timestamp: 2025-11-04T10:48:00.070Z
Learning: In magicblock-validator, the codebase uses a pattern where types containing non-Send/non-Sync fields (like Rc<RefCell<...>>) are marked with unsafe impl Send when they are guaranteed to be confined to a single thread through careful API design and thread spawning patterns.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.
Applied to files:
test-integration/programs/schedulecommit/src/utils/mod.rstest-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
test-integration/programs/schedulecommit/src/lib.rs
🧬 Code graph analysis (7)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (2)
test-integration/programs/schedulecommit/src/api.rs (2)
schedule_commit_diff_instruction_for_order_book(215-234)update_order_book_instruction(197-213)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
get_context_with_delegated_committees(16-35)assert_one_committee_was_committed(41-65)assert_one_committee_account_was_undelegated_on_chain(190-196)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
try_new(72-74)ncommittees(102-121)try_new_random_keys(66-71)
test-integration/programs/schedulecommit/src/utils/mod.rs (1)
magicblock-committor-program/src/state/changeset.rs (1)
lamports(105-110)
test-integration/programs/schedulecommit/src/api.rs (1)
test-integration/programs/flexi-counter/src/state.rs (1)
pda(34-37)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (2)
test-integration/programs/schedulecommit/src/api.rs (2)
pda_and_bump(404-408)schedule_commit_cpi_instruction(177-195)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
get_context_with_delegated_committees(16-35)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
assert_is_signer(30-44)assert_keys_equal(16-28)allocate_account_and_assign_owner(58-109)test-integration/programs/schedulecommit/src/order_book.rs (1)
try_new(109-143)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
test-integration/programs/schedulecommit/src/api.rs (3)
init_order_book_instruction(51-69)init_payer_escrow(92-113)init_account_instruction(31-49)
⏰ 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). (3)
- GitHub Check: run_make_ci_lint
- GitHub Check: run_make_ci_test
- GitHub Check: Build Project
🔇 Additional comments (14)
test-integration/programs/schedulecommit/src/utils/mod.rs (1)
75-79: LGTM! Useful debug logging for test scenarios.The added log statement provides helpful observability by showing the calculated rent requirement and payer's available balance before the transfer operation. This will aid in diagnosing insufficient funds errors during test execution.
magicblock-committor-service/src/intent_executor/mod.rs (2)
9-10: LGTM: Test-only module correctly scoped.The
#[cfg(test)]attribute properly ensures this module is only compiled in test builds, as agreed upon in previous review feedback. The placement is correct per Rust conventions.
28-29: LGTM: Public re-export correctly enables cross-module test usage.The public re-export with
#[cfg(test)]correctly makesNullTaskInfoFetcheravailable to tests in other modules while ensuring it's excluded from production builds.magicblock-committor-service/src/tasks/mod.rs (3)
32-32: LGTM! TaskBuilderImpl re-export enables public builder access.Re-exporting
TaskBuilderImplmakes the builder pattern accessible from the tasks module, which aligns with the PR objective of moving task construction logic into TaskBuilder. This is an intentional public API change.
111-117: LGTM! CommitDiffTask is well-structured.The new
CommitDiffTaskstruct cleanly represents diff-based commits with the requiredbase_accountfield for diff computation. The#[derive(Clone, Debug)]is appropriate and enables proper debugging.
304-445: LGTM! Tests are properly simplified.The serialization tests correctly validate all task variants without unnecessary async complexity. The tests were appropriately simplified per past review feedback to remove
TaskBuilderImplusage from pure serialization validation, keeping them focused and maintainable.Based on past review comments.
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
16-35: LGTM! UserSeeds integration is clean and consistent.The function correctly accepts and forwards the
user_seedparameter to context constructors, and the explicitinit_committees()anddelegate_committees()calls provide clear visibility into the setup flow.test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (3)
56-59: LGTM! Consistent UserSeeds integration.All context creation call sites correctly pass
UserSeeds::MagicScheduleCommitto align with the new API requirements.Also applies to: 176-179, 239-242, 741-744
113-167: LGTM! Order book commit helper is well-structured.The function correctly:
- Creates a context with
UserSeeds::OrderBook- Constructs both the update and schedule-commit instructions
- Bundles them in a single transaction
- Returns the context and transaction result for verification
The implementation mirrors the existing commit helpers and follows established patterns.
300-362: LGTM! Excellent use of seeded randomness for reproducible testing.The test correctly:
- Uses
OsRngto generate a seed andStdRngfor deterministic generation- Prints the seed for easy reproduction on failures (line 309)
- Generates realistic random order book data
- Verifies the committed order book matches the input
- Includes the seed in assertion messages for debugging
The random order book generation and thorough verification logic provide good test coverage for the diff-based commit path.
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
48-51: LGTM! UserSeeds parameter correctly threaded through.All call sites properly pass
UserSeeds::MagicScheduleCommitto align with the updated API signatures.Also applies to: 104-107, 238-238
test-integration/programs/schedulecommit/src/api.rs (1)
16-29: LGTM! Type-safe seed handling.The
UserSeedsenum provides a clean, type-safe alternative to passing raw byte slices. Thebytes()method provides clear mapping to the actual seed values used for PDA derivation.test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
66-80: LGTM! UserSeeds integration is clean.The constructors correctly accept and store the
user_seedparameter, threading it through to internal construction and preserving it in the context struct.Also applies to: 158-158
265-303: LGTM! delegate_committees correctly passes UserSeeds.The function properly forwards
self.user_seedtodelegate_account_cpi_instruction, maintaining type safety with theUserSeedsenum.
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
magicblock-committor-service/src/tasks/args_task.rs (1)
200-206:reset_commit_idmust also handleCommitDifftasks.When a CommitDiff task is recycled, the current code silently returns without updating the commit_id, leaving stale data. This will cause issues if commit IDs need to be refreshed after failures.
🔎 Proposed fix
fn reset_commit_id(&mut self, commit_id: u64) { - let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { - return; - }; - - commit_task.commit_id = commit_id; + match &mut self.task_type { + ArgsTaskType::Commit(task) => { + task.commit_id = commit_id; + } + ArgsTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + _ => {} + } }
♻️ Duplicate comments (6)
test-integration/test-tools/src/scheduled_commits.rs (1)
229-231: Verify if debug logging should be removed per past feedback.Past review comments indicated this unconditional
dump_chain_logsloop should be removed (taco-paco) or gated behind a debug flag. The code remains after recent cleanup commits. Confirm whether this is intentionally retained as temporary debugging code or was overlooked during review cleanup.test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
41-47: Unnecessary trait bounds on genericT.The trait bounds
std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eqare not used by this function. The body only inspectsres.included.len(),res.excluded.len(), andres.included.get(&pda)— none of which require deserializing or comparing values of typeT.🔎 Proposed fix
pub fn assert_one_committee_was_committed<T>( ctx: &ScheduleCommitTestContext, res: &ScheduledCommitResult<T>, is_single_stage: bool, -) where - T: std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq, -{ +) {magicblock-committor-service/src/tasks/task_strategist.rs (2)
419-425: Fix typo in comment: "Noti Found" → "Not Found".🔎 Proposed fix
async fn get_base_accounts( &self, _pubkeys: &[Pubkey], ) -> TaskInfoFetcherResult<HashMap<Pubkey, Account>> { - Ok(Default::default()) + Ok(Default::default()) // Account Not Found }
377-377: Minor: Inconsistent system program import usage.Line 439 uses
system_program::id()while line 497 usessystem_program_id(). Consider using one style consistently.test-integration/programs/schedulecommit/src/lib.rs (2)
359-364: Typo in error message: usespayer.keyinstead ofbook_manager.key.The error message references
payer.keybut should referencebook_manager.keysince the PDA is derived frombook_manager.🔎 Proposed fix
assert_keys_equal(order_book.key, &pda, || { format!( "PDA for the account ('{}') and for book_manager ('{}') is incorrect", - order_book.key, payer.key + order_book.key, book_manager.key ) })?;
390-423:process_delegate_order_bookis missing payer signer validation.The handler performs delegation CPI without first verifying that
payeris a signer. While the CPI may fail with a less clear error, an explicit check provides better error messages.🔎 Proposed fix
pub fn process_delegate_order_book( accounts: &[AccountInfo], args: DelegateOrderBookArgs, ) -> Result<(), ProgramError> { msg!("Processing delegate_order_book instruction"); let [payer, order_book, owner_program, buffer, delegation_record, delegation_metadata, delegation_program, system_program] = accounts else { return Err(ProgramError::NotEnoughAccountKeys); }; + assert_is_signer(payer, "payer")?; + let seeds_no_bump = [b"order_book", args.book_manager.as_ref()];
🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
153-156: Consider usingremoveinstead ofget().cloned()as noted in the TODO.The TODO is valid - if accounts are guaranteed unique (which they should be since they're PDAs), using
removewould avoid the clone overhead. However, keepingget().cloned()is defensive and won't cause correctness issues.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.locktest-integration/schedulecommit/elfs/dlp.sois excluded by!**/*.so
📒 Files selected for processing (32)
Cargo.tomlmagicblock-committor-service/src/intent_executor/mod.rsmagicblock-committor-service/src/intent_executor/null_task_info_fetcher.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/buffer_task.rsmagicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/Cargo.tomltest-integration/programs/schedulecommit/Cargo.tomltest-integration/programs/schedulecommit/src/api.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/programs/schedulecommit/src/utils/mod.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/schedulecommit/client/src/verify.rstest-integration/schedulecommit/test-scenarios/Cargo.tomltest-integration/schedulecommit/test-scenarios/tests/01_commits.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/schedulecommit/test-security/tests/01_invocations.rstest-integration/test-committor-service/Cargo.tomltest-integration/test-committor-service/tests/common.rstest-integration/test-committor-service/tests/test_delivery_preparator.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/test-committor-service/tests/utils/instructions.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-ledger-restore/tests/08_commit_update.rstest-integration/test-tools/src/integration_test_context.rstest-integration/test-tools/src/scheduled_commits.rs
🚧 Files skipped from review as they are similar to previous changes (11)
- Cargo.toml
- test-integration/programs/schedulecommit/Cargo.toml
- magicblock-committor-service/src/intent_executor/mod.rs
- test-integration/schedulecommit/client/src/verify.rs
- test-integration/schedulecommit/test-security/tests/01_invocations.rs
- test-integration/Cargo.toml
- test-integration/test-committor-service/tests/utils/instructions.rs
- test-integration/test-committor-service/tests/test_delivery_preparator.rs
- magicblock-committor-service/src/tasks/buffer_task.rs
- test-integration/programs/schedulecommit/src/api.rs
- test-integration/programs/schedulecommit/src/utils/mod.rs
🧰 Additional context used
🧠 Learnings (21)
📓 Common learnings
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
test-integration/test-ledger-restore/tests/08_commit_update.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rsmagicblock-committor-service/src/intent_executor/null_task_info_fetcher.rstest-integration/test-tools/src/integration_test_context.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/test-tools/src/scheduled_commits.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/schedulecommit/client/src/schedule_commit_context.rsmagicblock-committor-service/src/tasks/args_task.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
test-integration/test-ledger-restore/tests/08_commit_update.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/test-tools/src/integration_test_context.rstest-integration/test-committor-service/tests/utils/transactions.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
test-integration/test-ledger-restore/tests/08_commit_update.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/test-committor-service/tests/test_ix_commit_local.rsmagicblock-committor-service/src/intent_executor/null_task_info_fetcher.rstest-integration/test-tools/src/integration_test_context.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/test-tools/src/scheduled_commits.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
test-integration/test-ledger-restore/tests/08_commit_update.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/programs/schedulecommit/src/order_book.rsmagicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-19T12:55:48.931Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-tools/src/validator.rs:193-197
Timestamp: 2025-11-19T12:55:48.931Z
Learning: In the magicblock-validator codebase, when constructing arguments for the light CLI test validator in start_light_validator_with_config (test-integration/test-tools/src/validator.rs), the shlex::split approach is necessary because the light CLI does not handle whitespaces properly in validator arguments. The string concatenation + shlex parsing pattern should not be refactored to direct argument construction in this specific case.
Applied to files:
test-integration/test-ledger-restore/tests/08_commit_update.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/programs/schedulecommit/src/order_book.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/programs/schedulecommit/src/lib.rsmagicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/programs/schedulecommit/src/order_book.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-10-26T16:53:29.820Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: magicblock-chainlink/src/remote_account_provider/mod.rs:134-0
Timestamp: 2025-10-26T16:53:29.820Z
Learning: In magicblock-chainlink/src/remote_account_provider/mod.rs, the `Endpoint::separate_pubsub_url_and_api_key()` method uses `split_once("?api-key=")` because the api-key parameter is always the only query parameter right after `?`. No additional query parameter parsing is needed for this use case.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
test-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rs
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.
Applied to files:
test-integration/test-committor-service/Cargo.toml
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.
Applied to files:
test-integration/programs/schedulecommit/src/order_book.rstest-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-11-20T08:57:07.217Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 650
File: magicblock-chainlink/src/submux/subscription_task.rs:13-99
Timestamp: 2025-11-20T08:57:07.217Z
Learning: In the magicblock-validator repository, avoid posting review comments that merely confirm code is correct or matches intended behavior without providing actionable feedback, suggestions for improvement, or identifying potential issues. Such confirmatory comments are considered unhelpful noise by the maintainers.
Applied to files:
test-integration/test-tools/src/scheduled_commits.rs
📚 Learning: 2025-11-21T11:03:26.756Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 664
File: magicblock-chainlink/src/testing/mod.rs:342-370
Timestamp: 2025-11-21T11:03:26.756Z
Learning: In the magicblock-validator codebase, avoid leaving review comments that merely acknowledge code is correct or well-structured when there is no actionable suggestion, improvement, or issue to flag. Only comment when there is something specific to recommend, fix, or clarify.
Applied to files:
test-integration/test-tools/src/scheduled_commits.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-04T10:48:00.070Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/mod.rs:217-219
Timestamp: 2025-11-04T10:48:00.070Z
Learning: In magicblock-validator, the codebase uses a pattern where types containing non-Send/non-Sync fields (like Rc<RefCell<...>>) are marked with unsafe impl Send when they are guaranteed to be confined to a single thread through careful API design and thread spawning patterns.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
test-integration/schedulecommit/test-scenarios/Cargo.tomltest-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (11)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
test-integration/test-ledger-restore/src/lib.rs (1)
setup_validator_with_local_remote(104-118)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
get_base_accounts(35-40)test-integration/test-committor-service/tests/common.rs (2)
get_base_accounts(146-163)new(53-56)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (2)
test-integration/test-committor-service/tests/utils/transactions.rs (2)
init_and_delegate_order_book_on_chain(240-298)fund_validator_auth_and_ensure_validator_fees_vault(301-342)test-integration/test-committor-service/tests/utils/mod.rs (1)
ensure_validator_authority(35-44)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
try_new(72-74)ncommittees(102-121)try_new_random_keys(66-71)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (2)
init_account_and_delegate_ixs(21-52)init_order_book_account_and_delegate_ixs(61-94)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (2)
test-integration/programs/schedulecommit/src/api.rs (2)
set_count_instruction(371-379)update_order_book_instruction(197-213)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (2)
get_context_with_delegated_committees(16-35)assert_one_committee_was_committed(41-65)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (4)
test-integration/test-committor-service/tests/common.rs (2)
new(53-56)create_commit_task(175-191)magicblock-committor-service/src/tasks/args_task.rs (1)
new(42-47)magicblock-committor-service/src/tasks/buffer_task.rs (1)
new(40-48)magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-82)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
test-integration/programs/schedulecommit/src/api.rs (3)
init_order_book_instruction(51-69)init_payer_escrow(92-113)init_account_instruction(31-49)
test-integration/programs/schedulecommit/src/lib.rs (3)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
assert_is_signer(30-44)assert_keys_equal(16-28)allocate_account_and_assign_owner(58-109)test-integration/test-tools/src/integration_test_context.rs (2)
delegate_account(601-619)try_new(116-118)test-integration/programs/schedulecommit/src/order_book.rs (1)
try_new(109-143)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
pda_and_bump(404-408)schedule_commit_cpi_instruction(177-195)
test-integration/test-committor-service/tests/common.rs (2)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4)
new(58-65)get_base_accounts(41-44)get_base_accounts(273-290)pubkeys(112-123)magicblock-rpc-client/src/lib.rs (1)
new(243-245)
⏰ 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). (3)
- GitHub Check: run_make_ci_lint
- GitHub Check: run_make_ci_test
- GitHub Check: Build Project
🔇 Additional comments (55)
test-integration/schedulecommit/test-scenarios/Cargo.toml (1)
19-20: Bothrandandborshdev-dependencies are actively used in the test code.randis imported intests/02_commit_and_undelegate.rsfor random number generation (RngCore,SeedableRng), andborshis used intests/utils/mod.rsas a trait bound for deserialization. No issues found.test-integration/test-tools/src/integration_test_context.rs (2)
160-162: LGTM! The format placeholder fix is correct.The error message now properly includes the
labelparameter, so the panic will show which RPC client is missing (e.g., "rpc_client for [chain] does not exist" instead of the literal string "rpc_client for [{}] does not exist").
171-177: LGTM! The conditional transaction version logic is now documented.The added comment clarifies that the chain cluster requires explicit version 0 support while the ephemeral cluster uses default version handling. This makes the conditional logic more maintainable.
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
55-55: LGTM: Proper TempDir lifetime management.Binding the
TempDirto_tmpdir(rather than discarding with_) correctly keeps the temporary directory alive for the entire function scope, preventing premature cleanup while the validator is running. The underscore prefix appropriately signals that the variable is intentionally unused while maintaining the necessary lifetime. This pattern is consistent with line 42.Also applies to: 170-170
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
16-34: LGTM! UserSeeds parameter threading is correct.The
user_seedparameter is properly propagated totry_newandtry_new_random_keys, consistent with theScheduleCommitTestContextAPI shown in the relevant code snippets.test-integration/test-committor-service/Cargo.toml (1)
26-26: LGTM! Dependency addition follows established patterns.The
program-schedulecommitdev-dependency withfeatures = ["no-entrypoint"]is consistent with other program dependencies in this file and enables the test utilities that referenceprogram_schedulecommittypes (e.g.,UserSeeds, order book instructions).magicblock-committor-service/src/tasks/mod.rs (5)
17-17: LGTM! Import addition for Account type.The
solana_account::Accountimport is required for the newCommitDiffTask.base_accountfield.
32-33: LGTM! TaskBuilderImpl re-export.Re-exporting
TaskBuilderImplfrom the module root provides a cleaner public API surface for callers.
111-117: LGTM! CommitDiffTask struct is well-structured.The struct correctly includes
Debugin its derives (addressing past review feedback) and has the required fields for diff-based commits:
commit_idfor transaction orderingallow_undelegationfor post-commit behaviorcommitted_accountcontaining the current ephemeral statebase_accountfor computing the diff against chain state
34-40: LGTM! TaskType enum expansion.The addition of
Finalize,Undelegate, andActionvariants provides complete coverage of the task type system.
304-445: LGTM! Serialization safety tests.The tests properly exercise all
ArgsTaskTypevariants (Commit, Finalize, Undelegate, BaseAction) andBufferTaskinstruction serialization, ensuring instructions can be round-tripped through bincode.magicblock-committor-service/src/tasks/task_strategist.rs (2)
429-468: LGTM! create_test_commit_task helper properly tests diff scenarios.The helper correctly:
- Creates a
CommittedAccountwith the specified data size- When
diff_len > 0, creates a modifiedbase_accountby wrapping bytes to simulate changes- Uses
TaskBuilderImpl::create_commit_taskto produce the appropriate task type based on whether a base_account is providedThis enables testing both CommitState (no base_account) and CommitDiff (with base_account) paths.
561-621: LGTM! Tests for diff-based commit strategy selection.The new tests properly verify the CommitDiff optimization behavior:
test_build_strategy_does_not_optimize_large_account_but_small_diff: 66KB account with threshold-sized diff stays as Argstest_build_strategy_does_not_optimize_large_account_and_above_threshold_diff: 66KB account with diff just above threshold stays as Argstest_build_strategy_does_optimize_large_account_and_large_diff: 66KB account with 4× threshold diff optimizes to BufferThis validates that the CommitDiff strategy avoids buffer overhead when diffs are small enough to fit in instruction args.
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
40-44: LGTM! Batched get_base_accounts trait method.This addresses the past review suggestion for batched base-account fetching. The method signature enables efficient retrieval of multiple accounts in a single RPC call.
272-290: LGTM! CacheTaskInfoFetcher implementation of get_base_accounts.The implementation correctly:
- Uses
get_multiple_accountsfor efficient batched fetching (reducing RPC round-trips)- Maps errors consistently with other methods using
MagicBlockRpcClientError- Filters out
Nonevalues (accounts that don't exist) and returns only found accounts- Returns a
HashMap<Pubkey, Account>for easy lookup by callersThe pattern matches the
MockTaskInfoFetcherimplementation shown in the relevant code snippets.test-integration/test-committor-service/tests/test_ix_commit_local.rs (4)
34-34: LGTM! Import for order book test utilities.The import enables the new order book mutation tests that exercise the CommitDiff path with real on-chain accounts.
98-121: LGTM! Order book mutation tests for CommitDiff.These tests exercise the CommitDiff path by:
- Creating real on-chain order book accounts via
init_and_delegate_order_book_on_chain- Modifying account data to create diffs of varying sizes
- Verifying the correct commit strategy is selected
The boundary tests (679, 680, 681 bytes) document the exact threshold where the strategy transitions from Args to FromBuffer, which is valuable for understanding and debugging the optimization behavior.
188-251: LGTM! commit_book_order_account helper is well-structured.The helper correctly:
- Initializes and delegates an order book on chain (providing a base account for diff computation)
- Modifies
changed_lenbytes withwrapping_add(1)to create predictable diffs- Sets the owner to
program_schedulecommit::id()for proper account handling- Builds and submits the commit intent with appropriate strategy expectations
This enables end-to-end testing of the CommitDiff optimization with real chain state.
260-408: LGTM! Updated strategy expectations reflect Args-based commit flow.The expectation updates (e.g.,
CommitStrategy::Argsinstead ofFromBufferfor various tests) correctly reflect the new commit planner that favors instruction args when transaction size permits. Tests that still expectFromBufferWithLookupTableare for larger bundles where the optimization correctly falls back to buffers.magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
1-41: LGTM! NullTaskInfoFetcher implementation.This is a well-implemented Null Object pattern for testing scenarios that don't require real chain data:
- All fetch methods return empty/default values
get_base_accountsreturns an emptyHashMap, which correctly triggers the CommitState fallback (since no base accounts are found for diff computation)- The implementation is minimal and consistent with the trait contract
This enables unit tests to construct tasks without RPC dependencies.
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (3)
8-8: LGTM! UserSeeds enum import.Using the
UserSeedsenum instead of raw byte strings (as discussed in past reviews) provides type safety and better self-documentation.
48-51: LGTM! UserSeeds parameter usage.The
UserSeeds::MagicScheduleCommitparameter is correctly passed toget_context_with_delegated_committees, consistent with the updated API.
234-239: LGTM! UserSeeds in delegate_account_cpi_instruction.The
UserSeeds::MagicScheduleCommitparameter is correctly passed todelegate_account_cpi_instruction, ensuring consistent seed usage across init and delegate operations.magicblock-committor-service/src/tasks/task_builder.rs (3)
45-51: LGTM! Clear threshold documentation and reasonable default.The 256-byte threshold is well-documented and provides a sensible boundary between small accounts (where full state transfer is efficient) and larger accounts (where diff-based commits reduce data transfer).
53-83: Task creation logic is correct and cleanly structured.The helper correctly:
- Filters out
base_accountfor small accounts (≤ threshold) to force CommitState- Uses CommitDiff only when both the account exceeds the threshold AND a base_account is available
- Falls back to CommitState when base_account fetch fails or returns None
This ensures CommitDiff is only used when it can provide actual benefit.
113-132: Good use of parallel fetching to minimize latency.Using
tokio::join!to fetch commit IDs and base accounts concurrently is the right approach. This addresses the earlier reviewer feedback about sequential network calls.magicblock-committor-service/src/tasks/args_task.rs (4)
1-6: Clean integration of CommitDiff imports and variant.The new imports from
dlp(CommitDiffArgs,CommitStateArgs,compute_diff) and theCommitDiff(CommitDiffTask)variant are properly structured.Also applies to: 23-23
67-85: Instruction building is correct and efficient.The diff is computed at instruction-building time using the stored
base_account, avoiding any network I/O ininstruction(). This addresses the earlier review concern about RPC calls in this method.
134-146: Acknowledged: Temporary downgrade path for CommitDiff optimization.The TODO clearly documents that CommitDiff is converted back to CommitTask when optimizing to BufferTask because BufferTask doesn't yet support CommitDiff. This is a reasonable interim approach.
170-178: Compute units and task type mapping are consistent.CommitDiff correctly uses the same 70,000 compute units as Commit, and mapping both to
TaskType::Commitis reasonable since they're semantically similar operations. Based on learnings, these compute units represent per-task budgets that sum for multi-task transactions.Also applies to: 185-192
test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)
7-11: Import adjustments align with new task creation API.Replacing direct
CommitTaskusage withTaskBuilderImplensures tests use the same task creation logic as production code.
37-47: Test correctly usesTaskBuilderImpl::create_commit_task.Passing
Noneforbase_accountensures a CommitState task is created (since the account data is small), which is appropriate for this test scenario.
93-102: BufferTask creation pattern is correct.The
.task_type.into()chain correctly extracts theArgsTaskTypeand converts it toBufferTaskTypefor buffer-based task preparation.test-integration/test-committor-service/tests/utils/transactions.rs (2)
124-134: Pragmatic handling of CommitState/CommitDiff in log matching.The inline comment explains the rationale well - CommitDiff is an optimized form chosen by the service, so treating "CommitState" needle as matching either variant avoids widespread test changes.
238-298: New order book delegation helper follows established patterns.The
init_and_delegate_order_book_on_chainfunction mirrors the existinginit_and_delegate_account_on_chainstructure, using the appropriate order-book-specific instructions and account destructuring.test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4)
56-59: UserSeeds enum provides type-safe seed selection.Using
UserSeeds::MagicScheduleCommitinstead of raw byte slices improves clarity and prevents mismatched seeds.
113-167: Order book commit helper is well-structured.The function correctly:
- Creates context with
UserSeeds::OrderBook- Constructs update and diff instructions
- Sends transaction and returns result for verification
300-362: Excellent test design with reproducible randomness.The test uses
OsRngto generate a seed, thenStdRngfor deterministic generation. Including the seed in assertion messages enables easy reproduction of failures. The order book verification correctly checks both lengths and content equality.
309-309: Keepingprintln!for the seed is correct.As discussed in past comments, this needs to print even when the test fails so the seed can be used for debugging. Using
debug!would hide this critical information.test-integration/test-committor-service/tests/common.rs (2)
116-119: Mock fetcher now properly wraps the RPC client.The
MockTaskInfoFetcher(MagicblockRpcClient)tuple struct andcreate_task_info_fetcherhelper provide clean test infrastructure.Also applies to: 122-122
146-163:get_base_accountsimplementation correctly mirrors production code.The implementation:
- Calls
get_multiple_accountson the RPC client- Maps errors to
TaskInfoFetcherError::MagicBlockRpcClientError- Filters out
Nonevalues (non-existent accounts) and collects into a HashMapThis matches the pattern in
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs.test-integration/schedulecommit/client/src/schedule_commit_context.rs (4)
66-80: Constructor signatures cleanly propagate UserSeeds.Both
try_new_random_keysandtry_newacceptUserSeedsand delegate to the internal constructor, maintaining a clean API.
115-118: PDA derivation uses the correct seed pattern.Using
user_seed.bytes()ensures the PDA derivation matches the on-chain program's expected seeds.
166-208: Instruction generation correctly branches on UserSeeds variant.The match expression:
MagicScheduleCommit→init_account_instructionOrderBook→init_order_book_instructionThe compute budget instructions (1,400,000 units, 10,000 price) are reasonable for complex initialization transactions.
193-206: Tracked: Commented TODO for grow_order_book.The comment explains the 10KB delegation limit and the planned future work. This is acceptable as a tracked limitation.
test-integration/programs/schedulecommit/src/lib.rs (4)
36-41: Order book module and types are properly integrated.The module structure and public exports (
BookUpdate,OrderBookOwned,OrderLevel) along with the newDelegateOrderBookArgsstruct provide a clean API for order book operations.Also applies to: 56-61
310-341:process_init_order_bookcorrectly allocates and assigns ownership.The function:
- Validates payer is a signer
- Derives the expected PDA
- Validates the provided order_book matches the derived PDA
- Allocates 10KB and assigns to this program
Note: Past review flagged missing
book_managersigner check. Sincebook_manageris used in PDA derivation seeds forallocate_account_and_assign_owner, the operation will fail if the account doesn't match, but an explicit early check would provide clearer errors.
449-469:process_schedulecommit_for_orderbookcorrectly validates payer and commits.The handler validates the payer is a signer before calling
commit_and_undelegate_accounts. The lack of PDA/ownership validation was noted in past reviews, but since this is test code and downstream checks exist, it's acceptable.
822-841: Undelegate handling now supports both account types.The match on
data.len()to determine whether to deserialize asMainAccountorOrderBookis a reasonable approach for this test program. Error logging provides visibility into deserialization failures.test-integration/programs/schedulecommit/src/order_book.rs (6)
1-27: LGTM: Struct definitions and compile-time assertions.The
OrderLevelandBookUpdatestructs are well-defined. The use of#[repr(C)]and compile-time assertions ensures predictable layout and catches size/alignment mismatches at build time.
28-53: LGTM: Header and owned representation.The
OrderBookHeaderandOrderBookOwneddesigns are sound. The conversion correctly reverses asks back to their original order (line 50), matching the internal storage invariant.
86-143: LGTM: Safe construction with proper validation.The
try_newconstructor correctly validates alignment (lines 112–123) and capacity bounds (lines 131–136) before creating typed references. These checks prevent the undefined behavior that would arise from unaligned access or out-of-bounds slices inbids()/asks_reversed().
150-187: LGTM: Safe and correct bid/ask insertion.Both
add_bidsandadd_asksproperly check capacity before using unsafe slices. The unsafe helper methods are sound because:
- Bounds are validated by the capacity check
- Uninitialized memory is immediately filled before the slice is returned
- Header lengths are updated atomically
The reverse-order copy in
add_asks(lines 179–183) correctly implements the storage invariant.
189-210: LGTM: Safe accessors protected by constructor invariants.The unsafe
from_raw_partscalls inbids()andasks_reversed()are sound because:
- The constructor validates alignment (lines 112–123) and capacity bounds (lines 131–136)
add_bids/add_asksare the only mutators and maintain the invariantbids_len + asks_len ≤ capacity- Header is private and cannot be corrupted externally
The u32→usize casts are safe in Solana's 64-bit environment.
212-234: LGTM: Private helpers and capacity calculation are sound.The unsafe helper methods (lines 212–227) are correctly scoped as private and called only after capacity validation by their public callers (
add_bids/add_asks), ensuring bounds are valid.The
remaining_capacitycalculation (lines 229–234) performs u32 arithmetic that cannot overflow in practice: Solana's 10MB account limit means at most ~625K entries (10MB ÷ 16 bytes), well belowu32::MAX. The constructor's capacity check (lines 131–136) ensureschecked_subwill not fail.
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
magicblock-committor-service/src/tasks/task_strategist.rs (2)
377-379: Minor: Inconsistent system program import usage.Two imports for the same program ID are used inconsistently (line 439 uses
system_program::id(), line 497 usessystem_program_id()). Consider consolidating to one style for consistency.🔎 Suggested consolidation
-use solana_program::system_program; use solana_pubkey::Pubkey; use solana_system_program::id as system_program_id;Then update line 439:
- owner: system_program::id(), + owner: system_program_id(),
419-425: MockInfoFetcher returns empty base accounts—intentional limitation.This mock always returns an empty HashMap, so tests using
TaskBuilderImpl::commit_taskswon't exercise theCommitDiffpath. The unit tests in this file work around this by usingcreate_test_commit_task, which directly providesbase_account. For full integration coverage of the diff path, consider adding tests that use a mock returning actual base account data.
🧹 Nitpick comments (2)
magicblock-committor-service/src/tasks/task_builder.rs (2)
119-125: Minor inconsistency: threshold comparisons differ (>=vs>).Line 122 uses
>= COMMIT_STATE_SIZE_THRESHOLDto filter accounts for base fetching, but line 61 uses> COMMIT_STATE_SIZE_THRESHOLDto decide whether to use the diff. This means a 256-byte account will have its base fetched but won't use it (falling back toCommitState). Not incorrect, but wasteful for the edge case.🔎 Align the comparisons
let diffable_pubkeys = accounts .iter() .filter(|account| { - account.account.data.len() >= COMMIT_STATE_SIZE_THRESHOLD + account.account.data.len() > COMMIT_STATE_SIZE_THRESHOLD })
153-156: TODO is valid; consider addressing in this PR.The note about using
remove()instead ofget().cloned()is a minor optimization. If account pubkeys are guaranteed unique (which they likely are given they represent distinct delegated accounts), usingremove()avoids the clone cost.🔎 Use remove if uniqueness is guaranteed
- // TODO (snawaz): if accounts do not have duplicate, then we can use remove - // instead: - // let base_account = base_accounts.remove(&account.pubkey); - let base_account = base_accounts.get(&account.pubkey).cloned(); + let base_account = base_accounts.remove(&account.pubkey);Note: This requires
base_accountsto bemut.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/common.rstest-integration/test-committor-service/tests/test_transaction_preparator.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
🧰 Additional context used
🧠 Learnings (9)
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/test_transaction_preparator.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/test_transaction_preparator.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
test-integration/test-committor-service/tests/test_transaction_preparator.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
test-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
test-integration/test-committor-service/tests/common.rs
🧬 Code graph analysis (3)
magicblock-committor-service/src/tasks/task_builder.rs (3)
test-integration/test-committor-service/tests/common.rs (4)
create_commit_task(175-191)fetch_next_commit_ids(126-131)get_base_accounts(146-163)new(53-56)magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (5)
fetch_next_commit_ids(24-27)fetch_next_commit_ids(166-233)get_base_accounts(41-44)get_base_accounts(273-290)new(58-65)magicblock-committor-service/src/tasks/args_task.rs (1)
new(42-47)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)
test-integration/test-committor-service/tests/common.rs (2)
new(53-56)create_commit_task(175-191)magicblock-committor-service/src/tasks/buffer_task.rs (1)
new(40-48)magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-82)
magicblock-committor-service/src/tasks/task_strategist.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-82)
⏰ 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). (3)
- GitHub Check: Build Project
- GitHub Check: run_make_ci_lint
- GitHub Check: run_make_ci_test
🔇 Additional comments (10)
magicblock-committor-service/src/tasks/task_strategist.rs (2)
429-467: Well-structured test helper for diff scenarios.The helper correctly creates distinct
base_accountdata whendiff_len > 0, enabling proper testing of bothCommitDiffandCommittask paths. Thewrapping_add(1)approach ensures predictable byte differences for the diff encoding.
561-620: Good test coverage for diff-based optimization boundaries.These tests properly verify the optimization behavior around
COMMIT_STATE_SIZE_THRESHOLD:
- Small diff → Args strategy (no buffer needed)
- Threshold+1 diff → Args strategy (still fits)
- Large diff (4×threshold) → Buffer strategy (too large for args)
This addresses the reviewer concern about missing diff test coverage.
test-integration/test-committor-service/tests/test_transaction_preparator.rs (2)
37-47: Correct migration to TaskBuilderImpl for commit task creation.The test now uses
TaskBuilderImpl::create_commit_taskwithNoneforbase_account, which correctly produces aCommitStatetask for the small 5-byte account data. This aligns with the centralized task creation pattern.
93-102: BufferTask construction correctly extracts task_type from ArgsTask.The pattern
.task_type.into()properly converts theArgsTaskTypefrom the returnedArgsTaskintoBufferTaskTypefor buffer-based execution.magicblock-committor-service/src/tasks/task_builder.rs (3)
45-51: Good documentation for the threshold constant.The comment clearly explains the rationale for choosing 256 bytes as the threshold—sufficient for small accounts with typical integer fields. Making this
pub constenables tests to reference it for boundary testing.
127-138: Good use of parallel fetching.Using
tokio::join!to fetch commit IDs and base accounts concurrently reduces latency compared to sequential calls. Error handling correctly propagates failures from either fetch operation.
54-82: Clean encapsulation of commit task creation logic.The helper correctly:
- Clears
base_accountfor accounts at or below threshold (ensuring small accounts always useCommitState)- Creates
CommitDiffwhenbase_accountis provided for large accounts- Falls back to
CommitotherwiseThis centralizes the decision logic and prevents invalid task states.
test-integration/test-committor-service/tests/common.rs (3)
116-119: Good factory method for test infrastructure.Adding
create_task_info_fetcherimproves code reuse and ensures consistent fetcher creation across tests.
146-163: Correct implementation matching the main TaskInfoFetcher.The implementation correctly:
- Calls RPC to fetch multiple accounts
- Wraps errors into
TaskInfoFetcherError- Filters out
Noneresults (missing accounts)- Returns a
HashMap<Pubkey, Account>This mirrors the
CacheTaskInfoFetcherimplementation intask_info_fetcher.rs, ensuring consistent behavior in tests.
122-122: MockTaskInfoFetcher now carries RPC client for real lookups.The tuple struct change enables
get_base_accountsto perform actual RPC calls, which is appropriate for integration tests that need to verify real account data. Thecreate_task_info_fetcherfactory method abstracts construction.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (11)
magicblock-committor-service/src/tasks/args_task.rs (1)
200-206: CommitDiff tasks cannot be recycled—commit_id is never updated.
reset_commit_idonly handlesArgsTaskType::Commit, returning early for all other variants includingCommitDiff. When aCommitDifftask is recycled, the stalecommit_idremains, causing desync in future submissions.🔎 Proposed fix
- let ArgsTaskType::Commit(commit_task) = &mut self.task_type else { - return; - }; - - commit_task.commit_id = commit_id; + match &mut self.task_type { + ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => { + task.commit_id = commit_id; + } + _ => {} + }Based on past review comments.
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
41-47: Remove unused trait bounds.The trait bounds
std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eqare not used by this function. The function body (lines 48-65) only inspects the structure ofScheduledCommitResultand never deserializes, formats, or compares values of typeT.🔎 Proposed fix
pub fn assert_one_committee_was_committed<T>( ctx: &ScheduleCommitTestContext, res: &ScheduledCommitResult<T>, is_single_stage: bool, -) where - T: std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq, -{ +) {Based on past review comments.
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
166-169: Consider extracting compute budget constants.The compute unit limit (1,400,000) and price (10,000) are hardcoded. Extracting these as named constants would improve maintainability.
const INIT_COMPUTE_UNIT_LIMIT: u32 = 1_400_000; const INIT_COMPUTE_UNIT_PRICE: u64 = 10_000; let mut ixs = vec![ ComputeBudgetInstruction::set_compute_unit_limit(INIT_COMPUTE_UNIT_LIMIT), ComputeBudgetInstruction::set_compute_unit_price(INIT_COMPUTE_UNIT_PRICE), ];Based on past review comments.
193-206: Remove commented code block.The 14-line commented TODO about growing order books adds noise. Track the account size limitation and future
grow_order_book_instructionfeature in a GitHub issue, then remove this block.Based on past review comments.
test-integration/programs/schedulecommit/src/api.rs (3)
71-90: Authorization inconsistency:book_managershould be a signer.Line 80 marks
book_manageras a non-signer (false), butinit_order_book_instructionrequiresbook_managerto sign (line 59). This creates an authorization inconsistency where:
- Init requires
book_managersignature- Grow allows any payer to resize someone else's order book
If
book_managershould authorize growth (mirroring init semantics), change line 80 to markbook_manageras a signer and add the corresponding validation inprocess_grow_order_book.🔎 Proposed fix
let account_metas = vec![ AccountMeta::new(payer, true), - AccountMeta::new_readonly(book_manager, false), + AccountMeta::new_readonly(book_manager, true), AccountMeta::new(order_book, false), AccountMeta::new_readonly(system_program::id(), false), ];Based on past review comments.
197-213: Missingbook_managerauthorization.The function omits the
book_manageraccount. Since order books are PDAs derived from[b"order_book", book_manager.key], thebook_manageris the conceptual owner. Without validation, anyone can update any order book.Include
book_managerin the account metas and validate authorization on-chain.🔎 Proposed fix
pub fn update_order_book_instruction( payer: Pubkey, + book_manager: Pubkey, order_book: Pubkey, update: BookUpdate, ) -> Instruction { let program_id = crate::id(); let account_metas = vec![ AccountMeta::new(payer, true), + AccountMeta::new_readonly(book_manager, true), AccountMeta::new(order_book, false), ];Based on past review comments.
215-234: Missingbook_managerauthorization.Similar to
update_order_book_instruction, this function omits thebook_manageraccount. Anyone can schedule commits for any order book without proper authorization.🔎 Proposed fix
pub fn schedule_commit_diff_instruction_for_order_book( payer: Pubkey, + book_manager: Pubkey, order_book: Pubkey, magic_program_id: Pubkey, magic_context_id: Pubkey, ) -> Instruction { let program_id = crate::id(); let account_metas = vec![ AccountMeta::new(payer, true), + AccountMeta::new_readonly(book_manager, true), AccountMeta::new(order_book, false), AccountMeta::new(magic_context_id, false), AccountMeta::new_readonly(magic_program_id, false), ];Based on past review comments.
test-integration/programs/schedulecommit/src/lib.rs (3)
307-341: Missing signer validation:book_managermust be verified.Line 318 validates
payeris a signer, but there's no check forbook_manager. The instruction builder (api.rs line 59) marksbook_manageras a signer, but the handler never validates this. Failing late inallocate_account_and_assign_ownerproduces a less clear error than validating up front.🔎 Proposed fix
assert_is_signer(payer, "payer")?; + assert_is_signer(book_manager, "book_manager")?; let (pda, bump) = Pubkey::find_program_address(Based on past review comments.
390-423: Missing signer validation for payer before delegation CPI.The handler calls
delegate_account(which creates accounts and transfers lamports) without validating thatpayeris a signer. The CPI will fail with a less clear error if the payer flag is missing.🔎 Proposed fix
let [payer, order_book, owner_program, buffer, delegation_record, delegation_metadata, delegation_program, system_program] = accounts else { return Err(ProgramError::NotEnoughAccountKeys); }; + assert_is_signer(payer, "payer")?; + let seeds_no_bump = [b"order_book", args.book_manager.as_ref()];Based on past review comments.
449-469: Missing PDA and ownership validation for order_book_account.The handler schedules a commit and undelegate for
order_book_accountwithout verifying:
- The account is the expected PDA derived from
[b"order_book", book_manager.key]- The account is owned by this program
This allows committing arbitrary accounts via this instruction.
Full PDA validation requires
book_managerto be available (either as an additional account or in instruction data) to recompute and verify the PDA. Add explicit validation:
- Include
book_manageraccount or pass its pubkey in instruction data- Recompute PDA with seeds
[b"order_book", book_manager.key.as_ref()]- Assert
order_book_account.key == &pda- Assert
order_book_account.owner == program_idBased on past review comments.
magicblock-committor-service/src/tasks/task_strategist.rs (1)
420-425: Clarify which tests need CommitDiffTask coverage.MockInfoFetcher returning an empty
HashMapprevents tests usingTaskBuilderImpl::commit_tasks(such astest_build_single_stage_mode,test_build_two_stage_mode_no_alts) from exercising the CommitDiffTask path, sincebase_accountwill always beNone. However, the tests at lines 561-620 usecreate_test_commit_taskdirectly, which bypasses MockInfoFetcher and can already construct CommitDiffTask tasks.If the intent is to add integration tests that verify CommitDiffTask creation through the full
commit_tasksflow, update MockInfoFetcher to conditionally return base accounts for accounts aboveCOMMIT_STATE_SIZE_THRESHOLD. Alternatively, add assertions to the existing strategy tests to verify the task type ofoptimized_tasks[0]using the appropriate accessor method (nottask_type()).
🧹 Nitpick comments (3)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
41-45: Batch base-account fetch implementation looks good; consider an empty-slice fast pathThe new
get_base_accountsAPI andCacheTaskInfoFetcherimplementation correctly mirror the existingget_multiple_accountsusage and safely filter outNoneentries into aHashMap.As a small optimization, you could early-return
Ok(HashMap::new())whenpubkeys.is_empty()to avoid an unnecessary RPC call on the hot path where no diffable accounts exist. This is purely a micro-optimization; the current behavior is functionally fine.Also applies to: 273-290
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
68-121: Order-book commit strategy tests are well-targeted; consider clarifying the 679/680/681 commentThe new single-account and order-book tests nicely exercise the Args vs FromBuffer strategy boundary and verify we can still commit large (10KB) accounts via args when the diff is small.
One nit: in
test_ix_commit_order_book_change_680_bytes, the comment discusses 679/680 while the call useschanged_len = 681. To make future maintenance easier, it may be worth tightening that comment to explicitly mention 681 as the point where you expect the planner to flip fromArgstoFromBuffer, and briefly restate the encoded-size reasoning there.Also applies to: 188-251
magicblock-committor-service/src/tasks/task_builder.rs (1)
45-52: Align threshold comparisons to avoid unnecessary base-account fetches
create_commit_taskuseslen() > COMMIT_STATE_SIZE_THRESHOLDwhilediffable_pubkeysuseslen() >= COMMIT_STATE_SIZE_THRESHOLD. For an account of exactly 256 bytes, this means:
get_base_accountsis called for that pubkey, butcreate_commit_taskwill ignore any returnedbase_accountand fall back to CommitState.Functionally this is harmless but does introduce an avoidable RPC call. Consider making both checks either
>or>=(matching the comment’s intent) so fetch and usage are consistent.Also applies to: 119-125
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.locktest-integration/schedulecommit/elfs/dlp.sois excluded by!**/*.so
📒 Files selected for processing (30)
Cargo.tomlmagicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/buffer_task.rsmagicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/Cargo.tomltest-integration/programs/schedulecommit/Cargo.tomltest-integration/programs/schedulecommit/src/api.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/programs/schedulecommit/src/utils/mod.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/schedulecommit/client/src/verify.rstest-integration/schedulecommit/test-scenarios/Cargo.tomltest-integration/schedulecommit/test-scenarios/tests/01_commits.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/schedulecommit/test-security/tests/01_invocations.rstest-integration/test-committor-service/Cargo.tomltest-integration/test-committor-service/tests/common.rstest-integration/test-committor-service/tests/test_delivery_preparator.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/test-committor-service/tests/utils/instructions.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-ledger-restore/tests/08_commit_update.rstest-integration/test-tools/src/integration_test_context.rstest-integration/test-tools/src/scheduled_commits.rs
🚧 Files skipped from review as they are similar to previous changes (12)
- test-integration/test-tools/src/integration_test_context.rs
- test-integration/programs/schedulecommit/Cargo.toml
- test-integration/test-tools/src/scheduled_commits.rs
- test-integration/test-committor-service/tests/test_delivery_preparator.rs
- test-integration/test-ledger-restore/tests/08_commit_update.rs
- test-integration/programs/schedulecommit/src/utils/mod.rs
- magicblock-committor-service/src/tasks/buffer_task.rs
- Cargo.toml
- test-integration/schedulecommit/client/src/verify.rs
- test-integration/test-committor-service/tests/utils/instructions.rs
- test-integration/test-committor-service/Cargo.toml
- test-integration/test-committor-service/tests/test_transaction_preparator.rs
🧰 Additional context used
🧠 Learnings (20)
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/test-committor-service/tests/test_ix_commit_local.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/programs/schedulecommit/src/lib.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/programs/schedulecommit/src/api.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/client/src/schedule_commit_context.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rstest-integration/test-committor-service/tests/test_ix_commit_local.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/Cargo.tomlmagicblock-committor-service/src/tasks/task_builder.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/schedulecommit/test-security/tests/01_invocations.rsmagicblock-committor-service/src/tasks/args_task.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/test-committor-service/tests/test_ix_commit_local.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/client/src/schedule_commit_context.rsmagicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/programs/schedulecommit/src/api.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-10-26T16:53:29.820Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: magicblock-chainlink/src/remote_account_provider/mod.rs:134-0
Timestamp: 2025-10-26T16:53:29.820Z
Learning: In magicblock-chainlink/src/remote_account_provider/mod.rs, the `Endpoint::separate_pubsub_url_and_api_key()` method uses `split_once("?api-key=")` because the api-key parameter is always the only query parameter right after `?`. No additional query parameter parsing is needed for this use case.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/Cargo.tomlmagicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/test-committor-service/tests/utils/transactions.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rsmagicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
test-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
test-integration/Cargo.tomltest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/test-scenarios/Cargo.toml
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.
Applied to files:
test-integration/Cargo.tomltest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-11-20T08:57:07.217Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 650
File: magicblock-chainlink/src/submux/subscription_task.rs:13-99
Timestamp: 2025-11-20T08:57:07.217Z
Learning: In the magicblock-validator repository, avoid posting review comments that merely confirm code is correct or matches intended behavior without providing actionable feedback, suggestions for improvement, or identifying potential issues. Such confirmatory comments are considered unhelpful noise by the maintainers.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-11-21T11:03:26.756Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 664
File: magicblock-chainlink/src/testing/mod.rs:342-370
Timestamp: 2025-11-21T11:03:26.756Z
Learning: In the magicblock-validator codebase, avoid leaving review comments that merely acknowledge code is correct or well-structured when there is no actionable suggestion, improvement, or issue to flag. Only comment when there is something specific to recommend, fix, or clarify.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-04T10:48:00.070Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/mod.rs:217-219
Timestamp: 2025-11-04T10:48:00.070Z
Learning: In magicblock-validator, the codebase uses a pattern where types containing non-Send/non-Sync fields (like Rc<RefCell<...>>) are marked with unsafe impl Send when they are guaranteed to be confined to a single thread through careful API design and thread spawning patterns.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
🧬 Code graph analysis (12)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
test-integration/test-committor-service/tests/common.rs (2)
get_base_accounts(146-163)new(53-56)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (2)
test-integration/programs/schedulecommit/src/api.rs (3)
schedule_commit_diff_instruction_for_order_book(215-234)set_count_instruction(371-379)update_order_book_instruction(197-213)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
get_context_with_delegated_committees(16-35)assert_one_committee_was_committed(41-65)assert_one_committee_account_was_undelegated_on_chain(190-196)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
pda_and_bump(404-408)schedule_commit_cpi_instruction(177-195)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (3)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
init_and_delegate_order_book_on_chain(240-298)test-integration/test-committor-service/tests/utils/mod.rs (1)
ensure_validator_authority(35-44)magicblock-committor-service/src/service.rs (1)
try_start(262-289)
magicblock-committor-service/src/tasks/task_builder.rs (3)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (5)
fetch_next_commit_ids(24-27)fetch_next_commit_ids(166-233)get_base_accounts(41-44)get_base_accounts(273-290)new(58-65)magicblock-committor-service/src/tasks/args_task.rs (1)
new(42-47)magicblock-committor-service/src/tasks/buffer_task.rs (1)
new(40-48)
test-integration/programs/schedulecommit/src/lib.rs (3)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
assert_is_signer(30-44)assert_keys_equal(16-28)allocate_account_and_assign_owner(58-109)test-integration/test-tools/src/integration_test_context.rs (2)
delegate_account(601-619)try_new(116-118)test-integration/programs/schedulecommit/src/order_book.rs (1)
try_new(106-140)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
test-integration/programs/schedulecommit/src/api.rs (3)
init_order_book_instruction(51-69)init_payer_escrow(92-113)init_account_instruction(31-49)test-integration/test-tools/src/integration_test_context.rs (1)
try_new(116-118)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
try_new(72-74)try_new_random_keys(66-71)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
try_new(72-74)ncommittees(102-121)try_new_random_keys(66-71)
test-integration/programs/schedulecommit/src/api.rs (1)
test-integration/programs/flexi-counter/src/state.rs (1)
pda(34-37)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (3)
init_account_and_delegate_ixs(21-52)init_order_book_account_and_delegate_ixs(61-94)init_validator_fees_vault_ix(5-11)
test-integration/test-committor-service/tests/common.rs (1)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4)
new(58-65)get_base_accounts(41-44)get_base_accounts(273-290)pubkeys(112-123)
⏰ 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). (3)
- GitHub Check: run_make_ci_test
- GitHub Check: run_make_ci_lint
- GitHub Check: Build Project
🔇 Additional comments (8)
test-integration/Cargo.toml (1)
74-74: Dependencies are actively used and appropriately added.The additions of
rkyv = "0.7.45"andstatic_assertions = "1.1.0"to workspace dependencies are correct:
rkyvis actively used intest-integration/programs/schedulecommit/src/order_book.rsfor serialization viarkyv::AlignedVecstatic_assertionsis actively used in the same module for compile-time assertions viaconst_assert- Both are properly referenced as workspace dependencies in the schedulecommit program's Cargo.toml
- Versions are stable and compatible
test-integration/schedulecommit/test-scenarios/Cargo.toml (2)
19-19: LGTM! Appropriate test dependency.Adding
randas a dev-dependency is appropriate for the randomized test scenarios and seeded data generation mentioned in the PR objectives.
20-20: No action needed; borsh version is compatible.The test-scenarios crate does not interact with
magic-domain-programtypes. Addingborsh = { workspace = true }is appropriate for test serialization and uses workspace version 1.5.1, which is compatible with the 1.5.x series used elsewhere in the codebase (including the 1.5.3 pinned inmagicblock-api).Likely an incorrect or invalid review comment.
test-integration/programs/schedulecommit/src/order_book.rs (1)
55-75: Zero‑copyOrderBooklayout and unsafe usage look sound for this test programThe combination of:
repr(C)+const_assert!s on size/alignment,- explicit runtime alignment checks in
try_new,- header bounds check (
bids_len + asks_len <= capacity), and- using
rkyv::AlignedVecin the Borsh pathmakes the typed pointer/slice usages in
bids(),asks_reversed(), and the internal*_with_uninitialized_slotshelpers safe from UB, given Solana’s 10MB account bound.The remaining capacity math and asks/bids layout invariants are consistent with the documented growth model. For a test-only program this is a reasonable and robust design.
Also applies to: 106-140, 186-224, 209-230
magicblock-committor-service/src/tasks/mod.rs (1)
17-17: CommitDiffTask wiring and serialization tests are coherentExposing
TaskBuilderImpland addingCommitDiffTask { …, base_account: Account }integrate cleanly with the existing task/ArgsTask machinery. The serialization tests still cover all Args/Buffer variants (viaCommitTask), and the additional Account import is appropriate for both production and test code. No issues from this module’s changes.Also applies to: 32-33, 111-117, 304-437
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
1-1: UserSeeds integration in context setup is correctPassing
UserSeeds::MagicScheduleCommitintoScheduleCommitTestContext::try_new/try_new_random_keysaligns with the new API and makes the seed choice explicit for these security tests. Behavior remains equivalent to the previous hard-coded seed usage.Also applies to: 28-36
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)
13-19: Order-book CommitDiff flow and randomized regression test look solid
commit_and_undelegate_order_book_accountcorrectly chainsupdate_order_book_instructionwithschedule_commit_diff_instruction_for_order_bookusingUserSeeds::OrderBook, and the huge-order-book test validates that the committedOrderBookOwnedexactly matches the generatedBookUpdate(with a reproducible RNG seed).This gives good end-to-end coverage of the new diff-based order-book path.
Also applies to: 113-167, 300-362
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
5-11: UserSeeds::MagicScheduleCommit wiring keeps commit tests aligned with new APIUpdating both
get_context_with_delegated_committeescallers anddelegate_account_cpi_instructionto passUserSeeds::MagicScheduleCommitmatches the new API surface and makes the seed choice explicit. The commit/undelegate behavior under test remains the same, just parameterized via the enum.Also applies to: 45-52, 101-107, 222-239
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
test-integration/programs/schedulecommit/src/order_book.rs (1)
142-145: Consider failing loudly on capacity exhaustion to maintain test invariants.The current implementation silently ignores failures from
add_bidsandadd_asks, which can leave the order book in a partially updated state if capacity is exhausted mid-update (e.g., bids succeed but asks fail). For test code, this could mask capacity planning issues.Since you stated "It's a test. So let it panic!" in a previous review, consider unwrapping the results to make capacity issues immediately visible:
pub fn update_from(&mut self, updates: BookUpdate) { - self.add_bids(&updates.bids); - self.add_asks(&updates.asks); + self.add_bids(&updates.bids) + .expect("insufficient capacity for bids in update"); + self.add_asks(&updates.asks) + .expect("insufficient capacity for asks in update"); }This ensures test failures are loud rather than leaving the book in an inconsistent state.
🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
137-137: Base account fetch errors silently fall back to CommitState.Using
unwrap_or_default()means any error fetching base accounts is silently ignored, and all affected accounts will use CommitState instead of CommitDiff. This matches the PR's intent that CommitDiff is an optimization, not a requirement.Consider adding a debug/warn log when the fallback occurs to aid troubleshooting:
🔎 Optional: Add warning log on fallback
- let base_accounts = base_accounts.unwrap_or_default(); + let base_accounts = match base_accounts { + Ok(accounts) => accounts, + Err(err) => { + log::warn!( + "Failed to fetch base accounts for CommitDiff (intent_id={}): {}; falling back to CommitState", + base_intent.id, err + ); + Default::default() + } + };
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/test-committor-service/tests/common.rstest-integration/test-committor-service/tests/test_transaction_preparator.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- test-integration/test-committor-service/tests/common.rs
🧰 Additional context used
🧠 Learnings (11)
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/test-committor-service/tests/test_transaction_preparator.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/test-committor-service/tests/test_transaction_preparator.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-10-26T16:53:29.820Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: magicblock-chainlink/src/remote_account_provider/mod.rs:134-0
Timestamp: 2025-10-26T16:53:29.820Z
Learning: In magicblock-chainlink/src/remote_account_provider/mod.rs, the `Endpoint::separate_pubsub_url_and_api_key()` method uses `split_once("?api-key=")` because the api-key parameter is always the only query parameter right after `?`. No additional query parameter parsing is needed for this use case.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rstest-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.
Applied to files:
test-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
test-integration/test-committor-service/tests/test_transaction_preparator.rs
🧬 Code graph analysis (4)
magicblock-committor-service/src/tasks/task_builder.rs (2)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (3)
fetch_next_commit_ids(24-27)fetch_next_commit_ids(166-233)new(58-65)magicblock-committor-service/src/tasks/args_task.rs (1)
new(42-47)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
test-integration/test-committor-service/tests/common.rs (2)
get_base_accounts(146-163)new(53-56)
magicblock-committor-service/src/tasks/task_strategist.rs (3)
magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-82)magicblock-committor-service/src/tasks/args_task.rs (2)
new(42-47)strategy(181-183)magicblock-committor-service/src/tasks/buffer_task.rs (2)
new(40-48)strategy(132-134)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)
test-integration/test-committor-service/tests/common.rs (2)
new(53-56)create_commit_task(175-191)magicblock-committor-service/src/tasks/buffer_task.rs (1)
new(40-48)magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-82)
⏰ 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). (3)
- GitHub Check: Build Project
- GitHub Check: run_make_ci_lint
- GitHub Check: run_make_ci_test
🔇 Additional comments (12)
test-integration/programs/schedulecommit/src/order_book.rs (1)
1-231: LGTM! Previous critical issues have been successfully addressed.The implementation now includes proper safeguards:
- Alignment validation in
try_new(lines 109-120) prevents UB from unaligned typed references- Capacity bounds checking (lines 128-133) ensures header lengths never exceed backing storage
- Mutable aliasing issue resolved with
mut book_bytesbinding (line 64)The unsafe slice operations in
bids(),asks_reversed(), and the internal helpers are now safe because all invariants are established and validated at construction time intry_new.The remaining_capacity arithmetic is correct given Solana's 10MB account limit, as previously discussed.
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
40-44: Trait method addition looks correct.The new
get_base_accountsmethod extends theTaskInfoFetchertrait to support batch fetching of base accounts for CommitDiff optimization. The signature is appropriate for the use case.
273-290: Implementation is correct and handles missing accounts gracefully.The implementation correctly:
- Fetches accounts in a single batched RPC call
- Filters out
Nonevalues for accounts that don't exist- Maps errors appropriately
One observation: unlike
fetch_metadata_with_retries, this method has no retry logic. Per previous review discussions, base account fetching is treated as best-effort (falling back to CommitState if unavailable), so this is acceptable behavior.test-integration/test-committor-service/tests/test_transaction_preparator.rs (2)
38-43: Test now uses TaskBuilderImpl for task construction.Using
TaskBuilderImpl::create_commit_taskensures the test exercises the actual task creation logic and respects theCOMMIT_STATE_SIZE_THRESHOLDinvariants. PassingNoneforbase_accountcorrectly produces aCommitTask(notCommitDiff) since this test uses small account data.
93-102: TheFrom<ArgsTaskType>implementation forBufferTaskTypeis correctly implemented.The
.task_type.into()pattern extractsArgsTaskTypefrom theArgsTaskand converts it toBufferTaskTypevia theFromimplementation defined inmagicblock-committor-service/src/tasks/buffer_task.rs:68. Since the test usescreate_commit_task()which produces aCommitvariant, the conversion succeeds and constructs valid buffer tasks.magicblock-committor-service/src/tasks/task_builder.rs (3)
45-51: Threshold constant is well-documented.The
COMMIT_STATE_SIZE_THRESHOLDof 256 bytes is a reasonable choice for distinguishing small accounts (that benefit from CommitState's simplicity) from larger accounts (that benefit from CommitDiff's reduced data transfer). The comment clearly explains the rationale.
54-82: Task creation logic correctly implements CommitDiff selection.The method properly:
- Checks if the account size exceeds
COMMIT_STATE_SIZE_THRESHOLDbefore usingbase_account- Creates
CommitDiffTaskonly when a validbase_accountis available for large accounts- Falls back to
CommitTaskfor small accounts or when no base account existsThe
.into()conversion at the end cleanly wraps theArgsTaskTypeinto anArgsTask.
152-158: Task creation loop is correct; TODO for future optimization is valid.The TODO notes that
remove()could be used instead ofget().cloned()if accounts are guaranteed unique, which would avoid cloning. This is a reasonable future optimization but the current implementation is correct and safe.magicblock-committor-service/src/tasks/task_strategist.rs (4)
419-425: MockInfoFetcher correctly returns empty map for base accounts.Returning
Ok(Default::default())simulates the scenario where no base accounts are found on-chain, which causes all commit tasks to use CommitState. This is appropriate for existing tests that don't specifically test CommitDiff behavior.
429-468: Test helper correctly scaffolds diff-based commit task creation.The
create_test_commit_taskhelper:
- Creates a
CommitTaskwhendiff_len == 0(no base account)- Creates a
CommitDiffTaskwhendiff_len > 0by generating a modifiedbase_account- Uses
wrapping_add(1)to create realistic byte differencesThe assertion at line 455 guards against test misconfiguration. This enables comprehensive testing of both commit paths.
561-620: New tests comprehensively cover threshold-based optimization decisions.These tests verify the key optimization scenarios:
- Large account, small diff (line 565): Uses Args strategy because CommitDiff instruction is small
- Large account, threshold+1 diff (line 585): Still uses Args - diff is small enough
- Large account, large diff (line 604): Falls back to Buffer strategy when diff exceeds capacity
The tests exercise the new CommitDiff path through
TaskBuilderImpl::create_commit_taskand verify that the strategy selection correctly considers the encoded instruction size, not just raw data size.
502-517: Existing tests correctly updated withdiff_len=0parameter.All existing tests that previously tested CommitState behavior now explicitly pass
diff_len=0, preserving their original semantics while adapting to the new helper signature.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
119-125: Minor inconsistency:>=vs>threshold comparison.The
diffable_pubkeysfilter uses>=(line 122:account.account.data.len() >= COMMIT_STATE_SIZE_THRESHOLD), butcreate_commit_taskuses>(line 61:account.account.data.len() > COMMIT_STATE_SIZE_THRESHOLD).This means accounts with exactly 256 bytes will have their base account fetched but then ignored. Consider aligning both comparisons:
🔎 Proposed fix (use consistent `>` comparison)
let diffable_pubkeys = accounts .iter() .filter(|account| { - account.account.data.len() >= COMMIT_STATE_SIZE_THRESHOLD + account.account.data.len() > COMMIT_STATE_SIZE_THRESHOLD }) .map(|account| account.pubkey) .collect::<Vec<_>>();
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/test-committor-service/tests/common.rstest-integration/test-committor-service/tests/test_transaction_preparator.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
- test-integration/programs/schedulecommit/src/order_book.rs
🧰 Additional context used
🧠 Learnings (8)
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/test_transaction_preparator.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/test_transaction_preparator.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
test-integration/test-committor-service/tests/test_transaction_preparator.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
test-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/test-committor-service/tests/common.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
test-integration/test-committor-service/tests/common.rs
🧬 Code graph analysis (4)
magicblock-committor-service/src/tasks/task_builder.rs (3)
test-integration/test-committor-service/tests/common.rs (4)
create_commit_task(175-191)fetch_next_commit_ids(126-131)get_base_accounts(146-163)new(53-56)magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (5)
fetch_next_commit_ids(24-27)fetch_next_commit_ids(166-233)get_base_accounts(41-44)get_base_accounts(273-290)new(58-65)magicblock-committor-service/src/tasks/args_task.rs (1)
new(42-47)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (2)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
new(40-48)magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-82)
magicblock-committor-service/src/tasks/task_strategist.rs (3)
magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-82)magicblock-committor-service/src/tasks/args_task.rs (1)
strategy(181-183)magicblock-committor-service/src/tasks/buffer_task.rs (1)
strategy(132-134)
test-integration/test-committor-service/tests/common.rs (1)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4)
new(58-65)get_base_accounts(41-44)get_base_accounts(273-290)pubkeys(112-123)
⏰ 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). (2)
- GitHub Check: run_make_ci_test
- GitHub Check: Build Project
🔇 Additional comments (19)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (4)
6-11: Import changes look correct.The imports now reflect the shift to using
TaskBuilderImplfor commit task creation. The removal of directCommitTaskimport and addition ofTaskBuilderImplaligns with the PR's goal of centralizing task creation logic.
37-47: Correct usage ofTaskBuilderImpl::create_commit_task.The test properly uses the new task creation API with
Noneforbase_account, which will produce aCommitTask(notCommitDiff) since the account data is small (5 bytes, well below the 256-byte threshold).
93-122: Buffer task construction pattern is correct.The
.task_type.into()pattern properly extractsArgsTaskTypefrom the createdArgsTaskand converts it toBufferTaskTypefor theBufferTask::new_preparation_requiredcall. This aligns with theBufferTask::newsignature shown in the relevant code snippets.
194-215: Consistent task creation pattern maintained.The
BufferTaskconstruction follows the same pattern established in the previous test, ensuring consistency across the test suite.test-integration/test-committor-service/tests/common.rs (4)
13-14: Import additions are correct.The new imports for
TaskInfoFetcherErrorandTaskInfoFetcherResultare required for implementing theget_base_accountstrait method.
115-119: Good helper extraction forMockTaskInfoFetchercreation.Centralizing
MockTaskInfoFetcherconstruction increate_task_info_fetcherreduces duplication and ensures the mock is consistently initialized with the RPC client across all tests.
122-122: Struct change to hold RPC client is appropriate.Converting
MockTaskInfoFetcherto a tuple struct withMagicblockRpcClientis necessary for theget_base_accountsimplementation to make actual RPC calls in integration tests.
146-163:get_base_accountsimplementation mirrors production code correctly.The implementation follows the same pattern as
CacheTaskInfoFetcher::get_base_accountsshown in the relevant code snippets: callingget_multiple_accounts, mapping errors toTaskInfoFetcherError::MagicBlockRpcClientError, and building aHashMapby filtering outNoneresults.magicblock-committor-service/src/tasks/task_strategist.rs (6)
292-292: Debug log removal is good.Past review comments flagged debug
println!statements; this removal addresses that feedback.
377-393: Import additions support new test functionality.The
system_programandCOMMIT_STATE_SIZE_THRESHOLDimports are required for the updated test helper and new threshold-based test scenarios.
419-425: Mock returns empty base accounts, but new tests cover diff path directly.The
MockInfoFetcher::get_base_accountsreturns an empty map, which means tests usingTaskBuilderImpl::commit_taskswon't createCommitDifftasks. However, the new tests (lines 561-620) correctly test the diff path by callingcreate_test_commit_taskdirectly with abase_account, bypassing the fetcher and validatingcreate_commit_tasklogic.
429-468: Test helper correctly supports both CommitState and CommitDiff paths.The
create_test_commit_taskhelper:
- Creates a
CommittedAccountwithdata_sizebytes- When
diff_len > 0, creates abase_accountwith the firstdiff_lenbytes mutated- Passes the appropriate
base_account(Some or None) toTaskBuilderImpl::create_commit_taskThis design allows testing the threshold-based task type selection in
create_commit_task.
561-620: New threshold-based tests validate diff optimization correctly.These tests verify the strategy selection based on diff size:
- Lines 561-578: Large account (66KB) with small diff (256 bytes) →
TaskStrategy::Args(fits in transaction)- Lines 580-598: Large account with diff just above threshold (257 bytes) →
TaskStrategy::Args(still fits)- Lines 600-620: Large account with large diff (1024 bytes) →
TaskStrategy::Buffer(too large, needs buffer)The tests correctly validate that
CommitDifftasks are optimized to buffers only when the encoded diff exceeds transaction size limits.
505-505: Existing tests correctly updated withdiff_len=0.All pre-existing tests now pass
diff_len=0tocreate_test_commit_task, preserving their original behavior of testing theCommitStatepath.magicblock-committor-service/src/tasks/task_builder.rs (5)
9-13: Import additions are appropriate.The new imports for
Account,CommitDiffTask, andCommitTaskare required for thecreate_commit_taskimplementation.
45-51: Threshold constant is well-documented.The
COMMIT_STATE_SIZE_THRESHOLDof 256 bytes is appropriately documented with rationale for the choice. Making itpubenables its use in tests for threshold-based validation.
53-83:create_commit_taskimplementation is correct and clean.The function properly:
- Only considers
base_accountfor accounts larger than the threshold (line 61:>)- Creates
CommitDiffTaskwhenbase_accountis available- Falls back to
CommitTaskotherwise- Converts to
ArgsTaskvia.into()This ensures small accounts always use the simpler
CommitStatepath regardless of whether base data is available.
137-143: Graceful fallback on base account fetch failure.When
get_base_accountsfails, the code logs a warning and falls back to an empty map, causing all tasks to useCommitStateinstead ofCommitDiff. This is appropriate degradation behavior that prioritizes commit success over optimization.
154-164: Task creation loop correctly uses the new API.The loop properly:
- Retrieves
commit_idfrom the fetched map (with expect for invariant violation)- Clones
base_accountfrom the map when available- Delegates to
create_commit_taskfor task type selectionThe TODO about using
remove()instead ofget().cloned()is a reasonable future optimization if account uniqueness can be guaranteed.
…fficiently commit changes in delegated accounts
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (8)
test-integration/test-committor-service/tests/utils/instructions.rs (1)
2-4: Remove unusedSignerimport; order-book helper looks goodThe
InitOrderBookAndDelegateIxsstruct andinit_order_book_account_and_delegate_ixshelper correctly derive theorder_bookPDA, build the init and delegate instructions, and wireUserSeeds::OrderBook.However,
use test_kit::Signer;is unused and will causeunused_importlints; please drop it unless you plan to call trait methods from this module.The
println!("schedulecommit ID: {}", ID);is test‑only; if you want it to respect log levels, consider switching todebug!, but that’s optional.Also applies to: 54-94
test-integration/programs/schedulecommit/src/api.rs (3)
71-90: Authorization inconsistency: grow_order_book_instruction should require book_manager signature.Line 80 marks
book_manageras read-only non-signer (false), whileinit_order_book_instruction(line 59) marks it as a signer (true). This allows any payer to grow another entity's order book without authorization.If
book_managershould authorize growth (consistent with initialization), update line 80 to require a signature and add the corresponding on-chain validation inprocess_grow_order_book.
197-213: Missing book_manager authorization in update_order_book_instruction.Similar to past feedback, this function omits the
book_manageraccount. Since order books are PDAs derived from[b"order_book", book_manager.key], the conceptual owner should authorize updates.Consider adding
book_manageras a parameter and account meta, then validate authorization on-chain inprocess_update_order_book.
215-234: Missing book_manager authorization in schedule_commit_diff_instruction_for_order_book.As with
update_order_book_instruction, this function lacks thebook_manageraccount, allowing anyone to schedule commits for any order book.Add
book_manageras a parameter and validate authorization on-chain inprocess_schedulecommit_for_orderbook.test-integration/programs/schedulecommit/src/lib.rs (4)
307-341: Missing signer validation for book_manager in process_init_order_book.Line 318 validates
payeris a signer, but there's no corresponding check forbook_manager. The instruction builder inapi.rs(line 59) marksbook_manageras a signer, but this handler never validates it.Add
assert_is_signer(book_manager, "book_manager")?;after line 318 to ensure authorization is checked before account creation.
343-385: Error message typo: should reference book_manager, not payer.Line 362 incorrectly references
payer.keyin the PDA validation error message. It should referencebook_manager.keyto match the PDA derivation logic.🔎 Proposed fix
assert_keys_equal(order_book.key, &pda, || { format!( "PDA for the account ('{}') and for book_manager ('{}') is incorrect", - order_book.key, payer.key + order_book.key, book_manager.key ) })?;
390-423: Missing signer validation for payer in process_delegate_order_book.The handler calls
delegate_account(which creates accounts and transfers lamports) without first validating thatpayeris a signer. Add an explicit signer check before the CPI to provide clear error messages when the payer flag is missing.🔎 Proposed fix
let [payer, order_book, owner_program, buffer, delegation_record, delegation_metadata, delegation_program, system_program] = accounts else { return Err(ProgramError::NotEnoughAccountKeys); }; + assert_is_signer(payer, "payer")?; + let seeds_no_bump = [b"order_book", args.book_manager.as_ref()];
449-469: Missing PDA and ownership validation in process_schedulecommit_for_orderbook.The handler schedules a commit for
order_book_accountwithout verifying:
- The account is the expected PDA derived from the appropriate seeds.
- The account is owned by this program.
This allows committing arbitrary accounts via this instruction. Add explicit validation to verify ownership and optionally validate the PDA derivation if
book_managercan be passed as an account or in instruction data.🔎 Recommended validation
let [payer, order_book_account, magic_context, magic_program] = accounts else { return Err(ProgramError::NotEnoughAccountKeys); }; assert_is_signer(payer, "payer")?; + // Validate order_book_account is owned by this program + if order_book_account.owner != &crate::ID { + msg!("order_book_account must be owned by this program"); + return Err(ProgramError::IllegalOwner); + } + + // Note: Full PDA validation would require book_manager to be passed + // as an account or in instruction data + commit_and_undelegate_accounts(
🧹 Nitpick comments (5)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
273-290: Implementation looks correct.The batched RPC call with proper error wrapping and
filter_mapto exclude missing accounts is well-structured. Consider whether an emptypubkeysslice should short-circuit to avoid an unnecessary RPC call (similar tofetch_metadata_with_retriesat line 73-75), though this is a minor optimization.🔎 Optional: Early return for empty pubkeys
async fn get_base_accounts( &self, pubkeys: &[Pubkey], ) -> TaskInfoFetcherResult<HashMap<Pubkey, Account>> { + if pubkeys.is_empty() { + return Ok(HashMap::new()); + } self.rpc_client .get_multiple_accounts(pubkeys, None)test-integration/test-committor-service/tests/test_delivery_preparator.rs (2)
90-95: Unnecessaryjoin_allfor synchronous operations.The closure
|data| async { ... }doesn't perform any async I/O—create_commit_taskandBufferTask::new_preparation_requiredare synchronous. Wrapping them inasync {}and usingjoin_alladds overhead without concurrency benefit.🔎 Simpler synchronous collection
- let buffer_tasks = join_all(datas.iter().map(|data| async { - let task = BufferTaskType::Commit(create_commit_task(data.as_slice())); - Box::new(BufferTask::new_preparation_required(task)) - as Box<dyn BaseTask> - })) - .await; + let buffer_tasks: Vec<Box<dyn BaseTask>> = datas + .iter() + .map(|data| { + let task = BufferTaskType::Commit(create_commit_task(data.as_slice())); + Box::new(BufferTask::new_preparation_required(task)) as Box<dyn BaseTask> + }) + .collect();
166-170: Same observation:join_allwraps synchronous code.Similar to above—
ArgsTask::from(task)is synchronous, sojoin_allprovides no concurrency benefit here.test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
34-41: Order-book commit helper and strategy tests are sound; watch undelegate semantics laterThe new order-book flow (
init_and_delegate_order_book_on_chain+commit_book_order_account) correctly:
- funds the validator auth,
- starts the committor service,
- initializes and delegates an order-book account,
- mutates exactly
changed_lenbytes before committing, and- verifies the chosen
CommitStrategyfor diff‑vs‑buffer scenarios.The single/multi‑account tests updated to prefer
CommitStrategy::Argsare consistent with a diff‑first planner.One caveat for future extensions:
commit_book_order_accountacceptsundelegate, but all current call sites passfalse. If you later add order‑book tests withundelegate = true,ix_commit_local’sexpected_ownerlogic (which currently assumes flexi‑counter for undelegated accounts) will need to be extended to handle schedulecommit‑owned order‑book accounts.Also applies to: 68-121, 188-251
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
41-47: Generic trait bounds remain unused but acceptable.As noted in previous reviews, the trait bounds
BorshDeserialize,PartialEq, andEqon line 46 are not used by the function body. However, since this has been previously discussed and deferred, leaving them as-is for now is acceptable. Consider removing unused bounds in a future cleanup PR.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.locktest-integration/schedulecommit/elfs/dlp.sois excluded by!**/*.so
📒 Files selected for processing (30)
Cargo.tomlmagicblock-committor-service/src/intent_executor/task_info_fetcher.rsmagicblock-committor-service/src/tasks/args_task.rsmagicblock-committor-service/src/tasks/buffer_task.rsmagicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-committor-service/src/tasks/task_strategist.rstest-integration/Cargo.tomltest-integration/programs/schedulecommit/Cargo.tomltest-integration/programs/schedulecommit/src/api.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/order_book.rstest-integration/programs/schedulecommit/src/utils/mod.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/schedulecommit/client/src/verify.rstest-integration/schedulecommit/test-scenarios/Cargo.tomltest-integration/schedulecommit/test-scenarios/tests/01_commits.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/schedulecommit/test-security/tests/01_invocations.rstest-integration/test-committor-service/Cargo.tomltest-integration/test-committor-service/tests/common.rstest-integration/test-committor-service/tests/test_delivery_preparator.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/test-committor-service/tests/utils/instructions.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/test-ledger-restore/tests/08_commit_update.rstest-integration/test-tools/src/integration_test_context.rstest-integration/test-tools/src/scheduled_commits.rs
🚧 Files skipped from review as they are similar to previous changes (5)
- test-integration/test-tools/src/scheduled_commits.rs
- test-integration/programs/schedulecommit/Cargo.toml
- test-integration/test-tools/src/integration_test_context.rs
- test-integration/programs/schedulecommit/src/utils/mod.rs
- Cargo.toml
🧰 Additional context used
🧠 Learnings (21)
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rstest-integration/schedulecommit/client/src/verify.rstest-integration/test-ledger-restore/tests/08_commit_update.rstest-integration/schedulecommit/test-security/tests/01_invocations.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/common.rstest-integration/test-committor-service/tests/test_delivery_preparator.rsmagicblock-committor-service/src/tasks/args_task.rstest-integration/Cargo.tomltest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/programs/schedulecommit/src/order_book.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rstest-integration/test-ledger-restore/tests/08_commit_update.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/common.rstest-integration/programs/schedulecommit/src/api.rstest-integration/test-committor-service/tests/test_transaction_preparator.rsmagicblock-committor-service/src/tasks/task_builder.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rstest-integration/programs/schedulecommit/src/order_book.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/programs/schedulecommit/src/api.rsmagicblock-committor-service/src/tasks/args_task.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/order_book.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.
Applied to files:
magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
test-integration/schedulecommit/client/src/verify.rstest-integration/schedulecommit/test-scenarios/tests/01_commits.rsmagicblock-committor-service/src/tasks/buffer_task.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_delivery_preparator.rstest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
test-integration/test-ledger-restore/tests/08_commit_update.rsmagicblock-committor-service/src/tasks/buffer_task.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/test-committor-service/tests/test_delivery_preparator.rstest-integration/schedulecommit/test-scenarios/tests/utils/mod.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/programs/schedulecommit/src/lib.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
test-integration/test-ledger-restore/tests/08_commit_update.rsmagicblock-committor-service/src/tasks/mod.rstest-integration/Cargo.tomltest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/utils/transactions.rstest-integration/programs/schedulecommit/src/order_book.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-11-19T12:55:48.931Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-tools/src/validator.rs:193-197
Timestamp: 2025-11-19T12:55:48.931Z
Learning: In the magicblock-validator codebase, when constructing arguments for the light CLI test validator in start_light_validator_with_config (test-integration/test-tools/src/validator.rs), the shlex::split approach is necessary because the light CLI does not handle whitespaces properly in validator arguments. The string concatenation + shlex parsing pattern should not be refactored to direct argument construction in this specific case.
Applied to files:
test-integration/test-ledger-restore/tests/08_commit_update.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
magicblock-committor-service/src/tasks/mod.rstest-integration/schedulecommit/client/src/schedule_commit_context.rstest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/order_book.rsmagicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-04T10:48:00.070Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/mod.rs:217-219
Timestamp: 2025-11-04T10:48:00.070Z
Learning: In magicblock-validator, the codebase uses a pattern where types containing non-Send/non-Sync fields (like Rc<RefCell<...>>) are marked with unsafe impl Send when they are guaranteed to be confined to a single thread through careful API design and thread spawning patterns.
Applied to files:
magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.
Applied to files:
test-integration/test-committor-service/Cargo.tomltest-integration/Cargo.toml
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.
Applied to files:
test-integration/test-committor-service/tests/common.rstest-integration/test-committor-service/tests/test_delivery_preparator.rstest-integration/test-committor-service/tests/test_transaction_preparator.rstest-integration/test-committor-service/tests/test_ix_commit_local.rstest-integration/test-committor-service/tests/utils/transactions.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Applied to files:
test-integration/test-committor-service/tests/test_delivery_preparator.rstest-integration/Cargo.tomltest-integration/programs/schedulecommit/src/lib.rstest-integration/schedulecommit/test-scenarios/Cargo.toml
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.
Applied to files:
test-integration/Cargo.tomltest-integration/programs/schedulecommit/src/lib.rstest-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-11-20T08:57:07.217Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 650
File: magicblock-chainlink/src/submux/subscription_task.rs:13-99
Timestamp: 2025-11-20T08:57:07.217Z
Learning: In the magicblock-validator repository, avoid posting review comments that merely confirm code is correct or matches intended behavior without providing actionable feedback, suggestions for improvement, or identifying potential issues. Such confirmatory comments are considered unhelpful noise by the maintainers.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-11-21T11:03:26.756Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 664
File: magicblock-chainlink/src/testing/mod.rs:342-370
Timestamp: 2025-11-21T11:03:26.756Z
Learning: In the magicblock-validator codebase, avoid leaving review comments that merely acknowledge code is correct or well-structured when there is no actionable suggestion, improvement, or issue to flag. Only comment when there is something specific to recommend, fix, or clarify.
Applied to files:
test-integration/Cargo.toml
📚 Learning: 2025-10-26T16:53:29.820Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: magicblock-chainlink/src/remote_account_provider/mod.rs:134-0
Timestamp: 2025-10-26T16:53:29.820Z
Learning: In magicblock-chainlink/src/remote_account_provider/mod.rs, the `Endpoint::separate_pubsub_url_and_api_key()` method uses `split_once("?api-key=")` because the api-key parameter is always the only query parameter right after `?`. No additional query parameter parsing is needed for this use case.
Applied to files:
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
🧬 Code graph analysis (14)
magicblock-committor-service/src/tasks/task_strategist.rs (4)
magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-82)magicblock-committor-service/src/tasks/args_task.rs (2)
new(42-47)strategy(181-183)magicblock-committor-service/src/tasks/buffer_task.rs (2)
new(40-48)strategy(132-134)magicblock-committor-service/src/tasks/mod.rs (1)
strategy(90-90)
test-integration/test-ledger-restore/tests/08_commit_update.rs (2)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
ctx(148-149)test-integration/test-ledger-restore/src/lib.rs (1)
setup_validator_with_local_remote(104-118)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (2)
test-integration/programs/schedulecommit/src/api.rs (2)
pda_and_bump(404-408)schedule_commit_cpi_instruction(177-195)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
get_context_with_delegated_committees(16-35)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
magicblock-committor-service/src/tasks/args_task.rs (2)
from(36-38)value(210-218)
test-integration/test-committor-service/tests/test_delivery_preparator.rs (2)
test-integration/test-committor-service/tests/common.rs (2)
create_commit_task(175-191)new(53-56)magicblock-committor-service/src/tasks/buffer_task.rs (2)
new(40-48)new_preparation_required(33-38)
test-integration/test-committor-service/tests/utils/instructions.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
init_order_book_instruction(51-69)delegate_account_cpi_instruction(115-164)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)
test-integration/test-committor-service/tests/common.rs (2)
new(53-56)create_commit_task(175-191)magicblock-committor-service/src/tasks/buffer_task.rs (1)
new(40-48)magicblock-committor-service/src/tasks/task_builder.rs (1)
create_commit_task(54-82)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (2)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
ctx(148-149)test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
try_new(72-74)ncommittees(102-121)try_new_random_keys(66-71)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
test-integration/test-committor-service/tests/utils/transactions.rs (2)
init_and_delegate_order_book_on_chain(240-298)fund_validator_auth_and_ensure_validator_fees_vault(301-342)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
test-integration/programs/schedulecommit/src/order_book.rs (1)
try_new(106-140)test-integration/test-tools/src/integration_test_context.rs (1)
try_new(116-118)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (2)
init_account_and_delegate_ixs(21-52)init_order_book_account_and_delegate_ixs(61-94)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
assert_is_signer(30-44)assert_keys_equal(16-28)allocate_account_and_assign_owner(58-109)test-integration/programs/schedulecommit/src/order_book.rs (1)
try_new(106-140)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (3)
test-integration/programs/schedulecommit/src/api.rs (2)
schedule_commit_diff_instruction_for_order_book(215-234)set_count_instruction(371-379)test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (2)
get_context_with_delegated_committees(16-35)assert_one_committee_was_committed(41-65)test-integration/schedulecommit/client/src/verify.rs (1)
fetch_and_verify_order_book_commit_result_from_logs(16-23)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
test-integration/test-committor-service/tests/common.rs (2)
get_base_accounts(146-163)new(53-56)magicblock-rpc-client/src/lib.rs (1)
new(243-245)
⏰ 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). (3)
- GitHub Check: Build Project
- GitHub Check: run_make_ci_test
- GitHub Check: run_make_ci_lint
🔇 Additional comments (36)
test-integration/test-committor-service/Cargo.toml (1)
26-26: LGTM! Consistent dev-dependency addition.The new
program-schedulecommitdev-dependency follows the same pattern asprogram-flexi-counter(line 25) and correctly uses theno-entrypointfeature, which is standard for Solana programs used as library dependencies in tests.Verified that:
- The test-integration workspace
Cargo.tomldefinesprogram-schedulecommitatprograms/schedulecommit- The
program-schedulecommitcrate exports theno-entrypointfeature- This dependency is actively used in test files (e.g.,
test_ix_commit_local.rs)test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
55-61: LGTM! Proper TempDir binding prevents premature cleanup.Binding
_tmpdir(instead of_) ensures theTempDirstays alive for the function scope, preventing the temporary directory from being deleted while the validator is still running.Also applies to: 170-176
test-integration/schedulecommit/test-scenarios/Cargo.toml (1)
19-20: LGTM!Adding
randandborshas workspace dev-dependencies appropriately supports the new OrderBook test scaffolding introduced in this PR.test-integration/Cargo.toml (1)
40-40: LGTM!Dependency updates look appropriate:
ephemeral-rollups-sdkplacement normalizedmagicblock-delegation-programrev bump aligns with CommitDiff supportrkyvandstatic_assertionsadditions support test serialization needsAlso applies to: 60-62, 74-74, 93-93
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
41-44: LGTM! Clean trait extension for batch account fetching.The new
get_base_accountsmethod provides efficient batch retrieval for the CommitDiff optimization path.test-integration/test-committor-service/tests/utils/transactions.rs (3)
16-19: LGTM!Import additions properly expose the new
InitOrderBookAndDelegateIxsfor order book test setup.
124-134: Pragmatic CommitState/CommitDiff handling.The inline comment clearly explains why searching for "CommitState" also matches "CommitDiff"—this accommodates the optimizer's choice without forcing test updates. This trade-off is reasonable given the PR context.
238-298: LGTM! New order book initialization helper.The function follows the established pattern from
init_and_delegate_account_on_chainand correctly handles the two-phase init + delegate flow with thebook_managerkeypair as an additional signer.test-integration/test-committor-service/tests/test_delivery_preparator.rs (1)
2-2: Import added forjoin_all.test-integration/schedulecommit/test-security/tests/01_invocations.rs (2)
1-1: LGTM!Import addition for
UserSeedsalongside existing imports.
30-36: Correctly propagatesUserSeedsto test context constructors.The
UserSeeds::MagicScheduleCommitparameter is now consistently passed to bothtry_newandtry_new_random_keys, aligning with the broader API changes for seed-driven delegation flows.magicblock-committor-service/src/tasks/buffer_task.rs (2)
7-8: LGTM!The cfg guard correctly limits this import to test/dev contexts.
67-76: Temporary test scaffolding acknowledged.Per prior discussion, the
panic!forCommitDiffis intentional—this variant should not reach this code path in current tests, and the message clearly indicates this is temporary until the next PR adds proper support. The cfg guard ensures this doesn't affect production code.test-integration/schedulecommit/client/src/verify.rs (1)
2-23: Order-book verify helper correctly mirrors existing APIThe added
OrderBookOwnedimport andfetch_and_verify_order_book_commit_result_from_logshelper cleanly mirror the existingMainAccount-based function and keep call sites explicit. No changes needed.magicblock-committor-service/src/tasks/mod.rs (1)
17-17: CommitDiffTask and TaskBuilderImpl exposure look consistentImporting
Account, definingCommitDiffTaskwithbase_account: Account, and re‑exportingTaskBuilderImplalign with the new diff‑based commit flow and match the builder API. Struct fields and derives are appropriate; no further changes needed.Also applies to: 32-33, 111-117
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)
13-19: Order-book diff commit flow and randomized test are well wiredThe new order-book path (
commit_and_undelegate_order_book_accountplustest_committing_and_undelegating_huge_order_book_account) correctly usesUserSeeds::OrderBook, wiresupdate_order_book_instructionandschedule_commit_diff_instruction_for_order_book, and validates that the committedOrderBookOwnedexactly matches the generatedBookUpdate(with reproducible RNG seeding). Existing helpers updated to passUserSeeds::MagicScheduleCommitremain consistent with the new API.Also applies to: 113-167, 300-362, 741-744
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
5-11: UserSeeds integration in commit tests is consistentPassing
UserSeeds::MagicScheduleCommitto bothget_context_with_delegated_committeesanddelegate_account_cpi_instructionkeeps PDA derivation and delegation semantics in sync with the updated schedulecommit API. The tests remain logically identical while being explicit about the user seed in use.Also applies to: 45-52, 101-107, 222-239
magicblock-committor-service/src/tasks/task_strategist.rs (1)
377-392: Diff-aware strategist tests correctly exercise COMMIT_STATE_SIZE_THRESHOLD behaviorThe updated test scaffolding—
MockInfoFetcherwithget_base_accounts,create_test_commit_taskfeedingTaskBuilderImpl::create_commit_task, and the new diff‑size‑sensitive tests—does a good job of validating that:
- small diffs on large accounts stay on the Args/CommitDiff path, and
- only when the diff becomes large do we fall back to buffer‑based commits.
This keeps TaskStrategist’s optimization decisions aligned with
COMMIT_STATE_SIZE_THRESHOLDand the real commit task builder. No changes needed.Also applies to: 396-425, 428-468, 503-559, 561-620, 700-711, 713-751, 753-853
magicblock-committor-service/src/tasks/task_builder.rs (4)
45-51: LGTM! Threshold constant is well-documented.The 256-byte threshold is a reasonable choice for distinguishing small accounts that benefit from full-state commits versus larger accounts that benefit from differential commits. The documentation clearly explains the rationale.
53-83: LGTM! Task selection logic is sound.The method correctly:
- Applies the threshold to determine when differential commits are beneficial.
- Gracefully falls back to full-state commits when base_account is unavailable or account is too small.
- Uses field initialization shorthand for cleaner code.
113-143: LGTM! Parallel fetching optimizes latency.The implementation efficiently:
- Fetches commit IDs and base accounts concurrently using
tokio::join!.- Filters accounts by threshold to avoid unnecessary base account fetches.
- Handles errors appropriately: propagates commit ID failures (required) while gracefully degrading to full-state commits when base account fetches fail.
154-164: LGTM! Task creation integrates cleanly with the factory method.The code correctly:
- Retrieves commit IDs with appropriate error handling.
- Clones base accounts from the map (reasonable since the map is only used here).
- Delegates task creation to
create_commit_taskfor consistent behavior.The TODO comment about using
.remove()is a valid micro-optimization for the future if duplicate accounts are confirmed to never occur.test-integration/test-committor-service/tests/test_transaction_preparator.rs (1)
38-43: LGTM! Tests consistently use the factory method.All test cases now create commit tasks via
TaskBuilderImpl::create_commit_task(...), ensuring tests exercise the same code path as production. PassingNoneforbase_accountis appropriate for these tests, which focus on transaction preparation rather than differential commits.Also applies to: 94-101, 106-111, 195-202
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
16-34: LGTM! UserSeeds integration is clean.The function signature now accepts
user_seedand correctly propagates it to the context constructors. The explicit init and delegate calls with transaction hash logging are helpful for debugging test scenarios.test-integration/test-committor-service/tests/common.rs (2)
116-119: LGTM! Helper method simplifies test fixture usage.The
create_task_info_fetcherhelper correctly constructs anArc<MockTaskInfoFetcher>wrapping the test RPC client, centralizing the fetcher creation logic for test code.
122-122: LGTM! MockTaskInfoFetcher implementation is correct.The implementation:
- Correctly delegates to the inner
MagicblockRpcClientfor account fetches.- Maps RPC errors to the appropriate
TaskInfoFetcherErrorvariant.- Filters out
Noneaccounts and zips the results into a HashMap keyed by pubkey.This aligns with the production
CacheTaskInfoFetcherimplementation pattern.Also applies to: 146-163
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
66-80: LGTM! UserSeeds integration is consistent.The constructors now accept
user_seedand store it in the context. The PDA derivation at lines 115-118 correctly usesuser_seed.bytes()andpayer_ephem.pubkey(), matching the on-chain PDA derivation pattern in the program.Also applies to: 115-118
166-208: LGTM! Order-book initialization branch is correct.The
init_committeesmethod:
- Adds compute budget instructions for sufficient CU allocation.
- Branches on
user_seedto call the appropriate initialization instruction (MainAccount vs OrderBook).- The commented-out grow_order_book code (lines 193-206) documents future work but doesn't impede functionality.
The implementation aligns with the program's instruction handlers.
265-275: LGTM! Delegation correctly passes user_seed.The
delegate_committeesmethod now passesself.user_seedtodelegate_account_cpi_instruction, ensuring the CPI instruction derives the correct PDA and uses the appropriate delegation variant (DelegateCpi vs DelegateOrderBook).test-integration/programs/schedulecommit/src/api.rs (1)
16-29: LGTM! UserSeeds enum improves type safety.The enum-based approach is cleaner and safer than passing raw byte slices. The
bytes()helper provides a single source of truth for seed values.test-integration/programs/schedulecommit/src/lib.rs (1)
822-841: LGTM! Undelegate handler gracefully supports multiple account layouts.The updated logic:
- Attempts to deserialize as
MainAccountfirst (matching the discriminant size).- Falls back to
OrderBookfor other sizes.- Logs deserialization failures without failing the transaction (helpful for debugging).
This flexible approach allows undelegation to work across different account types.
test-integration/programs/schedulecommit/src/order_book.rs (5)
10-20: LGTM! Compile-time assertions document alignment requirements.The
const_assert!macros (lines 19-20, 34-35) document the expected alignment and size ofOrderLevelandOrderBookHeader. This helps catch unintended layout changes at compile time.Also applies to: 28-35
55-82: LGTM! Custom deserializer safely handles alignment.The
BorshDeserializeimplementation:
- Uses
rkyv::AlignedVecto ensure proper alignment before constructing theOrderBook.- Copies the input bytes to avoid aliasing violations (appropriate for test code).
- Converts via the safe
try_newconstructor, which validates alignment and capacity.This approach avoids undefined behavior while providing a convenient deserialization path for test code.
106-140: LGTM! Runtime validation prevents undefined behavior.The
try_newmethod includes critical safety checks:
- Lines 109-120: Validates alignment of header and levels to prevent misaligned pointer dereferences.
- Lines 126-133: Validates that header lengths don't exceed capacity, preventing out-of-bounds slice construction in
bids()andasks_reversed().These guards ensure the unsafe operations in this type are sound and will fail cleanly if given malformed data.
142-184: LGTM! Update methods correctly manage bidirectional growth.The
update_from,add_bids, andadd_asksmethods:
- Check remaining capacity before growing (preventing buffer overflows).
- Use
unsafehelpers to access uninitialized slots (appropriate for zero-copy pattern).- Correctly implement the bidirectional growth model (bids from left, asks from right in reverse order).
The implementation is sound given the validation in
try_new.
186-199: LGTM! Accessor methods are safe given validation.The
bids()andasks_reversed()methods useslice::from_raw_partsto create typed slices over the order levels. These operations are safe because:
try_newvalidates alignment.try_newvalidates thatbids_len + asks_len <= capacity.- The layout ensures no overlap between bids and asks regions.
The comment at line 191 correctly notes that
asks_reversed()returns entries in reverse order (latest first).
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
magicblock-committor-service/src/tasks/args_task.rs (2)
67-85: Consider caching the computed diff ifinstruction()may be called multiple times.The diff is computed on-demand each time
instruction()is called. Whilecompute_diffis a pure computation (no I/O), it still involves iterating through the account data. Ifinstruction()can be invoked multiple times for the same task (e.g., during serialization, logging, or retries), the diff would be recomputed unnecessarily.Consider computing the diff once during task construction and storing it in
CommitDiffTask, then referencing the cached value here. This would eliminate redundant computation while keeping the instruction builder clean.💡 Potential optimization approach
Add a
diff: Vec<u8>field toCommitDiffTaskand compute it once during task creation, then reference it here:ArgsTaskType::CommitDiff(value) => { let args = CommitDiffArgs { nonce: value.commit_id, lamports: value.committed_account.account.lamports, - diff: compute_diff( - value.base_account.data(), - value.committed_account.account.data(), - ) - .to_vec(), + diff: value.diff.clone(), allow_undelegation: value.allow_undelegation, };
188-188: Consider whetherCommitDiffwarrants a distinctTaskTypevariant.Mapping
CommitDifftoTaskType::Commitgroups two operations with different characteristics:
Commit: Full state transfer, directly optimizable toBufferTaskCommitDiff: Differential update, downgrades toCommitbeforeBufferTaskconversion (lines 134-146)While grouping them may simplify current logic, a distinct
TaskType::CommitDiffwould:
- Make the execution model differences explicit
- Enable separate metrics/monitoring for diff vs. full commits
- Align type semantics with actual behavior
This aligns with your TODO comment expressing uncertainty about the correct approach. Consider confirming with reviewers whether the semantic distinction justifies a separate variant.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
magicblock-committor-service/src/tasks/args_task.rs
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
Applied to files:
magicblock-committor-service/src/tasks/args_task.rs
⏰ 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). (1)
- GitHub Check: run_make_ci_lint
🔇 Additional comments (4)
magicblock-committor-service/src/tasks/args_task.rs (4)
1-27: LGTM!The imports and type definitions are clean and appropriate for adding CommitDiff support. The new
ArgsTaskType::CommitDiffvariant extends the enum naturally.
134-146: Temporary downgrade is acceptable given planned follow-up work.The TODO clearly documents that this downgrade from
CommitDifftoCommitTaskis temporary untilBufferTasksupportsCommitDiff. This is a reasonable intermediate state, and the explicit comment ensures the technical debt is tracked.
200-212: LGTM!
reset_commit_idnow correctly handles bothCommitandCommitDiffvariants. This addresses the previous critical issue whereCommitDifftasks would retain stale commit IDs during recycling or retries.
219-219: LGTM!The label value
"args_commit_diff"follows the existing naming pattern and enables proper metrics tracking forCommitDifftasks.

This PR does the following things:
CommitDiff. So now when a commit is scheduled, it triggers eitherCommitStateorCommitDiffin the delegation-program, depending on the account size and theCOMMIT_STATE_SIZE_THRESHOLD.CommitDiffis effectively an optimization that reduces the amount of data transferred when committing small changes in large accounts, which improves performance and reduces costs.args, notbufferaccount.OrderBookaccount (10 KB). I initially wanted to try a few MB, but realized currently that’s not possible yet.CommitDiffwas invoked (in the delegation-program) with onlydiff len = 286whereasdata len = 10240(see first screenshot).diff len = 8(encoding the size of account on ER and the number of offset-pairs), and logs a warning (see second screenshot).Update dlp.so
Updated
test-integration/schedulecommit/elfs/dlp.soto use latest version of DLP withCommitDiffix.Changes in the existing tests.
Two kinds of changes:
Since it is
CommitTaskwhich decides the exact DLP instructionCommitStateorCommitDiff, and many tests which earlier used to get executed asBufferTask, will now be executed asArgsTaskbecause large accounts with small changes can be executed asArgsTaskas long as the transaction size stays within limit. So made the related changes in the tests.For some tests, I made the following change:
It is because now
CommitTask::new()uses blockingRpcClientto fetch account from the base chain, so the tests fail because they run in a single-threaded environment, giving this error:Using
multi_threadwith 2 threads makes the tests work again.Screenshots
Summary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.