Skip to content

Commit

Permalink
Introduce automatic ABI maintenance mechanism (2/2; rollout) (#8012)
Browse files Browse the repository at this point in the history
* Introduce automatic ABI maintenance mechanism (2/2; rollout)

* Fix stable clippy

* Change to symlink

* Freeze abi of Tower

* fmt...

* Improve dev-experience!

* Update BankSlotDelta

$ diff -u /tmp/abi8/*7dg6BreYxTuxiVz6aLvk3p2Z7GQk2cJqfGvC9h4FAoSj* /tmp/abi8/*9chBcbXVJ4fK7uGgydQzam5aHipaAKFw6V4LDFpjbE4w*
--- /tmp/abi8/bank__BankSlotDelta_frozen_abi__test_abi_digest_7dg6BreYxTuxiVz6aLvk3p2Z7GQk2cJqfGvC9h4FAoSj      2020-06-18 18:01:22.831228087 +0900
+++ /tmp/abi8/bank__BankSlotDelta_frozen_abi__test_abi_digest_9chBcbXVJ4fK7uGgydQzam5aHipaAKFw6V4LDFpjbE4w      2020-07-03 15:59:58.430695244 +0900
@@ -140,7 +140,7 @@
                                                         field u8
                                                             primitive u8
                                                         field solana_sdk::instruction::InstructionError
-                                                            enum InstructionError (variants = 34)
+                                                            enum InstructionError (variants = 35)
                                                                 variant(0) GenericError (unit)
                                                                 variant(1) InvalidArgument (unit)
                                                                 variant(2) InvalidInstructionData (unit)
@@ -176,6 +176,7 @@
                                                                 variant(31) CallDepth (unit)
                                                                 variant(32) MissingAccount (unit)
                                                                 variant(33) ReentrancyNotAllowed (unit)
+                                                                variant(34) MaxSeedLengthExceeded (unit)
                                                     variant(9) CallChainTooDeep (unit)
                                                     variant(10) MissingSignatureForFee (unit)
                                                     variant(11) InvalidAccountIndex (unit)

* Fix some merge conflicts...
  • Loading branch information
ryoqun authored Jul 6, 2020
1 parent 823126b commit 39b3ac6
Show file tree
Hide file tree
Showing 67 changed files with 295 additions and 77 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions ci/test-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ _ ci/order-crates-for-publishing.py
_ cargo +"$rust_stable" fmt --all -- --check

# -Z... is needed because of clippy bug: https://github.com/rust-lang/rust-clippy/issues/4612
# run nightly clippy for `sdk/` as there's a moderate amount of nightly-only code there
_ cargo +"$rust_nightly" clippy -Zunstable-options --workspace --all-targets -- --deny=warnings

_ scripts/cargo-for-all-lock-files.sh +"$rust_stable" audit --ignore RUSTSEC-2020-0002 --ignore RUSTSEC-2020-0008
Expand Down
4 changes: 4 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ solana-net-utils = { path = "../net-utils", version = "1.3.0" }
solana-perf = { path = "../perf", version = "1.3.0" }
solana-runtime = { path = "../runtime", version = "1.3.0" }
solana-sdk = { path = "../sdk", version = "1.3.0" }
solana-sdk-macro-frozen-abi = { path = "../sdk/macro-frozen-abi", version = "1.3.0" }
solana-stake-program = { path = "../programs/stake", version = "1.3.0" }
solana-streamer = { path = "../streamer", version = "1.3.0" }
solana-sys-tuner = { path = "../sys-tuner", version = "1.3.0" }
Expand All @@ -82,6 +83,9 @@ serial_test = "0.4.0"
serial_test_derive = "0.4.0"
systemstat = "0.1.5"

[build-dependencies]
rustc_version = "0.2"

[[bench]]
name = "banking_stage"

Expand Down
1 change: 1 addition & 0 deletions core/build.rs
5 changes: 3 additions & 2 deletions core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl fmt::Debug for Locality {
}
}

#[derive(Debug, Default, Deserialize, Serialize)]
#[derive(Debug, Default, Deserialize, Serialize, AbiExample)]
pub struct PruneData {
/// Pubkey of the node that sent this prune data
pub pubkey: Pubkey,
Expand Down Expand Up @@ -357,7 +357,8 @@ pub fn make_accounts_hashes_message(
}

// TODO These messages should go through the gpu pipeline for spam filtering
#[derive(Serialize, Deserialize, Debug)]
#[frozen_abi(digest = "6qRS1ZwydpdSqzeyRdDvn5uwfDdFYkuUz4K4jSkd1oFW")]
#[derive(Serialize, Deserialize, Debug, AbiEnumVisitor, AbiExample)]
#[allow(clippy::large_enum_variant)]
enum Protocol {
/// Gossip protocol messages
Expand Down
2 changes: 2 additions & 0 deletions core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub(crate) struct ComputedBankState {
pub pubkey_votes: Vec<(Pubkey, Slot)>,
}

#[frozen_abi(digest = "2ZUeCLMVQxmHYbeqMH7M97ifVSKoVErGvRHzyxcQRjgU")]
#[derive(Serialize, AbiExample)]
pub struct Tower {
node_pubkey: Pubkey,
threshold_depth: usize,
Expand Down
2 changes: 1 addition & 1 deletion core/src/contact_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::cmp::{Ord, Ordering, PartialEq, PartialOrd};
use std::net::{IpAddr, SocketAddr};

/// Structure representing a node on the network
#[derive(Serialize, Deserialize, Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug, AbiExample)]
pub struct ContactInfo {
pub id: Pubkey,
/// gossip address
Expand Down
2 changes: 1 addition & 1 deletion core/src/crds_gossip_pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub const CRDS_GOSSIP_PULL_MSG_TIMEOUT_MS: u64 = 60000;
pub const FALSE_RATE: f64 = 0.1f64;
pub const KEYS: f64 = 8f64;

#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, AbiExample)]
pub struct CrdsFilter {
pub filter: Bloom<Hash>,
mask: u64,
Expand Down
12 changes: 6 additions & 6 deletions core/src/crds_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub type EpochSlotsIndex = u8;
pub const MAX_EPOCH_SLOTS: EpochSlotsIndex = 255;

/// CrdsValue that is replicated across the cluster
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
pub struct CrdsValue {
pub signature: Signature,
pub data: CrdsData,
Expand Down Expand Up @@ -67,7 +67,7 @@ impl Signable for CrdsValue {
/// * Merge Strategy - Latest wallclock is picked
/// * LowestSlot index is deprecated
#[allow(clippy::large_enum_variant)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample, AbiEnumVisitor)]
pub enum CrdsData {
ContactInfo(ContactInfo),
Vote(VoteIndex, Vote),
Expand Down Expand Up @@ -107,7 +107,7 @@ impl Sanitize for CrdsData {
}
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
pub struct SnapshotHash {
pub from: Pubkey,
pub hashes: Vec<(Slot, Hash)>,
Expand Down Expand Up @@ -137,7 +137,7 @@ impl SnapshotHash {
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
pub struct LowestSlot {
pub from: Pubkey,
root: Slot, //deprecated
Expand Down Expand Up @@ -181,7 +181,7 @@ impl Sanitize for LowestSlot {
}
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
pub struct Vote {
pub from: Pubkey,
pub transaction: Transaction,
Expand All @@ -208,7 +208,7 @@ impl Vote {
}
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
pub struct Version {
pub from: Pubkey,
pub wallclock: u64,
Expand Down
4 changes: 2 additions & 2 deletions core/src/deprecated.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use solana_sdk::clock::Slot;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample, AbiEnumVisitor)]
enum CompressionType {
Uncompressed,
GZip,
Expand All @@ -13,7 +13,7 @@ impl Default for CompressionType {
}
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, AbiExample)]
pub(crate) struct EpochIncompleteSlots {
first: Slot,
compression: CompressionType,
Expand Down
8 changes: 4 additions & 4 deletions core/src/epoch_slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use solana_sdk::pubkey::Pubkey;
use solana_sdk::sanitize::{Sanitize, SanitizeError};

const MAX_SLOTS_PER_ENTRY: usize = 2048 * 8;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
pub struct Uncompressed {
pub first_slot: Slot,
pub num: usize,
Expand All @@ -28,7 +28,7 @@ impl Sanitize for Uncompressed {
}
}

#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, AbiExample)]
pub struct Flate2 {
pub first_slot: Slot,
pub num: usize,
Expand Down Expand Up @@ -142,7 +142,7 @@ impl Uncompressed {
}
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample, AbiEnumVisitor)]
pub enum CompressedSlots {
Flate2(Flate2),
Uncompressed(Uncompressed),
Expand Down Expand Up @@ -211,7 +211,7 @@ impl CompressedSlots {
}
}

#[derive(Serialize, Deserialize, Clone, Default, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Default, PartialEq, AbiExample)]
pub struct EpochSlots {
pub from: Pubkey,
pub slots: Vec<CompressedSlots>,
Expand Down
4 changes: 4 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
//! The `solana` library implements the Solana high-performance blockchain architecture.
//! It includes a full Rust implementation of the architecture (see
//! [Validator](server/struct.Validator.html)) as well as hooks to GPU implementations of its most
Expand Down Expand Up @@ -86,6 +87,9 @@ extern crate serde_json;
#[macro_use]
extern crate solana_metrics;

#[macro_use]
extern crate solana_sdk_macro_frozen_abi;

#[cfg(test)]
#[macro_use]
extern crate matches;
7 changes: 7 additions & 0 deletions programs/bpf/Cargo.lock

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

7 changes: 7 additions & 0 deletions programs/librapay/Cargo.lock

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

4 changes: 4 additions & 0 deletions programs/stake/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ solana-metrics = { path = "../../metrics", version = "1.3.0" }
solana-sdk = { path = "../../sdk", version = "1.3.0" }
solana-vote-program = { path = "../vote", version = "1.3.0" }
solana-config-program = { path = "../config", version = "1.3.0" }
solana-sdk-macro-frozen-abi = { path = "../../sdk/macro-frozen-abi", version = "1.3.0" }
thiserror = "1.0"

[dev-dependencies]
solana-logger = { path = "../../logger", version = "1.3.0" }

[build-dependencies]
rustc_version = "0.2"

[lib]
crate-type = ["lib"]
name = "solana_stake_program"
Expand Down
1 change: 1 addition & 0 deletions programs/stake/build.rs
4 changes: 4 additions & 0 deletions programs/stake/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
use solana_sdk::genesis_config::GenesisConfig;

pub mod config;
Expand All @@ -9,3 +10,6 @@ solana_sdk::declare_id!("Stake11111111111111111111111111111111111111");
pub fn add_genesis_accounts(genesis_config: &mut GenesisConfig) -> u64 {
config::add_genesis_account(genesis_config)
}

#[macro_use]
extern crate solana_sdk_macro_frozen_abi;
Loading

0 comments on commit 39b3ac6

Please sign in to comment.