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
Remove frozen ABI modules from solana-sdk #13008
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ members = [ | |
| "dos", | ||
| "download-utils", | ||
| "faucet", | ||
| "frozen-abi", | ||
| "perf", | ||
| "validator", | ||
| "genesis", | ||
|
|
||
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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../sdk/build.rs | ||
| ../frozen-abi/build.rs |
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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| [package] | ||
| name = "solana-frozen-abi" | ||
| version = "1.5.0" | ||
| description = "Solana Frozen ABI" | ||
| authors = ["Solana Maintainers <maintainers@solana.foundation>"] | ||
| 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" |
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 |
|---|---|---|
| @@ -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"); | ||
| } | ||
| } | ||
| } |
4 changes: 2 additions & 2 deletions
4
sdk/macro-frozen-abi/Cargo.toml → frozen-abi/macro/Cargo.toml
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
File renamed without changes.
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 |
|---|---|---|
|
|
@@ -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")] | ||
|
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. 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
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. |
||
| #[derive(Serialize, AbiExample)] | ||
| struct TestVecEnum { | ||
| enums: Vec<TestTupleVariant>, | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -213,9 +213,9 @@ atomic_example_impls! { AtomicI64 } | |
| atomic_example_impls! { AtomicIsize } | ||
| atomic_example_impls! { AtomicBool } | ||
|
|
||
| #[cfg(feature = "everything")] | ||
|
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. 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()) | ||
|
|
||
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 |
|---|---|---|
| @@ -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()) | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -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; |
Oops, something went wrong.
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.
@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.