feat(operator): 🏗️ Add Multisig pallet (#22)

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
This commit is contained in:
Steve Degosserie 2025-04-02 16:22:53 +02:00 committed by GitHub
parent 8c2c2a351e
commit 35a80814ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 55 additions and 3 deletions

16
operator/Cargo.lock generated
View file

@ -1608,6 +1608,7 @@ dependencies = [
"pallet-evm-chain-id",
"pallet-grandpa",
"pallet-mmr",
"pallet-multisig",
"pallet-session",
"pallet-sudo",
"pallet-timestamp",
@ -5939,6 +5940,21 @@ dependencies = [
"sp-runtime",
]
[[package]]
name = "pallet-multisig"
version = "38.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk?branch=stable2409#43d7b1e329f50a37cbd67e15aae70c60556cbb59"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"log",
"parity-scale-codec",
"scale-info",
"sp-io",
"sp-runtime",
]
[[package]]
name = "pallet-session"
version = "38.0.0"

View file

@ -85,6 +85,7 @@ frame-try-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch
pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }

View file

@ -26,6 +26,7 @@ hex-literal.workspace = true
pallet-babe.workspace = true
pallet-balances.workspace = true
pallet-grandpa.workspace = true
pallet-multisig.workspace = true
pallet-session.workspace = true
pallet-sudo.workspace = true
pallet-timestamp.workspace = true
@ -92,6 +93,7 @@ std = [
"pallet-beefy-mmr/std",
"pallet-balances/std",
"pallet-grandpa/std",
"pallet-multisig/std",
"pallet-mmr/std",
"pallet-session/std",
"pallet-session/std",
@ -141,6 +143,7 @@ runtime-benchmarks = [
"datahaven-runtime-common/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
@ -162,6 +165,7 @@ try-runtime = [
"pallet-babe/try-runtime",
"pallet-balances/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-multisig/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",

View file

@ -27,6 +27,7 @@ frame_benchmarking::define_benchmarks!(
[frame_benchmarking, BaselineBench::<Runtime>]
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
[pallet_timestamp, Timestamp]
[pallet_utility, Utility]
[pallet_sudo, Sudo]

View file

@ -30,9 +30,9 @@ use crate::{Historical, SessionKeys, ValidatorSet};
// Local module imports
use super::{
AccountId, Babe, Balance, Balances, BeefyMmrLeaf, Block, BlockNumber, Hash, Nonce, PalletInfo,
Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin,
RuntimeTask, Session, System, EXISTENTIAL_DEPOSIT, SLOT_DURATION, VERSION,
deposit, AccountId, Babe, Balance, Balances, BeefyMmrLeaf, Block, BlockNumber, Hash, Nonce,
PalletInfo, Runtime, RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason,
RuntimeOrigin, RuntimeTask, Session, System, EXISTENTIAL_DEPOSIT, SLOT_DURATION, VERSION,
};
// Substrate and Polkadot dependencies
use codec::{Decode, Encode};
@ -236,6 +236,24 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeHoldReason;
}
parameter_types! {
// One storage item; key size is 32 + 20; value is size 4+4+16+20 bytes = 44 bytes.
pub const DepositBase: Balance = deposit(1, 96);
// Additional storage item size of 20 bytes.
pub const DepositFactor: Balance = deposit(0, 20);
pub const MaxSignatories: u32 = 100;
}
impl pallet_multisig::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = ();
}
impl pallet_validator_set::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddRemoveOrigin = EnsureRoot<AccountId>;

View file

@ -96,14 +96,23 @@ pub const DAYS: BlockNumber = HOURS * 24;
pub const BLOCK_HASH_COUNT: BlockNumber = 2400;
// Provide a common factor between runtimes based on a supply of 10_000_000 tokens.
pub const SUPPLY_FACTOR: Balance = 1;
// Unit = the base number of indivisible units for balances
pub const UNIT: Balance = 1_000_000_000_000;
pub const MILLI_UNIT: Balance = 1_000_000_000;
pub const MICRO_UNIT: Balance = 1_000_000;
pub const STORAGE_BYTE_FEE: Balance = 100 * MICRO_UNIT * SUPPLY_FACTOR;
/// Existential deposit.
pub const EXISTENTIAL_DEPOSIT: Balance = MILLI_UNIT;
pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 1 * UNIT * SUPPLY_FACTOR + (bytes as Balance) * STORAGE_BYTE_FEE
}
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
@ -249,6 +258,9 @@ mod runtime {
#[runtime::pallet_index(20)]
pub type Utility = pallet_utility;
#[runtime::pallet_index(24)]
pub type Multisig = pallet_multisig;
#[runtime::pallet_index(31)]
pub type Ethereum = pallet_ethereum;