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

Extract pubkey crate #2394

Merged
merged 56 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
79dec23
extract solana-pubkey from solana-program
kevinheavey Aug 1, 2024
321c31d
make curve25519_dalek an optional dep
kevinheavey Aug 1, 2024
509dcc7
make sha2 optional in solana-pubkey
kevinheavey Aug 1, 2024
cc0bece
move pubkey wasm code to solana-pubkey
kevinheavey Aug 1, 2024
741c1a3
make serde optional in solana-pubkey
kevinheavey Aug 1, 2024
3d28373
make bytemuck optional in solana-pubkey
kevinheavey Aug 1, 2024
5632ef8
put syscalls behind target_os = "solana"
kevinheavey Aug 1, 2024
69dadf3
move rand to dev deps
kevinheavey Aug 1, 2024
0eb0cc8
remove thiserror
kevinheavey Aug 1, 2024
03bc984
remove num_derive
kevinheavey Aug 1, 2024
0eb9d76
make std optional
kevinheavey Aug 1, 2024
880872e
use std when target_arch = "wasm32"
kevinheavey Aug 1, 2024
a1beb24
fix frozen-abi support
kevinheavey Aug 1, 2024
ca67903
update digests
kevinheavey Aug 1, 2024
e16beab
update digests
kevinheavey Aug 1, 2024
e260ee5
update nits.sh
kevinheavey Aug 1, 2024
d46e16e
update lock file
kevinheavey Aug 1, 2024
e68c420
make some doc examples text-only because order-crates-for-publishing.…
kevinheavey Aug 1, 2024
42f152a
add dev-context-only-utils to appease ci
kevinheavey Aug 1, 2024
a6413da
fmt
kevinheavey Aug 1, 2024
454df29
fix unused import when target_os = "solana"
kevinheavey Aug 1, 2024
bfadb77
fix imports in wasm target
kevinheavey Aug 1, 2024
9098a45
fix import issue
kevinheavey Aug 1, 2024
03a49fe
activate std feat when borsh feat is activated
kevinheavey Aug 1, 2024
19090c9
fix a conditional import
kevinheavey Aug 1, 2024
be990f6
fix more feature issues
kevinheavey Aug 1, 2024
af9be25
add default-features = false (otherwise we can't disable default feat…
kevinheavey Aug 2, 2024
cdcbb5c
activate std feature explicitly
kevinheavey Aug 2, 2024
5f2e7e5
clean up imports
kevinheavey Aug 2, 2024
138c7a4
fix test features
kevinheavey Aug 9, 2024
8663863
fix lints
kevinheavey Aug 19, 2024
01cd45a
post-rebase fixes
kevinheavey Sep 5, 2024
a50892f
make FromStr, Display and Debug no_std
kevinheavey Sep 5, 2024
37c69a7
fmt
kevinheavey Sep 5, 2024
55cc623
update digest
kevinheavey Sep 5, 2024
e04f9a6
fix duplicate line post-rebase
kevinheavey Sep 5, 2024
3e1954e
stop avoiding circular dev dep since CI now accommodates this
kevinheavey Sep 5, 2024
12ea4ba
make rustc_version optional
kevinheavey Sep 5, 2024
2f88c21
fix doc link
kevinheavey Sep 5, 2024
75fb344
fix frozen-abi deps
kevinheavey Sep 5, 2024
8656b85
update digests
kevinheavey Sep 6, 2024
86cd4c2
fmt
kevinheavey Sep 6, 2024
e561b68
don't require std for FromStr
kevinheavey Sep 8, 2024
7fa9113
simplify some imports
kevinheavey Sep 8, 2024
57e758f
use as_ref instead of to_bytes
kevinheavey Sep 9, 2024
12c4aad
use as_ref instead of to_bytes
kevinheavey Sep 9, 2024
5e84558
remove unnecessary test criterion in #[cfg()]
kevinheavey Sep 9, 2024
eb79c57
remove unnecessary test criterion in #[cfg()]
kevinheavey Sep 9, 2024
3a620c6
remove unrelated change
kevinheavey Sep 9, 2024
fdc1c86
but don't remove #[cfg(test)]
kevinheavey Sep 9, 2024
1847e06
call out doc tests in explanation of circular dev dep
kevinheavey Sep 9, 2024
94ea92d
add missing conversion
kevinheavey Sep 9, 2024
50b812a
remove unnecessary #[cfg(feature = "std")]
kevinheavey Sep 9, 2024
0540081
use strum to check that FromPrimitive impls are exhaustive
kevinheavey Sep 9, 2024
3a924b0
sort deps
kevinheavey Sep 9, 2024
3e40adf
add test for From<u64>
kevinheavey Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ members = [
"sdk/program",
"sdk/program-memory",
"sdk/program-option",
"sdk/pubkey",
"sdk/serde-varint",
"sdk/sha256-hasher",
"sdk/signature",
Expand Down Expand Up @@ -421,6 +422,7 @@ solana-program-memory = { path = "sdk/program-memory", version = "=2.1.0" }
solana-program-option = { path = "sdk/program-option", version = "=2.1.0" }
solana-program-runtime = { path = "program-runtime", version = "=2.1.0" }
solana-program-test = { path = "program-test", version = "=2.1.0" }
solana-pubkey = { path = "sdk/pubkey", version = "=2.1.0", default-features = false }
solana-pubsub-client = { path = "pubsub-client", version = "=2.1.0" }
solana-quic-client = { path = "quic-client", version = "=2.1.0" }
solana-rayon-threadlimit = { path = "rayon-threadlimit", version = "=2.1.0" }
Expand Down
1 change: 1 addition & 0 deletions ci/nits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ declare print_free_tree=(
':^sdk/msg/src/lib.rs'
':^sdk/program-option/src/lib.rs'
':^sdk/program/src/program_stubs.rs'
':^sdk/pubkey/src/lib.rs'
':programs/**.rs'
':^**bin**.rs'
':^**bench**.rs'
Expand Down
2 changes: 1 addition & 1 deletion core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pub(crate) enum BlockhashStatus {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "5BUswzvu7Qe44HbR4eBwPX4Jn9GSfhjmg8eijnBjoKUd")
frozen_abi(digest = "9ziHa1vA7WG5RCvXiE3g1f2qjSTNa47FB7e2czo7en7a")
)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Tower {
Expand Down
2 changes: 1 addition & 1 deletion core/src/consensus/tower1_14_11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "9P6J8ZtVLR5zbUxWT83q1iUsJMH6B7SwcomSqcoomPmg")
frozen_abi(digest = "6VhLW7DSHNzrcswtxbNo4cb47oGrKLcKuDmCWVpUMLLM")
)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Tower1_14_11 {
Expand Down
2 changes: 1 addition & 1 deletion core/src/consensus/tower1_7_14.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "DJVvkk4EFFCbA37vsKcFPGuwEULh2wEvMUESsTyvABzU")
frozen_abi(digest = "5bwSGBqA1BVmgNtnTenfYtEt123cciEzpfqt6bUX1dJo")
)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Tower1_7_14 {
Expand Down
6 changes: 3 additions & 3 deletions core/src/repair/serve_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl AncestorHashesRepairType {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiEnumVisitor, AbiExample),
frozen_abi(digest = "H7S44V9G9cjKeZdtSNZnRivsMrKaThkazF3k3c63TxP4")
frozen_abi(digest = "9SdneX58ekpqLJBzUwfwJsK2fZc9mN4vTcaS4temEjkP")
)]
#[derive(Debug, Deserialize, Serialize)]
pub enum AncestorHashesResponse {
Expand Down Expand Up @@ -224,7 +224,7 @@ pub(crate) type Ping = ping_pong::Ping<[u8; REPAIR_PING_TOKEN_SIZE]>;
#[cfg_attr(
feature = "frozen-abi",
derive(AbiEnumVisitor, AbiExample),
frozen_abi(digest = "CYguF3KopGoM48XFJJS9pw9Z4TDZ2eUTqPPqbm3L4mFr")
frozen_abi(digest = "3E2R8jiSt9QfVHdX3MgW3UdeNWfor7zNjJcLJLz2K1JY")
)]
#[derive(Debug, Deserialize, Serialize)]
pub enum RepairProtocol {
Expand Down Expand Up @@ -272,7 +272,7 @@ fn discard_malformed_repair_requests(
#[cfg_attr(
feature = "frozen-abi",
derive(AbiEnumVisitor, AbiExample),
frozen_abi(digest = "8TYqNDnUGbE5duZgbCJAyZ2nZDSx39ueYo9PLLZCsiVy")
frozen_abi(digest = "CpKVYghdpMDRMiGjZpa71dcnB7rCVHLVogZbB3AGDKAK")
)]
#[derive(Debug, Deserialize, Serialize)]
pub(crate) enum RepairResponse {
Expand Down
2 changes: 1 addition & 1 deletion gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>;
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample, AbiEnumVisitor),
frozen_abi(digest = "ANgFTZHXSMbjYEuvf9YphECo47tWWrqKdPDD6B9D1YGB")
frozen_abi(digest = "GfVFxfPfYcFLCaa29uxQxyKJAuTZ1cYqcRKhVrEKwDK7")
)]
#[derive(Serialize, Deserialize, Debug)]
#[allow(clippy::large_enum_variant)]
Expand Down
24 changes: 24 additions & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion runtime/src/bank/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ mod tests {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "FuFBQtx7rGruVC3cyh4zvZ3uN4RUtBiwh1pXJRwUCcoS")
frozen_abi(digest = "6d4H7gw1hSrspdTew8dAXZ5dZT1mwFc6VZdXnkuggJ8E")
)]
#[derive(Serialize)]
pub struct BankAbiTestWrapper {
Expand Down
5 changes: 4 additions & 1 deletion sdk/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ solana-hash = { workspace = true, features = [
solana-msg = { workspace = true }
solana-program-memory = { workspace = true }
solana-program-option = { workspace = true }
solana-pubkey = { workspace = true, features = ["bytemuck", "curve25519", "serde", "std"] }
solana-sanitize = { workspace = true }
solana-sdk-macro = { workspace = true }
solana-secp256k1-recover = { workspace = true }
Expand Down Expand Up @@ -91,6 +92,7 @@ assert_matches = { workspace = true }
itertools = { workspace = true }
serde_json = { workspace = true }
serial_test = { workspace = true }
solana-pubkey = { workspace = true, features = ["dev-context-only-utils"] }
static_assertions = { workspace = true }
test-case = { workspace = true }

Expand All @@ -105,13 +107,14 @@ crate-type = ["cdylib", "rlib"]

[features]
default = ["borsh"]
borsh = ["dep:borsh", "dep:borsh0-10", "solana-hash/borsh"]
borsh = ["dep:borsh", "dep:borsh0-10", "solana-hash/borsh", "solana-pubkey/borsh"]
dev-context-only-utils = ["dep:qualifier_attr"]
frozen-abi = [
"dep:rustc_version",
"dep:solana-frozen-abi",
"dep:solana-frozen-abi-macro",
"solana-hash/frozen-abi",
"solana-pubkey/frozen-abi",
"solana-short-vec/frozen-abi"
]

Expand Down
6 changes: 4 additions & 2 deletions sdk/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ pub mod program_error;
pub mod program_pack;
pub mod program_stubs;
pub mod program_utils;
pub mod pubkey;
pub mod rent;
pub mod secp256k1_program;
pub mod serialize_utils;
Expand Down Expand Up @@ -539,7 +538,10 @@ pub use solana_serde_varint as serde_varint;
pub use solana_short_vec as short_vec;
#[cfg(target_arch = "wasm32")]
pub use wasm_bindgen::prelude::wasm_bindgen;
pub use {solana_clock as clock, solana_msg::msg, solana_program_option as program_option};
pub use {
solana_clock as clock, solana_msg::msg, solana_program_option as program_option,
solana_pubkey as pubkey,
};

/// The [config native program][np].
///
Expand Down
10 changes: 5 additions & 5 deletions sdk/program/src/message/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ mod builtins {
// the value is "false"), or might be in one of these lists (if the value is "true")
pub static ref MAYBE_BUILTIN_KEY_OR_SYSVAR: [bool; 256] = {
let mut temp_table: [bool; 256] = [false; 256];
BUILTIN_PROGRAMS_KEYS.iter().for_each(|key| temp_table[key.0[0] as usize] = true);
sysvar::ALL_IDS.iter().for_each(|key| temp_table[key.0[0] as usize] = true);
BUILTIN_PROGRAMS_KEYS.iter().for_each(|key| temp_table[key.as_ref()[0] as usize] = true);
sysvar::ALL_IDS.iter().for_each(|key| temp_table[key.as_ref()[0] as usize] = true);
temp_table
};
}
Expand All @@ -76,7 +76,7 @@ mod builtins {
)]
#[allow(deprecated)]
pub fn is_builtin_key_or_sysvar(key: &Pubkey) -> bool {
if MAYBE_BUILTIN_KEY_OR_SYSVAR[key.0[0] as usize] {
if MAYBE_BUILTIN_KEY_OR_SYSVAR[key.as_ref()[0] as usize] {
return sysvar::is_sysvar_id(key) || BUILTIN_PROGRAMS_KEYS.contains(key);
}
false
Expand Down Expand Up @@ -123,7 +123,7 @@ fn compile_instructions(ixs: &[Instruction], keys: &[Pubkey]) -> Vec<CompiledIns
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(
feature = "frozen-abi",
frozen_abi(digest = "8T1Vi17ZrAmakpGPcPo4cMR4stSpbGNP9teYoB6wVR4z"),
frozen_abi(digest = "4kL6EbLGU25m5eMk4H1cW9YGhA5LejHSgj2w2fhY1NGp"),
derive(AbiExample)
)]
#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone)]
Expand Down Expand Up @@ -153,7 +153,7 @@ pub struct Message {
#[wasm_bindgen]
#[cfg_attr(
feature = "frozen-abi",
frozen_abi(digest = "8T1Vi17ZrAmakpGPcPo4cMR4stSpbGNP9teYoB6wVR4z"),
frozen_abi(digest = "4kL6EbLGU25m5eMk4H1cW9YGhA5LejHSgj2w2fhY1NGp"),
derive(AbiExample)
)]
#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/message/versions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub const MESSAGE_VERSION_PREFIX: u8 = 0x80;
/// format.
#[cfg_attr(
feature = "frozen-abi",
frozen_abi(digest = "3g49yJ9ZZPsT9iF6Za6FyWXV259vWcY6gfJ94uzQ5BcY"),
frozen_abi(digest = "EjjHMjAnRrd86DuTgysFXRicMiAQv3vTvzRzcMJCjYfC"),
derive(AbiEnumVisitor, AbiExample)
)]
#[derive(Debug, PartialEq, Eq, Clone)]
Expand Down
7 changes: 4 additions & 3 deletions sdk/program/src/syscalls/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pub use solana_msg::sol_log;
note = "Use `solana_program_memory::syscalls` instead"
)]
pub use solana_program_memory::syscalls::{sol_memcmp_, sol_memcpy_, sol_memmove_, sol_memset_};
#[deprecated(since = "2.1.0", note = "Use `solana_pubkey::syscalls` instead")]
pub use solana_pubkey::syscalls::{
sol_create_program_address, sol_log_pubkey, sol_try_find_program_address,
};
#[deprecated(
since = "2.1.0",
note = "Use `solana_secp256k1_recover::sol_secp256k1_recover` instead"
Expand All @@ -23,9 +27,6 @@ use {
};
define_syscall!(fn sol_log_64_(arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64));
define_syscall!(fn sol_log_compute_units_());
define_syscall!(fn sol_log_pubkey(pubkey_addr: *const u8));
define_syscall!(fn sol_create_program_address(seeds_addr: *const u8, seeds_len: u64, program_id_addr: *const u8, address_bytes_addr: *const u8) -> u64);
define_syscall!(fn sol_try_find_program_address(seeds_addr: *const u8, seeds_len: u64, program_id_addr: *const u8, address_bytes_addr: *const u8, bump_seed_addr: *const u8) -> u64);
define_syscall!(fn sol_keccak256(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
define_syscall!(fn sol_blake3(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64);
define_syscall!(fn sol_invoke_signed_c(instruction_addr: *const u8, account_infos_addr: *const u8, account_infos_len: u64, signers_seeds_addr: *const u8, signers_seeds_len: u64) -> u64);
Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/system_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static_assertions::const_assert_eq!(MAX_PERMITTED_DATA_LENGTH, 10_485_760);
/// An instruction to the system program.
#[cfg_attr(
feature = "frozen-abi",
frozen_abi(digest = "5e22s2kFu9Do77hdcCyxyhuKHD8ThAB6Q6dNaLTCjL5M"),
frozen_abi(digest = "2LnVTnJg7LxB1FawNZLoQEY8yiYx3MT3paTdx4s5kAXU"),
derive(AbiExample, AbiEnumVisitor)
)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/vote/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl<I> CircBuf<I> {

#[cfg_attr(
feature = "frozen-abi",
frozen_abi(digest = "EeenjJaSrm9hRM39gK6raRNtzG61hnk7GciUCJJRDUSQ"),
frozen_abi(digest = "87ULMjjHnMsPmCTEyzj4KPn2u5gdX1rmgtSdycpbSaLs"),
derive(AbiExample)
)]
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion sdk/program/src/vote/state/vote_state_1_14_11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const DEFAULT_PRIOR_VOTERS_OFFSET: usize = 82;

#[cfg_attr(
feature = "frozen-abi",
frozen_abi(digest = "CZTgLymuevXjAx6tM8X8T5J3MCx9AkEsFSmu4FJrEpkG"),
frozen_abi(digest = "64duaG8iUgwmgMM9y1Pdi8S9jBGoPcjS5HrE8RRfsxJJ"),
derive(AbiExample)
)]
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone)]
Expand Down
1 change: 0 additions & 1 deletion sdk/program/src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use wasm_bindgen::prelude::*;

pub mod instructions;
pub mod pubkey;
pub mod system_instruction;

/// Initialize Javascript logging and panic handler
Expand Down
Loading