feat: multiple instructions per crank#6
Conversation
WalkthroughHydra now supports scheduling multiple instructions per crank. The client API, on-chain Create processor, cranker, examples, tests, and README are updated to use ChangesMulti-instruction Hydra scheduling
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/hydra-api/src/instruction.rs (1)
141-143: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winValidate before the lossy wire-format casts.
as u8andas u16silently truncate oversizedmetas/datalengths; the on-chain Create parser then advances using the truncated values while the full bytes remain in the payload, which can reject the Create or deserialize unintended scheduled siblings.Proposed guard before serialization
+ assert!( + !args.scheduled.is_empty(), + "Create requires at least one scheduled instruction" + ); for s in args.scheduled { + assert!( + s.metas.len() <= u8::MAX as usize, + "scheduled instruction has too many account metas" + ); + assert!( + s.data.len() <= u16::MAX as usize, + "scheduled instruction data is too large" + ); data.push(s.metas.len() as u8); data.extend_from_slice(&(s.data.len() as u16).to_le_bytes());🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/hydra-api/src/instruction.rs` around lines 141 - 143, The Create serialization in instruction.rs is casting scheduled payload lengths with lossy conversions in the loop over args.scheduled, so validate each s.metas.len() and s.data.len() before pushing them into data. Add explicit bounds checks in the serialization path that uses args.scheduled, and fail early if either length exceeds what u8 or u16 can represent, so the Create parser never sees truncated lengths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@crates/hydra-api/src/instruction.rs`:
- Around line 141-143: The Create serialization in instruction.rs is casting
scheduled payload lengths with lossy conversions in the loop over
args.scheduled, so validate each s.metas.len() and s.data.len() before pushing
them into data. Add explicit bounds checks in the serialization path that uses
args.scheduled, and fail early if either length exceeds what u8 or u16 can
represent, so the Create parser never sees truncated lengths.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 46c43eaa-5bd0-4ee1-af49-0cc44edb9d16
📒 Files selected for processing (1)
crates/hydra-api/src/instruction.rs
Enables having multiple instructions executed on every trigger.
Summary by CodeRabbit
Release Notes
New Features
Trigger.Documentation
Tests
Examples
CreateArgsscheduled-slice format.Chores