Skip to content

Commit

Permalink
Merge branch 'xcm-v5' into outbound-queue-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ron committed Nov 5, 2024
2 parents e2c0c78 + abb8142 commit fffd895
Show file tree
Hide file tree
Showing 50 changed files with 1,107 additions and 425 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check-semver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
merge_group:

concurrency:
group: check-semver-${{ github.event.pull_request.number || github.ref }}
Expand Down
4 changes: 2 additions & 2 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ linked-hash-map = { version = "0.5.4" }
linked_hash_set = { version = "0.1.4" }
linregress = { version = "0.5.1" }
lite-json = { version = "0.2.0", default-features = false }
litep2p = { version = "0.7.0", features = ["websocket"] }
litep2p = { version = "0.8.0", features = ["websocket"] }
log = { version = "0.4.22", default-features = false }
macro_magic = { version = "0.5.1" }
maplit = { version = "1.0.2" }
Expand Down
4 changes: 2 additions & 2 deletions bridges/primitives/messages/src/lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ impl TypeId for LegacyLaneId {
/// concatenation (separated by some binary data). I.e.:
///
/// ```nocompile
/// let endpoint1 = X2(GlobalConsensus(NetworkId::ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(42));
/// let endpoint2 = X2(GlobalConsensus(NetworkId::ByGenesis(WOCOCO_GENESIS_HASH)), Parachain(777));
/// let endpoint1 = X2(GlobalConsensus(NetworkId::Polkadot), Parachain(42));
/// let endpoint2 = X2(GlobalConsensus(NetworkId::Kusama), Parachain(777));
///
/// let final_lane_key = if endpoint1 < endpoint2 {
/// (endpoint1, VALUES_SEPARATOR, endpoint2)
Expand Down
7 changes: 4 additions & 3 deletions bridges/snowbridge/primitives/router/src/inbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

pub mod v1;
pub mod v2;

use codec::Encode;
use sp_core::blake2_256;
use sp_std::marker::PhantomData;
use xcm::prelude::{AccountKey20, Ethereum, GlobalConsensus, Location};
use xcm_executor::traits::ConvertLocation;

pub struct GlobalConsensusEthereumConvertsFor<AccountId>(PhantomData<AccountId>);
impl<AccountId> ConvertLocation<AccountId> for GlobalConsensusEthereumConvertsFor<AccountId>
pub struct EthereumLocationsConverterFor<AccountId>(PhantomData<AccountId>);
impl<AccountId> ConvertLocation<AccountId> for EthereumLocationsConverterFor<AccountId>
where
AccountId: From<[u8; 32]> + Clone,
{
Expand All @@ -26,7 +27,7 @@ where
}
}

impl<AccountId> GlobalConsensusEthereumConvertsFor<AccountId> {
impl<AccountId> EthereumLocationsConverterFor<AccountId> {
pub fn from_chain_id(chain_id: &u64) -> [u8; 32] {
(b"ethereum-chain", chain_id).using_encoded(blake2_256)
}
Expand Down
10 changes: 5 additions & 5 deletions bridges/snowbridge/primitives/router/src/inbound/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]>
//! Converts messages from Ethereum to XCM messages
use crate::inbound::{CallIndex, GlobalConsensusEthereumConvertsFor};
use crate::inbound::{CallIndex, EthereumLocationsConverterFor};
use codec::{Decode, Encode};
use core::marker::PhantomData;
use frame_support::{traits::tokens::Balance as BalanceT, PalletError};
Expand Down Expand Up @@ -247,7 +247,7 @@ where

let bridge_location = Location::new(2, GlobalConsensus(network));

let owner = GlobalConsensusEthereumConvertsFor::<[u8; 32]>::from_chain_id(&chain_id);
let owner = EthereumLocationsConverterFor::<[u8; 32]>::from_chain_id(&chain_id);
let asset_id = Self::convert_token_address(network, token);
let create_call_index: [u8; 2] = CreateAssetCall::get();
let inbound_queue_pallet_index = InboundQueuePalletInstance::get();
Expand Down Expand Up @@ -447,7 +447,7 @@ where

#[cfg(test)]
mod tests {
use crate::inbound::{CallIndex, GlobalConsensusEthereumConvertsFor};
use crate::inbound::{CallIndex, EthereumLocationsConverterFor};
use frame_support::{assert_ok, parameter_types};
use hex_literal::hex;
use xcm::prelude::*;
Expand All @@ -471,7 +471,7 @@ mod tests {
let contract_location = Location::new(2, [GlobalConsensus(NETWORK)]);

let account =
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location)
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location)
.unwrap();

assert_eq!(account, expected_account);
Expand All @@ -482,7 +482,7 @@ mod tests {
let contract_location = Location::new(2, [GlobalConsensus(Polkadot), Parachain(1000)]);

assert_eq!(
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location),
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location),
None,
);
}
Expand Down
10 changes: 5 additions & 5 deletions bridges/snowbridge/primitives/router/src/inbound/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]>
//! Converts messages from Ethereum to XCM messages
use crate::inbound::{CallIndex, GlobalConsensusEthereumConvertsFor};
use crate::inbound::{CallIndex, EthereumLocationsConverterFor};
use codec::{Decode, Encode};
use core::marker::PhantomData;
use frame_support::{traits::tokens::Balance as BalanceT, PalletError};
Expand Down Expand Up @@ -247,7 +247,7 @@ where

