Skip to content

add index to GSFA response#9683

Merged
sam0x17 merged 24 commits into
anza-xyz:masterfrom
0xMavi:add-index-in-block-field
Jan 23, 2026
Merged

add index to GSFA response#9683
sam0x17 merged 24 commits into
anza-xyz:masterfrom
0xMavi:add-index-in-block-field

Conversation

@0xMavi
Copy link
Copy Markdown

@0xMavi 0xMavi commented Dec 22, 2025

Summary

  • Adds a transactionIndex field to getTransaction and getSignaturesForAddress RPC responses
  • The index represents the transaction's 0-based position within the block's flattened transaction list
  • Enables clients to determine transaction ordering within a block without fetching the entire block

Changes

  • Added index: u32 field to ConfirmedTransactionWithStatusMeta and ConfirmedTransactionStatusWithSignature structs
  • Modified find_transaction_in_slot in blockstore to return (VersionedTransaction, u32) tuple
  • Updated find_address_signatures_for_slot to return index alongside slot and signature
  • Added transaction_index to RpcConfirmedTransactionStatusWithSignature and EncodedConfirmedTransactionWithStatusMeta response types
  • Updated BigTable storage layer to propagate index through transaction lookups
  • Updated CLI code to ignore new struct field

Testing

  • Updated existing unit tests in blockstore.rs to verify index values are correctly returned
  • Tests confirm index matches expected transaction position within entries

@mergify mergify Bot requested a review from a team December 22, 2025 08:59
@0xMavi 0xMavi marked this pull request as ready for review December 22, 2025 09:21
Copy link
Copy Markdown

@sam0x17 sam0x17 left a comment

Choose a reason for hiding this comment

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

few nits, looks good, going to run CI

Comment thread .gitignore Outdated
Comment thread ledger/src/blockstore.rs Outdated
let slot_entries = self.get_slot_entries(slot, 0)?;
Ok(slot_entries
.iter()
.cloned()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

now that I'm seeing this, would be much more efficient if we could avoid doing an iter-level clone here, much better not to clone/copy until we find the versioned transaction we are looking for. Would you mind tweaking that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch! Switched to .into_iter() which consumes the owned Vec - so we don't need to clone the found transaction in the end.

@sam0x17 sam0x17 self-assigned this Jan 14, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 95.45455% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.7%. Comparing base (dca7a1f) to head (dfdb510).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #9683    +/-   ##
========================================
  Coverage    82.7%    82.7%            
========================================
  Files         853      853            
  Lines      319382   319467    +85     
========================================
+ Hits       264145   264269   +124     
+ Misses      55237    55198    -39     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sam0x17
Copy link
Copy Markdown

sam0x17 commented Jan 15, 2026

Just needs that one change and to pass code coverage looks like

@sam0x17
Copy link
Copy Markdown

sam0x17 commented Jan 19, 2026

An additional problem I missed:

the addition of transaction_index to RpcConfirmedTransactionStatusWithSignature and EncodedConfirmedTransactionWithStatusMeta would be a breaking change. We should make this Optional + Default so older clients/nodes don't break things when they don't support the field. Should probably do something like:

#[serde(default, skip_serializing_if = "Option::is_none")]
pub transaction_index: Option<u32>;

Copy link
Copy Markdown

@sam0x17 sam0x17 left a comment

Choose a reason for hiding this comment

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

make non-breaking change by using optional fields

Comment thread .gitignore Outdated
@sam0x17 sam0x17 self-requested a review January 22, 2026 17:08
Copy link
Copy Markdown

@sam0x17 sam0x17 left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Copy Markdown

@sam0x17 sam0x17 left a comment

Choose a reason for hiding this comment

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

semver issue

So right now this PR still adds index: u32 to internal/public structs like:

  • ConfirmedTransactionWithStatusMeta { …, index: u32 }
  • ConfirmedTransactionStatusWithSignature { …, index: u32 }

That’s an additive field, but in Rust it’s still breaking for downstream users doing struct literals or exhaustive destructuring, so this would break semver. In the very least, we need a change that makes these fields optional + default None.

I am double checking with the team to see if this should be a minor bump or a major bump, but minimally we should make it Option

slot vs transaction_slot nit

In find_address_signatures_for_slot, it currently pushes (slot, signature, transaction_index) using the function parameter slot rather than the transaction_slot read from the iterator. It’s probably fine because of the loop’s break condition, but it would be good to tweak this for clarity and future-proofing.

Comment thread transaction-status/src/lib.rs
Comment thread transaction-status-client-types/src/lib.rs
@sam0x17 sam0x17 added the wait for major release This PR should be reconsidered at next major release label Jan 22, 2026
@sam0x17
Copy link
Copy Markdown

sam0x17 commented Jan 22, 2026

Ok I got some clarity, this would indeed be a major version bump because of the addition of fields on public structs

But that is fine, because master is already on 4.0

Copy link
Copy Markdown

@sam0x17 sam0x17 left a comment

Choose a reason for hiding this comment

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

Ok this looks good now, I misspoke about the two last struct changes, we should be good to merge this in 4.x as soon as CI passes

@sam0x17 sam0x17 enabled auto-merge January 23, 2026 17:36
@sam0x17 sam0x17 added this pull request to the merge queue Jan 23, 2026
Merged via the queue into anza-xyz:master with commit c484b43 Jan 23, 2026
61 checks passed
pull Bot pushed a commit to Reality2byte/kit that referenced this pull request May 19, 2026
…za-xyz#1660)

* Add optional transactionIndex to getSignaturesForAddress response

Agave 4.0 (anza-xyz/agave#9683) added the 0 based transaction index inside the block to each signature returned by getSignaturesForAddress. This change exposes the new field on the Kit response type as an optional property so callers can read it where available without breaking against older RPC servers that omit it.

* Add transactionIndex to bigint exclusions

---------

Co-authored-by: Callum <callum.mcintyre@anza.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community need:merge-assist wait for major release This PR should be reconsidered at next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants