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:
Ryo Onodera
2020-07-06 20:22:23 +09:00
committed by GitHub
parent 823126b372
commit 39b3ac6a8d
67 changed files with 295 additions and 77 deletions

View File

@ -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)",
]

View File

@ -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)",
]

View File

@ -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"

1
programs/stake/build.rs Symbolic link
View File

@ -0,0 +1 @@
../../sdk/build.rs

View File

@ -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;

View File

@ -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

View File

@ -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"

1
programs/vote/build.rs Symbolic link
View File

@ -0,0 +1 @@
../../sdk/build.rs

View File

@ -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>,
}

View File

@ -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");

View File

@ -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,