Introduce automatic ABI maintenance mechanism (2/2; rollout) (#8012)
* 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...
This commit is contained in:
parent
823126b372
commit
39b3ac6a8d
|
@ -3950,6 +3950,7 @@ dependencies = [
|
|||
"rayon",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
|
@ -3972,6 +3973,7 @@ dependencies = [
|
|||
"solana-rayon-threadlimit",
|
||||
"solana-runtime",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"solana-stake-program",
|
||||
"solana-streamer",
|
||||
"solana-sys-tuner",
|
||||
|
@ -4561,6 +4563,7 @@ dependencies = [
|
|||
"rand 0.7.3",
|
||||
"rayon",
|
||||
"regex",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"solana-config-program",
|
||||
|
@ -4570,6 +4573,7 @@ dependencies = [
|
|||
"solana-noop-program",
|
||||
"solana-rayon-threadlimit",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"solana-stake-program",
|
||||
"solana-vote-program",
|
||||
"symlink",
|
||||
|
@ -4746,12 +4750,14 @@ dependencies = [
|
|||
"log 0.4.8",
|
||||
"num-derive 0.3.0",
|
||||
"num-traits",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"solana-config-program",
|
||||
"solana-logger",
|
||||
"solana-metrics",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"solana-vote-program",
|
||||
"thiserror",
|
||||
]
|
||||
|
@ -4871,9 +4877,13 @@ dependencies = [
|
|||
name = "solana-version"
|
||||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"log 0.4.8",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"solana-logger",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4900,10 +4910,13 @@ dependencies = [
|
|||
"log 0.4.8",
|
||||
"num-derive 0.3.0",
|
||||
"num-traits",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"solana-logger",
|
||||
"solana-metrics",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" }
|
||||
|
@ -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"
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../sdk/build.rs
|
|
@ -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,
|
||||
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
@ -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),
|
||||
|
@ -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)>,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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),
|
||||
|
@ -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>,
|
||||
|
|
|
@ -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
|
||||
|
@ -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;
|
||||
|
|
|
@ -1667,6 +1667,7 @@ dependencies = [
|
|||
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-config-program 1.3.0",
|
||||
|
@ -1675,6 +1676,7 @@ dependencies = [
|
|||
"solana-metrics 1.3.0",
|
||||
"solana-rayon-threadlimit 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi 1.3.0",
|
||||
"solana-stake-program 1.3.0",
|
||||
"solana-vote-program 1.3.0",
|
||||
"symlink 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1748,11 +1750,13 @@ dependencies = [
|
|||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-config-program 1.3.0",
|
||||
"solana-metrics 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi 1.3.0",
|
||||
"solana-vote-program 1.3.0",
|
||||
"thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -1765,10 +1769,13 @@ dependencies = [
|
|||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-logger 1.3.0",
|
||||
"solana-metrics 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi 1.3.0",
|
||||
"thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
|
@ -2497,6 +2497,7 @@ dependencies = [
|
|||
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-config-program 1.3.0",
|
||||
|
@ -2505,6 +2506,7 @@ dependencies = [
|
|||
"solana-metrics 1.3.0",
|
||||
"solana-rayon-threadlimit 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi 1.3.0",
|
||||
"solana-stake-program 1.3.0",
|
||||
"solana-vote-program 1.3.0",
|
||||
"symlink 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2578,11 +2580,13 @@ dependencies = [
|
|||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-config-program 1.3.0",
|
||||
"solana-metrics 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi 1.3.0",
|
||||
"solana-vote-program 1.3.0",
|
||||
"thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -2595,10 +2599,13 @@ dependencies = [
|
|||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-logger 1.3.0",
|
||||
"solana-metrics 1.3.0",
|
||||
"solana-sdk 1.3.0",
|
||||
"solana-sdk-macro-frozen-abi 1.3.0",
|
||||
"thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../../sdk/build.rs
|
|
@ -1,3 +1,4 @@
|
|||
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
|
||||
use solana_sdk::genesis_config::GenesisConfig;
|
||||
|
||||
pub mod config;
|
||||
|
@ -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;
|
||||
|
|
|
@ -21,7 +21,7 @@ use solana_sdk::{
|
|||
use solana_vote_program::vote_state::{VoteState, VoteStateVersions};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy, AbiExample)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum StakeState {
|
||||
Uninitialized,
|
||||
|
@ -91,13 +91,13 @@ impl StakeState {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy, AbiExample)]
|
||||
pub enum StakeAuthorize {
|
||||
Staker,
|
||||
Withdrawer,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone, Copy, AbiExample)]
|
||||
pub struct Lockup {
|
||||
/// UnixTimestamp at which this stake will allow withdrawal, unless the
|
||||
/// transaction is signed by the custodian
|
||||
|
@ -117,13 +117,13 @@ impl Lockup {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone, Copy, AbiExample)]
|
||||
pub struct Authorized {
|
||||
pub staker: Pubkey,
|
||||
pub withdrawer: Pubkey,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
|
||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone, Copy, AbiExample)]
|
||||
pub struct Meta {
|
||||
pub rent_exempt_reserve: u64,
|
||||
pub authorized: Authorized,
|
||||
|
@ -152,7 +152,7 @@ impl Meta {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy)]
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy, AbiExample)]
|
||||
pub struct Delegation {
|
||||
/// to whom the stake is delegated
|
||||
pub voter_pubkey: Pubkey,
|
||||
|
@ -313,7 +313,7 @@ impl Delegation {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone, Copy)]
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone, Copy, AbiExample)]
|
||||
pub struct Stake {
|
||||
pub delegation: Delegation,
|
||||
/// credits observed is credits from vote account state when delegated or redeemed
|
||||
|
|
|
@ -15,10 +15,15 @@ num-derive = "0.3"
|
|||
num-traits = "0.2"
|
||||
serde = "1.0.112"
|
||||
serde_derive = "1.0.103"
|
||||
solana-logger = { path = "../../logger", version = "1.3.0" }
|
||||
solana-metrics = { path = "../../metrics", 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" }
|
||||
thiserror = "1.0"
|
||||
|
||||
[build-dependencies]
|
||||
rustc_version = "0.2"
|
||||
|
||||
[lib]
|
||||
crate-type = ["lib"]
|
||||
name = "solana_vote_program"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../../sdk/build.rs
|
|
@ -3,7 +3,7 @@ use serde_derive::{Deserialize, Serialize};
|
|||
use solana_sdk::{clock::Epoch, pubkey::Pubkey};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone, AbiExample)]
|
||||
pub struct AuthorizedVoters {
|
||||
authorized_voters: BTreeMap<Epoch, Pubkey>,
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
|
||||
|
||||
pub mod authorized_voters;
|
||||
pub mod vote_instruction;
|
||||
pub mod vote_state;
|
||||
|
@ -6,4 +8,7 @@ pub mod vote_transaction;
|
|||
#[macro_use]
|
||||
extern crate solana_metrics;
|
||||
|
||||
#[macro_use]
|
||||
extern crate solana_sdk_macro_frozen_abi;
|
||||
|
||||
solana_sdk::declare_id!("Vote111111111111111111111111111111111111111");
|
||||
|
|
|
@ -36,7 +36,8 @@ pub const MAX_EPOCH_CREDITS_HISTORY: usize = 64;
|
|||
// defaults, intended to limit block time drift to < 1hr
|
||||
pub const TIMESTAMP_SLOT_INTERVAL: u64 = 4500;
|
||||
|
||||
#[derive(Serialize, Default, Deserialize, Debug, PartialEq, Eq, Clone)]
|
||||
#[frozen_abi(digest = "69hYtmmcuqPbhpc64ZaNJDidaUcg66CW6wzPFiuYZ3To")]
|
||||
#[derive(Serialize, Default, Deserialize, Debug, PartialEq, Eq, Clone, AbiExample)]
|
||||
pub struct Vote {
|
||||
/// A stack of votes starting with the oldest vote
|
||||
pub slots: Vec<Slot>,
|
||||
|
@ -60,7 +61,7 @@ impl Vote {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Default, Deserialize, Debug, PartialEq, Eq, Clone)]
|
||||
#[derive(Serialize, Default, Deserialize, Debug, PartialEq, Eq, Clone, AbiExample)]
|
||||
pub struct Lockout {
|
||||
pub slot: Slot,
|
||||
pub confirmation_count: u32,
|
||||
|
@ -103,7 +104,7 @@ pub enum VoteAuthorize {
|
|||
Withdrawer,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone, AbiExample)]
|
||||
pub struct BlockTimestamp {
|
||||
pub slot: Slot,
|
||||
pub timestamp: UnixTimestamp,
|
||||
|
@ -112,7 +113,7 @@ pub struct BlockTimestamp {
|
|||
// this is how many epochs a voter can be remembered for slashing
|
||||
const MAX_ITEMS: usize = 32;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, AbiExample)]
|
||||
pub struct CircBuf<I> {
|
||||
buf: [I; MAX_ITEMS],
|
||||
/// next pointer
|
||||
|
@ -153,7 +154,8 @@ impl<I> CircBuf<I> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone)]
|
||||
#[frozen_abi(digest = "H7z93iz4PiRJqahQ9G1aJXao1huusBz47SA5WfP8g4yd")]
|
||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone, AbiExample)]
|
||||
pub struct VoteState {
|
||||
/// the node that votes in this account
|
||||
pub node_pubkey: Pubkey,
|
||||
|
|
|
@ -37,6 +37,7 @@ solana-measure = { path = "../measure", version = "1.3.0" }
|
|||
solana-metrics = { path = "../metrics", version = "1.3.0" }
|
||||
solana-rayon-threadlimit = { path = "../rayon-threadlimit", 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-vote-program = { path = "../programs/vote", version = "1.3.0" }
|
||||
symlink = "0.1.0"
|
||||
|
@ -55,3 +56,6 @@ solana-noop-program = { path = "../programs/noop", version = "1.3.0" }
|
|||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[build-dependencies]
|
||||
rustc_version = "0.2"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../sdk/build.rs
|
|
@ -31,13 +31,13 @@ use std::{
|
|||
sync::{Arc, Mutex, RwLock},
|
||||
};
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
#[derive(Default, Debug, AbiExample)]
|
||||
pub(crate) struct ReadonlyLock {
|
||||
lock_count: Mutex<u64>,
|
||||
}
|
||||
|
||||
/// This structure handles synchronization for db
|
||||
#[derive(Default, Debug)]
|
||||
#[derive(Default, Debug, AbiExample)]
|
||||
pub struct Accounts {
|
||||
/// my slot
|
||||
pub slot: Slot,
|
||||
|
|
|
@ -132,7 +132,7 @@ impl AccountStorage {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone, Deserialize, Serialize, AbiExample, AbiEnumVisitor)]
|
||||
pub enum AccountStorageStatus {
|
||||
Available = 0,
|
||||
Full = 1,
|
||||
|
@ -324,7 +324,7 @@ pub fn get_temp_accounts_paths(count: u32) -> IOResult<(Vec<TempDir>, Vec<PathBu
|
|||
Ok((temp_dirs, paths))
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, AbiExample)]
|
||||
pub struct BankHashStats {
|
||||
pub num_updated_accounts: u64,
|
||||
pub num_removed_accounts: u64,
|
||||
|
@ -358,7 +358,7 @@ impl BankHashStats {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Default, Debug, Serialize, Deserialize, PartialEq, AbiExample)]
|
||||
pub struct BankHashInfo {
|
||||
pub hash: Hash,
|
||||
pub snapshot_hash: Hash,
|
||||
|
@ -431,6 +431,21 @@ fn make_min_priority_thread_pool() -> ThreadPool {
|
|||
.unwrap()
|
||||
}
|
||||
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
impl solana_sdk::abi_example::AbiExample for AccountsDB {
|
||||
fn example() -> Self {
|
||||
let accounts_db = AccountsDB::new_single();
|
||||
let key = Pubkey::default();
|
||||
let some_data_len = 5;
|
||||
let some_slot: Slot = 0;
|
||||
let account = Account::new(1, some_data_len, &key);
|
||||
accounts_db.store(some_slot, &[(&key, &account)]);
|
||||
accounts_db.add_root(0);
|
||||
|
||||
accounts_db
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AccountsDB {
|
||||
fn default() -> Self {
|
||||
let num_threads = get_thread_count();
|
||||
|
|
|
@ -100,7 +100,7 @@ impl<'a> StoredAccount<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, AbiExample)]
|
||||
#[allow(clippy::mutex_atomic)]
|
||||
pub struct AppendVec {
|
||||
path: PathBuf,
|
||||
|
|
|
@ -74,6 +74,7 @@ pub const SECONDS_PER_YEAR: f64 = 365.25 * 24.0 * 60.0 * 60.0;
|
|||
pub const MAX_LEADER_SCHEDULE_STAKES: Epoch = 5;
|
||||
|
||||
type BankStatusCache = StatusCache<Result<()>>;
|
||||
#[frozen_abi(digest = "9chBcbXVJ4fK7uGgydQzam5aHipaAKFw6V4LDFpjbE4w")]
|
||||
pub type BankSlotDelta = SlotDelta<Result<()>>;
|
||||
type TransactionAccountRefCells = Vec<Rc<RefCell<Account>>>;
|
||||
type TransactionLoaderRefCells = Vec<Vec<(Pubkey, RefCell<Account>)>>;
|
||||
|
@ -107,6 +108,20 @@ pub struct BankRc {
|
|||
pub(crate) slot: Slot,
|
||||
}
|
||||
|
||||
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
||||
use solana_sdk::abi_example::AbiExample;
|
||||
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
||||
impl AbiExample for BankRc {
|
||||
fn example() -> Self {
|
||||
BankRc {
|
||||
// Set parent to None to cut the recursion into another Bank
|
||||
parent: RwLock::new(None),
|
||||
accounts: AbiExample::example(),
|
||||
slot: AbiExample::example(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BankRc {
|
||||
pub(crate) fn new(accounts: Accounts, slot: Slot) -> Self {
|
||||
Self {
|
||||
|
@ -121,7 +136,7 @@ impl BankRc {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Default, AbiExample)]
|
||||
pub struct StatusCacheRc {
|
||||
/// where all the Accounts are stored
|
||||
/// A cache of signature statuses
|
||||
|
@ -188,7 +203,7 @@ impl HashAgeKind {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize)]
|
||||
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize, AbiExample)]
|
||||
struct UnusedAccounts {
|
||||
unused1: HashSet<Pubkey>,
|
||||
unused2: HashSet<Pubkey>,
|
||||
|
@ -196,7 +211,8 @@ struct UnusedAccounts {
|
|||
}
|
||||
|
||||
/// Manager for the state of all accounts and programs after processing its entries.
|
||||
#[derive(Default, Deserialize, Serialize)]
|
||||
#[frozen_abi(digest = "GsvisJfTaHxmTX4s6gQs2bZtxVggB7F325XDdXTA573p")]
|
||||
#[derive(Default, Deserialize, Serialize, AbiExample)]
|
||||
pub struct Bank {
|
||||
/// References to accounts, parent and signature status
|
||||
#[serde(skip)]
|
||||
|
|
|
@ -4,7 +4,7 @@ use solana_sdk::{
|
|||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, AbiExample)]
|
||||
struct HashAge {
|
||||
fee_calculator: FeeCalculator,
|
||||
hash_height: u64,
|
||||
|
@ -12,7 +12,8 @@ struct HashAge {
|
|||
}
|
||||
|
||||
/// Low memory overhead, so can be cloned for every checkpoint
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[frozen_abi(digest = "EwaoLA34VN18E95GvjmkeStUpWqTeBd7FGpd7mppLmEw")]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, AbiExample)]
|
||||
pub struct BlockhashQueue {
|
||||
/// updated whenever an hash is registered
|
||||
hash_height: u64,
|
||||
|
|
|
@ -11,7 +11,7 @@ pub trait BloomHashIndex {
|
|||
fn hash_at_index(&self, hash_index: u64) -> u64;
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)]
|
||||
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, AbiExample)]
|
||||
pub struct Bloom<T: BloomHashIndex> {
|
||||
pub keys: Vec<u64>,
|
||||
pub bits: BitVec<u64>,
|
||||
|
|
|
@ -7,13 +7,13 @@ use std::{collections::HashMap, sync::Arc};
|
|||
pub type NodeIdToVoteAccounts = HashMap<Pubkey, NodeVoteAccounts>;
|
||||
pub type EpochAuthorizedVoters = HashMap<Pubkey, Pubkey>;
|
||||
|
||||
#[derive(Clone, Serialize, Debug, Deserialize, Default, PartialEq)]
|
||||
#[derive(Clone, Serialize, Debug, Deserialize, Default, PartialEq, AbiExample)]
|
||||
pub struct NodeVoteAccounts {
|
||||
pub vote_accounts: Vec<Pubkey>,
|
||||
pub total_stake: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize, AbiExample)]
|
||||
pub struct EpochStakes {
|
||||
stakes: Arc<Stakes>,
|
||||
total_stake: u64,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
|
||||
pub mod accounts;
|
||||
pub mod accounts_db;
|
||||
pub mod accounts_index;
|
||||
|
@ -38,5 +39,8 @@ extern crate solana_metrics;
|
|||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[macro_use]
|
||||
extern crate solana_sdk_macro_frozen_abi;
|
||||
|
||||
extern crate fs_extra;
|
||||
extern crate tempfile;
|
||||
|
|
|
@ -262,6 +262,16 @@ impl Clone for MessageProcessor {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
||||
impl ::solana_sdk::abi_example::AbiExample for MessageProcessor {
|
||||
fn example() -> Self {
|
||||
// MessageProcessor's fields are #[serde(skip)]-ed and not Serialize
|
||||
// so, just rely on Default anyway.
|
||||
MessageProcessor::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl MessageProcessor {
|
||||
/// Add a static entrypoint to intercept instructions before the dynamic loader.
|
||||
pub fn add_program(&mut self, program_id: Pubkey, process_instruction: ProcessInstruction) {
|
||||
|
|
|
@ -4,7 +4,7 @@ use solana_sdk::{
|
|||
rent::Rent, sysvar,
|
||||
};
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone)]
|
||||
#[derive(Default, Serialize, Deserialize, Clone, AbiExample)]
|
||||
pub struct RentCollector {
|
||||
pub epoch: Epoch,
|
||||
pub epoch_schedule: EpochSchedule,
|
||||
|
|
|
@ -7,6 +7,9 @@ pub(super) struct SerializableAccountStorageEntry {
|
|||
accounts_current_len: usize,
|
||||
}
|
||||
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
impl solana_sdk::abi_example::IgnoreAsHelper for SerializableAccountStorageEntry {}
|
||||
|
||||
impl From<&AccountStorageEntry> for SerializableAccountStorageEntry {
|
||||
fn from(rhs: &AccountStorageEntry) -> Self {
|
||||
Self {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
use solana_sdk::abi_example::IgnoreAsHelper;
|
||||
use {super::*, solana_measure::measure::Measure, std::cell::RefCell};
|
||||
|
||||
// Serializable version of AccountStorageEntry for snapshot format
|
||||
|
@ -8,6 +10,9 @@ pub(super) struct SerializableAccountStorageEntry {
|
|||
count_and_status: (usize, AccountStorageStatus),
|
||||
}
|
||||
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
impl IgnoreAsHelper for SerializableAccountStorageEntry {}
|
||||
|
||||
impl From<&AccountStorageEntry> for SerializableAccountStorageEntry {
|
||||
fn from(rhs: &AccountStorageEntry) -> Self {
|
||||
Self {
|
||||
|
@ -30,6 +35,9 @@ struct SerializableAppendVec {
|
|||
current_len: usize,
|
||||
}
|
||||
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
impl IgnoreAsHelper for SerializableAppendVec {}
|
||||
|
||||
impl From<&AppendVec> for SerializableAppendVec {
|
||||
fn from(rhs: &AppendVec) -> SerializableAppendVec {
|
||||
SerializableAppendVec {
|
||||
|
|
|
@ -278,3 +278,50 @@ fn test_bank_serialize_newer() {
|
|||
fn test_bank_serialize_older() {
|
||||
test_bank_serialize_style(SerdeStyle::OLDER)
|
||||
}
|
||||
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
mod test_bank_rc_serialize {
|
||||
use super::*;
|
||||
|
||||
// These some what long test harness is required to freeze the ABI of
|
||||
// BankRc's serialization due to versioned nature
|
||||
#[frozen_abi(digest = "HfCP74JKqPdeAccNJEj7KEoNxtsmX3zRqc2rpTy1NC7H")]
|
||||
#[derive(Serialize, AbiExample)]
|
||||
pub struct BandRcAbiTestWrapperFuture {
|
||||
#[serde(serialize_with = "wrapper_future")]
|
||||
bank_rc: BankRc,
|
||||
}
|
||||
|
||||
pub fn wrapper_future<S>(bank_rc: &BankRc, s: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
let snapshot_storages = bank_rc.accounts.accounts_db.get_snapshot_storages(0);
|
||||
(SerializableBankRc::<future::Context> {
|
||||
bank_rc,
|
||||
snapshot_storages: &snapshot_storages,
|
||||
phantom: std::marker::PhantomData::default(),
|
||||
})
|
||||
.serialize(s)
|
||||
}
|
||||
|
||||
#[frozen_abi(digest = "43niyekyWwreLALcdEeFFpd7h8U6pgSXGqfKBRw8H7Vy")]
|
||||
#[derive(Serialize, AbiExample)]
|
||||
pub struct BandRcAbiTestWrapperLegacy {
|
||||
#[serde(serialize_with = "wrapper_legacy")]
|
||||
bank_rc: BankRc,
|
||||
}
|
||||
|
||||
pub fn wrapper_legacy<S>(bank_rc: &BankRc, s: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
let snapshot_storages = bank_rc.accounts.accounts_db.get_snapshot_storages(0);
|
||||
(SerializableBankRc::<legacy::Context> {
|
||||
bank_rc,
|
||||
snapshot_storages: &snapshot_storages,
|
||||
phantom: std::marker::PhantomData::default(),
|
||||
})
|
||||
.serialize(s)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ use serde::{
|
|||
ser::{SerializeSeq, SerializeTuple},
|
||||
Serialize, Serializer,
|
||||
};
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
use solana_sdk::abi_example::IgnoreAsHelper;
|
||||
|
||||
// consumes an iterator and returns an object that will serialize as a serde seq
|
||||
#[allow(dead_code)]
|
||||
|
@ -15,6 +17,9 @@ where
|
|||
iter: std::cell::RefCell<Option<I>>,
|
||||
}
|
||||
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
impl<I> IgnoreAsHelper for SerializableSequencedIterator<I> {}
|
||||
|
||||
impl<I> Serialize for SerializableSequencedIterator<I>
|
||||
where
|
||||
I: IntoIterator,
|
||||
|
@ -51,6 +56,9 @@ where
|
|||
iter: std::cell::RefCell<Option<I>>,
|
||||
}
|
||||
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
impl<I> IgnoreAsHelper for SerializableSequencedIterator<I> {}
|
||||
|
||||
impl<I> Serialize for SerializableSequencedIterator<I>
|
||||
where
|
||||
I: IntoIterator,
|
||||
|
@ -87,6 +95,9 @@ where
|
|||
iter: std::cell::RefCell<Option<I>>,
|
||||
}
|
||||
|
||||
#[cfg(all(test, RUSTC_WITH_SPECIALIZATION))]
|
||||
impl<I> IgnoreAsHelper for SerializableMappedIterator<I> {}
|
||||
|
||||
impl<K, V, I> Serialize for SerializableMappedIterator<I>
|
||||
where
|
||||
K: Serialize,
|
||||
|
|
|
@ -7,7 +7,7 @@ use solana_stake_program::stake_state::{new_stake_history_entry, Delegation, Sta
|
|||
use solana_vote_program::vote_state::VoteState;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize)]
|
||||
#[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize, AbiExample)]
|
||||
pub struct Stakes {
|
||||
/// vote accounts
|
||||
vote_accounts: HashMap<Pubkey, (u64, Account)>,
|
||||
|
|
|
@ -41,7 +41,7 @@ pub struct SignatureConfirmationStatus<T> {
|
|||
pub status: T,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, AbiExample)]
|
||||
pub struct StatusCache<T: Serialize + Clone> {
|
||||
cache: StatusMap<T>,
|
||||
roots: HashSet<Slot>,
|
||||
|
|
|
@ -7,7 +7,6 @@ repository = "https://github.com/solana-labs/solana"
|
|||
homepage = "https://solana.com/"
|
||||
license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
build = "../build.rs"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../build.rs
|
|
@ -307,7 +307,7 @@ fn quote_for_test(
|
|||
#[cfg(test)]
|
||||
mod #test_mod_ident {
|
||||
use super::*;
|
||||
use ::solana_sdk::{abi_digester::AbiEnumVisitor, abi_example::AbiExample};
|
||||
use ::solana_sdk::abi_example::{AbiExample, AbiEnumVisitor};
|
||||
|
||||
#[test]
|
||||
fn test_abi_digest() {
|
||||
|
@ -321,13 +321,18 @@ fn quote_for_test(
|
|||
::log::error!("digest error: {:#?}", result);
|
||||
}
|
||||
result.unwrap();
|
||||
let actual_digest = format!("{}", hash);
|
||||
if ::std::env::var("SOLANA_ABI_BULK_UPDATE").is_ok() {
|
||||
if #expected_digest != format!("{}", hash) {
|
||||
if #expected_digest != actual_digest {
|
||||
#p!("sed -i -e 's/{}/{}/g' $(git grep --files-with-matches frozen_abi)", #expected_digest, hash);
|
||||
}
|
||||
::log::warn!("Not testing the abi digest under SOLANA_ABI_BULK_UPDATE!");
|
||||
} else {
|
||||
assert_eq!(#expected_digest, format!("{}", hash), "Possibly ABI changed? Confirm the diff by rerunning before and after this test failed with SOLANA_ABI_DUMP_DIR");
|
||||
if let Ok(dir) = ::std::env::var("SOLANA_ABI_DUMP_DIR") {
|
||||
assert_eq!(#expected_digest, actual_digest, "Possibly ABI changed? Examine the diff in SOLANA_ABI_DUMP_DIR!: $ diff -u {}/*{}* {}/*{}*", dir, #expected_digest, dir, actual_digest);
|
||||
} else {
|
||||
assert_eq!(#expected_digest, actual_digest, "Possibly ABI changed? Confirm the diff by rerunning before and after this test failed with SOLANA_ABI_DUMP_DIR!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ impl<T: AbiExample> AbiExample for std::sync::RwLock<T> {
|
|||
}
|
||||
}
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
|
||||
|
||||
impl<
|
||||
T: std::cmp::Eq + std::hash::Hash + AbiExample,
|
||||
|
@ -379,6 +379,13 @@ impl<T: AbiExample> AbiExample for Vec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: AbiExample> AbiExample for VecDeque<T> {
|
||||
fn example() -> Self {
|
||||
info!("AbiExample for (Vec<T>): {}", type_name::<Self>());
|
||||
VecDeque::from(vec![T::example()])
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: std::cmp::Eq + std::hash::Hash + AbiExample, H: std::hash::BuildHasher + Default> AbiExample
|
||||
for HashSet<T, H>
|
||||
{
|
||||
|
|
|
@ -8,7 +8,8 @@ use std::{
|
|||
|
||||
/// An Account with data that is stored on chain
|
||||
#[repr(C)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Default)]
|
||||
#[frozen_abi(digest = "By9FhuLAM947tkLxbTVQru9ZKTrRQuvCR5W387nPSLNu")]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Default, AbiExample)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Account {
|
||||
/// lamports in the account
|
||||
|
|
|
@ -17,7 +17,7 @@ pub const MAX_LEADER_SCHEDULE_EPOCH_OFFSET: u64 = 3;
|
|||
pub const MINIMUM_SLOTS_PER_EPOCH: u64 = 32;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Deserialize, Serialize, AbiExample)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EpochSchedule {
|
||||
/// The maximum number of slots in each epoch.
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::clock::{DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT};
|
|||
use crate::message::Message;
|
||||
use log::*;
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, AbiExample)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FeeCalculator {
|
||||
// The current cost of a signature This amount may increase/decrease over time based on
|
||||
|
@ -30,7 +30,7 @@ impl FeeCalculator {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, AbiExample)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FeeRateGovernor {
|
||||
// The current cost of a signature This amount may increase/decrease over time based on
|
||||
|
|
|
@ -30,14 +30,15 @@ use std::{
|
|||
// deprecated default that is no longer used
|
||||
pub const UNUSED_DEFAULT: u64 = 1024;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, AbiEnumVisitor, AbiExample)]
|
||||
pub enum OperatingMode {
|
||||
Preview, // Next set of cluster features to be promoted to Stable
|
||||
Stable, // Stable cluster features
|
||||
Development, // All features (including experimental features)
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[frozen_abi(digest = "2KQs7m2DbLxkEx6pY9Z6qwYJAhN2Q4AdoNgUcULmscgB")]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, AbiExample)]
|
||||
pub struct GenesisConfig {
|
||||
/// when the network (bootstrap validator) was started relative to the UNIX Epoch
|
||||
pub creation_time: UnixTimestamp,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use byteorder::{ByteOrder, LittleEndian};
|
||||
use solana_sdk::clock::Slot;
|
||||
|
||||
#[derive(Default, Clone, Deserialize, Serialize)]
|
||||
#[derive(Default, Clone, Deserialize, Serialize, AbiExample)]
|
||||
pub struct HardForks {
|
||||
hard_forks: Vec<(Slot, usize)>,
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ use std::{convert::TryFrom, fmt, mem, str::FromStr};
|
|||
use thiserror::Error;
|
||||
|
||||
pub const HASH_BYTES: usize = 32;
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(
|
||||
Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash, AbiExample,
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
pub struct Hash([u8; HASH_BYTES]);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! configuration for network inflation
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug, Copy)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug, Copy, AbiExample)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Inflation {
|
||||
/// Initial inflation percentage, from time=0
|
||||
|
|
|
@ -7,7 +7,7 @@ use serde::Serialize;
|
|||
use thiserror::Error;
|
||||
|
||||
/// Reasons the runtime might have rejected an instruction.
|
||||
#[derive(Serialize, Deserialize, Debug, Error, PartialEq, Eq, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, Error, PartialEq, Eq, Clone, AbiExample, AbiEnumVisitor)]
|
||||
pub enum InstructionError {
|
||||
/// Deprecated! Use CustomError instead!
|
||||
/// The program instruction returned an error
|
||||
|
@ -214,7 +214,7 @@ impl AccountMeta {
|
|||
}
|
||||
|
||||
/// An instruction to execute a program
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, AbiExample)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CompiledInstruction {
|
||||
/// Index into the transaction keys array indicating the program account that executes this instruction
|
||||
|
|
|
@ -101,7 +101,5 @@ extern crate serde_derive;
|
|||
pub extern crate bs58;
|
||||
extern crate log as logger;
|
||||
|
||||
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate solana_sdk_macro_frozen_abi;
|
||||
|
|
|
@ -138,7 +138,8 @@ fn get_program_ids(instructions: &[Instruction]) -> Vec<Pubkey> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone)]
|
||||
#[frozen_abi(digest = "BVC5RhetsNpheGipt5rUrkR6RDDUHtD5sCLK1UjymL4S")]
|
||||
#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, AbiExample)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MessageHeader {
|
||||
/// The number of signatures required for this message to be considered valid. The
|
||||
|
@ -156,7 +157,8 @@ pub struct MessageHeader {
|
|||
pub num_readonly_unsigned_accounts: u8,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone)]
|
||||
#[frozen_abi(digest = "A18PN3BWKw4hU69STY79SyRS3tS6w54nCgYRRx77vQiL")]
|
||||
#[derive(Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, AbiExample)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Message {
|
||||
/// The message header, identifying signed and read-only `account_keys`
|
||||
|
|
|
@ -12,7 +12,8 @@ use std::{
|
|||
/// 8 bytes is the size of the fragment header
|
||||
pub const PACKET_DATA_SIZE: usize = 1280 - 40 - 8;
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[frozen_abi(digest = "9AiPd36yycNg18hDuCBVGwpTfzjX1VV4QtUKUdqeyAKH")]
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, AbiExample)]
|
||||
#[repr(C)]
|
||||
pub struct Meta {
|
||||
pub size: usize,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::clock::DEFAULT_TICKS_PER_SECOND;
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, AbiExample)]
|
||||
pub struct PohConfig {
|
||||
/// The target tick rate of the cluster.
|
||||
pub target_tick_duration: Duration,
|
||||
|
|
|
@ -26,7 +26,9 @@ impl<T> DecodeError<T> for PubkeyError {
|
|||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(
|
||||
Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash, AbiExample,
|
||||
)]
|
||||
pub struct Pubkey([u8; 32]);
|
||||
|
||||
impl crate::sanitize::Sanitize for Pubkey {}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! configuration for network rent
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Clone, Copy, Debug)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Clone, Copy, Debug, AbiExample)]
|
||||
pub struct Rent {
|
||||
/// Rental rate
|
||||
pub lamports_per_byte_year: u64,
|
||||
|
|
|
@ -10,6 +10,7 @@ use std::{fmt, marker::PhantomData, mem::size_of};
|
|||
/// bytes. Each byte follows the same pattern until the 3rd byte. The 3rd
|
||||
/// byte, if needed, uses all 8 bits to store the last byte of the original
|
||||
/// value.
|
||||
#[derive(AbiExample)]
|
||||
pub struct ShortU16(pub u16);
|
||||
|
||||
impl Serialize for ShortU16 {
|
||||
|
|
|
@ -47,7 +47,9 @@ impl Keypair {
|
|||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(
|
||||
Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash, AbiExample,
|
||||
)]
|
||||
pub struct Signature(GenericArray<u8, U64>);
|
||||
|
||||
impl crate::sanitize::Sanitize for Signature {}
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::ops::Deref;
|
|||
|
||||
pub const MAX_ENTRIES: usize = 512; // it should never take as many as 512 epochs to warm up or cool down
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Default, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Default, Clone, AbiExample)]
|
||||
pub struct StakeHistoryEntry {
|
||||
pub effective: u64, // effective stake at this epoch
|
||||
pub activating: u64, // sum of portion of stakes not fully warmed up
|
||||
|
@ -16,7 +16,7 @@ pub struct StakeHistoryEntry {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Default, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Default, Clone, AbiExample)]
|
||||
pub struct StakeHistory(Vec<(Epoch, StakeHistoryEntry)>);
|
||||
|
||||
impl StakeHistory {
|
||||
|
|
|
@ -52,7 +52,8 @@ impl<E> DecodeError<E> for NonceError {
|
|||
/// maximum permitted size of data: 10 MB
|
||||
pub const MAX_PERMITTED_DATA_LENGTH: u64 = 10 * 1024 * 1024;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||
#[frozen_abi(digest = "E343asdJPd3aEbHSsmeeGzvztc9X2maaHhWxVS4P6hvW")]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, AbiExample, AbiEnumVisitor)]
|
||||
pub enum SystemInstruction {
|
||||
/// Create a new account
|
||||
///
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::result;
|
|||
use thiserror::Error;
|
||||
|
||||
/// Reasons a transaction might be rejected.
|
||||
#[derive(Error, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
|
||||
#[derive(Error, Serialize, Deserialize, Debug, PartialEq, Eq, Clone, AbiExample, AbiEnumVisitor)]
|
||||
pub enum TransactionError {
|
||||
/// An account is already being processed in another transaction in a way
|
||||
/// that does not support parallelism
|
||||
|
@ -88,7 +88,8 @@ pub enum TransactionError {
|
|||
pub type Result<T> = result::Result<T, TransactionError>;
|
||||
|
||||
/// An atomic transaction
|
||||
#[derive(Debug, PartialEq, Default, Eq, Clone, Serialize, Deserialize)]
|
||||
#[frozen_abi(digest = "GoxM5ZMMjM2FSuY1VtuMhs1j8u9kMuYsH3dpYcSVVnTe")]
|
||||
#[derive(Debug, PartialEq, Default, Eq, Clone, Serialize, Deserialize, AbiExample)]
|
||||
pub struct Transaction {
|
||||
/// A set of digital signatures of `account_keys`, `program_ids`, `recent_blockhash`, and `instructions`, signed by the first
|
||||
/// signatures.len() keys of account_keys
|
||||
|
|
|
@ -9,12 +9,18 @@ homepage = "https://solana.com/"
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.8"
|
||||
serde = "1.0.112"
|
||||
serde_derive = "1.0.103"
|
||||
solana-logger = { path = "../logger", version = "1.3.0" }
|
||||
solana-sdk = { path = "../sdk", version = "1.3.0" }
|
||||
solana-sdk-macro-frozen-abi = { path = "../sdk/macro-frozen-abi", version = "1.2.0" }
|
||||
|
||||
[lib]
|
||||
name = "solana_version"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[build-dependencies]
|
||||
rustc_version = "0.2"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../sdk/build.rs
|
|
@ -1,9 +1,14 @@
|
|||
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
|
||||
|
||||
extern crate serde_derive;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use solana_sdk::sanitize::Sanitize;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[macro_use]
|
||||
extern crate solana_sdk_macro_frozen_abi;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
|
||||
pub struct Version {
|
||||
major: u16,
|
||||
minor: u16,
|
||||
|
|
Loading…
Reference in New Issue