Skip to content

fix: use wire size (1232), not encoded size (1644), for tx fit checks!#1285

Merged
snawaz merged 2 commits into
masterfrom
snawaz/fix-tx-size
Jun 4, 2026
Merged

fix: use wire size (1232), not encoded size (1644), for tx fit checks!#1285
snawaz merged 2 commits into
masterfrom
snawaz/fix-tx-size

Conversation

@snawaz
Copy link
Copy Markdown
Contributor

@snawaz snawaz commented Jun 3, 2026

  • 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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This 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

  • GabrielePicco
  • thlorenz
  • taco-paco
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch snawaz/fix-tx-size

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

❤️ Share

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

Copy link
Copy Markdown
Contributor Author

snawaz commented Jun 3, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee6832 and 1af9f16.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • Cargo.toml
  • magicblock-committor-service/Cargo.toml
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/transactions.rs

Comment thread magicblock-committor-service/src/transactions.rs
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
magicblock-committor-service/src/transactions.rs (1)

69-74: ⚠️ Potential issue | 🟠 Major

Remove 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 enforce MAX_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

📥 Commits

Reviewing files that changed from the base of the PR and between 1af9f16 and 6aa1294.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • magicblock-committor-service/Cargo.toml
  • magicblock-committor-service/src/transactions.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
💤 Files with no reviewable changes (1)
  • magicblock-committor-service/Cargo.toml

@snawaz snawaz marked this pull request as ready for review June 3, 2026 17:28
@snawaz snawaz changed the title fix: Fix committor transaction fit checks to use raw wire size fix: Fix committor transaction fit checks to use raw wire size (1232), not encoded size (1644) Jun 3, 2026
@snawaz snawaz changed the title fix: Fix committor transaction fit checks to use raw wire size (1232), not encoded size (1644) fix: use raw wire size (1232), not encoded size (1644), for committor transaction fit checks! Jun 3, 2026
@snawaz snawaz changed the title fix: use raw wire size (1232), not encoded size (1644), for committor transaction fit checks! fix: use raw wire size (1232), not encoded size (1644), for tx fit checks! Jun 3, 2026
@snawaz snawaz changed the title fix: use raw wire size (1232), not encoded size (1644), for tx fit checks! fix: use wire size (1232), not encoded size (1644), for tx fit checks! Jun 3, 2026
Copy link
Copy Markdown
Contributor

@taco-paco taco-paco left a comment

Choose a reason for hiding this comment

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

LGTM

@snawaz snawaz merged commit 55e3721 into master Jun 4, 2026
46 of 48 checks passed
@snawaz snawaz deleted the snawaz/fix-tx-size branch June 4, 2026 07:09
thlorenz added a commit that referenced this pull request Jun 5, 2026
* 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)
thlorenz added a commit that referenced this pull request Jun 5, 2026
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants