3

I'm looking to create a data pipeline that gets traces (both value transfers and contract executions like on the EVM) but, I can't find the equivalent to it on Solana's VM.

What is the equivalent to EVM traces in Solana's VM?

Appreciate any help in this direction.

Cheers!

Update:

So while I made some progress, I'm still in a quandary on how to get all lowest-level traces of transactions when Inner Instructions can be disabled.

1 Answer 1

1

I'm not very familiar with EVM traces but it seems very similar to emitting events in Solana.

We use events to log messages (anything you would do with msg!()). But they are not human readable as they are base64 encoded. Also msg!() with string formatting is relatively expensive for compute units

Here is an example

pub fn initialize(_ctx: Context<Initialize>) -> Result<()> {
        emit!(MyEvent {
            data: 5,
            label: "hello".to_string(),
        });
        Ok(())
    }

#[event]
pub struct MyEvent {
    pub data: u64,
    #[index]
    pub label: String,
}

And in the client side, you listen for events

listener = program.addEventListener("MyEvent", (event, slot) => {
    console.log([event, slot]);

    //      [ { data: 5,
    //        label: "hello".to_string(), } ,
    //       123131313 ]

});
3
  • thanks for getting back so quickly! That's very interesting. Actually in EVM, the solidity smart contract language has Emit/Events as well which looks similar to what you've shown. From what I understand about EVM traces, they exist at an abstraction level below solidity, closer to the byte code layer. Its meant to grap any type of transaction (b/w accounts, contracts and account-contracts) on the entire blockchain. So wondering if Solana has something like that. And the Inner Instruction looked like it.
    – witwiki
    Commented Feb 16, 2023 at 1:31
  • The mapping of the EVM Emit/Events is to msg! at Solana. Anchor framework provides the emit! macro with functionality but still based on top fo the msg! call. I think there is no more functionality above that. You can check discussion around the topic of events at Solana issues github.com/solana-labs/solana/issues/14076
    – chalda
    Commented Feb 16, 2023 at 9:47
  • + it sounds strange to me that the inner instructions could be somehow disabled. But I acknowledge that I don't know what exactly the documentation means with the phrase null if inner instruction recording was not enabled during this transaction. To me the inner transaction is recorded when they are called (a CPI call happens). When there is no CPI call then no inner transaction can be recorded. Strange that there could be some special switch for recording or not recording.
    – chalda
    Commented Feb 16, 2023 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.