Skip to content

Commit

Permalink
feat: CheckMetadataHash extension (#1865)
Browse files Browse the repository at this point in the history
* set dependency versions

* upgrade libs/*

* upgrade pallet-anchors

* upgrade pallet-fees

* upgrade pallet-bridge

* migrate simple pallets

* migrate pallet-order-book

* migrated collator-allowlist & swaps

* upgrade rewards

* upgraded pallet-mux

* upgrade transfer-allowlist

* fix hold reason in restricted tokens

* simplify set_balance removing the holding part

* upgrade restricted-xtokens

* upgrade some pallets

* upgrade pallet-ethereum-transaction

* upgrade pallet-loans

* upgrade pool-system

* upgrade pool-fees

* upgrade pool-registry

* upgrade liquidity-pools stuffs

* avoid duplicated polkadot-sdk repos

* minor fixes

* upgraded runtime-common

* CfgLocation to RestrictedTransferLocation

* restricted tokens with NativeIndex for native fungibles

* rename dependency

* upgraded development-runtime

* fix partially benchmarks

* fix benchmarks

* overpass xcmp-queue integrity tests

* minor coments

* upgrade altair & centrifuge

* remove some benchmarking pallets that are not needed

* fix runtime upgrades

* upgrade integration-test proc

* upgrade integration-tests framework

* upgraded all tests except liquidity pools

* 99% upgraded liquidity-pools tests

* fix lookup

* cargo fmt

* taplo fmt

* using nightly cargo in CI

* restore set_balance as it was

* allow nightly support in CI

* use restricted_tokens again to fetch from investement portfolio

* Install rust-src for docs

* fix tests

* remove unused restricted tokens

* fix block rewards

* fix WrongWitness for some tests in IT

* fix liquidity-pools

* minor fixes

* fix clippy

* remove unneeded tests

* feat: Update client to Polkadot v1.7.2 (#1844)

* wip: update client

* chore: update crate versions

* chore: update anchor rpc api

* chore: remove rewards, pools rpc

* chore: compile with development runtime

* fix: client for all runtimes

* fix: build spec

* feat: update relay docker images

* fix: apply deprecation of export genesis state to scripts

* fmt: taplo

* refactor: use xcm v4 sugar

* fix: revert tmp change in local para run

* refactor: simplify xcm v4 locations in chain spec

* cargo fmt

* fix clippy

* feat: Polkadot v1.7.2 migrations (#1849)

* feat: add hold reason migration

* feat: centrifuge migrations

* feat: altair migrations

* feat: dev + demo migrations

* fix: clippy

* fix: build

* fmt: fix using nightly

* last William iteration review

* increase passed blocks

* use rococo instead of polkadot-test-runtime

* fix tests

* remove line

* dirty fix to fix Hrmp test issue

* use default weights for treasury

* remove getrandom unused dep

* upgrade to last polkadot-sdk version

* feat: `CheckMetadataHash` extension

* fix it (#1866)

* fmt: taplo

* refactor: signed ext order

* fix: signed ext order for ITs

* IT: more support for router tests (#1885)

* move routers to its own module

* remove outdated markers

* for all runtimes

* remove previous tests

* minor fixes

* v0.11.2 rc

* panic if event is not found in the expected blocks (#1880)

* fix: ci

* remove generic module (#1887)

* revert check metadata hash disable

* fix: disable metadata hash check for integration tests

---------

Co-authored-by: lemunozm <[email protected]>
  • Loading branch information
wischli and lemunozm authored Jun 27, 2024
1 parent e7b54c9 commit 25e7e22
Show file tree
Hide file tree
Showing 58 changed files with 795 additions and 896 deletions.
64 changes: 60 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", default-featu
sp-trie = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.7.2" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, features = [
"tuples-96",
], branch = "release-polkadot-v1.7.2" } # Check when tuples-96 can be removed
Expand Down
1 change: 0 additions & 1 deletion pallets/liquidity-pools-gateway/routers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ where
T: frame_system::Config + pallet_xcm_transactor::Config,
{
pub xcm_domain: XcmDomain<T::CurrencyId>,
pub _marker: PhantomData<T>,
}

impl<T> XCMRouter<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use scale_info::{
TypeInfo,
};
use sp_core::{bounded::BoundedVec, ConstU32, H160};
use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData, vec, vec::Vec};
use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};

use crate::{
AccountIdOf, EVMRouter, MessageOf, AXELAR_DESTINATION_CHAIN_PARAM,
Expand All @@ -44,7 +44,6 @@ where
pub router: EVMRouter<T>,
pub evm_chain: BoundedVec<u8, ConstU32<MAX_AXELAR_EVM_CHAIN_SIZE>>,
pub liquidity_pools_contract_address: H160,
pub _marker: PhantomData<T>,
}

impl<T> AxelarEVMRouter<T>
Expand All @@ -66,7 +65,6 @@ where
router,
evm_chain,
liquidity_pools_contract_address,
_marker: Default::default(),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::{bounded::BoundedVec, ConstU32, H160};
use sp_runtime::DispatchError;
use sp_std::marker::PhantomData;

use crate::{
axelar_evm::get_axelar_encoded_msg, AccountIdOf, CurrencyIdOf, MessageOf, XCMRouter, XcmDomain,
Expand All @@ -37,7 +36,6 @@ where
pub router: XCMRouter<T>,
pub axelar_target_chain: BoundedVec<u8, ConstU32<MAX_AXELAR_EVM_CHAIN_SIZE>>,
pub axelar_target_contract: H160,
pub _marker: PhantomData<T>,
}

impl<T> AxelarXCMRouter<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use frame_support::{
};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_std::{collections::btree_map::BTreeMap, marker::PhantomData, vec, vec::Vec};
use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};

use crate::{AccountIdOf, MessageOf, XCMRouter, FUNCTION_NAME, MESSAGE_PARAM};

Expand All @@ -30,7 +30,6 @@ where
+ pallet_liquidity_pools_gateway::Config,
{
pub router: XCMRouter<T>,
pub _marker: PhantomData<T>,
}

impl<T> EthereumXCMRouter<T>
Expand Down
15 changes: 0 additions & 15 deletions pallets/liquidity-pools-gateway/routers/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ mod xcm_router {

let router = XCMRouter::<Runtime> {
xcm_domain: test_data.xcm_domain.clone(),
_marker: Default::default(),
};

assert_ok!(router.do_init());
Expand All @@ -247,7 +246,6 @@ mod xcm_router {

let router = XCMRouter::<Runtime> {
xcm_domain: test_data.xcm_domain.clone(),
_marker: Default::default(),
};

assert_ok!(router.do_send(test_data.sender, test_data.msg.clone()));
Expand Down Expand Up @@ -293,7 +291,6 @@ mod xcm_router {

let router = XCMRouter::<Runtime> {
xcm_domain: test_data.xcm_domain.clone(),
_marker: Default::default(),
};

assert_ok!(router.do_init());
Expand Down Expand Up @@ -383,7 +380,6 @@ mod axelar_evm {
evm_chain: TEST_EVM_CHAIN.clone(),
liquidity_pools_contract_address: test_data
.liquidity_pools_contract_address,
_marker: Default::default(),
});

assert_ok!(domain_router.init());
Expand All @@ -404,7 +400,6 @@ mod axelar_evm {
evm_chain: TEST_EVM_CHAIN.clone(),
liquidity_pools_contract_address: test_data
.liquidity_pools_contract_address,
_marker: Default::default(),
});

assert_noop!(
Expand Down Expand Up @@ -453,7 +448,6 @@ mod axelar_evm {
evm_chain: TEST_EVM_CHAIN.clone(),
liquidity_pools_contract_address: test_data
.liquidity_pools_contract_address,
_marker: Default::default(),
});

assert_ok!(domain_router.send(test_data.sender, test_data.msg));
Expand All @@ -474,7 +468,6 @@ mod axelar_evm {
evm_chain: TEST_EVM_CHAIN.clone(),
liquidity_pools_contract_address: test_data
.liquidity_pools_contract_address,
_marker: Default::default(),
});

let res = domain_router.send(test_data.sender, test_data.msg);
Expand Down Expand Up @@ -551,11 +544,9 @@ mod axelar_xcm {
DomainRouter::<Runtime>::AxelarXCM(AxelarXCMRouter::<Runtime> {
router: XCMRouter {
xcm_domain: test_data.xcm_domain.clone(),
_marker: Default::default(),
},
axelar_target_chain: test_data.axelar_target_chain,
axelar_target_contract: test_data.axelar_target_contract,
_marker: Default::default(),
});

assert_ok!(domain_router.init());
Expand All @@ -575,11 +566,9 @@ mod axelar_xcm {
DomainRouter::<Runtime>::AxelarXCM(AxelarXCMRouter::<Runtime> {
router: XCMRouter {
xcm_domain: test_data.xcm_domain.clone(),
_marker: Default::default(),
},
axelar_target_chain: test_data.axelar_target_chain.clone(),
axelar_target_contract: test_data.axelar_target_contract,
_marker: Default::default(),
});

assert_ok!(domain_router.init());
Expand Down Expand Up @@ -694,9 +683,7 @@ mod ethereum_xcm {
DomainRouter::<Runtime>::EthereumXCM(EthereumXCMRouter::<Runtime> {
router: XCMRouter {
xcm_domain: test_data.xcm_domain.clone(),
_marker: Default::default(),
},
_marker: Default::default(),
});

assert_ok!(domain_router.init());
Expand All @@ -716,9 +703,7 @@ mod ethereum_xcm {
DomainRouter::<Runtime>::EthereumXCM(EthereumXCMRouter::<Runtime> {
router: XCMRouter {
xcm_domain: test_data.xcm_domain.clone(),
_marker: Default::default(),
},
_marker: Default::default(),
});

assert_ok!(domain_router.init());
Expand Down
1 change: 1 addition & 0 deletions pallets/pool-system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ impl EnsureOriginWithArg<RuntimeOrigin, PoolId> for All {

#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin(_: &PoolId) -> Result<RuntimeOrigin, ()> {
use frame_support::dispatch::RawOrigin;
Ok(RawOrigin::Root.into())
}
}
Expand Down
12 changes: 12 additions & 0 deletions runtime/altair/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ sp-version = { workspace = true }

frame-benchmarking = { workspace = true, optional = true } # For benchmarking
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-benchmarking = { workspace = true, optional = true } # For benchmarking
Expand Down Expand Up @@ -169,6 +170,7 @@ std = [
"frame-system/std",
"frame-system-rpc-runtime-api/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-try-runtime?/std",
"frame-system-benchmarking?/std",
"frame-benchmarking?/std",
Expand Down Expand Up @@ -433,12 +435,22 @@ try-runtime = [
"staging-parachain-info/try-runtime",
]

# Enable the metadata hash generation.
#
# This is hidden behind a feature because it increases the compile time.
# The wasm binary needs to be compiled twice, once to fetch the metadata,
# generate the metadata hash and then a second time with the
# `RUNTIME_METADATA_HASH` environment variable set for the `CheckMetadataHash`
# extension.
metadata-hash = ["substrate-wasm-builder/metadata-hash"]

# A feature that should be enabled when the runtime should be build for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
on-chain-release-build = [
"sp-api/disable-logging",
"runtime-common/on-chain-release-build",
"metadata-hash",
]

# Set timing constants (e.g. session period) to faster versions to speed up testing.
Expand Down
19 changes: 13 additions & 6 deletions runtime/altair/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
use substrate_wasm_builder::WasmBuilder;
#[cfg(all(feature = "std", feature = "metadata-hash"))]
fn main() {
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("AIR", 18)
.build();
}

#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
substrate_wasm_builder::WasmBuilder::build_using_defaults();
}

/// The wasm builder is deactivated when compiling
/// this crate for wasm to speed up the compilation.
#[cfg(not(feature = "std"))]
fn main() {}
Loading

0 comments on commit 25e7e22

Please sign in to comment.