Skip to content

Commit

Permalink
Asset transfer (#52)
Browse files Browse the repository at this point in the history
* update registry to gateway

* added agent config

* ws

* increase message size
  • Loading branch information
alistair-singh authored Jul 28, 2023
1 parent c0d90e0 commit c6cf3c3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion parachains/runtimes/assets/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
(
FromSiblingParachain<parachain_info::Pallet<Runtime>>,
snowbridge_router_primitives::inbound::FromEthereumGlobalConsensus<
crate::bridging::EthereumRegistryLocation,
crate::bridging::EthereumGatewayLocation,
>,
),
ForeignCreatorsSovereignAccountOf,
Expand Down
10 changes: 5 additions & 5 deletions parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,11 @@ pub mod bridging {
pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(EthereumNetwork::get())));

// The Registry contract for the bridge which is also the origin for reserves and the prefix of all assets.
pub EthereumRegistryLocation: MultiLocation = EthereumLocation::get()
pub EthereumGatewayLocation: MultiLocation = EthereumLocation::get()
.pushed_with_interior(
AccountKey20 {
network: None,
key: hex_literal::hex!("D184c103F7acc340847eEE82a0B909E3358bc28d"),
key: hex_literal::hex!("EDa338E4dC46038493b885327842fD3E301CaB39"),
}
).unwrap();

Expand Down Expand Up @@ -604,14 +604,14 @@ pub mod bridging {
EthereumLocation::get(),
AssetFilter::ByMultiLocation(
MultiLocationFilter::default()
.add_starts_with(EthereumRegistryLocation::get())
.add_starts_with(EthereumGatewayLocation::get())
)
),
(
EthereumRegistryLocation::get(),
EthereumGatewayLocation::get(),
AssetFilter::ByMultiLocation(
MultiLocationFilter::default()
.add_starts_with(EthereumRegistryLocation::get())
.add_starts_with(EthereumGatewayLocation::get())
)
),
];
Expand Down
9 changes: 6 additions & 3 deletions parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub mod xcm_config;
use constants::currency::*;
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use snowbridge_beacon_primitives::{Fork, ForkVersions};
use snowbridge_router_primitives::outbound::AgentHashedDescription;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
Expand Down Expand Up @@ -73,7 +74,7 @@ use pallet_xcm::EnsureXcm;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm::v3::NetworkId::{self, Rococo};
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin, DescribeAgentLocation};
use xcm_config::{RelayLocation, UniversalLocation, XcmConfig, XcmOriginToTransactDispatchOrigin};

use bp_parachains::SingleParaStoredHeaderDataBuilder;
use bp_runtime::HeaderId;
Expand Down Expand Up @@ -601,7 +602,7 @@ impl snowbridge_inbound_queue::Config for Runtime {
}

parameter_types! {
pub const MaxMessagePayloadSize: u32 = 256;
pub const MaxMessagePayloadSize: u32 = 512;
pub const MaxMessagesPerBlock: u32 = 32;
}

Expand Down Expand Up @@ -681,7 +682,9 @@ impl snowbridge_control::Config for Runtime {
type WeightInfo = ();
type MaxUpgradeDataSize = MaxUpgradeDataSize;
type CreateAgentOrigin = EnsureXcm<Everything>;
type DescribeAgentLocation = DescribeAgentLocation;
type AgentHashedDescription = AgentHashedDescription;
type UniversalLocation = UniversalLocation;
type RelayLocation = RelayLocation;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
Expand Down
32 changes: 14 additions & 18 deletions parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ use pallet_xcm::XcmPassthrough;
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
use polkadot_parachain::primitives::Sibling;
use snowbridge_outbound_queue;
use snowbridge_router_primitives::outbound::EthereumBlobExporter;
use snowbridge_router_primitives::outbound::{AgentHashedDescription, EthereumBlobExporter};
use sp_core::Get;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAccountId32Terminal,
DescribeAccountKey20Terminal, DescribeAllTerminal, DescribeFamily, DescribePalletTerminal,
EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
};
use xcm_executor::{
traits::{ExportXcm, WithOriginFilter},
Expand All @@ -64,11 +63,11 @@ parameter_types! {
pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(EthereumNetwork::get())));

// The Registry contract for the bridge which is also the origin for reserves and the prefix of all assets.
pub EthereumRegistryLocation: MultiLocation = EthereumLocation::get()
pub EthereumGatewayLocation: MultiLocation = EthereumLocation::get()
.pushed_with_interior(
AccountKey20 {
network: None,
key: hex_literal::hex!("D184c103F7acc340847eEE82a0B909E3358bc28d"),
key: hex_literal::hex!("EDa338E4dC46038493b885327842fD3E301CaB39"),
}
).unwrap();
}
Expand Down Expand Up @@ -101,13 +100,6 @@ pub type LocationToAccountId = (
AccountId32Aliases<RelayNetwork, AccountId>,
);

pub type DescribeAgentLocation = (
DescribePalletTerminal,
DescribeAccountId32Terminal,
DescribeAccountKey20Terminal,
DescribeFamily<DescribeAllTerminal>,
);

/// Means for transacting the native currency on this chain.
pub type CurrencyTransactor = CurrencyAdapter<
// Use this currency:
Expand Down Expand Up @@ -355,8 +347,12 @@ impl cumulus_pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}

pub type SnowbridgeExporter =
EthereumBlobExporter<UniversalLocation, EthereumRegistryLocation, snowbridge_outbound_queue::Pallet<Runtime>>;
pub type SnowbridgeExporter = EthereumBlobExporter<
UniversalLocation,
EthereumGatewayLocation,
snowbridge_outbound_queue::Pallet<Runtime>,
AgentHashedDescription
>;

/// Hacky switch implementation, because we have just one runtime for Rococo and Wococo BridgeHub, so it means we have just one XcmConfig
pub struct BridgeHubRococoOrBridgeHubWococoSwitchExporter;
Expand Down

0 comments on commit c6cf3c3

Please sign in to comment.