solana icon indicating copy to clipboard operation
solana copied to clipboard

Add richer Instruction details to RPC/geyser output

Open CriesofCarrots opened this issue 2 years ago • 5 comments

Problem

RPC getTransaction and geyser transaction-info streaming report some details about transactions, including the fields inner_instructions and return_data. However, inner_instructions is flattened, so it is only possible to know which top-level instruction an inner-ix was invoked within, not the actual order of CPIs. Meanwhile, return_data only reports the last return data written, regardless of how many times it was used in the transactions.

Proposed Solution

Deprecate inner_instructions and return_data from relevant TransactionStatusMeta structs. Add a new field, perhaps rich_instruction_details, that would report inner_instructions as a multidimensional array to reflect actual CPI order/depth. A new instruction struct could also report return_data written, compute units consumed, and syscalls made. Perhaps this struct should include top-level instructions as well in order to provide the rich details consistently.

CriesofCarrots avatar Sep 12 '22 23:09 CriesofCarrots

Sounds great! Though I think we could expand on the existing inner_instructions field in RPC responses rather than replace it with a new field. I'm in favor of deprecating return_data though

jstarry avatar Sep 12 '22 23:09 jstarry

I would love to see this,

Perhaps its a as simple as adding the stack height in each inner instruction, then you can keep the same setup excep the innner instruction struct would change from

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InnerInstructions {
    /// Transaction instruction index
    pub index: u8,
    /// List of inner instructions
    pub instructions: Vec<CompiledInstruction>,
}

to

pub struct CompiledInnerInstruction {
  pub stack_height: u8,
  pub instruction: CompiledInstruction
}


#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct InnerInstructions {
    /// Transaction instruction index
    pub index: u8,
    /// List of inner instructions
    pub instructions: Vec<CompiledInnerInstruction>,
}

Or something similar.

austbot avatar Sep 13 '22 18:09 austbot

https://github.com/solana-labs/solana/pull/28430 adds the stack_height for inner instructions. It would still be nice to record return data and compute units used for each instruction

jstarry avatar Oct 24 '22 07:10 jstarry

#28430 adds stack height true, but it does not expose this to the geyser in any way.

austbot avatar Feb 17 '23 15:02 austbot

looks like this is included in 1.15

austbot avatar Feb 17 '23 15:02 austbot