Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/pool-systems-essence
Browse files Browse the repository at this point in the history
  • Loading branch information
wischli committed Apr 15, 2024
2 parents e256eb2 + 94ee4d7 commit 5903a10
Show file tree
Hide file tree
Showing 228 changed files with 5,651 additions and 7,260 deletions.
4,054 changes: 2,532 additions & 1,522 deletions Cargo.lock

Large diffs are not rendered by default.

818 changes: 248 additions & 570 deletions Cargo.toml

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions ci/run-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ case $TARGET in
;;

lint-taplo)
cargo install taplo-cli --locked
cargo install taplo-cli
taplo fmt --check
;;

Expand All @@ -41,26 +41,26 @@ case $TARGET in
docs-build)
RUSTDOCFLAGS="-D warnings" cargo doc --all --no-deps
;;

try-runtime)
if [ "$1" == "altair" ]; then
echo "Running try-runtime for altair"
cargo build -p centrifuge-chain --release --features try-runtime
if [ "$1" == "altair" ]; then
echo "Running try-runtime for altair"
RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \
cargo run --release --features try-runtime try-runtime \
try-runtime \
--runtime target/release/wbuild/altair-runtime/altair_runtime.wasm \
--chain altair on-runtime-upgrade live \
--uri wss://fullnode.altair.centrifuge.io:443
elif [ "$1" == "centrifuge" ]; then
echo "Running try-runtime for centrifuge"
on-runtime-upgrade live --uri wss://fullnode.altair.centrifuge.io:443
elif [ "$1" == "centrifuge" ]; then
echo "Running try-runtime for centrifuge"
RUST_LOG=runtime=trace,try-runtime::cli=trace,executor=trace \
cargo run --release --features try-runtime try-runtime \
try-runtime \
--runtime target/release/wbuild/centrifuge-runtime/centrifuge_runtime.wasm \
--chain centrifuge on-runtime-upgrade live --uri wss://fullnode.centrifuge.io:443
else
echo "Invalid argument. Please specify 'altair' or 'centrifuge'."
exit 1
fi
;;
on-runtime-upgrade live --uri wss://fullnode.centrifuge.io:443
else
echo "Invalid argument. Please specify 'altair' or 'centrifuge'."
exit 1
fi
;;
subalfred)
# Find all child directories containing Cargo.toml files
# TODO: Filter by crates found in the workspace
Expand Down
4 changes: 0 additions & 4 deletions docker/docker-compose-local-chain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ services:
--alice
--parachain-id="2000"
--wasm-execution=compiled
--execution=wasm
--port=30333
--rpc-port=9933
--rpc-external
Expand All @@ -30,7 +29,6 @@ services:
--database=rocksdb
--
--wasm-execution=compiled
--execution=wasm
--chain=/chainspec.json
--bootnodes="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWDLpRT9KFo6pKdkmdQQt599tmqVYpoeiHemY32Gf4RUpp"
--bootnodes="/ip4/127.0.0.1/tcp/30344/p2p/12D3KooWKpaJZbNymrZmKG6BNNDC58z8p9YKDXfZtyhEjktgtph4"
Expand All @@ -54,7 +52,6 @@ services:
--alice
--parachain-id="2000"
--wasm-execution=compiled
--execution=wasm
--rpc-external
--rpc-cors all
--ws-external
Expand All @@ -63,7 +60,6 @@ services:
--log="main,info,xcm=trace,xcm-executor=trace"
--
--wasm-execution=compiled
--execution=wasm
--chain=/chainspec.json
--bootnodes="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWDLpRT9KFo6pKdkmdQQt599tmqVYpoeiHemY32Gf4RUpp"
--bootnodes="/ip4/127.0.0.1/tcp/30344/p2p/12D3KooWKpaJZbNymrZmKG6BNNDC58z8p9YKDXfZtyhEjktgtph4"
20 changes: 13 additions & 7 deletions docs/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ It runs a [collator](https://wiki.polkadot.network/docs/learn-collator) node:
Similar to the relay chain, you can explore the parachain using the [polkadot.js (on localhost:11936)](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2Flocalhost%3A11936#/explorer) client.
You will see the block production frozen until you connect it to the relay chain.

By default, the initialized parachain will have the id `2000`.
If you need more than one parachain or choose other chain specifications,
you can set `PARA_ID` or `PARA_CHAIN_SPEC`, example:
By default, the initialized parachain will have the id `2000`.
Please note that for ephemeral chains specs such as `development`, `centrifuge-local` or `altair-local`, the
parachain ID is currently hardcoded.
If you need to customize it, please open an issue and we will add such a feature.
If choose other chain specifications, you can set the `PARA_CHAIN_SPEC` env var, e.g.:
```bash
PARA_ID=2001 ./scripts/init.sh start-parachain
PARA_CHAIN_SPEC=development ./scripts/init.sh start-parachain
```
The different `PARA_CHAIN_SPEC` values can be found at [`src/command.rs`](src/command.rs) under the `load_spec()` function.
The different `PARA_CHAIN_SPEC` values can be found at [`src/command.rs`](src/command.rs) under the `load_spec()`
function.

3. Onboard the parachain
This step will have the targeted parachain onboarded in the relay chain. The parachain will NOT produce blocks until this step is completed successfully.
Expand Down Expand Up @@ -109,9 +112,12 @@ Lint the source code with `cargo fmt --all`. This excludes certain paths (define
See more [here](docs/runtime-upgrade.md).
## Generate new Spec and Parachain files
This script will take a valid chain-spec chain_id, a parachain_id and a flag to build new spec or not, and will output genesis spec (raw and plain), wasm and state files.
This script will take a valid chain-spec chain_id and a flag to build new spec or not, and will output genesis spec (raw
and plain), wasm and state files.
```shell
./scripts/export_parachain_files.sh charcoal-staging 10001 true
./scripts/export_parachain_files.sh demo true
```
Adapt parameters accordingly.
Expand Down
4 changes: 2 additions & 2 deletions libs/mocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cfg-traits = { workspace = true }
cfg-types = { workspace = true }

orml-traits = { workspace = true }
xcm = { workspace = true }
staging-xcm = { workspace = true }

mock-builder = { workspace = true }

Expand All @@ -46,7 +46,7 @@ std = [
"sp-io/std",
"sp-runtime/std",
"orml-traits/std",
"xcm/std",
"staging-xcm/std",
"mock-builder/std",
]
runtime-benchmarks = [
Expand Down
42 changes: 23 additions & 19 deletions libs/mocks/src/asset_registry.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
#[frame_support::pallet]
#[frame_support::pallet(dev_mode)]
pub mod pallet {
use frame_support::pallet_prelude::*;
use mock_builder::{execute_call, register_call};
use orml_traits::asset_registry::{AssetMetadata, Inspect, Mutate};
use xcm::{v3::prelude::MultiLocation, VersionedMultiLocation};
use sp_std::fmt::Debug;
use staging_xcm::{v3::prelude::MultiLocation, VersionedMultiLocation};

#[pallet::config]
pub trait Config: frame_system::Config {
type AssetId;
type Balance;
type Balance: Clone + Debug + Eq + PartialEq;
type CustomMetadata: Parameter + Member + TypeInfo;
type StringLimit: Get<u32>;
}

#[pallet::pallet]
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
_,
Blake2_128Concat,
<Blake2_128 as frame_support::StorageHasher>::Output,
mock_builder::CallId,
>;
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_asset_id(f: impl Fn(&MultiLocation) -> Option<T::AssetId> + 'static) {
register_call!(f);
}

pub fn mock_metadata(
f: impl Fn(&T::AssetId) -> Option<AssetMetadata<T::Balance, T::CustomMetadata>> + 'static,
f: impl Fn(
&T::AssetId,
) -> Option<AssetMetadata<T::Balance, T::CustomMetadata, T::StringLimit>>
+ 'static,
) {
register_call!(f);
}

pub fn mock_metadata_by_location(
f: impl Fn(&MultiLocation) -> Option<AssetMetadata<T::Balance, T::CustomMetadata>> + 'static,
f: impl Fn(
&MultiLocation,
) -> Option<AssetMetadata<T::Balance, T::CustomMetadata, T::StringLimit>>
+ 'static,
) {
register_call!(f);
}
Expand All @@ -49,7 +52,7 @@ pub mod pallet {
pub fn mock_register_asset(
f: impl Fn(
Option<T::AssetId>,
AssetMetadata<T::Balance, T::CustomMetadata>,
AssetMetadata<T::Balance, T::CustomMetadata, T::StringLimit>,
) -> DispatchResult
+ 'static,
) {
Expand All @@ -60,8 +63,8 @@ pub mod pallet {
f: impl Fn(
T::AssetId,
Option<u32>,
Option<Vec<u8>>,
Option<Vec<u8>>,
Option<BoundedVec<u8, T::StringLimit>>,
Option<BoundedVec<u8, T::StringLimit>>,
Option<T::Balance>,
Option<Option<VersionedMultiLocation>>,
Option<T::CustomMetadata>,
Expand All @@ -76,20 +79,21 @@ pub mod pallet {
type AssetId = T::AssetId;
type Balance = T::Balance;
type CustomMetadata = T::CustomMetadata;
type StringLimit = T::StringLimit;

fn asset_id(a: &MultiLocation) -> Option<Self::AssetId> {
execute_call!(a)
}

fn metadata(
a: &Self::AssetId,
) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata>> {
) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>> {
execute_call!(a)
}

fn metadata_by_location(
a: &MultiLocation,
) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata>> {
) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>> {
execute_call!(a)
}

Expand All @@ -101,16 +105,16 @@ pub mod pallet {
impl<T: Config> Mutate for Pallet<T> {
fn register_asset(
a: Option<Self::AssetId>,
b: AssetMetadata<Self::Balance, Self::CustomMetadata>,
b: AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>,
) -> DispatchResult {
execute_call!((a, b))
}

fn update_asset(
a: Self::AssetId,
b: Option<u32>,
c: Option<Vec<u8>>,
d: Option<Vec<u8>>,
c: Option<BoundedVec<u8, Self::StringLimit>>,
d: Option<BoundedVec<u8, Self::StringLimit>>,
e: Option<Self::Balance>,
g: Option<Option<VersionedMultiLocation>>,
h: Option<Self::CustomMetadata>,
Expand Down
9 changes: 2 additions & 7 deletions libs/mocks/src/change_guard.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[frame_support::pallet]
#[frame_support::pallet(dev_mode)]
pub mod pallet {
use cfg_traits::changes::ChangeGuard;
use frame_support::pallet_prelude::*;
Expand All @@ -15,12 +15,7 @@ pub mod pallet {
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
_,
Blake2_128Concat,
<Blake2_128 as frame_support::StorageHasher>::Output,
mock_builder::CallId,
>;
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_note(
Expand Down
9 changes: 2 additions & 7 deletions libs/mocks/src/currency_conversion.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[frame_support::pallet]
#[frame_support::pallet(dev_mode)]
pub mod pallet {
use cfg_traits::IdentityCurrencyConversion;
use frame_support::pallet_prelude::*;
Expand All @@ -14,12 +14,7 @@ pub mod pallet {
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
_,
Blake2_128Concat,
<Blake2_128 as frame_support::StorageHasher>::Output,
mock_builder::CallId,
>;
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_stable_to_stable(
Expand Down
9 changes: 2 additions & 7 deletions libs/mocks/src/data.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[frame_support::pallet]
#[frame_support::pallet(dev_mode)]
pub mod pallet {
use cfg_traits::data::{DataCollection, DataRegistry};
use frame_support::pallet_prelude::*;
Expand All @@ -17,12 +17,7 @@ pub mod pallet {
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
_,
Blake2_128Concat,
<Blake2_128 as frame_support::StorageHasher>::Output,
mock_builder::CallId,
>;
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_get(
Expand Down
13 changes: 4 additions & 9 deletions libs/mocks/src/fees.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
#[frame_support::pallet]
#[frame_support::pallet(dev_mode)]
pub mod pallet {
use cfg_traits::fees::{Fee, FeeKey, Fees};
use cfg_traits::fees::{Fee, Fees};
use frame_support::{pallet_prelude::*, traits::tokens::Balance};
use mock_builder::{execute_call, register_call};

#[pallet::config]
pub trait Config: frame_system::Config {
type Balance: Balance;
type FeeKey: FeeKey;
type FeeKey;
}

#[pallet::pallet]
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
_,
Blake2_128Concat,
<Blake2_128 as frame_support::StorageHasher>::Output,
mock_builder::CallId,
>;
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_fee_value(f: impl Fn(T::FeeKey) -> T::Balance + 'static) {
Expand Down
9 changes: 2 additions & 7 deletions libs/mocks/src/investment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[frame_support::pallet]
#[frame_support::pallet(dev_mode)]
pub mod pallet {
use cfg_traits::investments::{Investment, InvestmentCollector};
use frame_support::pallet_prelude::*;
Expand All @@ -16,12 +16,7 @@ pub mod pallet {
pub struct Pallet<T>(_);

#[pallet::storage]
pub(super) type CallIds<T: Config> = StorageMap<
_,
Blake2_128Concat,
<Blake2_128 as frame_support::StorageHasher>::Output,
mock_builder::CallId,
>;
type CallIds<T: Config> = StorageMap<_, _, String, mock_builder::CallId>;

impl<T: Config> Pallet<T> {
pub fn mock_update_investment(
Expand Down
Loading

0 comments on commit 5903a10

Please sign in to comment.