fix(sequencer_rpc): replace unwrap with proper error handling, surface TX validation errors#378
Open
jimmy-claw wants to merge 1 commit intologos-blockchain:mainfrom
Open
Conversation
…e TX validation errors Replace `borsh::from_slice().unwrap()` with `map_err` that returns `RpcError::invalid_params`, preventing a panic that crashes the entire sequencer on malformed borsh input. Replace `mempool.push().expect()` with `map_err` that returns `RpcError::new_internal_error`, so a closed mempool returns a proper JSON-RPC error instead of panicking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 tasks
Arjentix
requested changes
Mar 10, 2026
Comment on lines
+128
to
+133
| .map_err(|_| { | ||
| RpcErr(RpcError::new_internal_error( | ||
| None, | ||
| "Mempool is closed, cannot accept transactions", | ||
| )) | ||
| })?; |
Collaborator
There was a problem hiding this comment.
This is redundant, it's an internal error this should never happen, panicking is okay here
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.
🎯 Purpose
Replaces panicking
unwrap()/expect()calls in the sequencer RPC handler with proper error handling. A single malformed request could previously crash the entire sequencer node (CVE-adjacent). Also surfaces TX validation errors to the caller instead of swallowing them.⚙️ Approach
borsh::from_slice().unwrap()→map_errreturningRpcError::invalid_paramsmempool.push().expect()→map_errreturning structuredRpcError🧪 How to Test
🔗 Dependencies
None.
🔜 Future Work
📋 PR Completion Checklist