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

Add HashedDescription XCM location converter and remove TinkernetMultisig configs #320

Merged
merged 1 commit into from
Feb 19, 2024
Merged
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
21 changes: 0 additions & 21 deletions Cargo.lock

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

52 changes: 32 additions & 20 deletions runtime/khala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ use primitive_types::U256;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, RuntimeDebug,
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdConversion, AccountIdLookup, Block as BlockT, Bounded, ConvertInto,
TrailingZeroInput,
},
transaction_validity::{TransactionSource, TransactionValidity},
AccountId32, ApplyExtrinsicResult, DispatchError, FixedPointNumber, Perbill, Percent, Permill,
Perquintill,
Perquintill, RuntimeDebug,
};
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
prelude::*,
};
use sp_std::{collections::{btree_map::BTreeMap, btree_set::BTreeSet}, prelude::*};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
Expand All @@ -77,10 +80,10 @@ pub use frame_support::{
pallet_prelude::Get,
parameter_types,
traits::{
tokens::nonfungibles::*, fungible::HoldConsideration, AsEnsureOriginWithArg, ConstBool, ConstU32, Contains, Currency,
EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, IsInVec,
KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing, OnUnbalanced, Randomness,
WithdrawReasons, SortedMembers,
fungible::HoldConsideration, tokens::nonfungibles::*, AsEnsureOriginWithArg, ConstBool,
ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance,
InstanceFilter, IsInVec, KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing,
OnUnbalanced, Randomness, SortedMembers, WithdrawReasons,
},
weights::{
constants::{
Expand All @@ -101,12 +104,13 @@ use polkadot_parachain_primitives::primitives::Sibling;
use xcm::latest::{prelude::*, AssetId as XcmAssetId, Weight as XCMWeight};
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds,
FungiblesAdapter, ParentIsPreset, RelayChainAsNative, NoChecking, MintLocation,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DescribeAllTerminal, DescribeFamily,
EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, HashedDescription, MintLocation,
NoChecking, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin,
};
use xcm_executor::{Config, XcmExecutor, traits::WithOriginFilter};
use xcm_executor::{traits::WithOriginFilter, Config, XcmExecutor};

use pallet_rmrk_core::{CollectionInfoOf, InstanceInfoOf, PropertyInfoOf, ResourceInfoOf};
use pallet_rmrk_equip::{BaseInfoOf, BoundedThemeOf, PartTypeOf};
Expand All @@ -126,9 +130,8 @@ pub use pallet_phala_world::{pallet_pw_incubation, pallet_pw_marketplace, pallet
#[cfg(any(feature = "std", test))]
pub use pallet_timestamp::Call as TimestampCall;
pub use phala_pallets::{
pallet_base_pool, pallet_computation, pallet_mq,
pallet_registry, pallet_stake_pool, pallet_stake_pool_v2, pallet_vault,
pallet_wrapped_balances,
pallet_base_pool, pallet_computation, pallet_mq, pallet_registry, pallet_stake_pool,
pallet_stake_pool_v2, pallet_vault, pallet_wrapped_balances,
};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand Down Expand Up @@ -218,9 +221,7 @@ pub type Executive = frame_executive::Executive<
>;
/// All migrations executed on runtime upgrade as a nested tuple of types implementing
/// `OnRuntimeUpgrade`.
type Migrations = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
);
type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,);

type EnsureRootOrHalfCouncil = EitherOfDiverse<
EnsureRoot<AccountId>,
Expand Down Expand Up @@ -359,7 +360,7 @@ impl Contains<RuntimeCall> for BaseCallFilter {
pallet_uniques::Call::freeze { .. }
| pallet_uniques::Call::thaw { .. }
| pallet_uniques::Call::set_team { .. }
| pallet_uniques::Call::set_accept_ownership { .. } => true,
| pallet_uniques::Call::set_accept_ownership { .. } => true,
_ => false,
};
}
Expand Down Expand Up @@ -1033,6 +1034,8 @@ pub type LocationToAccountId = (
SiblingParachainConvertsVia<Sibling, AccountId>,
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
AccountId32Aliases<RelayNetwork, AccountId>,
// Foreign locations alias into accounts according to a hash of their standard description.
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
);

/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
Expand Down Expand Up @@ -1070,6 +1073,14 @@ pub type Barrier = (
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
UniversalLocation,
ConstU32<8>,
>,
);

/// Means for transacting the native currency on this chain.
Expand Down Expand Up @@ -1428,7 +1439,8 @@ impl pallet_treasury::Config for Runtime {
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
>,
AccountId, MaxBalance,
AccountId,
MaxBalance,
>;
}

