Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to polkadot v1.1.0 release #1182

Merged
merged 30 commits into from
Mar 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0dfb858
feat: update all deps to polkadot v1.1.0
ashutoshvarma Jan 22, 2024
323187c
feat(assets-erc20): update imports for `frame_support`
ashutoshvarma Jan 22, 2024
bfe1ded
feat(xc-asset-config): update imports for `frame_support`
ashutoshvarma Jan 22, 2024
72e0462
feat(primitives): replace xcm `Convert` with `sp_runtime`'s `MaybeEqu…
ashutoshvarma Jan 22, 2024
2b2da4a
feat: update all pallets for polkadot v1.1.0
ashutoshvarma Jan 26, 2024
df09963
feat: update chain extensions
ashutoshvarma Jan 31, 2024
a7485e2
feat: update all precompiles
ashutoshvarma Jan 31, 2024
849581a
wip: local runtime
ashutoshvarma Feb 5, 2024
8694d1a
feat: update shibuya runtmie
ashutoshvarma Feb 5, 2024
5aa0433
feat: fix local runtime
ashutoshvarma Feb 7, 2024
035feda
feat: fix holds
ashutoshvarma Feb 7, 2024
709390f
feat: update astar and shiden runtime
ashutoshvarma Feb 7, 2024
0452862
feat: fix all tests
ashutoshvarma Feb 7, 2024
96c1404
feat: build works execpt tracing
ashutoshvarma Feb 15, 2024
75a09be
feat: evm tracing build works
ashutoshvarma Feb 16, 2024
a6a3fcd
feat: bump spec versions
ashutoshvarma Feb 16, 2024
c43995d
feat: streamline genesis state export
ashutoshvarma Feb 20, 2024
673824c
fix: max hold in local runtime
ashutoshvarma Feb 20, 2024
ce9bb84
fix: aura issue in eth pending api
ashutoshvarma Feb 20, 2024
fa491da
feat: review comments
ashutoshvarma Feb 24, 2024
e74105e
Merge branch 'master' into feat/polkadot-1.0.0-fix
ashutoshvarma Feb 27, 2024
0e4b49a
feat: copy `AllowTopLevelPaidExecutionFrom` barrier into primititves
ashutoshvarma Feb 27, 2024
0062a9b
fix: build error
ashutoshvarma Feb 27, 2024
f3240f0
fix: make taplo happy
ashutoshvarma Feb 27, 2024
f40c1f8
fix: review comments
ashutoshvarma Feb 29, 2024
79104e1
fix: add contract migration back into shiden
ashutoshvarma Feb 29, 2024
3c2c7a2
feat: remove `BlockNumberFor` clauses
ashutoshvarma Feb 29, 2024
01c22a2
fix: format
ashutoshvarma Mar 1, 2024
8c44754
fix: make clippy happy
ashutoshvarma Mar 1, 2024
7439a41
feat: update `CodeHashLockupDepositPercent` value
ashutoshvarma Mar 1, 2024
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
Prev Previous commit
Next Next commit
feat: copy AllowTopLevelPaidExecutionFrom barrier into primititves
ashutoshvarma committed Feb 27, 2024
commit 0e4b49af4a83b9ab1ec75cdef4ca3d33e8eb15d2
2 changes: 1 addition & 1 deletion bin/xcm-tools/src/command.rs
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@

use crate::cli::*;

use astar_primitives::xcm::DescribeAllTerminal;
use clap::Parser;
use cumulus_primitives_core::ParaId;
use polkadot_parachain::primitives::Sibling;
@@ -29,7 +30,6 @@ use sp_runtime::traits::AccountIdConversion;
use xcm::latest::prelude::*;
use xcm_builder::{DescribeFamily, HashedDescription, ParentIsPreset, SiblingParachainConvertsVia};
use xcm_executor::traits::ConvertLocation;
use astar_primitives::xcm::DescribeAllTerminal;

/// CLI error type.
pub type Error = String;
5 changes: 3 additions & 2 deletions precompiles/xcm/src/mock.rs
Original file line number Diff line number Diff line change
@@ -41,10 +41,11 @@ use sp_runtime::{
};
use sp_std::cell::RefCell;

