Skip to content

Commit

Permalink
Restore sudo moonbase (#652)
Browse files Browse the repository at this point in the history
* Revert "Remove sudo from Moonriver (and Alphanet temporarily) (#650)"

This reverts commit 2386b45.

* remove sudo from moonriver

(cherry picked from commit 89d17d5)

* also remove it from the integration tests

(cherry picked from commit d831ff0)

* restore pallet indeces

* Revert "Skipping introduced test with sudo (#653)"

This reverts commit 4f0bcad.
  • Loading branch information
JoshOrndorff authored Aug 5, 2021
1 parent cf80e60 commit 894dfe2
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 101 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions node/service/src/chain_spec/moonbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use moonbase_runtime::{
currency::UNIT, AccountId, AuthorFilterConfig, AuthorMappingConfig, Balance, BalancesConfig,
CouncilCollectiveConfig, CrowdloanRewardsConfig, DemocracyConfig, EVMConfig,
EthereumChainIdConfig, EthereumConfig, GenesisConfig, InflationInfo, ParachainInfoConfig,
ParachainStakingConfig, Precompiles, Range, SchedulerConfig, /*SudoConfig,*/ SystemConfig,
ParachainStakingConfig, Precompiles, Range, SchedulerConfig, SudoConfig, SystemConfig,
TechComitteeCollectiveConfig, WASM_BINARY,
};
use nimbus_primitives::NimbusId;
Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn development_chain_spec(mnemonic: Option<String>, num_accounts: Option<u32
move || {
testnet_genesis(
// Alith is Sudo
// accounts[0],
accounts[0],
// Council members: Baltathar, Charleth and Dorothy
vec![accounts[1], accounts[2], accounts[3]],
// Tech comitee members: Alith and Baltathar
Expand Down Expand Up @@ -106,7 +106,7 @@ pub fn get_chain_spec(para_id: ParaId) -> ChainSpec {
move || {
testnet_genesis(
// Alith is Sudo
// AccountId::from_str("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac").unwrap(),
AccountId::from_str("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac").unwrap(),
// Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from_str("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0").unwrap(),
Expand Down Expand Up @@ -182,7 +182,7 @@ pub fn moonbeam_inflation_config() -> InflationInfo<Balance> {
}

pub fn testnet_genesis(
// root_key: AccountId,
root_key: AccountId,
council_members: Vec<AccountId>,
tech_comittee_members: Vec<AccountId>,
candidates: Vec<(AccountId, NimbusId, Balance)>,
Expand Down Expand Up @@ -215,7 +215,7 @@ pub fn testnet_genesis(
crowdloan_rewards: CrowdloanRewardsConfig {
funded_amount: crowdloan_fund_pot,
},
// sudo: SudoConfig { key: root_key },
sudo: SudoConfig { key: root_key },
parachain_info: ParachainInfoConfig {
parachain_id: para_id,
},
Expand Down
2 changes: 1 addition & 1 deletion node/service/src/chain_spec/test_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn staking_spec(para_id: ParaId) -> ChainSpec {
move || {
testnet_genesis(
// Root
// AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b").unwrap(),
AccountId::from_str("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b").unwrap(),
// Council members: Baltathar, Charleth and Dorothy
vec![
AccountId::from_str("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0").unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonbase/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ frame-system = { git = "https://github.com/paritytech/substrate", default-featur
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
# pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }

frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
Expand Down Expand Up @@ -123,7 +123,7 @@ std = [
"pallet-randomness-collective-flip/std",
"pallet-timestamp/std",
"pallet-treasury/std",
#"pallet-sudo/std",
"pallet-sudo/std",
"pallet-transaction-payment/std",
"pallet-utility/std",
"pallet-ethereum/std",
Expand Down
10 changes: 5 additions & 5 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ impl pallet_transaction_payment::Config for Runtime {
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
}

// impl pallet_sudo::Config for Runtime {
// type Call = Call;
// type Event = Event;
// }
impl pallet_sudo::Config for Runtime {
type Call = Call;
type Event = Event;
}

impl pallet_ethereum_chain_id::Config for Runtime {}

Expand Down Expand Up @@ -774,7 +774,7 @@ construct_runtime! {
Utility: pallet_utility::{Pallet, Call, Event} = 1,
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2,
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 3,
// Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 4,
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 4,
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 5,
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>} = 6,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 7,
Expand Down
10 changes: 9 additions & 1 deletion runtime/moonbase/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ fn verify_pallet_prefixes() {
}
]
);
assert_eq!(
<moonbase_runtime::Sudo as StorageInfoTrait>::storage_info(),
vec![StorageInfo {
prefix: prefix(b"Sudo", b"Key"),
max_values: Some(1),
max_size: Some(20),
}]
);
assert_eq!(
<moonbase_runtime::Proxy as StorageInfoTrait>::storage_info(),
vec![
Expand Down Expand Up @@ -161,7 +169,7 @@ fn verify_pallet_indices() {
is_pallet_index::<moonbase_runtime::Utility>(1);
is_pallet_index::<moonbase_runtime::Timestamp>(2);
is_pallet_index::<moonbase_runtime::Balances>(3);
// Sudo was previously index 4
is_pallet_index::<moonbase_runtime::Sudo>(4);
is_pallet_index::<moonbase_runtime::RandomnessCollectiveFlip>(5);
is_pallet_index::<moonbase_runtime::ParachainSystem>(6);
is_pallet_index::<moonbase_runtime::TransactionPayment>(7);
Expand Down
149 changes: 72 additions & 77 deletions tests/tests/test-crowdloan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
genesisAccount = await keyring.addFromUri(GENESIS_ACCOUNT_PRIVATE_KEY, null, "ethereum");
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});
it.skip("should check initial state", async function () {
it("should check initial state", async function () {
// check that genesis has genesis balance
expect(Number(await context.web3.eth.getBalance(GENESIS_ACCOUNT))).to.eq(
Number(GENESIS_ACCOUNT_BALANCE)
Expand All @@ -54,7 +54,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
);
expect(isPayable.toHuman()).to.equal(null);
});
it.skip("should be able to register the genesis account for reward", async function () {
it("should be able to register the genesis account for reward", async function () {
// should be able to register the genesis account for reward
await context.polkadotApi.tx.sudo
.sudo(
Expand Down Expand Up @@ -95,7 +95,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
genesisAccount = await keyring.addFromUri(GENESIS_ACCOUNT_PRIVATE_KEY, null, "ethereum");
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});
it.skip("should be able to make a first claim", async function () {
it("should be able to make a first claim", async function () {
await context.polkadotApi.tx.sudo
.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec([
Expand Down Expand Up @@ -165,7 +165,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
genesisAccount = await keyring.addFromUri(GENESIS_ACCOUNT_PRIVATE_KEY, null, "ethereum");
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});
it.skip("should show the money after 5 blocks, after first claim was called", async function () {
it("should show me the money after 5 blocks, after first claim was called", async function () {
await context.polkadotApi.tx.sudo
.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec([
Expand Down Expand Up @@ -223,7 +223,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
genesisAccount = await keyring.addFromUri(GENESIS_ACCOUNT_PRIVATE_KEY, null, "ethereum");
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});
it.skip("should make first claim 5 blocks after initialization called", async function () {
it("should make first claim 5 blocks after initialization called", async function () {
await context.polkadotApi.tx.sudo
.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec([
Expand Down Expand Up @@ -276,7 +276,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
genesisAccount = await keyring.addFromUri(GENESIS_ACCOUNT_PRIVATE_KEY, null, "ethereum");
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});
it.skip("should not be able to call initializeRewardVec another time", async function () {
it("should not be able to call initializeRewardVec another time", async function () {
await context.polkadotApi.tx.sudo
.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec([
Expand Down Expand Up @@ -321,7 +321,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
alithAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});

it.skip("should be able to register the genesis account - with small amount", async function () {
it("should be able to register the genesis account - with small amount", async function () {
// initializeRewardVec
await context.polkadotApi.tx.sudo
.sudo(
Expand Down Expand Up @@ -380,7 +380,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});

it.skip("should be able to register many accounts : " + numberOfAccounts, async function () {
it("should be able to register many accounts : " + numberOfAccounts, async function () {
// should create a bunch of test eth accounts
this.timeout(30000);
let web3 = new Web3();
Expand Down Expand Up @@ -449,79 +449,74 @@ describeDevMoonbeam("Crowdloan", (context) => {
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});

it.skip(
"should be able to register many accounts - batch : " + numberOfAccounts,
async function () {
// should create a bunch of test eth accounts
this.timeout(20000);
let web3 = new Web3();
let accounts = new Array(numberOfAccounts).fill(0).map((_, i) => web3.eth.accounts.create());
largInput = accounts.map((acc: Account, i: number) => {
return [
acc.address + "111111111111111111111111",
acc.address,
(3_000_000n * GLMR) / BigInt(numberOfAccounts),
];
});
expect(largInput.length).to.eq(numberOfAccounts);
expect(largInput[0][1] !== largInput[numberOfAccounts - 1][1]).to.eq(true);

// should be able to register many accounts
await context.polkadotApi.tx.utility
.batch([
await context.polkadotApi.tx.sudo.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec(
largInput.slice(0, Math.floor(numberOfAccounts / 3))
)
),
await context.polkadotApi.tx.sudo.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec(
largInput.slice(
Math.floor(numberOfAccounts / 3),
Math.floor((numberOfAccounts * 2) / 3)
)
)
),
await context.polkadotApi.tx.sudo.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec(
largInput.slice(Math.floor((numberOfAccounts * 2) / 3), numberOfAccounts)
it("should be able to register many accounts - batch : " + numberOfAccounts, async function () {
// should create a bunch of test eth accounts
this.timeout(20000);
let web3 = new Web3();
let accounts = new Array(numberOfAccounts).fill(0).map((_, i) => web3.eth.accounts.create());
largInput = accounts.map((acc: Account, i: number) => {
return [
acc.address + "111111111111111111111111",
acc.address,
(3_000_000n * GLMR) / BigInt(numberOfAccounts),
];
});
expect(largInput.length).to.eq(numberOfAccounts);
expect(largInput[0][1] !== largInput[numberOfAccounts - 1][1]).to.eq(true);

// should be able to register many accounts
await context.polkadotApi.tx.utility
.batch([
await context.polkadotApi.tx.sudo.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec(
largInput.slice(0, Math.floor(numberOfAccounts / 3))
)
),
await context.polkadotApi.tx.sudo.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec(
largInput.slice(
Math.floor(numberOfAccounts / 3),
Math.floor((numberOfAccounts * 2) / 3)
)
),
])
.signAndSend(sudoAccount);
await context.createBlock();
)
),
await context.polkadotApi.tx.sudo.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec(
largInput.slice(Math.floor((numberOfAccounts * 2) / 3), numberOfAccounts)
)
),
])
.signAndSend(sudoAccount);
await context.createBlock();

let initBlock = (await context.polkadotApi.query.crowdloanRewards.initRelayBlock()) as any;
let initBlock = (await context.polkadotApi.query.crowdloanRewards.initRelayBlock()) as any;

// Complete initialization
await context.polkadotApi.tx.sudo
.sudo(
context.polkadotApi.tx.crowdloanRewards.completeInitialization(
Number(initBlock) + vesting
)
)
.signAndSend(sudoAccount);
await context.createBlock();
// Complete initialization
await context.polkadotApi.tx.sudo
.sudo(
context.polkadotApi.tx.crowdloanRewards.completeInitialization(Number(initBlock) + vesting)
)
.signAndSend(sudoAccount);
await context.createBlock();

const rewardPerContributor = formatBalance(
(3_000_000n * GLMR) / BigInt(numberOfAccounts),
{ withSi: true, withUnit: "UNIT" },
18
);
const rewardPerContributor = formatBalance(
(3_000_000n * GLMR) / BigInt(numberOfAccounts),
{ withSi: true, withUnit: "UNIT" },
18
);

await Promise.all(
largInput.map(async (input) => {
expect(
await Promise.all(
largInput.map(async (input) => {
expect(
(
(
(
await context.polkadotApi.query.crowdloanRewards.accountsPayable(input[1])
).toHuman() as any
).total_reward
).to.equal(rewardPerContributor);
})
);
}
);
await context.polkadotApi.query.crowdloanRewards.accountsPayable(input[1])
).toHuman() as any
).total_reward
).to.equal(rewardPerContributor);
})
);
});
});

describeDevMoonbeam("Crowdloan", (context) => {
Expand All @@ -532,7 +527,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
genesisAccount = await keyring.addFromUri(GENESIS_ACCOUNT_PRIVATE_KEY, null, "ethereum");
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});
it.skip("should be able to initialize through democracy", async function () {
it("should be able to initialize through democracy", async function () {
let calls = [];
// We are gonna put the initialization and completion in a batch_all utility call
calls.push(
Expand Down Expand Up @@ -622,7 +617,7 @@ describeDevMoonbeam("Crowdloan", (context) => {
genesisAccount = await keyring.addFromUri(GENESIS_ACCOUNT_PRIVATE_KEY, null, "ethereum");
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});
it.skip("should be able to burn the dust", async function () {
it("should be able to burn the dust", async function () {
await context.polkadotApi.tx.sudo
.sudo(
context.polkadotApi.tx.crowdloanRewards.initializeRewardVec([
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/test-parachain-bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describeDevMoonbeam("Staking - Parachain Bond - genesis and setParachainBondAcco
expect(parachainBondInfo.toHuman()["account"]).to.equal(ZERO_ADDRESS);
expect(parachainBondInfo.toHuman()["percent"]).to.equal("30.00%");
});
it.skip("should be able set the parachain bond with sudo", async function () {
it("should be able set the parachain bond with sudo", async function () {
// should be able to register the genesis account for reward
await context.polkadotApi.tx.sudo
.sudo(context.polkadotApi.tx.parachainStaking.setParachainBondAccount(GENESIS_ACCOUNT))
Expand Down Expand Up @@ -96,7 +96,7 @@ describeDevMoonbeam("Staking - Parachain Bond - setParachainBondReservePercent",
const keyring = new Keyring({ type: "ethereum" });
sudoAccount = await keyring.addFromUri(ALITH_PRIV_KEY, null, "ethereum");
});
it.skip("should be able set the parachain bond reserve percent with sudo", async function () {
it("should be able set the parachain bond reserve percent with sudo", async function () {
// should be able to register the genesis account
await context.polkadotApi.tx.sudo
.sudo(context.polkadotApi.tx.parachainStaking.setParachainBondReservePercent(TWENTY_PERCENT))
Expand Down
Loading

0 comments on commit 894dfe2

Please sign in to comment.