Expand Down
5 changes: 0 additions & 5 deletions runtime/rhala/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ sygma-fee-handler-router = { git = "https://github.com/sygmaprotocol/sygma-subst
sygma-percentage-feehandler = { git = "https://github.com/sygmaprotocol/sygma-substrate-pallets", branch = "release-polkadot-v1.2.0", default-features = false }
sygma-runtime-api = { git = "https://github.com/sygmaprotocol/sygma-substrate-pallets", branch = "release-polkadot-v1.2.0", default-features = false }

# ORML Tinkernet Multisig dependencies
orml-xcm-builder-kusama = { git = "https://github.com/open-web3-stack/orml-xcm-builder", branch = "polkadot-v1.2.0", default-features = false }

# Local dependencies
assets-registry = { path = "../../pallets/assets-registry", default-features = false }
pallet-parachain-info = { path = "../../pallets/parachain-info", default-features = false }
Expand Down Expand Up @@ -157,7 +154,6 @@ runtime-benchmarks = [
"xcm-builder/runtime-benchmarks",
"subbridge-pallets/runtime-benchmarks",
"pallet-uniques/runtime-benchmarks",
"orml-xcm-builder-kusama/runtime-benchmarks",
]
std = [
"codec/std",
Expand Down Expand Up @@ -245,7 +241,6 @@ std = [
"sygma-percentage-feehandler/std",
"sygma-runtime-api/std",
"primitive-types/std",
"orml-xcm-builder-kusama/std",
]

try-runtime = [
Expand Down
38 changes: 18 additions & 20 deletions runtime/rhala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ use primitive_types::U256;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, RuntimeDebug,
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdConversion, AccountIdLookup, Block as BlockT, Bounded, ConvertInto,
TrailingZeroInput,
},
transaction_validity::{TransactionSource, TransactionValidity},
AccountId32, ApplyExtrinsicResult, DispatchError, FixedPointNumber, Perbill, Percent, Permill,
Perquintill,
Perquintill, RuntimeDebug,
};
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
prelude::*,
};
use sp_std::{collections::{btree_map::BTreeMap, btree_set::BTreeSet}, prelude::*};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
Expand All @@ -77,10 +80,10 @@ pub use frame_support::{
pallet_prelude::Get,
parameter_types,
traits::{
tokens::nonfungibles::*, fungible::HoldConsideration, AsEnsureOriginWithArg, ConstBool, ConstU32, Contains, Currency,
EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, IsInVec,
KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing, OnUnbalanced, Randomness, SortedMembers,
WithdrawReasons,
fungible::HoldConsideration, tokens::nonfungibles::*, AsEnsureOriginWithArg, ConstBool,
ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance,
InstanceFilter, IsInVec, KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing,
OnUnbalanced, Randomness, SortedMembers, WithdrawReasons,
},
weights::{
constants::{
Expand All @@ -101,10 +104,11 @@ use polkadot_parachain_primitives::primitives::Sibling;
use xcm::latest::{prelude::*, AssetId as XcmAssetId, Weight as XCMWeight};
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds,
FungiblesAdapter, MintLocation, NoChecking, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin,
AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DescribeAllTerminal, DescribeFamily,
EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, HashedDescription, MintLocation,
NoChecking, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin,
};
use xcm_executor::{traits::WithOriginFilter, Config, XcmExecutor};

Expand Down Expand Up @@ -1029,8 +1033,8 @@ pub type LocationToAccountId = (
SiblingParachainConvertsVia<Sibling, AccountId>,
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
AccountId32Aliases<RelayNetwork, AccountId>,
// Mapping Tinkernet multisig to the correctly derived AccountId32.
orml_xcm_builder_kusama::TinkernetMultisigAsAccountId<AccountId>,
// Foreign locations alias into accounts according to a hash of their standard description.
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
);

/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,
Expand All @@ -1050,8 +1054,6 @@ pub type XcmOriginToTransactDispatchOrigin = (
// Native signed account converter; this just converts an `AccountId32` origin into a normal
// `Origin::Signed` origin of the same 32-byte value.
SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
// Derives signed AccountId32 origins for Tinkernet multisigs.
orml_xcm_builder_kusama::TinkernetMultisigAsNativeOrigin<RuntimeOrigin>,
// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
XcmPassthrough<RuntimeOrigin>,
);
Expand All @@ -1070,11 +1072,7 @@ pub type Barrier = (
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
WithComputedOrigin<
AllowTopLevelPaidExecutionFrom<orml_xcm_builder_kusama::tinkernet_multisigs::TinkernetMultisigMultiLocation>,
UniversalLocation,
ConstU32<8>,
>,
WithComputedOrigin<AllowTopLevelPaidExecutionFrom<Everything>, UniversalLocation, ConstU32<8>>,
);

/// Means for transacting the native currency on this chain.
Expand Down
Loading