-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Remove frozen ABI modules from solana-sdk #13008
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ members = [ | |
"dos", | ||
"download-utils", | ||
"faucet", | ||
"frozen-abi", | ||
"perf", | ||
"validator", | ||
"genesis", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../sdk/build.rs | ||
../frozen-abi/build.rs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "solana-frozen-abi" | ||
version = "1.5.0" | ||
description = "Solana Frozen ABI" | ||
authors = ["Solana Maintainers <[email protected]>"] | ||
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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]>"] | ||
repository = "https://github.com/solana-labs/solana" | ||
homepage = "https://solana.com/" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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")] | ||
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. here it is: $ diff -U3 /tmp/abi8/*CKxzv7VjyUrNR9fGJpTpKyMBWJM4gepKshCS8oV14T1Q* /tmp/abi8/*DywMfwKq8HZCbUfTwnemHWMN8LvMZCvipQuLddQ2ywwG*
--- /tmp/abi8/abi_digester__tests__TestVecEnum_frozen_abi__test_abi_digest_CKxzv7VjyUrNR9fGJpTpKyMBWJM4gepKshCS8oV14T1Q 2020-10-20 21:17:02.036989718 +0900
+++ /tmp/abi8/abi_digester__tests__TestVecEnum_frozen_abi__test_abi_digest_DywMfwKq8HZCbUfTwnemHWMN8LvMZCvipQuLddQ2ywwG 2020-10-20 21:21:09.171484610 +0900
@@ -1,7 +1,7 @@
struct TestVecEnum (fields = 1)
- field enums: alloc::vec::Vec<solana_sdk::abi_digester::tests::TestTupleVariant>
+ field enums: alloc::vec::Vec<solana_frozen_abi::abi_digester::tests::TestTupleVariant>
seq (elements = 1)
- element solana_sdk::abi_digester::tests::TestTupleVariant
+ element solana_frozen_abi::abi_digester::tests::TestTupleVariant
enum TestTupleVariant (variants = 2)
variant(0) VARIANT1 (fields = 2)
field u8
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.
|
||
#[derive(Serialize, AbiExample)] | ||
struct TestVecEnum { | ||
enums: Vec<TestTupleVariant>, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,9 +213,9 @@ atomic_example_impls! { AtomicI64 } | |
atomic_example_impls! { AtomicIsize } | ||
atomic_example_impls! { AtomicBool } | ||
|
||
#[cfg(feature = "everything")] | ||
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. Feature removal! |
||
#[cfg(not(target_arch = "bpf"))] | ||
use generic_array::{ArrayLength, GenericArray}; | ||
#[cfg(feature = "everything")] | ||
#[cfg(not(target_arch = "bpf"))] | ||
impl<T: Default, U: ArrayLength<T>> AbiExample for GenericArray<T, U> { | ||
fn example() -> Self { | ||
Self::default() | ||
|
@@ -413,14 +413,14 @@ impl<T: std::cmp::Ord + AbiExample> AbiExample for BTreeSet<T> { | |
} | ||
} | ||
|
||
#[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()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
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.
@ryoqun - These two hashes changed on me for some reason. Seems harmless though. Maybe it's due to the crate rename somenow?
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.
yeah, it detects such renames because it need to consider XX::Hash to be different from YY::Hash.