Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Fix sibling location #88

Merged
merged 4 commits into from
Dec 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use crate::{
xcm_config::{AgentIdOf, UniversalLocation},
Runtime,
};
use crate::{xcm_config::UniversalLocation, Runtime};
use snowbridge_rococo_common::EthereumNetwork;
use snowbridge_router_primitives::outbound::EthereumBlobExporter;

Expand All @@ -26,5 +23,5 @@ pub type SnowbridgeExporter = EthereumBlobExporter<
UniversalLocation,
EthereumNetwork,
snowbridge_outbound_queue::Pallet<Runtime>,
AgentIdOf,
snowbridge_core::AgentIdOf,
>;
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ use frame_system::{
EnsureRoot,
};

use bp_runtime::HeaderId;
#[cfg(not(feature = "runtime-benchmarks"))]
use bridge_hub_common::BridgeHubMessageRouter;
use bridge_hub_common::{
Expand All @@ -81,7 +82,6 @@ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm::VersionedMultiLocation;
use xcm_config::{TreasuryAccount, XcmOriginToTransactDispatchOrigin, XcmRouter};
use bp_runtime::HeaderId;

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand Down Expand Up @@ -630,7 +630,7 @@ impl snowbridge_system::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OutboundQueue = EthereumOutboundQueue;
type SiblingOrigin = EnsureXcm<AllowSiblingsOnly>;
type AgentIdOf = xcm_config::AgentIdOf;
type AgentIdOf = snowbridge_core::AgentIdOf;
type TreasuryAccount = TreasuryAccount;
type Token = Balances;
type WeightInfo = weights::snowbridge_system::WeightInfo<Runtime>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,21 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use snowbridge_core::DescribeHere;
use snowbridge_rococo_common::EthereumNetwork;
use snowbridge_runtime_common::XcmExportFeeToSibling;
use sp_core::{Get, H256};
use sp_core::Get;
use sp_runtime::traits::AccountIdConversion;
use sp_std::marker::PhantomData;
use xcm::latest::prelude::*;
#[allow(deprecated)]
use xcm_builder::{
deposit_or_burn_fee, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom,
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal,
DescribeFamily, EnsureXcmOrigin, HandleFee, HashedDescription, IsConcrete, ParentAsSuperuser,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
XcmFeeToAccount,
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, HandleFee,
IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeToAccount,
};
use xcm_executor::{
traits::{FeeManager, FeeReason, FeeReason::Export, TransactAsset, WithOriginFilter},
Expand Down Expand Up @@ -294,7 +292,7 @@ impl xcm_executor::Config for XcmConfig {
MaxInstructions,
>;
type Trader =
UsingComponents<WeightToFee, TokenLocation, AccountId, Balances, ToStakingPot<Runtime>>;
UsingComponents<WeightToFee, TokenLocation, AccountId, Balances, ToStakingPot<Runtime>>;
type ResponseHandler = PolkadotXcm;
type AssetTrap = PolkadotXcm;
type AssetLocker = ();
Expand Down Expand Up @@ -336,7 +334,7 @@ impl xcm_executor::Config for XcmConfig {
}

pub type PriceForParentDelivery =
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;

/// Converts a local signed origin into an XCM multilocation.
/// Forms the basis for local origins sending/executing XCMs.
Expand Down Expand Up @@ -388,10 +386,6 @@ impl cumulus_pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}

/// Creates an AgentId from a MultiLocation. An AgentId is a unique mapping to a Agent contract on
/// Ethereum which acts as the sovereign account for the MultiLocation.
pub type AgentIdOf = HashedDescription<H256, (DescribeHere, DescribeFamily<DescribeAllTerminal>)>;

/// A `HandleFee` implementation that simply deposits the fees for `ExportMessage` XCM instructions
/// into the accounts that are used for paying the relayer rewards.
/// Burns the fees in case of a failure.
Expand All @@ -404,19 +398,19 @@ pub struct XcmExportFeeToRelayerRewardAccounts<
>(PhantomData<(AssetTransactor, DestNetwork, DestParaId, DestBridgedChainId, BridgeLaneId)>);

impl<
AssetTransactor: TransactAsset,
DestNetwork: Get<NetworkId>,
DestParaId: Get<cumulus_primitives_core::ParaId>,
DestBridgedChainId: Get<ChainId>,
BridgeLaneId: Get<LaneId>,
> HandleFee
for XcmExportFeeToRelayerRewardAccounts<
AssetTransactor,
DestNetwork,
DestParaId,
DestBridgedChainId,
BridgeLaneId,
>
AssetTransactor: TransactAsset,
DestNetwork: Get<NetworkId>,
DestParaId: Get<cumulus_primitives_core::ParaId>,
DestBridgedChainId: Get<ChainId>,
BridgeLaneId: Get<LaneId>,
> HandleFee
for XcmExportFeeToRelayerRewardAccounts<
AssetTransactor,
DestNetwork,
DestParaId,
DestBridgedChainId,
BridgeLaneId,
>
{
fn handle_fee(
fee: MultiAssets,
Expand Down Expand Up @@ -489,7 +483,7 @@ pub struct XcmFeeManagerFromComponentsBridgeHub<WaivedLocations, HandleFee>(
PhantomData<(WaivedLocations, HandleFee)>,
);
impl<WaivedLocations: Contains<MultiLocation>, FeeHandler: HandleFee> FeeManager
for XcmFeeManagerFromComponentsBridgeHub<WaivedLocations, FeeHandler>
for XcmFeeManagerFromComponentsBridgeHub<WaivedLocations, FeeHandler>
{
fn is_waived(origin: Option<&MultiLocation>, fee_reason: FeeReason) -> bool {
let Some(loc) = origin else { return false };
Expand Down
Loading