use astar_primitives::xcm::AllowTopLevelPaidExecutionFrom;
use xcm::prelude::XcmVersion;
use xcm_builder::{
test_utils::TransactAsset, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, FixedWeightBounds, SignedToAccountId32, TakeWeightCredit,
test_utils::TransactAsset, AllowKnownQueryResponses, AllowSubscriptionsFrom, FixedWeightBounds,
SignedToAccountId32, TakeWeightCredit,
};
use xcm_executor::XcmExecutor;
// orml imports
73 changes: 68 additions & 5 deletions primitives/src/xcm/mod.rs
Original file line number Diff line number Diff line change
@@ -33,17 +33,18 @@
use crate::AccountId;

use frame_support::{
traits::{tokens::fungibles, ContainsPair, Get},
ensure,
traits::{tokens::fungibles, Contains, ContainsPair, Get, ProcessMessageError},
weights::constants::WEIGHT_REF_TIME_PER_SECOND,
};
use parity_scale_codec::Encode;
use sp_runtime::traits::{Bounded, Convert, MaybeEquivalence, Zero};
use sp_std::marker::PhantomData;
use sp_std::{marker::PhantomData, vec::Vec};

// Polkadot imports
use xcm::latest::{prelude::*, Weight};
use xcm_builder::TakeRevenue;
use xcm_executor::traits::{MatchesFungibles, WeightTrader};
use xcm_builder::{CreateMatcher, MatchXcm, TakeRevenue};
use xcm_executor::traits::{MatchesFungibles, Properties, ShouldExecute, WeightTrader};

// ORML imports
use orml_traits::location::{RelativeReserveProvider, Reserve};
@@ -268,7 +269,7 @@ impl<
}
}

// TODO: remove this after uplift to `polkadot-v0.9.44` or beyond, and replace it with code in XCM builder.
// TODO: remove this after uplift to `polkadot-v1.3.0` or beyond, and replace it with code in XCM builder.

pub struct DescribeBodyTerminal;
impl xcm_builder::DescribeLocation for DescribeBodyTerminal {
@@ -316,3 +317,65 @@ impl<AbsoluteLocation: Get<MultiLocation>> Reserve
})
}
}

// Copying the barrier here due to this issue - https://github.com/paritytech/polkadot-sdk/issues/1638
// The fix was introduced in v1.3.0 via this PR - https://github.com/paritytech/polkadot-sdk/pull/1733
// Below is the exact same copy from the fix PR.

const MAX_ASSETS_FOR_BUY_EXECUTION: usize = 2;

