Skip to content

[Indexes] Add TxIndex: Transaction index, RPC, and native pruning#860

Open
D-Stacks wants to merge 36 commits intokaspanet:masterfrom
D-Stacks:txindex
Open

[Indexes] Add TxIndex: Transaction index, RPC, and native pruning#860
D-Stacks wants to merge 36 commits intokaspanet:masterfrom
D-Stacks:txindex

Conversation

@D-Stacks
Copy link
Collaborator

@D-Stacks D-Stacks commented Feb 6, 2026

TxIndex: Transaction index, RPC, and pruning

Summary
This PR adds a new optional transaction index (TxIndex) that maintains acceptance and inclusion metadata for transactions, exposes get_transaction via RPC when enabled, supports resync from scratch, live updates from consensus notifications (virtual chain, block, and retention root events), and incremental on-the-fly self-pruning behavior tied to consensus retention root changes.


Activation

  • How to enable: Runtime flag --txindex.

New rpc call: GetTransaction

  • newly supported call when the TxIndex is active.
  • walk-thorough based on rust structs:
  • request:
pub struct GetTransactionRequest {
   // The to-query transaction
   pub transaction_id: RpcTransactionId,
   // weather to include non-accepted transactions into the data.
   // note: if include_unaccepted is false this will only include the data of the transaction that is currently accepted for both transaction as well as inclusion data results, else these will return a vec of all transactions registered by the txindex 
   pub include_unaccepted: bool,
   // the returned verbosity of the RpOptionalTransaction (if any), verbosity mimics GetVirtualChainV2 filtering. 
   // resolved input utxos are supplied on a best effort basis.  
   pub transaction_verbosity: Option<RpcDataVerbosityLevel>,
   // the inclusion data of txs found, 
   pub include_inclusion_data: bool,
   // the current canonical acceptance data found for the transaction (if any)
   pub include_acceptance_data: bool,
   // the confirmation count of the transaction  
   pub include_conf_count: bool,
}
  • response:
pub struct GetTransactionResponse {
    pub transaction_data: Option<RpcTransactionData>,
}
  • new Rpc structs:
pub struct RpcTransactionData {
    pub transactions: Vec<RpcOptionalTransaction>,
    pub inclusion_data: Vec<RpcTransactionInclusionData>,
    pub acceptance_data: Option<RpcTransactionAcceptanceData>,
    pub conf_count: Option<u64>,
}
pub struct RpcTransactionInclusionData {
    /// The hash of the block that includes the transaction
    pub including_block_hash: RpcHash,
    /// This is the daa score of the block that includes the transaction
    pub including_daa_score: u64,
    /// The index within the block that this transaction occupies
    pub index_within_block: TransactionIndexType,
}
pub struct RpcTransactionAcceptanceData {
    /// The hash of the block that accepted the transaction
    pub accepting_block_hash: RpcHash,
    /// The blue score of the block that accepted the transaction
    pub accepting_blue_score: u64,
    /// The index of the including block within the mergeset of the accepting block
    pub mergeset_index: MergesetIndexType,
}

… in consensus client; make non-vec fields optional
…ansactionVerbosity (RpcDataVerbosityLevel); wire through core, grpc convert, service, consensus converter, CLI and tests
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.

1 participant