let bridge_location = Location::new(2, GlobalConsensus(network));

let owner = GlobalConsensusEthereumConvertsFor::<[u8; 32]>::from_chain_id(&chain_id);
let owner = EthereumLocationsConverterFor::<[u8; 32]>::from_chain_id(&chain_id);
let asset_id = Self::convert_token_address(network, token);
let create_call_index: [u8; 2] = CreateAssetCall::get();
let inbound_queue_pallet_index = InboundQueuePalletInstance::get();
Expand Down Expand Up @@ -447,7 +447,7 @@ where

#[cfg(test)]
mod tests {
use crate::inbound::{CallIndex, GlobalConsensusEthereumConvertsFor};
use crate::inbound::{CallIndex, EthereumLocationsConverterFor};
use frame_support::{assert_ok, parameter_types};
use hex_literal::hex;
use xcm::prelude::*;
Expand All @@ -471,7 +471,7 @@ mod tests {
let contract_location = Location::new(2, [GlobalConsensus(NETWORK)]);

let account =
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location)
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location)
.unwrap();

assert_eq!(account, expected_account);
Expand All @@ -482,7 +482,7 @@ mod tests {
let contract_location = Location::new(2, [GlobalConsensus(Polkadot), Parachain(1000)]);

assert_eq!(
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location),
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location),
None,
);
}
Expand Down
8 changes: 3 additions & 5 deletions cumulus/client/consensus/aura/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@ use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterfa
use cumulus_client_consensus_common::{self as consensus_common, ParachainBlockImportMarker};
use cumulus_client_consensus_proposer::ProposerInterface;
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
use cumulus_primitives_core::{
ClaimQueueOffset, CollectCollationInfo, PersistedValidationData, DEFAULT_CLAIM_QUEUE_OFFSET,
};
use cumulus_primitives_core::{ClaimQueueOffset, CollectCollationInfo, PersistedValidationData};
use cumulus_relay_chain_interface::RelayChainInterface;

use polkadot_node_primitives::{PoV, SubmitCollationParams};
use polkadot_node_subsystem::messages::CollationGenerationMessage;
use polkadot_overseer::Handle as OverseerHandle;
use polkadot_primitives::{
BlockNumber as RBlockNumber, CollatorPair, Hash as RHash, HeadData, Id as ParaId,
OccupiedCoreAssumption,
vstaging::DEFAULT_CLAIM_QUEUE_OFFSET, BlockNumber as RBlockNumber, CollatorPair, Hash as RHash,
HeadData, Id as ParaId, OccupiedCoreAssumption,
};

use futures::prelude::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterfa
use cumulus_client_consensus_common::{self as consensus_common, ParachainBlockImportMarker};
use cumulus_client_consensus_proposer::ProposerInterface;
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
use cumulus_primitives_core::{
GetCoreSelectorApi, PersistedValidationData, DEFAULT_CLAIM_QUEUE_OFFSET,
};
use cumulus_primitives_core::{GetCoreSelectorApi, PersistedValidationData};
use cumulus_relay_chain_interface::RelayChainInterface;

