This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
sdk: add "everything" feature #12985
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ use thiserror::Error; | |
|
|
||
| #[cfg(feature = "program")] | ||
| use crate::info; | ||
| #[cfg(not(feature = "program"))] | ||
| #[cfg(all(feature = "everything", not(feature = "program")))] | ||
|
Contributor
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. Was this the underlying motivation for this change?
Contributor
Author
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. Not directly. When trying to test stuff over in SPL land, the semantics of enabling "program" causing code to be removed was generating confusing errors. |
||
| use log::info; | ||
|
|
||
| /// Reasons the program may fail | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,11 +1,5 @@ | ||
| #[cfg(all(feature = "program", target_arch = "bpf"))] | ||
| use crate::entrypoint::SUCCESS; | ||
| #[cfg(not(all(feature = "program", target_arch = "bpf")))] | ||
| use crate::hash::Hasher; | ||
| use crate::{decode_error::DecodeError, hash::hashv}; | ||
| use num_derive::{FromPrimitive, ToPrimitive}; | ||
| #[cfg(not(feature = "program"))] | ||
| use std::error; | ||
| use std::{convert::TryFrom, fmt, mem, str::FromStr}; | ||
| use thiserror::Error; | ||
|
|
||
|
|
@@ -130,7 +124,7 @@ impl Pubkey { | |
| // not supported | ||
| #[cfg(not(all(feature = "program", target_arch = "bpf")))] | ||
| { | ||
| let mut hasher = Hasher::default(); | ||
| let mut hasher = crate::hash::Hasher::default(); | ||
|
Contributor
Author
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. |
||
| for seed in seeds.iter() { | ||
| if seed.len() > MAX_SEED_LEN { | ||
| return Err(PubkeyError::MaxSeedLengthExceeded); | ||
|
|
@@ -170,7 +164,7 @@ impl Pubkey { | |
| ) | ||
| }; | ||
| match result { | ||
| SUCCESS => Ok(Pubkey::new(&bytes)), | ||
| crate::entrypoint::SUCCESS => Ok(Pubkey::new(&bytes)), | ||
| _ => Err(result.into()), | ||
| } | ||
| } | ||
|
|
@@ -194,7 +188,7 @@ impl Pubkey { | |
| panic!("Unable to find a viable program address bump seed"); | ||
| } | ||
|
|
||
| #[cfg(not(feature = "program"))] | ||
| #[cfg(feature = "everything")] | ||
| pub fn new_rand() -> Self { | ||
| Self::new(&rand::random::<[u8; 32]>()) | ||
| } | ||
|
|
@@ -236,8 +230,8 @@ impl fmt::Display for Pubkey { | |
| } | ||
| } | ||
|
|
||
| #[cfg(not(feature = "program"))] | ||
| pub fn write_pubkey_file(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn error::Error>> { | ||
| #[cfg(feature = "everything")] | ||
| pub fn write_pubkey_file(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn std::error::Error>> { | ||
| use std::io::Write; | ||
|
|
||
| let printable = format!("{}", pubkey); | ||
|
|
@@ -252,8 +246,8 @@ pub fn write_pubkey_file(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn er | |
| Ok(()) | ||
| } | ||
|
|
||
| #[cfg(not(feature = "program"))] | ||
| pub fn read_pubkey_file(infile: &str) -> Result<Pubkey, Box<dyn error::Error>> { | ||
| #[cfg(feature = "everything")] | ||
| pub fn read_pubkey_file(infile: &str) -> Result<Pubkey, Box<dyn std::error::Error>> { | ||
| let f = std::fs::File::open(infile.to_string())?; | ||
| let printable: String = serde_json::from_reader(f)?; | ||
| Ok(Pubkey::from_str(&printable)?) | ||
|
|
@@ -434,7 +428,7 @@ mod tests { | |
| } | ||
|
|
||
| #[test] | ||
| fn test_read_write_pubkey() -> Result<(), Box<dyn error::Error>> { | ||
| fn test_read_write_pubkey() -> Result<(), Box<dyn std::error::Error>> { | ||
| let filename = "test_pubkey.json"; | ||
| let pubkey = Pubkey::new_rand(); | ||
| write_pubkey_file(filename, pubkey)?; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
freebie: this fixes a compile error when using
Pubkey::create_program_address()from a program when not targeting BPF