mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Test validator set's voting on a key
Needed for the in-instructions pallet to verify in-instructions are appropriately signed and continue developing that. Fixes a bug in the validator-sets pallet, moves several items from the pallet to primitives.
This commit is contained in:
@@ -19,8 +19,10 @@ scale-info = { version = "2", default-features = false, features = ["derive"] }
|
||||
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
|
||||
sp-core = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||
|
||||
serai-primitives = { path = "../../serai/primitives", default-features = false }
|
||||
|
||||
[features]
|
||||
std = ["zeroize", "scale/std", "scale-info/std", "serde", "serai-primitives/std"]
|
||||
std = ["zeroize", "scale/std", "scale-info/std", "serde", "sp-core/std", "serai-primitives/std"]
|
||||
default = ["std"]
|
||||
|
||||
@@ -9,7 +9,12 @@ use scale_info::TypeInfo;
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use serai_primitives::NetworkId;
|
||||
use sp_core::{ConstU32, sr25519, bounded::BoundedVec};
|
||||
|
||||
use serai_primitives::{NetworkId, Network, Amount};
|
||||
|
||||
// Support keys up to 96 bytes (BLS12-381 G2).
|
||||
const MAX_KEY_LEN: u32 = 96;
|
||||
|
||||
/// The type used to identify a specific session of validators.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]
|
||||
@@ -23,3 +28,22 @@ pub struct ValidatorSet {
|
||||
pub session: Session,
|
||||
pub network: NetworkId,
|
||||
}
|
||||
|
||||
/// The data for a validator set.
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]
|
||||
pub struct ValidatorSetData {
|
||||
pub bond: Amount,
|
||||
pub network: Network,
|
||||
|
||||
// Participant and their amount bonded to this set
|
||||
// Limit each set to 100 participants for now
|
||||
pub participants: BoundedVec<(sr25519::Public, Amount), ConstU32<100>>,
|
||||
}
|
||||
|
||||
type MaxKeyLen = ConstU32<MAX_KEY_LEN>;
|
||||
/// The type representing a Key from an external network.
|
||||
pub type ExternalKey = BoundedVec<u8, MaxKeyLen>;
|
||||
|
||||
/// A Validator Set's Ristretto key, used for signing InInstructions, and their key on the external
|
||||
/// network.
|
||||
pub type KeyPair = (sr25519::Public, ExternalKey);
|
||||
|
||||
Reference in New Issue
Block a user