use polkadot_primitives::{
vstaging::{ClaimQueueOffset, CoreSelector},
vstaging::{ClaimQueueOffset, CoreSelector, DEFAULT_CLAIM_QUEUE_OFFSET},
BlockId, CoreIndex, Hash as RelayHash, Header as RelayHeader, Id as ParaId,
OccupiedCoreAssumption,
};
Expand Down
4 changes: 2 additions & 2 deletions cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ use core::{cmp, marker::PhantomData};
use cumulus_primitives_core::{
relay_chain::{
self,
vstaging::{ClaimQueueOffset, CoreSelector},
vstaging::{ClaimQueueOffset, CoreSelector, DEFAULT_CLAIM_QUEUE_OFFSET},
},
AbridgedHostConfiguration, ChannelInfo, ChannelStatus, CollationInfo, GetChannelInfo,
InboundDownwardMessage, InboundHrmpMessage, ListChannelInfos, MessageSendError,
OutboundHrmpMessage, ParaId, PersistedValidationData, UpwardMessage, UpwardMessageSender,
XcmpMessageHandler, XcmpMessageSource, DEFAULT_CLAIM_QUEUE_OFFSET,
XcmpMessageHandler, XcmpMessageSource,
};
use cumulus_primitives_parachain_inherent::{MessageQueueChain, ParachainInherentData};
use frame_support::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use snowbridge_pallet_inbound_queue_fixtures::{
};
use snowbridge_pallet_system;
use snowbridge_router_primitives::inbound::{
Command, Destination, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage,
Command, Destination, EthereumLocationsConverterFor, MessageV1, VersionedMessage,
};
use sp_core::H256;
use sp_runtime::{DispatchError::Token, TokenError::FundsUnavailable};
Expand Down Expand Up @@ -308,8 +308,7 @@ fn send_token_from_ethereum_to_penpal() {

// Fund ethereum sovereign on AssetHub
let ethereum_sovereign: AccountId =
GlobalConsensusEthereumConvertsFor::<AccountId>::convert_location(&origin_location)
.unwrap();
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
AssetHubRococo::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);

// Create asset on the Penpal parachain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use rococo_westend_system_emulated_network::asset_hub_westend_emulated_chain::ge
use snowbridge_core::{outbound::OperatingMode, AssetMetadata, TokenIdOf};
use snowbridge_router_primitives::inbound::{
v1::{Command, Destination, MessageV1, VersionedMessage},
GlobalConsensusEthereumConvertsFor,
EthereumLocationsConverterFor,
};
use sp_core::H256;
use testnet_parachains_constants::westend::snowbridge::EthereumNetwork;
Expand Down Expand Up @@ -292,7 +292,7 @@ fn transfer_relay_token() {
let expected_token_id = TokenIdOf::convert_location(&expected_asset_id).unwrap();

let ethereum_sovereign: AccountId =
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&Location::new(
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&Location::new(
2,
[GlobalConsensus(EthereumNetwork::get())],
))
Expand Down Expand Up @@ -440,7 +440,7 @@ fn transfer_ah_token() {
let ethereum_destination = Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]);

