Skip to content

Commit

Permalink
Move short_vec to its own crate (#1796)
Browse files Browse the repository at this point in the history
* move short_vec.rs to its own crate

* update short_vec dependents to use new crate

* update lock file

* reexport short_vec with deprecation notice

* re-export in sdk too

* fmt

* remove duplicate frozen-abi stuff

* fix frozen-abi usage and activation

* update lock file

* fmt

* update expected digests after confirming not a real abi change

* update another digest

* add missing activation of frozen-abi feature

* update digests in sdk and program

* update VoteTransaction digest

* fmt
  • Loading branch information
kevinheavey authored Jul 17, 2024
1 parent 150f4d7 commit b2c4742
Show file tree
Hide file tree
Showing 33 changed files with 118 additions and 33 deletions.
20 changes: 20 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 @@ -105,6 +105,7 @@ members = [
"sdk/package-metadata-macro",
"sdk/program",
"send-transaction-service",
"short-vec",
"stake-accounts",
"storage-bigtable",
"storage-bigtable/build-proto",
Expand Down Expand Up @@ -399,6 +400,7 @@ solana-sdk = { path = "sdk", version = "=2.1.0" }
solana-sdk-macro = { path = "sdk/macro", version = "=2.1.0" }
solana-secp256k1-recover = { path = "curves/secp256k1-recover", version = "=2.1.0", default-features = false }
solana-send-transaction-service = { path = "send-transaction-service", version = "=2.1.0" }
solana-short-vec = { path = "short-vec", version = "=2.1.0" }
solana-stake-program = { path = "programs/stake", version = "=2.1.0" }
solana-storage-bigtable = { path = "storage-bigtable", version = "=2.1.0" }
solana-storage-proto = { path = "storage-proto", version = "=2.1.0" }
Expand Down
2 changes: 2 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ solana-runtime = { workspace = true }
solana-sanitize = { workspace = true }
solana-sdk = { workspace = true }
solana-send-transaction-service = { workspace = true }
solana-short-vec = { workspace = true }
solana-streamer = { workspace = true }
solana-svm = { workspace = true }
solana-timings = { workspace = true }
Expand Down Expand Up @@ -129,6 +130,7 @@ frozen-abi = [
"solana-program-runtime/frozen-abi",
"solana-runtime/frozen-abi",
"solana-sdk/frozen-abi",
"solana-short-vec/frozen-abi",
"solana-svm/frozen-abi",
"solana-vote/frozen-abi",
"solana-vote-program/frozen-abi",
Expand Down
2 changes: 1 addition & 1 deletion core/src/banking_stage/immutable_deserialized_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use {
hash::Hash,
message::Message,
pubkey::Pubkey,
short_vec::decode_shortu16_len,
signature::Signature,
transaction::{
AddressLoader, SanitizedTransaction, SanitizedVersionedTransaction,
VersionedTransaction,
},
},
solana_short_vec::decode_shortu16_len,
std::{cmp::Ordering, collections::HashSet, mem::size_of},
thiserror::Error,
};
Expand Down
2 changes: 1 addition & 1 deletion core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub(crate) enum BlockhashStatus {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "679XkZ4upGc389SwqAsjs5tr2qB4wisqjbwtei7fGhxC")
frozen_abi(digest = "H6T5A66kgJYANFXVrUprxV76WD5ce7Gf62q9SiBC2uYk")
)]
#[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 = "4LayQwoKrE2jPhbNtg3TSpKrtEtjcPiwsVPJN7aCavri")
frozen_abi(digest = "EqYa8kwY9Z1Zbjxgs2aBbqKyCK4f7WAG8gJ7pVSQyKzk")
)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Tower1_14_11 {
Expand Down
2 changes: 2 additions & 0 deletions gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ solana-rpc-client = { workspace = true }
solana-runtime = { workspace = true }
solana-sanitize = { workspace = true }
solana-sdk = { workspace = true }
solana-short-vec = { workspace = true }
solana-streamer = { workspace = true }
solana-tpu-client = { workspace = true }
solana-version = { workspace = true }
Expand All @@ -71,6 +72,7 @@ frozen-abi = [
"solana-perf/frozen-abi",
"solana-runtime/frozen-abi",
"solana-sdk/frozen-abi",
"solana-short-vec/frozen-abi",
"solana-version/frozen-abi",
"solana-vote/frozen-abi",
"solana-vote-program/frozen-abi",
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 @@ -310,7 +310,7 @@ pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>;
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample, AbiEnumVisitor),
frozen_abi(digest = "ogEqvffeEkPpojAaSiUbCv2HdJcdXDQ1ykgYyvKvLo2")
frozen_abi(digest = "6YaMJand6tKtNLUrqvusC5QVDmVLCWYRg5LtxYNi6XN4")
)]
#[derive(Serialize, Deserialize, Debug)]
#[allow(clippy::large_enum_variant)]
Expand Down
3 changes: 2 additions & 1 deletion gossip/src/contact_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use {
pubkey::Pubkey,
quic::QUIC_PORT_OFFSET,
rpc_port::{DEFAULT_RPC_PORT, DEFAULT_RPC_PUBSUB_PORT},
serde_varint, short_vec,
serde_varint,
},
solana_short_vec as short_vec,
solana_streamer::socket::SocketAddrSpace,
static_assertions::const_assert_eq,
std::{
Expand Down
2 changes: 2 additions & 0 deletions perf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ solana-frozen-abi-macro = { workspace = true, optional = true }
solana-metrics = { workspace = true }
solana-rayon-threadlimit = { workspace = true }
solana-sdk = { workspace = true }
solana-short-vec = { workspace = true }
solana-vote-program = { workspace = true }

[target."cfg(target_os = \"linux\")".dependencies]
Expand All @@ -50,6 +51,7 @@ frozen-abi = [
"dep:solana-frozen-abi",
"dep:solana-frozen-abi-macro",
"solana-sdk/frozen-abi",
"solana-short-vec/frozen-abi",
"solana-vote-program/frozen-abi",
]

Expand Down
2 changes: 1 addition & 1 deletion perf/src/sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use {
hash::Hash,
message::{MESSAGE_HEADER_LENGTH, MESSAGE_VERSION_PREFIX},
pubkey::Pubkey,
short_vec::decode_shortu16_len,
signature::Signature,
},
solana_short_vec::decode_shortu16_len,
std::{convert::TryFrom, mem::size_of},
};

