Initial validator sets pallet (#187)

* Initial work on a Validator Sets pallet

* Update Validator Set docs per current discussions

* Update validator-sets primitives and storage handling

* Add validator set pallets to deny.toml

* Remove Curve from primitives

Since we aren't reusing keys across coins, there's no reason for it to be
on-chain (as previously planned).

* Update documentation on Validator Sets

* Use Twox64Concat instead of Identity

Ensures an even distribution of keys. While xxhash is breakable, these keys
aren't manipulatable by users.

* Add math ops on Amount and define a coin as 1e8

* Add validator-sets to the runtime and remove contracts

Also removes the randomness pallet which was only required by the contracts
runtime.

Does not remove the contracts folder yet so they can still be referred to while
validator-sets is under development. Does remove them from Cargo.toml.

* Add vote function to validator-sets

* Remove contracts folder

* Create an event for the Validator Sets pallet

* Remove old contracts crates from deny.toml

* Remove line from staking branch

* Remove staking from runtime

* Correct VS Config in runtime

* cargo update

* Resolve a few PR comments on terminology

* Create a serai-primitives crate

Move types such as Amount/Coin out of validator-sets. Will be expanded in the
future.

* Fixes for last commit

* Don't reserve set 0

* Further fixes

* Add files meant for last commit

* Remove Staking transfer
This commit is contained in:
Luke Parker
2023-01-04 22:52:41 -05:00
committed by GitHub
parent 52913a6e8d
commit e979883f2d
26 changed files with 572 additions and 1151 deletions

View File

@@ -18,7 +18,7 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use frame_support::{
traits::{ConstBool, ConstU8, ConstU32, ConstU64},
traits::{ConstU8, ConstU32, ConstU64},
weights::{
constants::{RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND},
IdentityFee, Weight,
@@ -130,7 +130,6 @@ parameter_types! {
.get(DispatchClass::Normal)
.max_total
.unwrap_or(BlockWeights::get().max_block);
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
}
impl frame_system::Config for Runtime {
@@ -163,8 +162,6 @@ impl frame_system::Config for Runtime {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
impl pallet_randomness_collective_flip::Config for Runtime {}
impl pallet_timestamp::Config for Runtime {
type Moment = u64;
type OnTimestampSet = ();
@@ -193,34 +190,6 @@ impl pallet_transaction_payment::Config for Runtime {
type FeeMultiplierUpdate = ();
}
impl pallet_contracts::Config for Runtime {
type Time = Timestamp;
type Randomness = RandomnessCollectiveFlip;
type Currency = Balances;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type CallFilter = frame_support::traits::Nothing;
type DepositPerItem = DepositPerItem;
type DepositPerByte = DepositPerByte;
type CallStack = [pallet_contracts::Frame<Self>; 31];
type WeightPrice = pallet_transaction_payment::Pallet<Self>;
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
type ChainExtension = ();
type DeletionQueueDepth = DeletionQueueDepth;
type DeletionWeightLimit = DeletionWeightLimit;
type Schedule = Schedule;
type AddressGenerator = pallet_contracts::DefaultAddressGenerator;
type MaxCodeLen = ConstU32<{ 128 * 1024 }>;
type MaxStorageKeyLen = ConstU32<128>;
type UnsafeUnstableInterface = ConstBool<false>;
type MaxDebugBufferLen = ConstU32<255>;
}
impl pallet_tendermint::Config for Runtime {}
const SESSION_LENGTH: BlockNumber = 5 * DAYS;
type Sessions = PeriodicSessions<ConstU32<{ SESSION_LENGTH }>, ConstU32<{ SESSION_LENGTH }>>;
@@ -231,6 +200,10 @@ impl Convert<Public, Option<Public>> for IdentityValidatorIdOf {
}
}
impl validator_sets_pallet::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
}
impl pallet_session::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ValidatorId = AccountId;
@@ -243,6 +216,8 @@ impl pallet_session::Config for Runtime {
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
}
impl pallet_tendermint::Config for Runtime {}
pub type Address = AccountId;
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
@@ -274,11 +249,11 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system,
RandomnessCollectiveFlip: pallet_randomness_collective_flip,
Timestamp: pallet_timestamp,
Balances: pallet_balances,
TransactionPayment: pallet_transaction_payment,
Contracts: pallet_contracts,
ValidatorSets: validator_sets_pallet,
Session: pallet_session,
Tendermint: pallet_tendermint,
}