let ethereum_sovereign: AccountId =
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&ethereum_destination)
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&ethereum_destination)
.unwrap()
.into();
AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor;
use snowbridge_router_primitives::inbound::EthereumLocationsConverterFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto, TryConvertInto};
use testnet_parachains_constants::rococo::snowbridge::{
EthereumNetwork, INBOUND_QUEUE_PALLET_INDEX,
Expand Down Expand Up @@ -105,7 +105,7 @@ pub type LocationToAccountId = (
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
// Ethereum contract sovereign account.
// (Used to get convert ethereum contract locations to sovereign account)
GlobalConsensusEthereumConvertsFor<AccountId>,
EthereumLocationsConverterFor<AccountId>,
);

/// Means for transacting the native currency on this chain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor;
use snowbridge_router_primitives::inbound::EthereumLocationsConverterFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto, TryConvertInto};
use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH};
use xcm_builder::{
Expand Down Expand Up @@ -101,7 +101,7 @@ pub type LocationToAccountId = (
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
// Ethereum contract sovereign account.
// (Used to get convert ethereum contract locations to sovereign account)
GlobalConsensusEthereumConvertsFor<AccountId>,
EthereumLocationsConverterFor<AccountId>,
);

/// Means for transacting the native currency on this chain.
Expand Down
10 changes: 5 additions & 5 deletions cumulus/parachains/runtimes/assets/common/src/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ mod tests {

parameter_types! {
pub UniversalLocation: InteriorLocation = [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(1000)].into();
pub ExpectedNetworkId: NetworkId = ByGenesis(WOCOCO_GENESIS_HASH);
pub ExpectedNetworkId: NetworkId = ByGenesis(WESTEND_GENESIS_HASH);
}

#[test]
Expand All @@ -159,14 +159,14 @@ mod tests {
let asset: Location = (
Parent,
Parent,
GlobalConsensus(ByGenesis(WOCOCO_GENESIS_HASH)),
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(1000),
PalletInstance(1),
GeneralIndex(1),
)
.into();
let origin: Location =
(Parent, Parent, GlobalConsensus(ByGenesis(WOCOCO_GENESIS_HASH)), Parachain(1000))
(Parent, Parent, GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(1000))
.into();
assert!(FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));

Expand Down Expand Up @@ -201,15 +201,15 @@ mod tests {
)
.into();
let origin: Location =
(Parent, Parent, GlobalConsensus(ByGenesis(WOCOCO_GENESIS_HASH)), Parachain(1000))
(Parent, Parent, GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(1000))
.into();
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));

// origin from different consensus fails
let asset: Location = (
Parent,
Parent,
GlobalConsensus(ByGenesis(WOCOCO_GENESIS_HASH)),
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(1000),
PalletInstance(1),
GeneralIndex(1),
Expand Down
7 changes: 0 additions & 7 deletions cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ use pallet_xcm::XcmPassthrough;
use parachains_common::{xcm_config::AssetFeeAsExistentialDepositMultiplier, TREASURY_PALLET_ID};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::{impls::ToAuthor, xcm_sender::ExponentialPrice};
use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto, Identity, TryConvertInto};
use xcm::latest::{prelude::*, WESTEND_GENESIS_HASH};
use xcm_builder::{
Expand Down Expand Up @@ -94,12 +93,6 @@ pub type LocationToAccountId = (
AccountId32Aliases<RelayNetwork, AccountId>,
// Foreign locations alias into accounts according to a hash of their standard description.
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
// Different global consensus parachain sovereign account.
// (Used for over-bridge transfers and reserve processing)
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
// Ethereum contract sovereign account.
// (Used to get convert ethereum contract locations to sovereign account)
GlobalConsensusEthereumConvertsFor<AccountId>,
);

/// Means for transacting assets on this chain.
Expand Down
4 changes: 0 additions & 4 deletions cumulus/primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ pub mod rpsr_digest {
}
}

/// The default claim queue offset to be used if it's not configured/accessible in the parachain
/// runtime
pub const DEFAULT_CLAIM_QUEUE_OFFSET: u8 = 0;

/// Information about a collation.
///
/// This was used in version 1 of the [`CollectCollationInfo`] runtime api.
Expand Down
2 changes: 1 addition & 1 deletion polkadot/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct RunCmd {

/// Disable the BEEFY gadget.
///
/// Currently enabled by default on 'Rococo' and 'Versi'.
/// Currently enabled by default.
#[arg(long)]
pub no_beefy: bool,

Expand Down
4 changes: 2 additions & 2 deletions polkadot/node/collation-generation/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use polkadot_primitives::vstaging::CandidateReceiptError;
use polkadot_primitives::vstaging::CommittedCandidateReceiptError;
use thiserror::Error;

#[derive(Debug, Error)]
Expand All @@ -34,7 +34,7 @@ pub enum Error {
#[error("Collation submitted before initialization")]
SubmittedBeforeInit,
#[error("V2 core index check failed: {0}")]
CandidateReceiptCheck(CandidateReceiptError),
CandidateReceiptCheck(CommittedCandidateReceiptError),
#[error("PoV size {0} exceeded maximum size of {1}")]
POVSizeExceeded(usize, usize),
}
Expand Down
Loading

0 comments on commit fffd895

Please sign in to comment.