-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate key deduplication logic into standalone crate (#36)
- Loading branch information
1 parent
6810892
commit fab7c1f
Showing
14 changed files
with
493 additions
and
171 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "mollusk-svm-error" | ||
description = "Errors thrown by the Mollusk SVM harness." | ||
documentation = "https://docs.rs/mollusk-svm-error" | ||
authors = { workspace = true } | ||
repository = { workspace = true } | ||
readme = { workspace = true } | ||
license = { workspace = true } | ||
edition = { workspace = true } | ||
version = { workspace = true } | ||
|
||
[dependencies] | ||
solana-sdk = { workspace = true } | ||
thiserror = { workspace = true } |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! Errors thrown by the Mollusk SVM harness. | ||
|
||
pub mod error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//! Instruction <-> Transaction account compilation, with key deduplication, | ||
//! privilege handling, and program account stubbing. | ||
|
||
use { | ||
mollusk_svm_keys::{ | ||
accounts::{ | ||
compile_instruction_accounts, compile_instruction_without_data, | ||
compile_transaction_accounts_for_instruction, | ||
}, | ||
keys::KeyMap, | ||
}, | ||
solana_sdk::{ | ||
account::{AccountSharedData, WritableAccount}, | ||
instruction::Instruction, | ||
pubkey::Pubkey, | ||
transaction_context::{InstructionAccount, TransactionAccount}, | ||
}, | ||
}; | ||
|
||
pub struct CompiledAccounts { | ||
pub program_id_index: u16, | ||
pub instruction_accounts: Vec<InstructionAccount>, | ||
pub transaction_accounts: Vec<TransactionAccount>, | ||
} | ||
|
||
pub fn compile_accounts( | ||
instruction: &Instruction, | ||
accounts: &[(Pubkey, AccountSharedData)], | ||
loader_key: Pubkey, | ||
) -> CompiledAccounts { | ||
let stub_out_program_account = move || { | ||
let mut program_account = AccountSharedData::default(); | ||
program_account.set_owner(loader_key); | ||
program_account.set_executable(true); | ||
program_account | ||
}; | ||
|
||
let key_map = KeyMap::compile_from_instruction(instruction); | ||
let compiled_instruction = compile_instruction_without_data(&key_map, instruction); | ||
let instruction_accounts = compile_instruction_accounts(&key_map, &compiled_instruction); | ||
let transaction_accounts = compile_transaction_accounts_for_instruction( | ||
&key_map, | ||
instruction, | ||
accounts, | ||
Some(Box::new(stub_out_program_account)), | ||
); | ||
|
||
CompiledAccounts { | ||
program_id_index: compiled_instruction.program_id_index as u16, | ||
instruction_accounts, | ||
transaction_accounts, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "mollusk-svm-keys" | ||
description = "SVM transaction keys utils." | ||
documentation = "https://docs.rs/mollusk-svm-keys" | ||
authors = { workspace = true } | ||
repository = { workspace = true } | ||
readme = { workspace = true } | ||
license = { workspace = true } | ||
edition = { workspace = true } | ||
version = { workspace = true } | ||
|
||
[dependencies] | ||
mollusk-svm-error = { workspace = true } | ||
solana-sdk = { workspace = true } |
Oops, something went wrong.