Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVM: account_loader.rs generic over SVMMessage #2303

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

apfitzge
Copy link

@apfitzge apfitzge commented Jul 26, 2024

Problem

#2109 - for SVM to be generic over transaction/message type, account_loader.rs must be generic over the traits

Summary of Changes

  • Make functions in account_loader.rs generic over SVMMessage

Fixes #2109

@apfitzge apfitzge marked this pull request as ready for review July 26, 2024 17:39
@apfitzge apfitzge requested review from LucasSte and buffalojoec July 26, 2024 17:39
Copy link

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

Woohoo!

AccountSharedData::from(Account {
data: construct_instructions_data(&message.decompile_instructions()),
data: construct_instructions_data(&decompiled_instructions),
Copy link

@LucasSte LucasSte Jul 29, 2024

Choose a reason for hiding this comment

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

The original decompile_instructions function is also used in benchmarks and some tests. Have you considered adding it to your trait?

I am thinking that these new lines may become repeated code at some point.

Copy link
Author

Choose a reason for hiding this comment

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

I originally had it as a function, but the only part in actual code it was called was here. Removed as part of the trait simplification.

But also wanted to remove the allocation that BorrowedInstruction requires:

pub struct BorrowedInstruction<'a> {
    pub program_id: &'a Pubkey,
    pub accounts: Vec<BorrowedAccountMeta<'a>>, //<-- allocation here
    pub data: &'a [u8],
}

In this first step I'm just doing a drop-in replacement where we still do this allocation.
As a follow-up I will write a version of construct_instructions_data (and its' input) that require no allocations).
This was the reasoning I had behind not having this as part of the trait.

@apfitzge apfitzge force-pushed the apfitzge/issue2108 branch from 51039e7 to 7d33ed7 Compare August 1, 2024 16:06
@apfitzge
Copy link
Author

apfitzge commented Aug 1, 2024

rebased on master to remove the dependency add commit - last time I relied on auto-merging it seemed to break CI: see #2388

@apfitzge apfitzge linked an issue Aug 1, 2024 that may be closed by this pull request
@apfitzge apfitzge merged commit e8ec9dc into anza-xyz:master Aug 1, 2024
42 checks passed
@apfitzge apfitzge deleted the apfitzge/issue2108 branch August 1, 2024 17:45
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.

SVM: account_loader.rs generic over SVMMessage
3 participants