Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 4 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ on:
env:
TARPAULIN_VERSION: 0.19.1

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Coverage Report
runs-on: [self-hosted]
steps:
- name: Cancel Previous Runs
# Only cancel non-master branch runs
if: ${{ github.ref != 'refs/heads/master' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout repository
uses: actions/checkout@v3
with:
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@ on:
paths-ignore:
- '**/README.md'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
cancel:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
# Only cancel non-master branch runs
if: ${{ github.ref != 'refs/heads/master' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
build:
runs-on: [self-hosted]
env:
SCCACHE_CACHE_SIZE: "50G"
needs: cancel
SCCACHE_CACHE_SIZE: "60G"
steps:
- uses: actions/checkout@v3
- name: Install toolchain
Expand Down
149 changes: 69 additions & 80 deletions Cargo.dev.toml

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,20 @@ dev-check: Cargo.toml check

dev-check-tests: Cargo.toml
cargo check --tests --all
cargo check --tests --features=bench --package=orml-weight-meter --package=orml-bencher-test

dev-test: Cargo.toml
cargo test --all --features=runtime-benchmarks
cargo test --features=bench --package=orml-weight-meter --package=orml-bencher-test

# run benchmarks via Acala node
benchmark-all:
cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_auction --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./auction/src/weights.rs --template ../templates/orml-weight-template.hbs
cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_auction --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./auction/src/weights.rs --template ../templates/orml-weight-template.hbs

cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_authority --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./authority/src/weights.rs --template ../templates/orml-weight-template.hbs
cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_authority --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./authority/src/weights.rs --template ../templates/orml-weight-template.hbs

cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=module_currencies --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./currencies/src/weights.rs --template ../templates/orml-weight-template.hbs
cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=module_currencies --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./currencies/src/weights.rs --template ../templates/orml-weight-template.hbs

cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_oracle --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./oracle/src/weights.rs --template ../templates/orml-weight-template.hbs
cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_oracle --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./oracle/src/weights.rs --template ../templates/orml-weight-template.hbs

cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_tokens --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./tokens/src/weights.rs --template ../templates/orml-weight-template.hbs
cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_tokens --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./tokens/src/weights.rs --template ../templates/orml-weight-template.hbs

cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_vesting --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./vesting/src/weights.rs --template ../templates/orml-weight-template.hbs
cargo run --release --bin=acala --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=orml_vesting --extrinsic="*" --wasm-execution=compiled --heap-pages=4096 --output=./vesting/src/weights.rs --template ../templates/orml-weight-template.hbs
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,8 @@ The Open Runtime Module Library (ORML) is a community maintained collection of S
- Used by multiple parachains for their XCM token transfer implementation.

#### Benchmarking
- [bencher](https://github.com/open-web3-stack/open-runtime-module-library/tree/master/bencher)
- Benchmarking tool using cargo bench for benchmarking
- [benchmarking](https://github.com/open-web3-stack/open-runtime-module-library/tree/master/benchmarking)
- Fork of frame-benchmarking in Substrate to allow implement runtime specific benchmarks
- [weight-gen](https://github.com/open-web3-stack/open-runtime-module-library/tree/master/weight-gen)
- Weight meter file generation
- [weight-meter](https://github.com/open-web3-stack/open-runtime-module-library/tree/master/weight-meter)
- A low overhead dynamic weight meter

## Example

Expand Down Expand Up @@ -94,12 +88,13 @@ _In alphabetical order_
- [Bit.Country](https://github.com/bit-country/Bit-Country-Blockchain)
- [Centrifuge](https://github.com/centrifuge/centrifuge-chain)
- [ChainX](https://github.com/chainx-org/ChainX)
- [Composable](https://github.com/ComposableFi/composable)
- [Crust](https://github.com/crustio/crust)
- [GameDAO Protocol](https://github.com/gamedaoco)
- [HydraDX](https://github.com/galacticcouncil/hack.HydraDX-node)
- [Interlay and Kintsugi](https://github.com/interlay/interbtc)
- [InvArch and Tinkernet](https://github.com/InvArch/InvArch-Node)
- [KodaDot: MetaPrime Network](https://github.com/kodadot/metaprime.network)
- [KodaDot: MetaPrime Network](https://github.com/kodadot/metaprime.network)
- [Laminar Chain](https://github.com/laminar-protocol/laminar-chain)
- [Libra](https://github.com/atscaletech/libra)
- [Listen](https://github.com/listenofficial)
Expand Down
44 changes: 23 additions & 21 deletions asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,45 @@ authors = ["Interlay Ltd, etc"]
edition = "2021"

[dependencies]
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
log = { version = "0.4.20", default-features = false }
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.136", optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["max-encoded-len"] }

# substrate
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v1.0.0" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v1.0.0" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v1.0.0" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v1.0.0" }
frame-support = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }
frame-system = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }
sp-io = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }
sp-runtime = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }
sp-std = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }

# polkadot
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v1.0.0" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v1.0.0" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v1.0.0" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v1.0.0" }
pallet-xcm = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }
xcm = { package = "staging-xcm", git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }

# orml
orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false }

[dev-dependencies]
# substrate
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v1.0.0" }
pallet-message-queue = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" }
pallet-balances = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }
sp-core = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }
sp-io = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", default-features = false , branch = "moonbeam-polkadot-v1.1.0" }
pallet-message-queue = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }

# cumulus
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v1.0.0" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v1.0.0" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v1.0.0" }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v1.0.0" }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v1.0.0" }
cumulus-primitives-core = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }
cumulus-pallet-dmp-queue = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }
cumulus-pallet-xcm = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }
parachain-info = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }

# polkadot
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0" }
xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v1.0.0" }
polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }
polkadot-runtime-parachains = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }
xcm-simulator = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.1.0" }

# orml
orml-tokens = { path = "../tokens" }
Expand Down
22 changes: 13 additions & 9 deletions asset-registry/src/impls.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::module::*;
use frame_support::{log, pallet_prelude::*, weights::constants::WEIGHT_REF_TIME_PER_SECOND};
use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_REF_TIME_PER_SECOND};
use orml_traits::{
asset_registry::{
AssetMetadata, AssetProcessor, FixedConversionRateProvider, Inspect, Mutate, WeightToFeeConverter,
Expand All @@ -18,7 +18,8 @@ use xcm_builder::TakeRevenue;
use xcm_executor::{traits::WeightTrader, Assets};

/// Alias for AssetMetadata to improve readability (and to placate clippy)
pub type DefaultAssetMetadata<T> = AssetMetadata<<T as Config>::Balance, <T as Config>::CustomMetadata>;
pub type DefaultAssetMetadata<T> =
AssetMetadata<<T as Config>::Balance, <T as Config>::CustomMetadata, <T as Config>::StringLimit>;

/// An AssetProcessor that assigns a sequential ID
pub struct SequentialId<T>(PhantomData<T>);
Expand Down Expand Up @@ -89,7 +90,7 @@ impl<W: WeightToFeeConverter, R: TakeRevenue> WeightTrader for AssetRegistryTrad
}
}

fn buy_weight(&mut self, weight: XcmWeight, payment: Assets) -> Result<Assets, XcmError> {
fn buy_weight(&mut self, weight: XcmWeight, payment: Assets, _context: &XcmContext) -> Result<Assets, XcmError> {
log::trace!(
target: "xcm::weight",
"AssetRegistryTrader::buy_weight weight: {:?}, payment: {:?}",
Expand Down Expand Up @@ -131,7 +132,7 @@ impl<W: WeightToFeeConverter, R: TakeRevenue> WeightTrader for AssetRegistryTrad
Err(XcmError::TooExpensive)
}

fn refund_weight(&mut self, weight: XcmWeight) -> Option<MultiAsset> {
fn refund_weight(&mut self, weight: XcmWeight, _context: &XcmContext) -> Option<MultiAsset> {
log::trace!(target: "xcm::weight", "AssetRegistryTrader::refund_weight weight: {:?}", weight);

match self.bought_weight {
Expand Down Expand Up @@ -177,16 +178,19 @@ impl<T: Config> Inspect for Pallet<T> {
type AssetId = T::AssetId;
type Balance = T::Balance;
type CustomMetadata = T::CustomMetadata;
type StringLimit = T::StringLimit;

fn asset_id(location: &MultiLocation) -> Option<Self::AssetId> {
Pallet::<T>::location_to_asset_id(location)
}

fn metadata(id: &Self::AssetId) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata>> {
fn metadata(id: &Self::AssetId) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>> {
Pallet::<T>::metadata(id)
}

fn metadata_by_location(location: &MultiLocation) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata>> {
fn metadata_by_location(
location: &MultiLocation,
) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>> {
Pallet::<T>::fetch_metadata_by_location(location)
}

Expand All @@ -198,16 +202,16 @@ impl<T: Config> Inspect for Pallet<T> {
impl<T: Config> Mutate for Pallet<T> {
fn register_asset(
asset_id: Option<Self::AssetId>,
metadata: AssetMetadata<Self::Balance, Self::CustomMetadata>,
metadata: AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>,
) -> DispatchResult {
Pallet::<T>::do_register_asset(metadata, asset_id)
}

fn update_asset(
asset_id: Self::AssetId,
decimals: Option<u32>,
name: Option<Vec<u8>>,
symbol: Option<Vec<u8>>,
name: Option<BoundedVec<u8, Self::StringLimit>>,
symbol: Option<BoundedVec<u8, Self::StringLimit>>,
existential_deposit: Option<Self::Balance>,
location: Option<Option<VersionedMultiLocation>>,
additional: Option<Self::CustomMetadata>,
Expand Down
Loading