Skip to content

Commit

Permalink
Add multisig pallet and prefund multisig account in the genesis config (
Browse files Browse the repository at this point in the history
#48)

closes #44 

Co-authored-by: echevrier <edith.chevrier@scs.ch>
  • Loading branch information
echevrier and echevrier authored Sep 28, 2021
1 parent 0d92564 commit 803ac86
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 33 deletions.
77 changes: 46 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use integritee_node_runtime::{AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY, TreasuryPalletId};
use integritee_node_runtime::{AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY, TreasuryPalletId, Multisig};
use sc_service::ChainType;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{sr25519, Pair, Public};
Expand Down Expand Up @@ -57,9 +57,17 @@ pub fn development_config() -> Result<ChainSpec, String> {
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
treasury_account_id(),
// The address of a multi-signature account is deterministically generated from the signers and threshold of the multisig wallet.
// Creating a multi-sig account from Polkadot-JS Apps UI, always sort the accounts according to the keys. Here we do the same
Multisig::multi_account_id(&[
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice"),
], 2),
],
true,
)
Expand Down Expand Up @@ -107,6 +115,12 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
treasury_account_id(),
Multisig::multi_account_id(&[
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
], 3),
],
true,
)
Expand Down
3 changes: 3 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://
pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-treasury = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-multisig = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }

sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-block-builder = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
Expand Down Expand Up @@ -76,6 +77,7 @@ std = [
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-treasury/std",
"pallet-multisig/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
Expand All @@ -98,5 +100,6 @@ runtime-benchmarks = [
"pallet-balances/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
27 changes: 26 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ pub const TEER: Balance = 1_000_000_000_000;
pub const MILLITEER: Balance = 1_000_000_000;
pub const MICROTEER: Balance = 1_000_000;

//Logic from polkaodt/kusuma
pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 20 * TEER + (bytes as Balance) * 1_000 * MICROTEER
}

/// added by Integritee
/// A timestamp: milliseconds since the unix epoch.
pub type Moment = u64;
Expand Down Expand Up @@ -379,6 +384,24 @@ impl pallet_treasury::Config for Runtime {
type WeightInfo = ();
}

parameter_types! {
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u16 = 10; //100
}

impl pallet_multisig::Config for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = ();
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime where
Expand All @@ -397,6 +420,7 @@ construct_runtime!(
// added by Integritee
Teerex: pallet_teerex::{Pallet, Call, Storage, Event<T>},
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>},
}
);

Expand Down Expand Up @@ -574,7 +598,7 @@ impl_runtime_apis! {
list_benchmark!(list, extra, pallet_balances, Balances);
list_benchmark!(list, extra, pallet_timestamp, Timestamp);
list_benchmark!(list, extra, pallet_treasury, Treasury);

list_benchmark!(list, extra, pallet_multisig, Multisig);
let storage_info = AllPalletsWithSystem::storage_info();

return (list, storage_info)
Expand Down Expand Up @@ -610,6 +634,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_treasury, Treasury);
add_benchmark!(params, batches, pallet_multisig, Multisig);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
Expand Down

0 comments on commit 803ac86

Please sign in to comment.