fix(sequencer): replace panicking .expect() calls with typed error returns#441
Open
paschal533 wants to merge 2 commits intologos-blockchain:mainfrom
Open
fix(sequencer): replace panicking .expect() calls with typed error returns#441paschal533 wants to merge 2 commits intologos-blockchain:mainfrom
paschal533 wants to merge 2 commits intologos-blockchain:mainfrom
Conversation
This was referenced Apr 11, 2026
…ationError Replace panicking .expect() calls in send_transaction with proper error propagation using TransactionMalformationError variants. Unify the size error to use TransactionMalformationError::TransactionTooLarge instead of a raw format string. Add unit tests for too-large and valid transaction paths.
7f229e5 to
6d7f481
Compare
schouhy
approved these changes
Apr 22, 2026
Collaborator
schouhy
left a comment
There was a problem hiding this comment.
Thanks for the PR. Good catch!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The sequencer service was panicking and crashing the whole process when it received a transaction it could not encode to check its size. Two call sites in
send_transactionused.expect()on operations that can legitimately fail with well-formed client input:borsh::to_vec(&tx).expect(...), can fail if the transaction graph contains types that cannot be serializedu64::try_from(encoded_tx.len()).expect(...), truncation on platforms whereusize > u64maximum, which is not the current target but is still unreachable-panicking codeInstead of killing the server, these paths now return typed
TransactionMalformationErrorvariants over RPC so the caller gets a meaningful error code (InvalidParams) and message.Changes
common/src/transaction.rs, addFrom<TransactionMalformationError> for ErrorObjectOwnedmapping every variant toInvalidParams. Three unit tests verify the mapping for each variant.common/Cargo.toml, addjsonrpseeworkspace dependency (needed by theFromimpl).sequencer/service/src/service.rs, replace both.expect()sites withmap_err(ErrorObjectOwned::from)?, using the newFromimpl. The transaction-too-large check now usessaturating_subto keep the header overhead arithmetic panic-free as well.Why this matters
A single malformed or oversized transaction submitted by any client could previously take down the entire sequencer, requiring a manual restart. With this change the server stays alive and returns the error to the sender.
Test plan
cargo test -p common, three new malformation error mapping testscargo test -p sequencer_service send_transaction, existing tests still pass; the newsend_transaction_too_large_returns_invalid_paramstest verifies the size limit path returnsInvalidParams(not a panic)