/// Allows execution from `origin` if it is contained in `T` (i.e. `T::Contains(origin)`) taking
/// payments into account.
///
/// Only allows for `TeleportAsset`, `WithdrawAsset`, `ClaimAsset` and `ReserveAssetDeposit` XCMs
/// because they are the only ones that place assets in the Holding Register to pay for execution.
pub struct AllowTopLevelPaidExecutionFrom<T>(PhantomData<T>);
impl<T: Contains<MultiLocation>> ShouldExecute for AllowTopLevelPaidExecutionFrom<T> {
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
instructions: &mut [Instruction<RuntimeCall>],
max_weight: Weight,
_properties: &mut Properties,
) -> Result<(), ProcessMessageError> {
log::trace!(
target: "xcm::barriers",
"AllowTopLevelPaidExecutionFrom origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}",
origin, instructions, max_weight, _properties,
);

ensure!(T::contains(origin), ProcessMessageError::Unsupported);
// We will read up to 5 instructions. This allows up to 3 `ClearOrigin` instructions. We
// allow for more than one since anything beyond the first is a no-op and it's conceivable
// that composition of operations might result in more than one being appended.
let end = instructions.len().min(5);
instructions[..end]
.matcher()
.match_next_inst(|inst| match inst {
ReceiveTeleportedAsset(..) | ReserveAssetDeposited(..) => Ok(()),
WithdrawAsset(ref assets) if assets.len() <= MAX_ASSETS_FOR_BUY_EXECUTION => Ok(()),
ClaimAsset { ref assets, .. } if assets.len() <= MAX_ASSETS_FOR_BUY_EXECUTION => {
Ok(())
}
_ => Err(ProcessMessageError::BadFormat),
})?
.skip_inst_while(|inst| matches!(inst, ClearOrigin))?
.match_next_inst(|inst| match inst {
BuyExecution {
weight_limit: Limited(ref mut weight),
..
} if weight.all_gte(max_weight) => {
*weight = max_weight;
Ok(())
}
BuyExecution {
ref mut weight_limit,
..
} if weight_limit == &Unlimited => {
*weight_limit = Limited(max_weight);
Ok(())
}
_ => Err(ProcessMessageError::Overweight(max_weight)),
})?;
Ok(())
}
}
14 changes: 7 additions & 7 deletions runtime/astar/src/xcm_config.rs
Original file line number Diff line number Diff line change
@@ -34,11 +34,11 @@ use sp_runtime::traits::{Convert, MaybeEquivalence};
use xcm::latest::prelude::*;
use xcm_builder::{
Account32Hash, AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin,
FixedWeightBounds, FungiblesAdapter, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
UsingComponents,
};
use xcm_executor::{
traits::{JustTry, WithOriginFilter},
@@ -50,8 +50,8 @@ use orml_xcm_support::DisabledParachainFee;

// Astar imports
use astar_primitives::xcm::{
AbsoluteAndRelativeReserveProvider, AccountIdToMultiLocation, FixedRateOfForeignAsset,
ReserveAssetFilter, XcmFungibleFeeHandler,
AbsoluteAndRelativeReserveProvider, AccountIdToMultiLocation, AllowTopLevelPaidExecutionFrom,
FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler,
};

parameter_types! {
18 changes: 9 additions & 9 deletions runtime/shibuya/src/xcm_config.rs
Original file line number Diff line number Diff line change
@@ -33,13 +33,12 @@ use sp_runtime::traits::{Convert, MaybeEquivalence};
// Polkadot imports
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter,
DescribeFamily, EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
WithComputedOrigin,
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowUnpaidExecutionFrom,
ConvertedConcreteId, CurrencyAdapter, DescribeFamily, EnsureXcmOrigin, FungiblesAdapter,
HashedDescription, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
UsingComponents, WeightInfoBounds, WithComputedOrigin,
};
use xcm_executor::{traits::JustTry, XcmExecutor};

@@ -48,8 +47,9 @@ use orml_xcm_support::DisabledParachainFee;

// Astar imports
use astar_primitives::xcm::{
AbsoluteAndRelativeReserveProvider, AccountIdToMultiLocation, DescribeAllTerminal,
FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler, MAX_ASSETS,
AbsoluteAndRelativeReserveProvider, AccountIdToMultiLocation, AllowTopLevelPaidExecutionFrom,
DescribeAllTerminal, FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler,
MAX_ASSETS,
};

parameter_types! {
17 changes: 8 additions & 9 deletions runtime/shiden/src/xcm_config.rs
Original file line number Diff line number Diff line change
@@ -33,13 +33,12 @@ use sp_runtime::traits::{Convert, MaybeEquivalence};
// Polkadot imports
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter,
DescribeFamily, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, HashedDescription,
IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WithComputedOrigin,
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowUnpaidExecutionFrom,
ConvertedConcreteId, CurrencyAdapter, DescribeFamily, EnsureXcmOrigin, FixedWeightBounds,
FungiblesAdapter, HashedDescription, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
UsingComponents, WithComputedOrigin,
};
use xcm_executor::{
traits::{JustTry, WithOriginFilter},
@@ -51,8 +50,8 @@ use orml_xcm_support::DisabledParachainFee;

// Astar imports
use astar_primitives::xcm::{
AbsoluteAndRelativeReserveProvider, AccountIdToMultiLocation, DescribeAllTerminal,
FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler,
AbsoluteAndRelativeReserveProvider, AccountIdToMultiLocation, AllowTopLevelPaidExecutionFrom,
DescribeAllTerminal, FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler,
};

parameter_types! {
9 changes: 5 additions & 4 deletions tests/xcm-simulator/src/mocks/parachain.rs
Original file line number Diff line number Diff line change
@@ -49,9 +49,9 @@ use super::msg_queue::*;
use xcm::latest::prelude::{AssetId as XcmAssetId, *};
use xcm_builder::{
Account32Hash, AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter,
EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, IsConcrete,
NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin,
FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, IsConcrete, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin,
};
@@ -62,7 +62,8 @@ use orml_xcm_support::DisabledParachainFee;
use xcm_executor::{traits::JustTry, XcmExecutor};

use astar_primitives::xcm::{
AssetLocationIdConverter, FixedRateOfForeignAsset, ReserveAssetFilter, XcmFungibleFeeHandler,
AllowTopLevelPaidExecutionFrom, AssetLocationIdConverter, FixedRateOfForeignAsset,
ReserveAssetFilter, XcmFungibleFeeHandler,
};

pub type AccountId = AccountId32;