Skip to content

Commit

Permalink
Merge branch 'master' into gpestana/epm-mb
Browse files Browse the repository at this point in the history
  • Loading branch information
kianenigma authored Jan 16, 2025
2 parents c5efc26 + 64abc74 commit 3ab3a17
Show file tree
Hide file tree
Showing 68 changed files with 4,894 additions and 1,360 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-semver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: install parity-publish
if: ${{ !contains(github.event.pull_request.labels.*.name, 'R0-silent') }}
# Set the target dir to cache the build.
run: CARGO_TARGET_DIR=./target/ cargo install [email protected].3 --locked -q
run: CARGO_TARGET_DIR=./target/ cargo install [email protected].4 --locked -q

- name: check semver
if: ${{ !contains(github.event.pull_request.labels.*.name, 'R0-silent') }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/publish-check-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ jobs:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7

- name: Rust Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-on-failure: true

- name: install parity-publish
run: cargo install [email protected] --locked -q
run: |
rustup override set 1.82.0
cargo install [email protected] --locked -q
- name: parity-publish update plan
run: parity-publish --color always plan --skip-check --prdoc prdoc/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-check-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7

- name: Rust Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-on-failure: true

- name: install parity-publish
run: cargo install [email protected].3 --locked -q
run: cargo install [email protected].4 --locked -q

- name: parity-publish check
run: parity-publish --color always check --allow-unpublished
4 changes: 2 additions & 2 deletions .github/workflows/publish-claim-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7

- name: Rust Cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
with:
cache-on-failure: true

- name: install parity-publish
run: cargo install [email protected].3 --locked -q
run: cargo install [email protected].4 --locked -q

- name: parity-publish claim
env:
Expand Down
31 changes: 29 additions & 2 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ members = [
"substrate/frame/asset-conversion",
"substrate/frame/asset-conversion/ops",
"substrate/frame/asset-rate",
"substrate/frame/asset-rewards",
"substrate/frame/assets",
"substrate/frame/assets-freezer",
"substrate/frame/atomic-swap",
Expand Down Expand Up @@ -850,7 +851,7 @@ linked-hash-map = { version = "0.5.4" }
linked_hash_set = { version = "0.1.4" }
linregress = { version = "0.5.1" }
lite-json = { version = "0.2.0", default-features = false }
litep2p = { version = "0.8.4", features = ["websocket"] }
litep2p = { version = "0.9.0", features = ["websocket"] }
log = { version = "0.4.22", default-features = false }
macro_magic = { version = "0.5.1" }
maplit = { version = "1.0.2" }
Expand Down Expand Up @@ -893,6 +894,7 @@ pallet-asset-conversion = { path = "substrate/frame/asset-conversion", default-f
pallet-asset-conversion-ops = { path = "substrate/frame/asset-conversion/ops", default-features = false }
pallet-asset-conversion-tx-payment = { path = "substrate/frame/transaction-payment/asset-conversion-tx-payment", default-features = false }
pallet-asset-rate = { path = "substrate/frame/asset-rate", default-features = false }
pallet-asset-rewards = { path = "substrate/frame/asset-rewards", default-features = false }
pallet-asset-tx-payment = { path = "substrate/frame/transaction-payment/asset-tx-payment", default-features = false }
pallet-assets = { path = "substrate/frame/assets", default-features = false }
pallet-assets-freezer = { path = "substrate/frame/assets-freezer", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workspace = true

# Substrate
frame-support = { workspace = true }
pallet-asset-rewards = { workspace = true }
sp-core = { workspace = true }
sp-keyring = { workspace = true }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ pub const USDT_ID: u32 = 1984;

pub const PENPAL_A_ID: u32 = 2000;
pub const PENPAL_B_ID: u32 = 2001;
pub const ASSET_HUB_ROCOCO_ID: u32 = 1000;
pub const ASSET_HUB_WESTEND_ID: u32 = 1000;
pub const ASSETS_PALLET_ID: u8 = 50;

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ codec = { workspace = true }
# Substrate
frame-support = { workspace = true }
pallet-asset-conversion = { workspace = true }
pallet-asset-rewards = { workspace = true }
pallet-assets = { workspace = true }
pallet-balances = { workspace = true }
pallet-message-queue = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ mod imports {
genesis::ED as ROCOCO_ED,
rococo_runtime::{
governance as rococo_governance,
governance::pallet_custom_origins::Origin::Treasurer,
xcm_config::{
UniversalLocation as RococoUniversalLocation, XcmConfig as RococoXcmConfig,
},
OriginCaller as RococoOriginCaller,
Dmp, OriginCaller as RococoOriginCaller,
},
RococoRelayPallet as RococoPallet,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
mod claim_assets;
mod hybrid_transfers;
mod reserve_transfer;
mod reward_pool;
mod send;
mod set_xcm_versions;
mod swap;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::imports::*;
use codec::Encode;
use frame_support::{assert_ok, sp_runtime::traits::Dispatchable, traits::schedule::DispatchTime};
use xcm_executor::traits::ConvertLocation;

#[test]
fn treasury_creates_asset_reward_pool() {
AssetHubRococo::execute_with(|| {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
type Balances = <AssetHubRococo as AssetHubRococoPallet>::Balances;

let treasurer =
Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]);
let treasurer_account =
ahr_xcm_config::LocationToAccountId::convert_location(&treasurer).unwrap();

assert_ok!(Balances::force_set_balance(
<AssetHubRococo as Chain>::RuntimeOrigin::root(),
treasurer_account.clone().into(),
ASSET_HUB_ROCOCO_ED * 100_000,
));

let events = AssetHubRococo::events();
match events.iter().last() {
Some(RuntimeEvent::Balances(pallet_balances::Event::BalanceSet { who, .. })) =>
assert_eq!(*who, treasurer_account),
_ => panic!("Expected Balances::BalanceSet event"),
}
});

Rococo::execute_with(|| {
type AssetHubRococoRuntimeCall = <AssetHubRococo as Chain>::RuntimeCall;
type AssetHubRococoRuntime = <AssetHubRococo as Chain>::Runtime;
type RococoRuntimeCall = <Rococo as Chain>::RuntimeCall;
type RococoRuntime = <Rococo as Chain>::Runtime;
type RococoRuntimeEvent = <Rococo as Chain>::RuntimeEvent;
type RococoRuntimeOrigin = <Rococo as Chain>::RuntimeOrigin;

Dmp::make_parachain_reachable(AssetHubRococo::para_id());

let staked_asset_id = bx!(RelayLocation::get());
let reward_asset_id = bx!(RelayLocation::get());

let reward_rate_per_block = 1_000_000_000;
let lifetime = 1_000_000_000;
let admin = None;

let create_pool_call =
RococoRuntimeCall::XcmPallet(pallet_xcm::Call::<RococoRuntime>::send {
dest: bx!(VersionedLocation::V4(
xcm::v4::Junction::Parachain(AssetHubRococo::para_id().into()).into()
)),
message: bx!(VersionedXcm::V5(Xcm(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
Transact {
origin_kind: OriginKind::SovereignAccount,
fallback_max_weight: None,
call: AssetHubRococoRuntimeCall::AssetRewards(
pallet_asset_rewards::Call::<AssetHubRococoRuntime>::create_pool {
staked_asset_id,
reward_asset_id,
reward_rate_per_block,
expiry: DispatchTime::After(lifetime),
admin
}
)
.encode()
.into(),
}
]))),
});

let treasury_origin: RococoRuntimeOrigin = Treasurer.into();
assert_ok!(create_pool_call.dispatch(treasury_origin));

assert_expected_events!(
Rococo,
vec![
RococoRuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {},
]
);
});

AssetHubRococo::execute_with(|| {
type Runtime = <AssetHubRococo as Chain>::Runtime;
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;

assert_eq!(1, pallet_asset_rewards::Pools::<Runtime>::iter().count());

let events = AssetHubRococo::events();
match events.iter().last() {
Some(RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed {
success: true,
..
})) => (),
_ => panic!("Expected MessageQueue::Processed event"),
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ frame-metadata-hash-extension = { workspace = true, default-features = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-asset-conversion = { workspace = true }
pallet-asset-rewards = { workspace = true }
pallet-asset-tx-payment = { workspace = true }
pallet-assets = { workspace = true }
pallet-balances = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ mod imports {
},
westend_emulated_chain::{
genesis::ED as WESTEND_ED,
westend_runtime::xcm_config::{
UniversalLocation as WestendUniversalLocation, XcmConfig as WestendXcmConfig,
westend_runtime::{
governance::pallet_custom_origins::Origin::Treasurer,
xcm_config::{
UniversalLocation as WestendUniversalLocation, XcmConfig as WestendXcmConfig,
},
Dmp,
},
WestendRelayPallet as WestendPallet,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod claim_assets;
mod fellowship_treasury;
mod hybrid_transfers;
mod reserve_transfer;
mod reward_pool;
mod send;
mod set_asset_claimer;
mod set_xcm_versions;
Expand Down
Loading

0 comments on commit 3ab3a17

Please sign in to comment.