fix: use wire size (1232), not encoded size (1644), for tx fit checks!#1285
Conversation
📝 WalkthroughWalkthroughThis PR replaces base64-encoded transaction size checks with serialized wire-size checks. It adds MAX_TRANSACTION_WIRE_SIZE derived from solana_packet::PACKET_DATA_SIZE, a serialized_transaction_size helper using bincode, updates packing constants (process-and-close 5→4, undelegate 16→15), switches all size comparisons in task strategist and transaction helpers to use wire-size, updates tests to measure wire-size, and adds solana-packet to workspace/crate dependencies while removing base64 from the crate dependencies. Suggested reviewers
✨ Finishing Touches🧪 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 |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@magicblock-committor-service/src/transactions.rs`:
- Around line 86-91: The function serialized_transaction_size currently calls
bincode::serialized_size(transaction).unwrap() and
usize::try_from(...).unwrap(), which can panic; change the API to return a
Result<usize, E> (e.g., Result<usize, anyhow::Error> or a crate-specific error)
so callers handle serialization failures and width-conversion failures. Inside
serialized_transaction_size (and when referencing SerializableTransaction), call
bincode::serialized_size(transaction) and propagate errors (map bincode::Error
to your error type), then convert the u64 size to usize using
usize::try_from(size).map_err(...) and return that Result instead of unwrapping.
Update any callers to handle the Result accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7c024429-37b3-4665-9871-7366755cc779
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
Cargo.tomlmagicblock-committor-service/Cargo.tomlmagicblock-committor-service/src/tasks/mod.rsmagicblock-committor-service/src/tasks/task_strategist.rsmagicblock-committor-service/src/transactions.rs
There was a problem hiding this comment.
♻️ Duplicate comments (1)
magicblock-committor-service/src/transactions.rs (1)
69-74:⚠️ Potential issue | 🟠 MajorRemove the panic path from
serialized_transaction_size.This helper still has two
.unwrap()calls in production code, so a serialization failure here aborts sizing/strategy selection instead of surfacing an error to callers that enforceMAX_TRANSACTION_WIRE_SIZE.As per coding guidelines: "Treat any usage of
.unwrap()or.expect()in production Rust code as a MAJOR issue."🤖 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 `@magicblock-committor-service/src/transactions.rs` around lines 69 - 74, serialized_transaction_size currently panics via two .unwrap() calls; change its signature from fn serialized_transaction_size(transaction: &impl SerializableTransaction) -> usize to return a Result<usize, Box<dyn std::error::Error + Send + Sync>> (or a concrete error type used in the crate), then propagate errors instead of unwrapping: call bincode::serialized_size(transaction)? to get the u64 and convert it with usize::try_from(...)? (or .try_into()?) and map/propagate the TryFromIntError so callers can handle serialization/size failures; keep the function name serialized_transaction_size and the SerializableTransaction trait reference so the change is localized.
🤖 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.
Duplicate comments:
In `@magicblock-committor-service/src/transactions.rs`:
- Around line 69-74: serialized_transaction_size currently panics via two
.unwrap() calls; change its signature from fn
serialized_transaction_size(transaction: &impl SerializableTransaction) -> usize
to return a Result<usize, Box<dyn std::error::Error + Send + Sync>> (or a
concrete error type used in the crate), then propagate errors instead of
unwrapping: call bincode::serialized_size(transaction)? to get the u64 and
convert it with usize::try_from(...)? (or .try_into()?) and map/propagate the
TryFromIntError so callers can handle serialization/size failures; keep the
function name serialized_transaction_size and the SerializableTransaction trait
reference so the change is localized.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4245a7ca-d273-4629-9922-dc0069eb8960
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.locktest-integration/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
magicblock-committor-service/Cargo.tomlmagicblock-committor-service/src/transactions.rstest-integration/test-committor-service/tests/test_ix_commit_local.rs
💤 Files with no reviewable changes (1)
- magicblock-committor-service/Cargo.toml
* master: fix: reject short account responses (#1290) fix: wait for pubsub listeners before reconnect (#1253) fix: retry failed program subscriptions (#1268) release: 0.12.0 (#1299) Ignore compute unit price in processor fees (#1298) Recover recent pending intents on restart (#1296) chore: adjust log level (#1297) release: v0.11.4 (#1292) fix(scheduler): remove block subscription in the scheduler (#1293) fix(committor): race-condition on cleanup (#1291) Handle ALT extend invalid instruction data (#1287) fix: use provided compute limits instead of defaults (#1289) feat: snapshot accountsdb even in the replica mode (#1282) feat: added vrf ephemeral test queue, delegation record and metadata for mb-test-validator (#1281) fix: use wire size (1232), not encoded size (1644), for tx fit checks! (#1285) chore: simplify, rename out_of_order_slot and add a comment (#1284) fix: execute post-delegation actions after clone (#1278) Handle oversized single-stage committor transactions (#1277) Reduce committor RPC confirmation calls (#1271) fix: preserve streams on optimize failure (#1273)
* master: fix: reject short account responses (#1290) fix: wait for pubsub listeners before reconnect (#1253) fix: retry failed program subscriptions (#1268) release: 0.12.0 (#1299) Ignore compute unit price in processor fees (#1298) Recover recent pending intents on restart (#1296) chore: adjust log level (#1297) release: v0.11.4 (#1292) fix(scheduler): remove block subscription in the scheduler (#1293) fix(committor): race-condition on cleanup (#1291) Handle ALT extend invalid instruction data (#1287) fix: use provided compute limits instead of defaults (#1289) feat: snapshot accountsdb even in the replica mode (#1282) feat: added vrf ephemeral test queue, delegation record and metadata for mb-test-validator (#1281) fix: use wire size (1232), not encoded size (1644), for tx fit checks! (#1285)

Use the serialized transaction wire size for committor fit checks because Solana sendability is capped by
PACKET_DATA_SIZE (1232 bytes), not the RPC base64 string limit (1644).bug: the old encoded-length check was imprecise: raw sizes like 1231, 1232, and 1233 all encode to 1644 bytes, so we could accept a 1233-byte transaction that cannot be sent.