Skip to content

Comments

Add defensive coding and matching unit tests for fee bumps#605

Merged
Shaptic merged 3 commits intomainfrom
defensive-fee-bump
Feb 19, 2026
Merged

Add defensive coding and matching unit tests for fee bumps#605
Shaptic merged 3 commits intomainfrom
defensive-fee-bump

Conversation

@Shaptic
Copy link
Contributor

@Shaptic Shaptic commented Feb 18, 2026

What

Add guardrails around accessing possibly-nil pointers when inspecting transactions.

Why

When passing a fee-bump transaction containing a soroban operation, the following check:

			if txEnvelope.Type != xdr.EnvelopeTypeEnvelopeTypeTx && txEnvelope.V1.Tx.Ext.V != 1 {

would cause a nil pointer reference because V1 is nil. While this has no security implications (the panic is simply caught and logged like any other error), it is good to be defensive.

Copilot AI review requested due to automatic review settings February 18, 2026 22:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds defensive nil pointer checks when extracting Soroban transaction data from transaction envelopes, preventing panics when processing fee-bump transactions containing Soroban operations. The changes refactor the code into well-structured helper functions and add comprehensive test coverage.

Changes:

  • Introduced sorobanDataFromEnvelope and sorobanDataFromTx helper functions with defensive nil checks for all pointer accesses
  • Refactored existing code to use new helper functions, eliminating unsafe nil pointer access in fee-bump transaction handling
  • Added unit test verifying that fee-bump transactions with missing Soroban data return appropriate error messages instead of panicking

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/stellar-rpc/internal/methods/simulate_transaction.go Added two helper functions with comprehensive nil checks; replaced unsafe direct field access with calls to these helpers
cmd/stellar-rpc/internal/methods/simulate_transaction_test.go Added test case and helper function to verify fee-bump transactions without Soroban data are handled gracefully

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Shaptic Shaptic enabled auto-merge (squash) February 19, 2026 00:47
@Shaptic Shaptic merged commit a431ae0 into main Feb 19, 2026
40 checks passed
@Shaptic Shaptic deleted the defensive-fee-bump branch February 19, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants