diff --git a/Cargo.lock b/Cargo.lock index 7bfab2529d1c8f..06040f9617f907 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3753,6 +3753,8 @@ dependencies = [ "solana-clap-utils", "solana-client", "solana-faucet", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-ledger", "solana-logger 1.5.0", "solana-measure", @@ -3763,7 +3765,6 @@ dependencies = [ "solana-rayon-threadlimit", "solana-runtime", "solana-sdk 1.5.0", - "solana-sdk-macro-frozen-abi 1.5.0", "solana-stake-program", "solana-storage-bigtable", "solana-streamer", @@ -3908,6 +3909,35 @@ dependencies = [ "tokio-codec", ] +[[package]] +name = "solana-frozen-abi" +version = "1.5.0" +dependencies = [ + "bs58", + "bv", + "generic-array 0.14.3", + "log 0.4.8", + "memmap", + "rustc_version", + "serde", + "serde_derive", + "sha2", + "solana-frozen-abi-macro", + "solana-logger 1.5.0", + "thiserror", +] + +[[package]] +name = "solana-frozen-abi-macro" +version = "1.5.0" +dependencies = [ + "lazy_static", + "proc-macro2 1.0.19", + "quote 1.0.6", + "rustc_version", + "syn 1.0.27", +] + [[package]] name = "solana-genesis" version = "1.5.0" @@ -4356,13 +4386,14 @@ dependencies = [ "serde", "serde_derive", "solana-config-program", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-logger 1.5.0", "solana-measure", "solana-metrics", "solana-noop-program", "solana-rayon-threadlimit", "solana-sdk 1.5.0", - "solana-sdk-macro-frozen-abi 1.5.0", "solana-secp256k1-program", "solana-stake-program", "solana-vote-program", @@ -4419,7 +4450,7 @@ dependencies = [ "solana-crate-features 1.4.0", "solana-logger 1.4.0", "solana-sdk-macro 1.4.0", - "solana-sdk-macro-frozen-abi 1.4.0", + "solana-sdk-macro-frozen-abi", "thiserror", ] @@ -4458,9 +4489,10 @@ dependencies = [ "sha2", "sha3", "solana-crate-features 1.5.0", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-logger 1.5.0", "solana-sdk-macro 1.5.0", - "solana-sdk-macro-frozen-abi 1.5.0", "thiserror", "tiny-bip39", ] @@ -4502,17 +4534,6 @@ dependencies = [ "syn 1.0.27", ] -[[package]] -name = "solana-sdk-macro-frozen-abi" -version = "1.5.0" -dependencies = [ - "lazy_static", - "proc-macro2 1.0.19", - "quote 1.0.6", - "rustc_version", - "syn 1.0.27", -] - [[package]] name = "solana-secp256k1-program" version = "1.5.0" @@ -4596,10 +4617,11 @@ dependencies = [ "serde", "serde_derive", "solana-config-program", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-logger 1.5.0", "solana-metrics", "solana-sdk 1.5.0", - "solana-sdk-macro-frozen-abi 1.5.0", "solana-vote-program", "thiserror", ] @@ -4769,10 +4791,11 @@ dependencies = [ "rustc_version", "serde", "serde_derive", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-logger 1.5.0", "solana-runtime", "solana-sdk 1.5.0", - "solana-sdk-macro-frozen-abi 1.5.0", ] [[package]] @@ -4802,10 +4825,11 @@ dependencies = [ "rustc_version", "serde", "serde_derive", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-logger 1.5.0", "solana-metrics", "solana-sdk 1.5.0", - "solana-sdk-macro-frozen-abi 1.5.0", "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index 5e8a55476d902e..97daafeb1a3b96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ members = [ "dos", "download-utils", "faucet", + "frozen-abi", "perf", "validator", "genesis", diff --git a/core/Cargo.toml b/core/Cargo.toml index 3129ff56ad6371..e1fbb2e09f05c9 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -58,7 +58,8 @@ solana-net-utils = { path = "../net-utils", version = "1.5.0" } solana-perf = { path = "../perf", version = "1.5.0" } solana-runtime = { path = "../runtime", version = "1.5.0" } solana-sdk = { path = "../sdk", version = "1.5.0" } -solana-sdk-macro-frozen-abi = { path = "../sdk/macro-frozen-abi", version = "1.5.0" } +solana-frozen-abi = { path = "../frozen-abi", version = "1.5.0" } +solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "1.5.0" } solana-stake-program = { path = "../programs/stake", version = "1.5.0" } solana-storage-bigtable = { path = "../storage-bigtable", version = "1.5.0" } solana-streamer = { path = "../streamer", version = "1.5.0" } diff --git a/core/build.rs b/core/build.rs index 8780ebe559a1cd..ae66c237c5f4fd 120000 --- a/core/build.rs +++ b/core/build.rs @@ -1 +1 @@ -../sdk/build.rs \ No newline at end of file +../frozen-abi/build.rs \ No newline at end of file diff --git a/core/src/lib.rs b/core/src/lib.rs index 8a3c224570dac5..30737faa35485d 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -93,7 +93,7 @@ extern crate serde_json; extern crate solana_metrics; #[macro_use] -extern crate solana_sdk_macro_frozen_abi; +extern crate solana_frozen_abi_macro; #[cfg(test)] #[macro_use] diff --git a/frozen-abi/Cargo.toml b/frozen-abi/Cargo.toml new file mode 100644 index 00000000000000..487e20fe1eead8 --- /dev/null +++ b/frozen-abi/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "solana-frozen-abi" +version = "1.5.0" +description = "Solana Frozen ABI" +authors = ["Solana Maintainers "] +repository = "https://github.com/solana-labs/solana" +homepage = "https://solana.com/" +license = "Apache-2.0" +edition = "2018" + +[dependencies] +bs58 = "0.3.1" +bv = { version = "0.11.1", features = ["serde"] } +log = "0.4.8" +serde = "1.0.112" +serde_derive = "1.0.103" +sha2 = "0.8.2" +solana-frozen-abi-macro = { path = "macro", version = "1.5.0" } +thiserror = "1.0" + +[target.'cfg(not(target_arch = "bpf"))'.dependencies] +solana-logger = { path = "../logger", version = "1.5.0" } +generic-array = { version = "0.14.3", default-features = false, features = ["serde", "more_lengths"]} +memmap = "0.7.0" + +[build-dependencies] +rustc_version = "0.2" diff --git a/frozen-abi/build.rs b/frozen-abi/build.rs new file mode 100644 index 00000000000000..c9550c1c5c4f22 --- /dev/null +++ b/frozen-abi/build.rs @@ -0,0 +1,27 @@ +extern crate rustc_version; +use rustc_version::{version_meta, Channel}; + +fn main() { + // Copied and adapted from + // https://github.com/Kimundi/rustc-version-rs/blob/1d692a965f4e48a8cb72e82cda953107c0d22f47/README.md#example + // Licensed under Apache-2.0 + MIT + match version_meta().unwrap().channel { + Channel::Stable => { + println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION"); + } + Channel::Beta => { + println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION"); + } + Channel::Nightly => { + println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION"); + } + Channel::Dev => { + println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION"); + // See https://github.com/solana-labs/solana/issues/11055 + // We may be running the custom `rust-bpf-builder` toolchain, + // which currently needs `#![feature(proc_macro_hygiene)]` to + // be applied. + println!("cargo:rustc-cfg=RUSTC_NEEDS_PROC_MACRO_HYGIENE"); + } + } +} diff --git a/sdk/macro-frozen-abi/Cargo.toml b/frozen-abi/macro/Cargo.toml similarity index 83% rename from sdk/macro-frozen-abi/Cargo.toml rename to frozen-abi/macro/Cargo.toml index a5db6c34da2ad8..83582ece5dbfd2 100644 --- a/sdk/macro-frozen-abi/Cargo.toml +++ b/frozen-abi/macro/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "solana-sdk-macro-frozen-abi" +name = "solana-frozen-abi-macro" version = "1.5.0" -description = "Solana SDK Macro frozen abi" +description = "Solana Frozen ABI Macro" authors = ["Solana Maintainers "] repository = "https://github.com/solana-labs/solana" homepage = "https://solana.com/" diff --git a/sdk/macro-frozen-abi/build.rs b/frozen-abi/macro/build.rs similarity index 100% rename from sdk/macro-frozen-abi/build.rs rename to frozen-abi/macro/build.rs diff --git a/sdk/macro-frozen-abi/src/lib.rs b/frozen-abi/macro/src/lib.rs similarity index 94% rename from sdk/macro-frozen-abi/src/lib.rs rename to frozen-abi/macro/src/lib.rs index 876400c9b3c485..83316cca1d0665 100644 --- a/sdk/macro-frozen-abi/src/lib.rs +++ b/frozen-abi/macro/src/lib.rs @@ -167,7 +167,7 @@ fn derive_abi_sample_enum_type(input: ItemEnum) -> TokenStream { #injection #[automatically_derived] #( #attrs )* - impl #impl_generics ::solana_sdk::abi_example::AbiExample for #type_name #ty_generics #where_clause { + impl #impl_generics ::solana_frozen_abi::abi_example::AbiExample for #type_name #ty_generics #where_clause { fn example() -> Self { ::log::info!( "AbiExample for enum: {}", @@ -221,13 +221,13 @@ fn derive_abi_sample_struct_type(input: ItemStruct) -> TokenStream { #injection #[automatically_derived] #( #attrs )* - impl #impl_generics ::solana_sdk::abi_example::AbiExample for #type_name #ty_generics #where_clause { + impl #impl_generics ::solana_frozen_abi::abi_example::AbiExample for #type_name #ty_generics #where_clause { fn example() -> Self { ::log::info!( "AbiExample for struct: {}", std::any::type_name::<#type_name #ty_generics>() ); - use ::solana_sdk::abi_example::AbiExample; + use ::solana_frozen_abi::abi_example::AbiExample; #type_name #turbofish #sample_fields } @@ -272,11 +272,11 @@ fn do_derive_abi_enum_visitor(input: ItemEnum) -> TokenStream { let type_str = format!("{}", type_name); (quote! { - impl #impl_generics ::solana_sdk::abi_example::AbiEnumVisitor for #type_name #ty_generics #where_clause { - fn visit_for_abi(&self, digester: &mut ::solana_sdk::abi_digester::AbiDigester) -> ::solana_sdk::abi_digester::DigestResult { + impl #impl_generics ::solana_frozen_abi::abi_example::AbiEnumVisitor for #type_name #ty_generics #where_clause { + fn visit_for_abi(&self, digester: &mut ::solana_frozen_abi::abi_digester::AbiDigester) -> ::solana_frozen_abi::abi_digester::DigestResult { let enum_name = #type_str; use ::serde::ser::Serialize; - use ::solana_sdk::abi_example::AbiExample; + use ::solana_frozen_abi::abi_example::AbiExample; digester.update_with_string(format!("enum {} (variants = {})", enum_name, #variant_count)); #serialized_variants Ok(digester.create_child()) @@ -310,12 +310,12 @@ fn quote_for_test( #[cfg(test)] mod #test_mod_ident { use super::*; - use ::solana_sdk::abi_example::{AbiExample, AbiEnumVisitor}; + use ::solana_frozen_abi::abi_example::{AbiExample, AbiEnumVisitor}; #[test] fn test_abi_digest() { ::solana_logger::setup(); - let mut digester = ::solana_sdk::abi_digester::AbiDigester::create(); + let mut digester = ::solana_frozen_abi::abi_digester::AbiDigester::create(); let example = <#type_name>::example(); let result = <_>::visit_for_abi(&&example, &mut digester); let mut hash = digester.finalize(); diff --git a/sdk/src/abi_digester.rs b/frozen-abi/src/abi_digester.rs similarity index 99% rename from sdk/src/abi_digester.rs rename to frozen-abi/src/abi_digester.rs index a6dc06da185fe6..3caa77d593cf8d 100644 --- a/sdk/src/abi_digester.rs +++ b/frozen-abi/src/abi_digester.rs @@ -550,7 +550,7 @@ mod tests { test_field2: i8, } - #[frozen_abi(digest = "Hv597t4PieHYvgiXnwRSpKBRTWqteUS4nHZHY6ZxX69v")] + #[frozen_abi(digest = "GMeECsxg37a5qznstWXeeX3d6HXs6j12oB4SKaZZuNJk")] #[derive(Serialize, AbiExample)] struct TestNest { nested_field: [TestStruct; 5], @@ -573,7 +573,7 @@ mod tests { VARIANT2(u8, u16), } - #[frozen_abi(digest = "CKxzv7VjyUrNR9fGJpTpKyMBWJM4gepKshCS8oV14T1Q")] + #[frozen_abi(digest = "DywMfwKq8HZCbUfTwnemHWMN8LvMZCvipQuLddQ2ywwG")] #[derive(Serialize, AbiExample)] struct TestVecEnum { enums: Vec, diff --git a/sdk/src/abi_example.rs b/frozen-abi/src/abi_example.rs similarity index 99% rename from sdk/src/abi_example.rs rename to frozen-abi/src/abi_example.rs index ba5436689d853b..3b38a38e863994 100644 --- a/sdk/src/abi_example.rs +++ b/frozen-abi/src/abi_example.rs @@ -213,9 +213,9 @@ atomic_example_impls! { AtomicI64 } atomic_example_impls! { AtomicIsize } atomic_example_impls! { AtomicBool } -#[cfg(feature = "everything")] +#[cfg(not(target_arch = "bpf"))] use generic_array::{ArrayLength, GenericArray}; -#[cfg(feature = "everything")] +#[cfg(not(target_arch = "bpf"))] impl> AbiExample for GenericArray { fn example() -> Self { Self::default() @@ -413,14 +413,14 @@ impl AbiExample for BTreeSet { } } -#[cfg(feature = "everything")] +#[cfg(not(target_arch = "bpf"))] impl AbiExample for memmap::MmapMut { fn example() -> Self { memmap::MmapMut::map_anon(1).expect("failed to map the data file") } } -#[cfg(feature = "everything")] +#[cfg(not(target_arch = "bpf"))] impl AbiExample for std::path::PathBuf { fn example() -> Self { std::path::PathBuf::from(String::example()) diff --git a/frozen-abi/src/hash.rs b/frozen-abi/src/hash.rs new file mode 100644 index 00000000000000..311102973cb397 --- /dev/null +++ b/frozen-abi/src/hash.rs @@ -0,0 +1,28 @@ +use sha2::{Digest, Sha256}; +use std::{convert::TryFrom, fmt}; + +const HASH_BYTES: usize = 32; +#[derive(AbiExample)] +pub struct Hash(pub [u8; HASH_BYTES]); + +#[derive(Default)] +pub struct Hasher { + hasher: Sha256, +} + +impl Hasher { + pub fn hash(&mut self, val: &[u8]) { + self.hasher.input(val); + } + pub fn result(self) -> Hash { + // At the time of this writing, the sha2 library is stuck on an old version + // of generic_array (0.9.0). Decouple ourselves with a clone to our version. + Hash(<[u8; HASH_BYTES]>::try_from(self.hasher.result().as_slice()).unwrap()) + } +} + +impl fmt::Display for Hash { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", bs58::encode(self.0).into_string()) + } +} diff --git a/frozen-abi/src/lib.rs b/frozen-abi/src/lib.rs new file mode 100644 index 00000000000000..4641f74ca05633 --- /dev/null +++ b/frozen-abi/src/lib.rs @@ -0,0 +1,22 @@ +#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))] +#![cfg_attr(RUSTC_NEEDS_PROC_MACRO_HYGIENE, feature(proc_macro_hygiene))] + +// Allows macro expansion of `use ::solana_frozen_abi::*` to work within this crate +extern crate self as solana_frozen_abi; + +#[cfg(RUSTC_WITH_SPECIALIZATION)] +pub mod abi_digester; +#[cfg(RUSTC_WITH_SPECIALIZATION)] +pub mod abi_example; + +#[cfg(RUSTC_WITH_SPECIALIZATION)] +mod hash; + +#[cfg(RUSTC_WITH_SPECIALIZATION)] +#[macro_use] +extern crate solana_frozen_abi_macro; + +#[cfg(RUSTC_WITH_SPECIALIZATION)] +#[cfg(test)] +#[macro_use] +extern crate serde_derive; diff --git a/programs/bpf/Cargo.lock b/programs/bpf/Cargo.lock index cf19b778f86a67..6b044500d93b3c 100644 --- a/programs/bpf/Cargo.lock +++ b/programs/bpf/Cargo.lock @@ -2017,6 +2017,35 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "solana-frozen-abi" +version = "1.5.0" +dependencies = [ + "bs58", + "bv", + "generic-array 0.14.3", + "log", + "memmap", + "rustc_version", + "serde", + "serde_derive", + "sha2", + "solana-frozen-abi-macro", + "solana-logger", + "thiserror", +] + +[[package]] +name = "solana-frozen-abi-macro" +version = "1.5.0" +dependencies = [ + "lazy_static", + "proc-macro2 1.0.19", + "quote 1.0.6", + "rustc_version", + "syn 1.0.27", +] + [[package]] name = "solana-logger" version = "1.5.0" @@ -2088,12 +2117,13 @@ dependencies = [ "serde", "serde_derive", "solana-config-program", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-logger", "solana-measure", "solana-metrics", "solana-rayon-threadlimit", "solana-sdk", - "solana-sdk-macro-frozen-abi", "solana-secp256k1-program", "solana-stake-program", "solana-vote-program", @@ -2139,9 +2169,10 @@ dependencies = [ "sha2", "sha3", "solana-crate-features", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-logger", "solana-sdk-macro", - "solana-sdk-macro-frozen-abi", "thiserror", ] @@ -2156,17 +2187,6 @@ dependencies = [ "syn 1.0.27", ] -[[package]] -name = "solana-sdk-macro-frozen-abi" -version = "1.5.0" -dependencies = [ - "lazy_static", - "proc-macro2 1.0.19", - "quote 1.0.6", - "rustc_version", - "syn 1.0.27", -] - [[package]] name = "solana-secp256k1-program" version = "1.5.0" @@ -2192,9 +2212,10 @@ dependencies = [ "serde", "serde_derive", "solana-config-program", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-metrics", "solana-sdk", - "solana-sdk-macro-frozen-abi", "solana-vote-program", "thiserror", ] @@ -2210,10 +2231,11 @@ dependencies = [ "rustc_version", "serde", "serde_derive", + "solana-frozen-abi", + "solana-frozen-abi-macro", "solana-logger", "solana-metrics", "solana-sdk", - "solana-sdk-macro-frozen-abi", "thiserror", ] diff --git a/programs/stake/Cargo.toml b/programs/stake/Cargo.toml index 9c59ced821058b..a4e1fe14d61eed 100644 --- a/programs/stake/Cargo.toml +++ b/programs/stake/Cargo.toml @@ -15,11 +15,12 @@ num-derive = "0.3" num-traits = "0.2" serde = "1.0.112" serde_derive = "1.0.103" +solana-frozen-abi = { path = "../../frozen-abi", version = "1.5.0" } +solana-frozen-abi-macro = { path = "../../frozen-abi/macro", version = "1.5.0" } solana-metrics = { path = "../../metrics", version = "1.5.0" } solana-sdk = { path = "../../sdk", version = "1.5.0" } solana-vote-program = { path = "../vote", version = "1.5.0" } solana-config-program = { path = "../config", version = "1.5.0" } -solana-sdk-macro-frozen-abi = { path = "../../sdk/macro-frozen-abi", version = "1.5.0" } thiserror = "1.0" [dev-dependencies] diff --git a/programs/stake/build.rs b/programs/stake/build.rs index c632c0d98b6bd4..84539eddaa6ded 120000 --- a/programs/stake/build.rs +++ b/programs/stake/build.rs @@ -1 +1 @@ -../../sdk/build.rs \ No newline at end of file +../../frozen-abi/build.rs \ No newline at end of file diff --git a/programs/stake/src/lib.rs b/programs/stake/src/lib.rs index de15175b0a8ced..57c4616bc43849 100644 --- a/programs/stake/src/lib.rs +++ b/programs/stake/src/lib.rs @@ -12,4 +12,4 @@ pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig) -> u64 { } #[macro_use] -extern crate solana_sdk_macro_frozen_abi; +extern crate solana_frozen_abi_macro; diff --git a/programs/vote/Cargo.toml b/programs/vote/Cargo.toml index 668596dd3934fa..58a59ba2816689 100644 --- a/programs/vote/Cargo.toml +++ b/programs/vote/Cargo.toml @@ -15,10 +15,11 @@ num-derive = "0.3" num-traits = "0.2" serde = "1.0.112" serde_derive = "1.0.103" +solana-frozen-abi = { path = "../../frozen-abi", version = "1.5.0" } +solana-frozen-abi-macro = { path = "../../frozen-abi/macro", version = "1.5.0" } solana-logger = { path = "../../logger", version = "1.5.0" } solana-metrics = { path = "../../metrics", version = "1.5.0" } solana-sdk = { path = "../../sdk", version = "1.5.0" } -solana-sdk-macro-frozen-abi = { path = "../../sdk/macro-frozen-abi", version = "1.5.0" } thiserror = "1.0" [build-dependencies] diff --git a/programs/vote/build.rs b/programs/vote/build.rs index c632c0d98b6bd4..84539eddaa6ded 120000 --- a/programs/vote/build.rs +++ b/programs/vote/build.rs @@ -1 +1 @@ -../../sdk/build.rs \ No newline at end of file +../../frozen-abi/build.rs \ No newline at end of file diff --git a/programs/vote/src/lib.rs b/programs/vote/src/lib.rs index 3ab1cb58287642..9e6daccb55207a 100644 --- a/programs/vote/src/lib.rs +++ b/programs/vote/src/lib.rs @@ -9,6 +9,6 @@ pub mod vote_transaction; extern crate solana_metrics; #[macro_use] -extern crate solana_sdk_macro_frozen_abi; +extern crate solana_frozen_abi_macro; solana_sdk::declare_id!("Vote111111111111111111111111111111111111111"); diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index c42715d845c674..01bdc835cd7d0e 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -35,12 +35,13 @@ regex = "1.3.9" serde = { version = "1.0.112", features = ["rc"] } serde_derive = "1.0.103" solana-config-program = { path = "../programs/config", version = "1.5.0" } +solana-frozen-abi = { path = "../frozen-abi", version = "1.5.0" } +solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "1.5.0" } solana-logger = { path = "../logger", version = "1.5.0" } solana-measure = { path = "../measure", version = "1.5.0" } solana-metrics = { path = "../metrics", version = "1.5.0" } solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "1.5.0" } solana-sdk = { path = "../sdk", version = "1.5.0" } -solana-sdk-macro-frozen-abi = { path = "../sdk/macro-frozen-abi", version = "1.5.0" } solana-stake-program = { path = "../programs/stake", version = "1.5.0" } solana-vote-program = { path = "../programs/vote", version = "1.5.0" } solana-secp256k1-program = { path = "../programs/secp256k1", version = "1.5.0" } diff --git a/runtime/build.rs b/runtime/build.rs index 8780ebe559a1cd..ae66c237c5f4fd 120000 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -1 +1 @@ -../sdk/build.rs \ No newline at end of file +../frozen-abi/build.rs \ No newline at end of file diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 79ae010c41e7ad..8a423198b37337 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -469,7 +469,7 @@ fn make_min_priority_thread_pool() -> ThreadPool { } #[cfg(all(test, RUSTC_WITH_SPECIALIZATION))] -impl solana_sdk::abi_example::AbiExample for AccountsDB { +impl solana_frozen_abi::abi_example::AbiExample for AccountsDB { fn example() -> Self { let accounts_db = AccountsDB::new_single(); let key = Pubkey::default(); diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index ef590cde770c90..b25a8076b7f217 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -330,7 +330,7 @@ pub struct BankRc { } #[cfg(RUSTC_WITH_SPECIALIZATION)] -use solana_sdk::abi_example::AbiExample; +use solana_frozen_abi::abi_example::AbiExample; #[cfg(RUSTC_WITH_SPECIALIZATION)] impl AbiExample for BankRc { fn example() -> Self { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 5b8eea61a1491c..c2345e0dddaf32 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -44,7 +44,7 @@ extern crate solana_metrics; extern crate serde_derive; #[macro_use] -extern crate solana_sdk_macro_frozen_abi; +extern crate solana_frozen_abi_macro; extern crate fs_extra; extern crate tempfile; diff --git a/runtime/src/message_processor.rs b/runtime/src/message_processor.rs index 35bb5ad756665d..c8a8e92fbfde18 100644 --- a/runtime/src/message_processor.rs +++ b/runtime/src/message_processor.rs @@ -387,7 +387,7 @@ impl Clone for MessageProcessor { } #[cfg(RUSTC_WITH_SPECIALIZATION)] -impl ::solana_sdk::abi_example::AbiExample for MessageProcessor { +impl ::solana_frozen_abi::abi_example::AbiExample for MessageProcessor { fn example() -> Self { // MessageProcessor's fields are #[serde(skip)]-ed and not Serialize // so, just rely on Default anyway. diff --git a/runtime/src/serde_snapshot.rs b/runtime/src/serde_snapshot.rs index f914e25749841c..7bce4531e2392f 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -39,7 +39,7 @@ use { }; #[cfg(RUSTC_WITH_SPECIALIZATION)] -use solana_sdk::abi_example::IgnoreAsHelper; +use solana_frozen_abi::abi_example::IgnoreAsHelper; mod common; mod future; diff --git a/runtime/src/serde_snapshot/future.rs b/runtime/src/serde_snapshot/future.rs index da1c6fdd36a525..effa073a60bd4b 100644 --- a/runtime/src/serde_snapshot/future.rs +++ b/runtime/src/serde_snapshot/future.rs @@ -1,6 +1,6 @@ use super::common::UnusedAccounts; #[cfg(all(test, RUSTC_WITH_SPECIALIZATION))] -use solana_sdk::abi_example::IgnoreAsHelper; +use solana_frozen_abi::abi_example::IgnoreAsHelper; use {super::*, solana_measure::measure::Measure, std::cell::RefCell}; type AccountsDbFields = super::AccountsDbFields; @@ -13,7 +13,7 @@ pub(super) struct SerializableAccountStorageEntry { } #[cfg(all(test, RUSTC_WITH_SPECIALIZATION))] -impl solana_sdk::abi_example::IgnoreAsHelper for SerializableAccountStorageEntry {} +impl solana_frozen_abi::abi_example::IgnoreAsHelper for SerializableAccountStorageEntry {} impl From<&AccountStorageEntry> for SerializableAccountStorageEntry { fn from(rhs: &AccountStorageEntry) -> Self { diff --git a/runtime/src/serde_snapshot/tests.rs b/runtime/src/serde_snapshot/tests.rs index 9238ae0e4ea829..e1d7c059f17495 100644 --- a/runtime/src/serde_snapshot/tests.rs +++ b/runtime/src/serde_snapshot/tests.rs @@ -262,7 +262,7 @@ mod test_bank_serialize { // These some what long test harness is required to freeze the ABI of // Bank's serialization due to versioned nature - #[frozen_abi(digest = "5rd8RyVSLH3hm12xJDVCJWgc1gyqb4Ukt2hJLJNfsB5v")] + #[frozen_abi(digest = "ULV2jDndxR3JB677ayyjaamtAcZ24q75tCkHS2bKVoy")] #[derive(Serialize, AbiExample)] pub struct BankAbiTestWrapperFuture { #[serde(serialize_with = "wrapper_future")] diff --git a/runtime/src/serde_snapshot/utils.rs b/runtime/src/serde_snapshot/utils.rs index a6af938e842844..1651d224401bd0 100644 --- a/runtime/src/serde_snapshot/utils.rs +++ b/runtime/src/serde_snapshot/utils.rs @@ -3,7 +3,7 @@ use serde::{ Serialize, Serializer, }; #[cfg(all(test, RUSTC_WITH_SPECIALIZATION))] -use solana_sdk::abi_example::IgnoreAsHelper; +use solana_frozen_abi::abi_example::IgnoreAsHelper; // consumes an iterator and returns an object that will serialize as a serde seq #[allow(dead_code)] diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index b4951ee8b80e10..468745d0dc7fb7 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -61,8 +61,9 @@ thiserror = "1.0" ed25519-dalek = { version = "=1.0.0-pre.4", optional = true } solana-crate-features = { path = "../crate-features", version = "1.5.0", optional = true } solana-logger = { path = "../logger", version = "1.5.0", optional = true } +solana-frozen-abi = { path = "../frozen-abi", version = "1.5.0" } +solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "1.5.0" } solana-sdk-macro = { path = "macro", version = "1.5.0" } -solana-sdk-macro-frozen-abi = { path = "macro-frozen-abi", version = "1.5.0" } rustversion = "1.0.3" libsecp256k1 = { version = "0.3.5", optional = true } sha3 = { version = "0.9.1", optional = true } diff --git a/sdk/build.rs b/sdk/build.rs deleted file mode 100644 index c9550c1c5c4f22..00000000000000 --- a/sdk/build.rs +++ /dev/null @@ -1,27 +0,0 @@ -extern crate rustc_version; -use rustc_version::{version_meta, Channel}; - -fn main() { - // Copied and adapted from - // https://github.com/Kimundi/rustc-version-rs/blob/1d692a965f4e48a8cb72e82cda953107c0d22f47/README.md#example - // Licensed under Apache-2.0 + MIT - match version_meta().unwrap().channel { - Channel::Stable => { - println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION"); - } - Channel::Beta => { - println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION"); - } - Channel::Nightly => { - println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION"); - } - Channel::Dev => { - println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION"); - // See https://github.com/solana-labs/solana/issues/11055 - // We may be running the custom `rust-bpf-builder` toolchain, - // which currently needs `#![feature(proc_macro_hygiene)]` to - // be applied. - println!("cargo:rustc-cfg=RUSTC_NEEDS_PROC_MACRO_HYGIENE"); - } - } -} diff --git a/sdk/build.rs b/sdk/build.rs new file mode 120000 index 00000000000000..ae66c237c5f4fd --- /dev/null +++ b/sdk/build.rs @@ -0,0 +1 @@ +../frozen-abi/build.rs \ No newline at end of file diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 0d8db94537fc5a..6b9d6da1e3f785 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -4,11 +4,6 @@ // Allows macro expansion of `use ::solana_sdk::*` to work within this crate extern crate self as solana_sdk; -#[cfg(RUSTC_WITH_SPECIALIZATION)] -pub mod abi_digester; -#[cfg(RUSTC_WITH_SPECIALIZATION)] -pub mod abi_example; - pub mod account; pub mod account_utils; pub mod bpf_loader; @@ -131,4 +126,4 @@ pub extern crate bs58; extern crate log as logger; #[macro_use] -extern crate solana_sdk_macro_frozen_abi; +extern crate solana_frozen_abi_macro; diff --git a/test-abi.sh b/test-abi.sh new file mode 100755 index 00000000000000..a10c5ca27609ac --- /dev/null +++ b/test-abi.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Easily run the ABI tests for the entire repo or a subset +# + +here=$(dirname "$0") +set -x +exec ${here}/cargo nightly test --lib -- test_abi_ diff --git a/version/Cargo.toml b/version/Cargo.toml index 42c3f0fd434a38..cee468f885aa20 100644 --- a/version/Cargo.toml +++ b/version/Cargo.toml @@ -12,10 +12,11 @@ edition = "2018" log = "0.4.8" serde = "1.0.112" serde_derive = "1.0.103" +solana-frozen-abi = { path = "../frozen-abi", version = "1.5.0" } +solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "1.5.0" } solana-logger = { path = "../logger", version = "1.5.0" } solana-sdk = { path = "../sdk", version = "1.5.0" } solana-runtime = { path = "../runtime", version = "1.5.0" } -solana-sdk-macro-frozen-abi = { path = "../sdk/macro-frozen-abi", version = "1.5.0" } [lib] name = "solana_version" diff --git a/version/build.rs b/version/build.rs index 8780ebe559a1cd..ae66c237c5f4fd 120000 --- a/version/build.rs +++ b/version/build.rs @@ -1 +1 @@ -../sdk/build.rs \ No newline at end of file +../frozen-abi/build.rs \ No newline at end of file diff --git a/version/src/lib.rs b/version/src/lib.rs index 37474804bae0ee..c9b0c3630e6eac 100644 --- a/version/src/lib.rs +++ b/version/src/lib.rs @@ -5,7 +5,7 @@ use serde_derive::{Deserialize, Serialize}; use solana_sdk::sanitize::Sanitize; use std::{convert::TryInto, fmt}; #[macro_use] -extern crate solana_sdk_macro_frozen_abi; +extern crate solana_frozen_abi_macro; // Older version structure used earlier 1.3.x releases #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]