Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
85bde1c
feat: migrate to polkadot-v1.0.0
Aug 22, 2023
35e301e
feat: add missing migrations for polkadot-v1.0.0
Aug 24, 2023
7f13ca7
Fix Benchmkaring
hbulgarini Aug 24, 2023
e484833
".git/.scripts/commands/bench-all/bench-all.sh" --runtime=trappist --…
Aug 24, 2023
900877f
Fix compilation
hbulgarini Aug 24, 2023
923b9f7
add pallet for teleport foreign assets into ah
metricaez Aug 24, 2023
74db417
clean duplicated errors
metricaez Aug 25, 2023
08a93cf
cargo fmt
metricaez Aug 25, 2023
38918dd
comments
metricaez Aug 25, 2023
ac306c0
fix typo
metricaez Aug 28, 2023
92e5940
foreign asset by reanchoring
metricaez Aug 28, 2023
fb6d26b
Burn withdrawn assets on origin
metricaez Aug 28, 2023
935f233
Merge branch 'main' into emi-proxy-teleport-pallet
metricaez Aug 28, 2023
f280b8e
add comments and remove fee_asset_item
metricaez Aug 29, 2023
575e655
import through prelude
metricaez Sep 1, 2023
fa7b919
add foreign locations for LocationToAccountId
metricaez Sep 1, 2023
42f9527
Merge branch 'main' into emi-proxy-teleport-pallet
metricaez Sep 1, 2023
3d28e3c
minor fixes and add execution check
metricaez Sep 4, 2023
ab8bfbc
add obnoxious comments to avoid misusage
metricaez Sep 4, 2023
41aea01
cargo fmt
metricaez Sep 4, 2023
69fb3fe
prelude wildcard
metricaez Sep 5, 2023
55fb0fe
cargo fmt
metricaez Sep 5, 2023
7541ba1
dismiss "proxy" wording
metricaez Sep 5, 2023
a5c8dd4
typo
metricaez Sep 6, 2023
baefbba
Withdraw derivative on origin (#275)
metricaez Sep 14, 2023
4477bb8
Merge branch 'main' into emi-proxy-teleport-pallet
metricaez Sep 14, 2023
6aca06b
add hash of foreign location
metricaez Sep 14, 2023
3aeab64
typo and remove job limit on git workflow
metricaez Sep 15, 2023
8d26c7d
use teleport fallback weight
metricaez Sep 15, 2023
d2bac9e
add jobs 1 flag to check.yml
metricaez Sep 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,530 changes: 830 additions & 700 deletions Cargo.lock

Large diffs are not rendered by default.

227 changes: 114 additions & 113 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trappist"
version = "0.9.43"
version = "1.0.0"
description = "A versatile Proof-of-Authority (PoA) Blockchain network."
authors = { workspace = true }
license = { workspace = true }
Expand Down
19 changes: 13 additions & 6 deletions node/src/chain_spec/stout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ use sc_service::ChainType;
use sp_core::sr25519;
use stout_runtime::{
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig,
CouncilConfig, GenesisConfig, SessionConfig, SessionKeys, SudoConfig, SystemConfig,
CouncilConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys, SudoConfig, SystemConfig,
};

const DEFAULT_PROTOCOL_ID: &str = "stout";

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<stout_runtime::GenesisConfig, Extensions>;
pub type ChainSpec = sc_service::GenericChainSpec<stout_runtime::RuntimeGenesisConfig, Extensions>;

const STOUT_PARA_ID: u32 = 3000;

Expand Down Expand Up @@ -105,18 +105,22 @@ pub fn testnet_genesis(
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> GenesisConfig {
GenesisConfig {
) -> RuntimeGenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
code: stout_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.into_iter().map(|k| (k, 1 << 60)).collect(),
},
parachain_info: stout_runtime::ParachainInfoConfig { parachain_id: id },
parachain_info: stout_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
collator_selection: stout_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().map(|(acc, _)| acc).cloned().collect(),
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
Expand All @@ -139,7 +143,10 @@ pub fn testnet_genesis(
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: stout_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) },
polkadot_xcm: stout_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
sudo: SudoConfig {
// Assign network admin rights.
key: Some(root_key),
Expand Down
31 changes: 21 additions & 10 deletions node/src/chain_spec/trappist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ use sc_service::ChainType;
use sp_core::{crypto::UncheckedInto, sr25519};
use trappist_runtime::{
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig,
CouncilConfig, GenesisConfig, LockdownModeConfig, SessionConfig, SessionKeys, SudoConfig,
SystemConfig,
CouncilConfig, LockdownModeConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys,
SudoConfig, SystemConfig,
};

const DEFAULT_PROTOCOL_ID: &str = "hop";

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<trappist_runtime::GenesisConfig, Extensions>;
pub type ChainSpec =
sc_service::GenericChainSpec<trappist_runtime::RuntimeGenesisConfig, Extensions>;

const TRAPPIST_PARA_ID: u32 = 1836;

Expand Down Expand Up @@ -159,18 +160,22 @@ pub fn testnet_genesis(
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> GenesisConfig {
GenesisConfig {
) -> RuntimeGenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
code: trappist_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.into_iter().map(|k| (k, 1 << 60)).collect(),
},
parachain_info: trappist_runtime::ParachainInfoConfig { parachain_id: id },
parachain_info: trappist_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
collator_selection: trappist_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().map(|(acc, _)| acc).cloned().collect(),
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
Expand All @@ -196,6 +201,7 @@ pub fn testnet_genesis(
parachain_system: Default::default(),
polkadot_xcm: trappist_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
sudo: SudoConfig {
// Assign network admin rights.
Expand All @@ -207,7 +213,7 @@ pub fn testnet_genesis(
phantom: Default::default(),
},
treasury: Default::default(),
lockdown_mode: LockdownModeConfig { initial_status: false },
lockdown_mode: LockdownModeConfig { initial_status: false, ..Default::default() },
}
}

Expand Down Expand Up @@ -267,12 +273,13 @@ fn trappist_live_genesis(
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
id: ParaId,
) -> GenesisConfig {
GenesisConfig {
) -> RuntimeGenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
code: trappist_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
balances: BalancesConfig {
balances: endowed_accounts
Expand All @@ -281,7 +288,10 @@ fn trappist_live_genesis(
.chain(std::iter::once((root_key.clone(), 1_000_000_000_000_000_000)))
.collect(),
},
parachain_info: trappist_runtime::ParachainInfoConfig { parachain_id: id },
parachain_info: trappist_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
collator_selection: trappist_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().map(|(acc, _)| acc).cloned().collect(),
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
Expand All @@ -305,6 +315,7 @@ fn trappist_live_genesis(
parachain_system: Default::default(),
polkadot_xcm: trappist_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
},
sudo: SudoConfig {
// Assign network admin rights.
Expand Down
51 changes: 23 additions & 28 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use parachains_common::AuraId;
use parity_scale_codec::Encode;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
NetworkParams, Result, SharedParams, SubstrateCli,
};
use sc_service::config::{BasePath, PrometheusConfig};
use sp_core::hexdisplay::HexDisplay;
Expand All @@ -35,9 +35,12 @@ use crate::{
benchmarking::{inherent_benchmark_data, RemarkBuilder},
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
service::{new_partial, Block, RuntimeExecutor},
service::{new_partial, Block},
};

#[cfg(feature = "try-runtime")]
use crate::service::RuntimeExecutor;

/// Dispatches the code to the currently selected runtime.
macro_rules! dispatch_runtime {
($runtime:expr, |$alias: ident| $code:expr) => {
Expand Down Expand Up @@ -226,10 +229,6 @@ impl SubstrateCli for Cli {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
load_spec(id)
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
dispatch_runtime!(chain_spec.runtime(), |runtime| &runtime::VERSION)
}
}

impl SubstrateCli for RelayChainCli {
Expand Down Expand Up @@ -266,10 +265,6 @@ impl SubstrateCli for RelayChainCli {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
polkadot_cli::Cli::native_runtime_version(chain_spec)
}
}

/// Parse command line arguments into service configuration.
Expand Down Expand Up @@ -324,11 +319,9 @@ pub fn run() -> Result<()> {
})
},
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|_config| {
construct_async_run!(|components, cli, cmd, _config| {
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::native_runtime_version(&spec).state_version();
cmd.run::<crate::service::Block>(&*spec, state_version)
Ok(async move { cmd.run::<crate::service::Block>(&*spec, &*components.client) })
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
Expand All @@ -351,7 +344,7 @@ pub fn run() -> Result<()> {
}

dispatch_runtime!(config.chain_spec.runtime(), |runtime| {
cmd.run::<Block, RuntimeExecutor<runtime::Runtime>>(config)
cmd.run::<Block, ()>(config)
})
},
BenchmarkCmd::Block(cmd) => {
Expand Down Expand Up @@ -445,10 +438,8 @@ pub fn run() -> Result<()> {
let parachain_account =
AccountIdConversion::<polkadot_primitives::AccountId>::into_account_truncating(&id);

let state_version = Cli::native_runtime_version(&config.chain_spec).state_version();

let block: crate::service::Block =
generate_genesis_block(&*config.chain_spec, state_version)
generate_genesis_block(&*config.chain_spec, sp_runtime::StateVersion::V1)
.map_err(|e| format!("{e:?}"))?;
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));

Expand Down Expand Up @@ -700,16 +691,20 @@ mod tests {
assert_resolved_runtime(
Runtime::Trappist,
vec![
Box::new(create_default_with_extensions::<trappist_runtime::GenesisConfig, _>(
"trappist-1",
Extensions1::default(),
crate::chain_spec::trappist::testnet_genesis,
)),
Box::new(create_default_with_extensions::<trappist_runtime::GenesisConfig, _>(
"trappist-2",
Extensions2::default(),
crate::chain_spec::trappist::testnet_genesis,
)),
Box::new(
create_default_with_extensions::<trappist_runtime::RuntimeGenesisConfig, _>(
"trappist-1",
Extensions1::default(),
crate::chain_spec::trappist::testnet_genesis,
),
),
Box::new(
create_default_with_extensions::<trappist_runtime::RuntimeGenesisConfig, _>(
"trappist-2",
Extensions2::default(),
crate::chain_spec::trappist::testnet_genesis,
),
),
Box::new(crate::chain_spec::trappist::trappist_local_testnet_config()),
],
)
Expand Down
7 changes: 3 additions & 4 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

use std::sync::Arc;

use parachains_common::{
AccountId, AssetIdForTrustBackedAssets as AssetId, Balance, Block, Index as Nonce,
};
use parachains_common::{AccountId, AssetIdForTrustBackedAssets as AssetId, Balance, Block, Nonce};
use sc_client_api::AuxStore;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};

Expand Down Expand Up @@ -55,6 +53,7 @@ where
+ Send
+ Sync
+ 'static,
C: CallApiAt<Block>,
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
Expand Down
2 changes: 1 addition & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use cumulus_relay_chain_interface::RelayChainInterface;
use futures::lock::Mutex;
use jsonrpsee::RpcModule;
pub use parachains_common::{
AccountId, AssetIdForTrustBackedAssets as AssetId, Balance, Block, Header, Index as Nonce,
AccountId, AssetIdForTrustBackedAssets as AssetId, Balance, Block, Header, Nonce,
};
use parity_scale_codec::Codec;
use sc_consensus::{
Expand Down
22 changes: 8 additions & 14 deletions pallets/asset-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
// limitations under the License.

use crate as pallet_asset_registry;
use frame_support::traits::{AsEnsureOriginWithArg, ConstU16, ConstU64, GenesisBuild};
use frame_support::traits::{AsEnsureOriginWithArg, ConstU16, ConstU64};
use frame_system as system;
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, ConstU32, IdentityLookup},
BuildStorage,
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

frame_support::parameter_types! {
Expand All @@ -35,11 +34,7 @@ frame_support::parameter_types! {

// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
pub struct Test {
System: frame_system,
AssetRegistry: pallet_asset_registry::{Pallet, Call, Storage, Event<T>},
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
Expand All @@ -48,19 +43,18 @@ frame_support::construct_runtime!(
);

impl system::Config for Test {
type RuntimeEvent = RuntimeEvent;
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type RuntimeEvent = RuntimeEvent;
type Block = Block;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type Version = ();
Expand Down Expand Up @@ -100,7 +94,7 @@ impl pallet_balances::Config for Test {
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type FreezeIdentifier = ();
type MaxLocks = ();
type MaxReserves = ();
Expand Down Expand Up @@ -135,7 +129,7 @@ pub const LOCAL_ASSET_ID: u32 = 10;

// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut storage = system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut storage = system::GenesisConfig::<Test>::default().build_storage().unwrap();

let config: pallet_assets::GenesisConfig<Test> = pallet_assets::GenesisConfig {
assets: vec![
Expand Down
Loading