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

Harness: Dedupe accounts and coalesce privileges #28

Merged
merged 3 commits into from
Oct 16, 2024
Merged

Conversation

buffalojoec
Copy link
Owner

Problem

Currently, if you provide the same account twice to Mollusk's process_instruction API, the permissions are taken directly from the instruction AccountMeta entries, so even if two metas have the same public key, their perms as AccountInfo will reflect those of the instruction metas.

In other words, if I provide the same account twice, as so...

let key = Pubkey::new_unique();
let metas = vec![
    AccountMeta::new(key, false),         // writable
    AccountMeta::new_readonly(key, true), // signer
];

... then my program will see the first account as writable, and the second as a signer, but they will have the same address. These must be coalesced, as is done in the VM's serialization step. Unfortunately, this deduping depends on the TransactionContext, so this fix has to go into Mollusk!

Summary of Changes

Employ a simple map and an extra iteration to coalesce account privileges across accounts with the same address.

@buffalojoec buffalojoec merged commit 8691813 into main Oct 16, 2024
4 checks passed
@buffalojoec buffalojoec deleted the tx-acct-dedupe branch October 16, 2024 14:44
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