-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Make solana-address-lookup-table-program crate bpf compatible #23700
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#[cfg(not(target_arch = "bpf"))] | ||
use solana_sdk::transaction::TransactionError; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error, PartialEq, Eq, Clone)] | ||
pub enum AddressLookupError { | ||
/// Attempted to lookup addresses from a table that does not exist | ||
#[error("Attempted to lookup addresses from a table that does not exist")] | ||
LookupTableAccountNotFound, | ||
|
||
/// Attempted to lookup addresses from an account owned by the wrong program | ||
#[error("Attempted to lookup addresses from an account owned by the wrong program")] | ||
InvalidAccountOwner, | ||
|
||
/// Attempted to lookup addresses from an invalid account | ||
#[error("Attempted to lookup addresses from an invalid account")] | ||
InvalidAccountData, | ||
|
||
/// Address lookup contains an invalid index | ||
#[error("Address lookup contains an invalid index")] | ||
InvalidLookupIndex, | ||
} | ||
|
||
#[cfg(not(target_arch = "bpf"))] | ||
impl From<AddressLookupError> for TransactionError { | ||
fn from(err: AddressLookupError) -> Self { | ||
match err { | ||
AddressLookupError::LookupTableAccountNotFound => Self::AddressLookupTableNotFound, | ||
AddressLookupError::InvalidAccountOwner => Self::InvalidAddressLookupTableOwner, | ||
AddressLookupError::InvalidAccountData => Self::InvalidAddressLookupTableData, | ||
AddressLookupError::InvalidLookupIndex => Self::InvalidAddressLookupTableIndex, | ||
} | ||
} | ||
} | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ edition = "2021" | |
[dependencies] | ||
byteorder = { version = "1", default-features = false } | ||
solana-program = { path = "../../../../sdk/program", version = "=1.10.3" } | ||
# list of crates which must be buildable for bpf programs | ||
solana-address-lookup-table-program = { path = "../../../../programs/address-lookup-table", version = "=1.10.3" } | ||
Comment on lines
+15
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a great idea! |
||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: what do you think about keeping just this part in
solana-sdk
? Then you can avoid at least onetarget_arch
cfgThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then
solana-sdk
would need to depend onsolana-address-lookup-table-program
and there would be a circular dependencyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, of course