Expand Down
1 change: 1 addition & 0 deletions programs/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ serde_derive = { workspace = true }
solana-log-collector = { workspace = true }
solana-program-runtime = { workspace = true }
solana-sdk = { workspace = true }
solana-short-vec = { workspace = true }

[dev-dependencies]
solana-logger = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion programs/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use {
solana_sdk::{
account::{Account, AccountSharedData},
pubkey::Pubkey,
short_vec,
},
solana_short_vec as short_vec,
};

pub trait ConfigState: serde::Serialize + Default {
Expand Down
15 changes: 15 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 programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample, AbiEnumVisitor),
frozen_abi(digest = "EcS3xgfomytEAQ1eVd8R76ZejwyHp2Ed8dHqQWh6zi5v")
frozen_abi(digest = "3R2hRL3FM6jovbYubq2UWeiVDEVzrhH6M1ihoCPZWLsk")
)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum VoteTransaction {
Expand Down
2 changes: 2 additions & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ frozen-abi = [
"dep:solana-frozen-abi",
"dep:solana-frozen-abi-macro",
"solana-program/frozen-abi",
"solana-short-vec/frozen-abi"
]

[dependencies]
Expand Down Expand Up @@ -85,6 +86,7 @@ solana-program = { workspace = true }
solana-sanitize = { workspace = true }
solana-sdk-macro = { workspace = true }
solana-secp256k1-recover = { workspace = true }
solana-short-vec = { workspace = true }
thiserror = { workspace = true }
uriparse = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion sdk/benches/short_vec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(test)]

extern crate test;
use {bincode::deserialize, solana_sdk::short_vec::ShortVec, test::Bencher};
use {bincode::deserialize, solana_short_vec::ShortVec, test::Bencher};

// Return a ShortVec with 127 bytes
fn create_encoded_short_vec() -> Vec<u8> {
Expand Down
3 changes: 2 additions & 1 deletion sdk/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ solana-frozen-abi-macro = { workspace = true, optional = true }
solana-sanitize = { workspace = true }
solana-sdk-macro = { workspace = true }
solana-secp256k1-recover = { workspace = true }
solana-short-vec = { workspace = true }
thiserror = { workspace = true }

# This is currently needed to build on-chain programs reliably.
Expand Down Expand Up @@ -97,4 +98,4 @@ crate-type = ["cdylib", "rlib"]
default = ["borsh"]
borsh = ["dep:borsh", "dep:borsh0-10"]
dev-context-only-utils = ["dep:qualifier_attr"]
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"]
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", "solana-short-vec/frozen-abi"]
7 changes: 2 additions & 5 deletions sdk/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ use crate::wasm_bindgen;
#[cfg(feature = "borsh")]
use borsh::BorshSerialize;
use {
crate::{pubkey::Pubkey, short_vec},
bincode::serialize,
serde::Serialize,
solana_sanitize::Sanitize,
thiserror::Error,
crate::pubkey::Pubkey, bincode::serialize, serde::Serialize, solana_sanitize::Sanitize,
solana_short_vec as short_vec, thiserror::Error,
};

/// Reasons the runtime might have rejected an instruction.
Expand Down
3 changes: 2 additions & 1 deletion sdk/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ pub mod rent;
pub mod secp256k1_program;
pub mod serde_varint;
pub mod serialize_utils;
pub mod short_vec;
pub mod slot_hashes;
pub mod slot_history;
pub mod stable_layout;
Expand All @@ -538,6 +537,8 @@ pub mod wasm;
pub use solana_sanitize as sanitize;
#[deprecated(since = "2.1.0", note = "Use `solana-secp256k1-recover` crate instead")]
pub use solana_secp256k1_recover as secp256k1_recover;
#[deprecated(since = "2.1.0", note = "Use `solana-short-vec` crate instead")]
pub use solana_short_vec as short_vec;
#[cfg(target_arch = "wasm32")]
pub use wasm_bindgen::prelude::wasm_bindgen;

Expand Down
Loading

0 comments on commit b2c4742

Please sign in to comment.