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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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