From 44dacae23c4d39891034894e302241155a3edbbf Mon Sep 17 00:00:00 2001 From: Vorrol <33810949+tikhono@users.noreply.github.com> Date: Fri, 28 Jan 2022 18:15:26 +0200 Subject: [PATCH 1/4] Module publish (#170) * publish module * lock * lock * add sudo * update: fix addresses, some tests * remove: sudo deps, and from mock * remove debug and reuse rawpublish * refactor, delete obsolete comments * add method destiption * typo * typo * rename test * remove redurant clone * remove dublicate * correct error codes Co-authored-by: borispovod --- Cargo.toml | 3 -- pallets/sp-mvm/Cargo.toml | 1 + pallets/sp-mvm/src/lib.rs | 52 ++++++++++++++++++---------- pallets/sp-mvm/tests/balances.rs | 4 +-- pallets/sp-mvm/tests/common/mock.rs | 2 +- pallets/sp-mvm/tests/common/utils.rs | 33 +++++++++++++++++- pallets/sp-mvm/tests/gas.rs | 2 +- pallets/sp-mvm/tests/std.rs | 28 ++++++++++++--- runtime/src/lib.rs | 2 +- runtime/src/tests/mvm.rs | 2 +- 10 files changed, 96 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ad11350c..5880c385 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,3 @@ members = [ [profile.release] panic = 'unwind' rpath = false -# opt size: -# lto = "thin" -# opt-level = 's' diff --git a/pallets/sp-mvm/Cargo.toml b/pallets/sp-mvm/Cargo.toml index 1fb2a145..e0610150 100644 --- a/pallets/sp-mvm/Cargo.toml +++ b/pallets/sp-mvm/Cargo.toml @@ -65,6 +65,7 @@ orml-traits = { default-features = false, git = 'https://github.com/open-web3-st # serde is for lcs/bcs only # used for benchmarking (runtime, std, no-std) serde-alt = { version = "1", default-features = false, package = "alt_serde", features = ["derive", "alloc"], optional = true } + [dependencies.bcs-alt] package = "bcs" default-features = false diff --git a/pallets/sp-mvm/src/lib.rs b/pallets/sp-mvm/src/lib.rs index af5861c4..6273eba3 100644 --- a/pallets/sp-mvm/src/lib.rs +++ b/pallets/sp-mvm/src/lib.rs @@ -104,7 +104,7 @@ pub mod pallet { type GasWeightMapping: gas::GasWeightMapping; /// The AccountId that can perform a standard library update or deploy module under 0x address. - type UpdaterOrigin: EnsureOrigin; + type UpdateOrigin: EnsureOrigin; /// Describes weights for Move VM extrinsics. type WeightInfo: WeightInfo; @@ -165,9 +165,9 @@ pub mod pallet { /// [account] ModulePublished(T::AccountId), - /// Event about successful move-module publishing + /// Event about successful move-package published /// [account] - StdModulePublished, + PackagePublished(T::AccountId), } // Dispatchable functions allows users to interact with the pallet and invoke state changes. @@ -220,17 +220,18 @@ pub mod pallet { module_bc: Vec, gas_limit: u64, ) -> DispatchResultWithPostInfo { - let who = ensure_signed(origin)?; - debug!("executing `publish` with signed {:?}", who); + // Allows to update Standard Library if root. + let (sender, signer) = Self::ensure_and_convert(origin)?; + debug!("executing `publish module` with signed {:?}", sender); // Publish module. - let vm_result = Self::raw_publish_module(&who, module_bc, gas_limit, false)?; + let vm_result = Self::raw_publish_module(&signer, module_bc, gas_limit, false)?; // produce result with spended gas: let result = result::from_vm_result::(vm_result)?; // Emit an event: - Self::deposit_event(Event::ModulePublished(who)); + Self::deposit_event(Event::ModulePublished(signer)); Ok(result) } @@ -252,17 +253,8 @@ pub mod pallet { gas_limit: u64, ) -> DispatchResultWithPostInfo { // Allows to update Standard Library if root. - let sender = match T::UpdaterOrigin::ensure_origin(origin.clone()) { - Ok(_) => { - debug!("executing `publish package` with root"); - CORE_CODE_ADDRESS - } - Err(_) => { - let signer = ensure_signed(origin)?; - debug!("executing `publish package` with signed {:?}", signer); - addr::account_to_account_address(&signer) - } - }; + let (sender, signer) = Self::ensure_and_convert(origin)?; + debug!("executing `publish package` with signed {:?}", sender); let vm = Self::get_vm()?; let gas = Self::get_move_gas_limit(gas_limit)?; @@ -278,6 +270,9 @@ pub mod pallet { // produce result with spended gas: let result = result::from_vm_result::(vm_result)?; + // Emit an event: + Self::deposit_event(Event::PackagePublished(signer)); + Ok(result) } } @@ -464,6 +459,25 @@ pub mod pallet { Ok(res) } + /// Ensures origin is root or signed and returns account id with associated move-address. + pub fn ensure_and_convert( + origin: OriginFor, + ) -> Result<(AccountAddress, T::AccountId), Error> { + // Allows to update Standard Library if root. + match T::UpdateOrigin::ensure_origin(origin.clone()) { + Ok(_) => { + let signer = addr::address_to_account(&CORE_CODE_ADDRESS) + .map_err(|_| Error::::AccountAddressConversionError)?; + Ok((CORE_CODE_ADDRESS, signer)) + } + Err(_) => { + let signer = + ensure_signed(origin).map_err(|_| Error::::InvalidSignature)?; + Ok((addr::account_to_account_address(&signer), signer)) + } + } + } + /// Publish Move module script with provided account, module bytecode, gas limit, and dry run configuration. /// In case of dry run nothing would be written to storage after execution (required mostly by RPC calls, e.g. estimate gas etc). pub fn raw_publish_module( @@ -609,6 +623,8 @@ pub mod pallet { TransactionValidationError, /// Transaction signers num isn't eq signers TransactionSignersNumError, + /// AccountAddress conversion error. + AccountAddressConversionError, /// Transaction is not allowed. TransactionIsNotAllowedError, diff --git a/pallets/sp-mvm/tests/balances.rs b/pallets/sp-mvm/tests/balances.rs index 28aec3b7..76d01d5a 100644 --- a/pallets/sp-mvm/tests/balances.rs +++ b/pallets/sp-mvm/tests/balances.rs @@ -199,7 +199,7 @@ fn transfer_vested_fails() { result, DispatchError::Module { index: 6, - error: 154, + error: 155, message: Some("Aborted") } ); @@ -233,7 +233,7 @@ fn transfer_token_vested_fails() { result, DispatchError::Module { index: 6, - error: 154, + error: 155, message: Some("Aborted") } ); diff --git a/pallets/sp-mvm/tests/common/mock.rs b/pallets/sp-mvm/tests/common/mock.rs index 55bf28be..c2ff9246 100644 --- a/pallets/sp-mvm/tests/common/mock.rs +++ b/pallets/sp-mvm/tests/common/mock.rs @@ -227,7 +227,7 @@ parameter_types! { impl sp_mvm::Config for Test { type Event = Event; type GasWeightMapping = MoveVMGasWeightMapping; - type UpdaterOrigin = EnsureRoot; + type UpdateOrigin = EnsureRoot; type PalletId = MVMPalletId; type CurrencyId = CurrencyId; type Currencies = Currencies; diff --git a/pallets/sp-mvm/tests/common/utils.rs b/pallets/sp-mvm/tests/common/utils.rs index 1631b83e..4d17e384 100644 --- a/pallets/sp-mvm/tests/common/utils.rs +++ b/pallets/sp-mvm/tests/common/utils.rs @@ -9,6 +9,7 @@ use move_core_types::language_storage::StructTag; use move_core_types::language_storage::TypeTag; use move_vm::io::state::State; use move_vm::types::ModulePackage; +use move_core_types::language_storage::CORE_CODE_ADDRESS; use move_core_types::resolver::ModuleResolver; use move_core_types::resolver::ResourceResolver; @@ -41,6 +42,21 @@ pub fn publish_module_unchecked( Mvm::publish_module(Origin::signed(signer), module.bytes().to_vec(), gas_limit) } +/// Publish module as root __without__ storage check +pub fn publish_module_as_root_unchecked(module: &Asset, gas_limit: Option) -> PsResult { + let gas_limit = gas_limit.unwrap_or(DEFAULT_GAS_LIMIT); + Mvm::publish_module(Origin::root(), module.bytes().to_vec(), gas_limit) +} + +/// Publish module as root __with__ storage check +pub fn publish_module_as_root(module: &Asset, gas_limit: Option) -> PsResult { + let bytecode = module.bytes().to_vec(); + let name = module.name(); + let result = publish_module_as_root_unchecked(module, gas_limit)?; + check_storage_module(CORE_CODE_ADDRESS, bytecode, name); + Ok(result) +} + /// Publish package. /// /// Publish package __with__ storage check @@ -52,7 +68,22 @@ pub fn publish_package(signer: AccountId, package: &Package, gas_limit: Option) -> PsResult { + let bytecode = package.bytes().to_vec(); + let names = package.modules(); + let result = publish_package_unchecked_as_root(package, gas_limit)?; + check_storage_package(CORE_CODE_ADDRESS, bytecode, names); + Ok(result) +} + +/// Publish package as root __without__ storage checks. +pub fn publish_package_unchecked_as_root(package: &Package, gas_limit: Option) -> PsResult { + let gas_limit = gas_limit.unwrap_or(DEFAULT_GAS_LIMIT); + Mvm::publish_package(Origin::root(), package.bytes().to_vec(), gas_limit) +} + +/// Publish package __without__ storage check pub fn publish_package_unchecked( signer: AccountId, package: &Package, diff --git a/pallets/sp-mvm/tests/gas.rs b/pallets/sp-mvm/tests/gas.rs index 1ee2f620..89b83eef 100644 --- a/pallets/sp-mvm/tests/gas.rs +++ b/pallets/sp-mvm/tests/gas.rs @@ -6,7 +6,7 @@ use common::mock::*; use common::addr::*; use common::utils; -const OUT_OF_GAS_ERROR_CODE: u8 = 149; +const OUT_OF_GAS_ERROR_CODE: u8 = 150; const MINIMAL_GAS_LIMIT: u64 = 1; /// Check status == out of gas diff --git a/pallets/sp-mvm/tests/std.rs b/pallets/sp-mvm/tests/std.rs index 28642268..d80adbc6 100644 --- a/pallets/sp-mvm/tests/std.rs +++ b/pallets/sp-mvm/tests/std.rs @@ -13,8 +13,16 @@ use common::addr::*; use common::utils; #[test] -/// publish modules personally as root -fn publish_module() { +/// publish modules personally as root unchecked +fn publish_module_as_root() { + new_test_ext().execute_with(|| { + utils::publish_module_as_root(&modules::root::EVENT_PROXY, None).unwrap(); + }); +} + +#[test] +/// publish modules personally as root (ps) +fn publish_module_as_root_ps() { new_test_ext().execute_with(|| { let root = root_ps_acc(); utils::publish_module(root, &modules::root::EVENT_PROXY, None).unwrap(); @@ -68,7 +76,7 @@ fn execute_script_as_root() { result, DispatchError::Module { index: 6, - error: 6, + error: 7, message: Some("TransactionIsNotAllowedError") } ); @@ -76,8 +84,8 @@ fn execute_script_as_root() { } #[test] -/// publish package as root -fn publish_package_as_root() { +/// publish package as root (ps) +fn publish_package_as_root_ps() { new_test_ext().execute_with(|| { let package = &ROOT_PACKAGE; let root = root_ps_acc(); @@ -86,6 +94,16 @@ fn publish_package_as_root() { }); } +/// publish package as root. +#[test] +fn publish_package_as_root() { + new_test_ext().execute_with(|| { + let package = &ROOT_PACKAGE; + + utils::publish_package_as_root(package, None).unwrap(); + }); +} + #[test] /// publish package as origin fn publish_package_as_origin() { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 4c2993b8..15724998 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -823,7 +823,7 @@ impl sp_mvm::Config for Runtime { type GasWeightMapping = MoveVMGasWeightMapping; /// Only sudo can deploy modules under 0x or update standard library. - type UpdaterOrigin = EnsureRoot; + type UpdateOrigin = EnsureRoot; /// Pallet Id. type PalletId = MVMPalletId; diff --git a/runtime/src/tests/mvm.rs b/runtime/src/tests/mvm.rs index d26d8a39..b888ce5a 100644 --- a/runtime/src/tests/mvm.rs +++ b/runtime/src/tests/mvm.rs @@ -164,7 +164,7 @@ fn transfer_vested_balance_fails() { ), DispatchError::Module { index: 67, - error: 154, + error: 155, message: Some("Aborted") }, ); From fd0bc6cbbc0a73f0de0c3995b746cdcf1ab1c408 Mon Sep 17 00:00:00 2001 From: Alexander Koz Date: Sat, 5 Feb 2022 21:31:49 +0300 Subject: [PATCH 2/4] Merge branch 'release-v0.5' (#178) * Merge branch 'release-v0.5' * release-v0.5: westend-native -> kusama-native nox nodes nox nodes preparation Module publish (#170) parachain id only from specs update lock update node version westend readme fixes rococo nodes * CI: fix coverage, grcov new release filename --- .github/workflows/coverage.yml | 15 +- Cargo.lock | 4 +- README.md | 4 +- node/Cargo.toml | 4 +- node/src/chain_spec.rs | 357 +++++++++++++++++- node/src/cli.rs | 4 - node/src/command.rs | 8 +- .../sp-mvm/tests/benchmark_assets/Move.toml | 4 +- 8 files changed, 361 insertions(+), 39 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2ebd99ee..c775eb45 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -26,7 +26,9 @@ jobs: matrix: cfg: - os: self-hosted - grcov: grcov-linux-x86_64.tar.bz2 + grcov: + version: tags/v0.8.6 + file: grcov-v0.8.6-x86_64-unknown-linux-gnu.tar.gz dove: 1.5.5 env: @@ -49,18 +51,19 @@ jobs: run: cargo clean - name: get latest grcov binary - uses: dsaltares/fetch-gh-release-asset@0.0.5 + uses: dsaltares/fetch-gh-release-asset@0.0.7 with: repo: mozilla/grcov - version: "latest" - file: ${{ matrix.cfg.grcov }} + # TODO: use `version: "latest"` and wildcard in the `file` + version: ${{ matrix.cfg.grcov.version }} + file: ${{ matrix.cfg.grcov.file }} - name: unpack grcov release binary run: | - tar -xvf ${{ matrix.cfg.grcov }} + tar -xvf ${{ matrix.cfg.grcov.file }} sudo chown runner ./grcov && chmod +x ./grcov cp grcov ~/.cargo/bin/grcov - rm ${{ matrix.cfg.grcov }} + rm ${{ matrix.cfg.grcov.file }} - name: cache Dove uses: actions/cache@v2 diff --git a/Cargo.lock b/Cargo.lock index 05f1112a..b5d5edfa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6833,11 +6833,11 @@ dependencies = [ "beefy-primitives", "frame-benchmarking", "frame-system-rpc-runtime-api", + "kusama-runtime", "pallet-mmr-primitives", "pallet-transaction-payment-rpc-runtime-api", "polkadot-primitives", "polkadot-runtime", - "rococo-runtime", "sc-client-api", "sc-consensus", "sc-executor", @@ -7817,7 +7817,7 @@ dependencies = [ [[package]] name = "pontem-node" -version = "0.4.4" +version = "0.5.0" dependencies = [ "async-io", "constants", diff --git a/README.md b/README.md index f1afc23b..230d7924 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Add Nimbus key: ```sh # Use "//Alice" for URI. -./target/release/pontem key insert --keystore-path ~/.pontem/keystore-1 --key-type nmbs +./target/release/pontem key insert --keystore-path ~/.pontem/keystore-1 --key-type nmbs --scheme sr25519 ``` ```sh @@ -127,7 +127,7 @@ Add Nimbus key: ```sh # Use "//Alice" for URI. -./target/release/pontem key insert --keystore-path ~/.pontem/keystore-1 --key-type nmbs +./target/release/pontem key insert --keystore-path ~/.pontem/keystore-1 --key-type nmbs --scheme sr25519 ``` Launch parachain node as collator: diff --git a/node/Cargo.toml b/node/Cargo.toml index 76c825e6..091e23e0 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -7,7 +7,7 @@ license = 'Apache-2.0' name = 'pontem-node' edition = '2021' build = 'build.rs' -version = '0.4.4' +version = '0.5.0' [[bin]] name = 'pontem' @@ -105,7 +105,7 @@ constants = { path = '../constants' } # # ** Don't enable relay chains you don't need, as this is a **very** heavy build for no reason** # More info: https://github.com/paritytech/polkadot/pull/3189 -polkadot-cli = { git = 'http://github.com/paritytech/polkadot.git', branch = 'release-v0.9.13', features = ["rococo-native"] } +polkadot-cli = { git = 'http://github.com/paritytech/polkadot.git', branch = 'release-v0.9.13', features = ["kusama-native"] } [dependencies.move-vm] package = "mvm" diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index a9d25362..b1c4ba76 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,5 +1,5 @@ use cumulus_primitives_core::ParaId; -use sc_service::ChainType; +use sc_service::{ChainType, config::MultiaddrWithPeerId}; use sp_core::{sr25519, Pair, Public, crypto::Ss58Codec}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sp_runtime::{ @@ -48,6 +48,11 @@ pub fn get_from_seed(seed: &str) -> ::Pu .public() } +// Get a public key from address. +pub fn get_public_from_address(addr: &str) -> TPublic { + TPublic::from_ss58check(addr).unwrap() +} + type AccountPublic = ::Signer; /// Generate an account ID from seed. @@ -63,6 +68,7 @@ pub fn get_account_id_from_address(addr: &str) -> AccountId { AccountId::from_ss58check(addr).unwrap() } +/// The network properties. fn properties() -> Option { let currency = CurrencyId::default(); @@ -75,6 +81,45 @@ fn properties() -> Option { .cloned() } +/// Convert nodes. +fn convert_nodes(nodes: &[&str]) -> Vec { + nodes + .iter() + .map(|node| node.parse().unwrap()) + .collect::>() +} + +/// Westend bootnodes. +fn westend_bootnodes() -> Vec { + convert_nodes( + &[ + "/dns/p2p.ams-1.para.prod.pontem.network/tcp/20331/p2p/12D3KooWSpcN6dDJXFQfLn9w4mviBiqF4YJBtGxz6TRm9RFLcgX9", + "/dns/p2p.ams-2.para.prod.pontem.network/tcp/20331/p2p/12D3KooWSU6TXJJcgEjPwmPpPsQdECxbRdoHGcxczbcpKUDkgtoX", + "/dns/p2p.ams-3.para.prod.pontem.network/tcp/20331/p2p/12D3KooWBGrHhbdcAZJKzNfd3DvdeYyBLyAEEQQKicetMmWLNY5P", + "/dns/p2p.ams-4.para.prod.pontem.network/tcp/20331/p2p/12D3KooWQ5mu9nE7YMhQZEEUTmjHdAX35kEvb2rXQPB2XX6M4YTW", + ] + ) +} + +/// Nox bootnodes. +fn nox_bootnodes() -> Vec { + convert_nodes( + &[ + "/dns/p2p.ams-1.para.prod.pontem.network/tcp/30331/p2p/12D3KooWK87KJJu86GUWAJFcuDJFrVe2ej5ov2jsjKpkAcEJiJb4", + "/dns/p2p.ams-2.para.prod.pontem.network/tcp/30331/p2p/12D3KooWHXC2RtmyPqyQWnFtgWrJZP79hQ61sMtPrQgakU7jEEDK", + "/dns/p2p.ams-3.para.prod.pontem.network/tcp/30331/p2p/12D3KooWPsgduwqGacCxj98BxSa9J26MRaB29owd98YHGLt6eQfM", + "/dns/p2p.ams-4.para.prod.pontem.network/tcp/30331/p2p/12D3KooWPJzRPmysDdkzTch2pwgY2xA8fAM76om5mtyNxjeZexoF", + "/dns/p2p.fra-1.para.prod.pontem.network/tcp/30331/p2p/12D3KooWL19HLdRNwcvJrZUehsaiFDHQuFzEmQyQcgb2NCjx2e2P", + "/dns/p2p.fra-2.para.prod.pontem.network/tcp/30331/p2p/12D3KooWC7NRg4Kn4cPRuKTWMCwjtLinkMJf9WEDLngj6fCFrXWY", + "/dns/p2p.fra-3.para.prod.pontem.network/tcp/30331/p2p/12D3KooWG2DK2LsuWAW8f253GXNtkSKwzqpKxVhUwKJ8HpSw2jJd", + "/dns/p2p.fra-4.para.prod.pontem.network/tcp/30331/p2p/12D3KooWKjeHv7VjaKKyymwbYTnDEFbHsJXfNeFHy7BdptYY2ZPG", + "/dns/p2p.lon-1.para.prod.pontem.network/tcp/30331/p2p/12D3KooWMqgzU4cJz6UHMgDEv3DcNGy9sbnpsxGsfiABgsadpLme", + "/dns/p2p.lon-2.para.prod.pontem.network/tcp/30331/p2p/12D3KooWDucRm5hTfNToLMn8z433Ew9FEE3BpggjPtZL6TCDEHsH", + "/dns/p2p.sgp-1.para.prod.pontem.network/tcp/30331/p2p/12D3KooWMQdavA82jJKkwntcW5hNHFNjKQgePCg4APdxc6A9HYuj", + ] + ) +} + /// The list of paused extrinsics (mostly used for Nox mainnet). fn paused_extrinsics() -> Vec<(Vec, Vec)> { vec![ @@ -299,16 +344,16 @@ pub fn local_testnet_config() -> Result { )) } -/// Rococo configuration. -pub fn rococo_config() -> Result { +/// Westend configuration. +pub fn westend_config() -> Result { let wasm_binary = WASM_BINARY.ok_or_else(|| "Live wasm not available".to_string())?; - let parachain_id = ParaId::from(2018); + let parachain_id = ParaId::from(2101); Ok(ChainSpec::from_genesis( // Name - "Nox Rococo", + "Nox Westend", // ID - "nox_rococo", + "nox_westend", ChainType::Live, move || { genesis( @@ -316,11 +361,96 @@ pub fn rococo_config() -> Result { // Sudo account get_account_id_from_address("gkPQdcMrECsnUbVnCqTUuTaS9o72LM179rmRu3hzkC5zovUgB"), // Candidates - vec![], + vec![ + // Node 1. + ( + get_account_id_from_address( + "gkLsuHAWUiJL8tCrSYMKJjBBNyyZF2TFSs1tcTcsyHpD6x7Lr", + ), + get_public_from_address::( + "gkLsuHAWUiJL8tCrSYMKJjBBNyyZF2TFSs1tcTcsyHpD6x7Lr", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 2. + ( + get_account_id_from_address( + "gkPp7Scc7zPvdPfA7YHWxsxtrzLPEW4AodGRZz9U6vqd5LFtf", + ), + get_public_from_address::( + "gkPp7Scc7zPvdPfA7YHWxsxtrzLPEW4AodGRZz9U6vqd5LFtf", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 3. + ( + get_account_id_from_address( + "gkLkCGJohbgtNfXi9TkyxscHEodLvPzVUZ28MfCybvU6vN4Xn", + ), + get_public_from_address::( + "gkLkCGJohbgtNfXi9TkyxscHEodLvPzVUZ28MfCybvU6vN4Xn", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 4. + ( + get_account_id_from_address( + "gkR2sZmh7tS2KgQLsByjUFHMukmGJwKgcBUshxNRAPXV5ZcZL", + ), + get_public_from_address::( + "gkR2sZmh7tS2KgQLsByjUFHMukmGJwKgcBUshxNRAPXV5ZcZL", + ), + CurrencyId::NATIVE * 100_000, + ), + ], // Nominators vec![], // Pre-funded accounts - vec![], + vec![ + // Nimbus nodes. + ( + // Node 1. + get_account_id_from_address( + "gkLsuHAWUiJL8tCrSYMKJjBBNyyZF2TFSs1tcTcsyHpD6x7Lr", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 2. + get_account_id_from_address( + "gkPp7Scc7zPvdPfA7YHWxsxtrzLPEW4AodGRZz9U6vqd5LFtf", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 3. + get_account_id_from_address( + "gkLkCGJohbgtNfXi9TkyxscHEodLvPzVUZ28MfCybvU6vN4Xn", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 4. + get_account_id_from_address( + "gkR2sZmh7tS2KgQLsByjUFHMukmGJwKgcBUshxNRAPXV5ZcZL", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Sudo. + get_account_id_from_address( + "gkPQdcMrECsnUbVnCqTUuTaS9o72LM179rmRu3hzkC5zovUgB", + ), + CurrencyId::NATIVE * 10_000, + ), + ( + // Bank. + get_account_id_from_address( + "gkLdwjgcSFtoEvKbsgLuFBc2k6TgZxgrfj61CjcduCvgyKeux", + ), + CurrencyId::NATIVE * 200_000, + ), + ], // Vesting accounts vec![], // Paused extrinsics @@ -330,23 +460,23 @@ pub fn rococo_config() -> Result { ) }, // Bootnodes - vec![], + westend_bootnodes(), // Telemetry None, // Protocol ID - Some("nox_rococo"), + Some("nox_westend"), // Properties properties(), // Extensions Extensions { - relay_chain: "rococo".into(), + relay_chain: "westend".into(), para_id: parachain_id.into(), }, )) } /// NOX (Kusama) config. -/// TODO: it's still missing bootnodes, accounts, etc. +/// TODO: vesting balances, user accounts initial balances. pub fn nox_config() -> Result { let wasm_binary = WASM_BINARY.ok_or_else(|| "Live wasm not available".to_string())?; let parachain_id = ParaId::from(constants::PARACHAIN_ID); @@ -363,11 +493,208 @@ pub fn nox_config() -> Result { // Sudo account get_account_id_from_address("gkPQdcMrECsnUbVnCqTUuTaS9o72LM179rmRu3hzkC5zovUgB"), // Candidates - vec![], + vec![ + // Node 1. + ( + get_account_id_from_address( + "gkPie4Vc57KSTDNmG7vyZRCHuuFbnx7m64AqrSgcG8hejuemS", + ), + get_public_from_address::( + "gkPie4Vc57KSTDNmG7vyZRCHuuFbnx7m64AqrSgcG8hejuemS", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 2. + ( + get_account_id_from_address( + "gkQMs9aemyMsFJWBBes95pkLD5dQ6Vture2PwEPBWJ8y4ubuR", + ), + get_public_from_address::( + "gkQMs9aemyMsFJWBBes95pkLD5dQ6Vture2PwEPBWJ8y4ubuR", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 3. + ( + get_account_id_from_address( + "gkMeEtHVsBL7MSrdQCJnbEvwZ3XGPAeH3ojL72WTDPL46EpET", + ), + get_public_from_address::( + "gkMeEtHVsBL7MSrdQCJnbEvwZ3XGPAeH3ojL72WTDPL46EpET", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 4. + ( + get_account_id_from_address( + "gkLCjGZNEmLKoMrACf3Av8VNS8WzRi3cwKxAScYfxBXZpUpi1", + ), + get_public_from_address::( + "gkLCjGZNEmLKoMrACf3Av8VNS8WzRi3cwKxAScYfxBXZpUpi1", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 5. + ( + get_account_id_from_address( + "gkQ3Hcy3Lk954hV2NtY8MGxP3MtVemSepEGChhuKk7UuHLALB", + ), + get_public_from_address::( + "gkQ3Hcy3Lk954hV2NtY8MGxP3MtVemSepEGChhuKk7UuHLALB", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 6. + ( + get_account_id_from_address( + "gkQfFjHhMitdXnJXU3SLy2Fmc2F2fW4n2BbZPzu2UVvKGaFc8", + ), + get_public_from_address::( + "gkQfFjHhMitdXnJXU3SLy2Fmc2F2fW4n2BbZPzu2UVvKGaFc8", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 7. + ( + get_account_id_from_address( + "gkL1f4fX4PAhFLpMrfVy8BXB3dfArbYvkZxQ8hpujKqwmU5sK", + ), + get_public_from_address::( + "gkL1f4fX4PAhFLpMrfVy8BXB3dfArbYvkZxQ8hpujKqwmU5sK", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 8. + ( + get_account_id_from_address( + "gkN1FFFwf3YuSE283f52mjnTQthri5goZkaXhGUmsjkRxJKrN", + ), + get_public_from_address::( + "gkN1FFFwf3YuSE283f52mjnTQthri5goZkaXhGUmsjkRxJKrN", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 9. + ( + get_account_id_from_address( + "gkQUtpCMfemhhXCB2Mk9TEamDfjbC2GVEzSzCusMKkreooGzq", + ), + get_public_from_address::( + "gkQUtpCMfemhhXCB2Mk9TEamDfjbC2GVEzSzCusMKkreooGzq", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 10. + ( + get_account_id_from_address( + "gkLX45RaBmFm1uJzskr6WktGiWRgENpqQMYTDLZfrahv177yH", + ), + get_public_from_address::( + "gkLX45RaBmFm1uJzskr6WktGiWRgENpqQMYTDLZfrahv177yH", + ), + CurrencyId::NATIVE * 100_000, + ), + // Node 11. + ( + get_account_id_from_address( + "gkQb84kxpjeytTCJ12DPxf2Fi8nmsZWqJLTRv8U78RE7fGMY5", + ), + get_public_from_address::( + "gkQb84kxpjeytTCJ12DPxf2Fi8nmsZWqJLTRv8U78RE7fGMY5", + ), + CurrencyId::NATIVE * 100_000, + ), + ], // Nominators vec![], // Pre-funded accounts - vec![], + vec![ + // Nimbus nodes. + ( + // Node 1. + get_account_id_from_address( + "gkPie4Vc57KSTDNmG7vyZRCHuuFbnx7m64AqrSgcG8hejuemS", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 2. + get_account_id_from_address( + "gkQMs9aemyMsFJWBBes95pkLD5dQ6Vture2PwEPBWJ8y4ubuR", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 3. + get_account_id_from_address( + "gkMeEtHVsBL7MSrdQCJnbEvwZ3XGPAeH3ojL72WTDPL46EpET", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 4. + get_account_id_from_address( + "gkLCjGZNEmLKoMrACf3Av8VNS8WzRi3cwKxAScYfxBXZpUpi1", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 5. + get_account_id_from_address( + "gkQ3Hcy3Lk954hV2NtY8MGxP3MtVemSepEGChhuKk7UuHLALB", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + //Node 6. + get_account_id_from_address( + "gkQfFjHhMitdXnJXU3SLy2Fmc2F2fW4n2BbZPzu2UVvKGaFc8", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 7. + get_account_id_from_address( + "gkL1f4fX4PAhFLpMrfVy8BXB3dfArbYvkZxQ8hpujKqwmU5sK", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 8. + get_account_id_from_address( + "gkN1FFFwf3YuSE283f52mjnTQthri5goZkaXhGUmsjkRxJKrN", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 9. + get_account_id_from_address( + "gkQUtpCMfemhhXCB2Mk9TEamDfjbC2GVEzSzCusMKkreooGzq", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 10. + get_account_id_from_address( + "gkLX45RaBmFm1uJzskr6WktGiWRgENpqQMYTDLZfrahv177yH", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Node 11. + get_account_id_from_address( + "gkQb84kxpjeytTCJ12DPxf2Fi8nmsZWqJLTRv8U78RE7fGMY5", + ), + CurrencyId::NATIVE * 110_000, + ), + ( + // Sudo. + get_account_id_from_address( + "gkPQdcMrECsnUbVnCqTUuTaS9o72LM179rmRu3hzkC5zovUgB", + ), + CurrencyId::NATIVE * 10_000, + ), + ], // Vesting accounts vec![], // Paused extrinsics @@ -377,7 +704,7 @@ pub fn nox_config() -> Result { ) }, // Bootnodes - vec![], + nox_bootnodes(), // Telemetry None, // Protocol ID diff --git a/node/src/cli.rs b/node/src/cli.rs index b4d567b7..d712e067 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -38,10 +38,6 @@ pub struct Cli { #[structopt(long, default_value = "instant")] pub sealing: Sealing, - /// Id of the parachain this collator collates for. - #[structopt(long)] - pub parachain_id: Option, - /// Whether to run node in development node (single node, no consensus) #[structopt(long)] pub dev_service: bool, diff --git a/node/src/command.rs b/node/src/command.rs index 1da370e8..64d74249 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -47,7 +47,7 @@ fn load_spec(id: &str) -> std::result::Result, St "dev" => Box::new(chain_spec::development_config()?), "" | "local" => Box::new(chain_spec::local_testnet_config()?), "nox" => Box::new(chain_spec::nox_config()?), - "rococo" => Box::new(chain_spec::rococo_config()?), + "westend" => Box::new(chain_spec::westend_config()?), path => Box::new(chain_spec::ChainSpec::from_json_file( std::path::PathBuf::from(path), )?), @@ -259,11 +259,7 @@ pub fn run() -> sc_cli::Result<()> { let polkadot_cli = RelayChainCli::new(&config, cli.relaychain_args.into_iter()); - let id = ParaId::from( - cli.parachain_id - .or(para_id) - .unwrap_or(constants::PARACHAIN_ID), - ); + let id = ParaId::from(para_id.unwrap()); let parachain_account = AccountIdConversion::::into_account(&id); diff --git a/pallets/sp-mvm/tests/benchmark_assets/Move.toml b/pallets/sp-mvm/tests/benchmark_assets/Move.toml index 198463ae..9deff2f6 100644 --- a/pallets/sp-mvm/tests/benchmark_assets/Move.toml +++ b/pallets/sp-mvm/tests/benchmark_assets/Move.toml @@ -15,8 +15,8 @@ Bob = "gkNW9pAcCHxZrnoVkhLkEQtsLsW5NWTC75cdAdxAMs9LNYCYg" [dependencies.PontStdlib] git = "https://github.com/pontem-network/pont-stdlib.git" -rev = "1f094231de16cad54f2303093a7f866474bccd12" +rev = "release-v1.0.0" [dependencies.MoveStdlib] git = "https://github.com/pontem-network/move-stdlib.git" -rev = "12c5488729b8377b90f247537459f16ef1383d43" +rev = "release-v1.0.0" From 6afbe0cbe5f68e65c9c6273dcc42faf90c057e57 Mon Sep 17 00:00:00 2001 From: Alexander Koz Date: Tue, 8 Feb 2022 19:29:59 +0300 Subject: [PATCH 3/4] CI: use rust-toolchain.toml (#176) * CI: use rust-toolchain in toml format, do not parse file and trust rustup & gh-action. * remove old rust-toolchain file * fix typo * temporarily using gh-action fork zephraph/toolchain with path https://github.com/actions-rs/toolchain/pull/209 --- .github/workflows/coverage.yml | 3 +- .github/workflows/release.yml | 14 +++------ .github/workflows/tests.yml | 53 +++++++++------------------------- rust-toolchain | 1 - rust-toolchain.toml | 2 +- 5 files changed, 21 insertions(+), 52 deletions(-) delete mode 100644 rust-toolchain diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index c775eb45..0fd5b97a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -42,7 +42,8 @@ jobs: uses: actions/checkout@v2 - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + # uses: actions-rs/toolchain@v1 + uses: zephraph/toolchain@support-toolchain-toml with: profile: minimal override: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 44a88549..19269623 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -148,19 +148,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - id: rust # MSRV - name: Read required Rust version - run: | - echo "WASM_BUILD_TOOLCHAIN=$(cat rust-toolchain)" >> $GITHUB_ENV - echo ::set-output name=version::$(cat rust-toolchain) - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + # uses: actions-rs/toolchain@v1 + uses: zephraph/toolchain@support-toolchain-toml with: - toolchain: ${{ steps.rust.outputs.version }} profile: minimal target: wasm32-unknown-unknown - override: false + override: true - name: Restore Rust cache uses: Swatinem/rust-cache@v1 @@ -173,7 +167,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Build - run: cargo +${{ steps.rust.outputs.version }} build --release + run: cargo build --release - name: Upload Node uses: actions/upload-release-asset@v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index befb7a62..d98bd05f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,19 +33,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - id: rust # MSRV - name: use required Rust version - run: | - echo "WASM_BUILD_TOOLCHAIN=$(cat rust-toolchain)" >> $GITHUB_ENV - echo ::set-output name=version::$(cat rust-toolchain) - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + # uses: actions-rs/toolchain@v1 + uses: zephraph/toolchain@support-toolchain-toml with: - toolchain: ${{ steps.rust.outputs.version }} profile: minimal components: rustfmt - override: false + override: true - name: Check formatting run: cargo fmt -- --check @@ -66,7 +60,7 @@ jobs: run: make assets - name: Tests - run: cargo +${{ steps.rust.outputs.version }} test --all --no-fail-fast -- --nocapture --test-threads=1 + run: cargo test --all --no-fail-fast -- --nocapture --test-threads=1 env: { SKIP_WASM_BUILD: 1 } clippy: @@ -89,16 +83,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - id: rust # MSRV - name: use required Rust version - run: | - echo "WASM_BUILD_TOOLCHAIN=$(cat rust-toolchain)" >> $GITHUB_ENV - echo ::set-output name=version::$(cat rust-toolchain) - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + # uses: actions-rs/toolchain@v1 + uses: zephraph/toolchain@support-toolchain-toml with: - toolchain: ${{ steps.rust.outputs.version }} profile: minimal components: clippy target: wasm32-unknown-unknown @@ -115,7 +103,6 @@ jobs: uses: actions-rs/clippy-check@v1 with: name: Clippy report - toolchain: ${{ steps.rust.outputs.version }} token: ${{ secrets.GITHUB_TOKEN }} args: -p=sp-mvm -p=sp-mvm-rpc -p=sp-mvm-rpc-runtime @@ -141,19 +128,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - id: rust # MSRV - name: use required Rust version - run: | - echo "WASM_BUILD_TOOLCHAIN=$(cat rust-toolchain)" >> $GITHUB_ENV - echo ::set-output name=version::$(cat rust-toolchain) - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + # uses: actions-rs/toolchain@v1 + uses: zephraph/toolchain@support-toolchain-toml with: - toolchain: ${{ steps.rust.outputs.version }} profile: minimal target: wasm32-unknown-unknown - override: false + override: true - name: get dove uses: pontem-network/get-dove@main @@ -163,7 +144,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Build - run: cargo +${{ steps.rust.outputs.version }} build --all + run: cargo build --all - name: make artifact if: "contains(github.event.head_commit.message, 'save artifact') || contains(github.event.head_commit.message, '+artifact')" @@ -198,19 +179,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - id: rust # MSRV - name: use required Rust version - run: | - echo "WASM_BUILD_TOOLCHAIN=$(cat rust-toolchain)" >> $GITHUB_ENV - echo ::set-output name=version::$(cat rust-toolchain) - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + # uses: actions-rs/toolchain@v1 + uses: zephraph/toolchain@support-toolchain-toml with: - toolchain: ${{ steps.rust.outputs.version }} profile: minimal target: wasm32-unknown-unknown - override: false + override: true - name: get dove uses: pontem-network/get-dove@main @@ -220,7 +195,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Build - run: cargo +${{ steps.rust.outputs.version }} build --features "runtime-benchmarks" --release + run: cargo build --features "runtime-benchmarks" --release - name: Run benchmarks run: | diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 23bb83b0..00000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly-2021-11-07 diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7ec2336c..f96fe958 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] channel = "nightly-2021-11-07" -progile = "complete" +profile = "complete" targets = [ "wasm32-unknown-unknown"] From 3478d81e5e5d5db2a6ec69a082ad7f73fe80a9b5 Mon Sep 17 00:00:00 2001 From: Alexander Koz Date: Wed, 9 Feb 2022 17:12:29 +0300 Subject: [PATCH 4/4] CI: fix main crate name (#181) --- .github/workflows/tag-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tag-version.yml b/.github/workflows/tag-version.yml index 6271a3d0..ee055ce4 100644 --- a/.github/workflows/tag-version.yml +++ b/.github/workflows/tag-version.yml @@ -17,7 +17,7 @@ jobs: name: try create tag uses: pontem-network/tag-crate-version@main with: - crate: pontem-node + crate: pontem version-to-tag: "v$1" token: ${{ secrets.GITHUB_TOKEN }}