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

Snowbridge Rococo deployment updates #2792

Merged
merged 27 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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 @@ -77,7 +77,6 @@ std = [
'frame-benchmarking/std',
]
runtime-benchmarks = [
"beacon-spec-mainnet",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
Expand All @@ -92,4 +91,5 @@ try-runtime = [
"pallet-timestamp?/try-runtime",
"sp-runtime/try-runtime",
]
beacon-spec-mainnet = []
beacon-spec-minimal = []
fast-runtime = ["beacon-spec-minimal"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use static_assertions::const_assert;
pub mod mainnet;
pub mod minimal;

#[cfg(not(feature = "beacon-spec-mainnet"))]
#[cfg(all(feature = "beacon-spec-minimal", not(feature = "runtime-benchmarks")))]
pub use minimal::*;

#[cfg(feature = "beacon-spec-mainnet")]
#[cfg(any(not(feature = "beacon-spec-minimal"), feature = "runtime-benchmarks"))]
pub use mainnet::*;

// Generalized Indices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mod weights;
#[cfg(any(test, feature = "fuzzing"))]
pub mod mock;

#[cfg(all(test, not(feature = "beacon-spec-mainnet")))]
#[cfg(all(test, feature = "beacon-spec-minimal"))]
mod tests;

#[cfg(feature = "runtime-benchmarks")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use primitives::{Fork, ForkVersions};
use sp_core::H256;
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};

#[cfg(not(feature = "beacon-spec-mainnet"))]
#[cfg(feature = "beacon-spec-minimal")]
pub mod minimal {
use super::*;

Expand Down Expand Up @@ -182,7 +182,7 @@ pub mod minimal {
}
}

#[cfg(feature = "beacon-spec-mainnet")]
#[cfg(any(not(feature = "beacon-spec-minimal"), feature = "runtime-benchmarks"))]
pub mod mainnet {
use super::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use snowbridge_core::{eth, outbound::OperatingMode};
use sp_runtime::SaturatedConversion;
use xcm::prelude::*;

#[allow(clippy::result_large_err)]
fn fund_sovereign_account<T: Config>(para_id: ParaId) -> Result<(), BenchmarkError> {
let amount: BalanceOf<T> = (10_000_000_000_000_u64).saturated_into::<u128>().saturated_into();
let sovereign_account = sibling_sovereign_account::<T>(para_id);
Expand Down
4 changes: 2 additions & 2 deletions bridges/snowbridge/parachain/runtime/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ try-runtime = [
"snowbridge-system/try-runtime",
"sp-runtime/try-runtime",
]
beacon-spec-mainnet = [
"snowbridge-ethereum-beacon-client/beacon-spec-mainnet",
fast-runtime = [
"snowbridge-ethereum-beacon-client/beacon-spec-minimal",
]
experimental = ["pallet-aura/experimental"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bridge-runtime-common = { path = "../../../../../bridges/bin/runtime-common", fe
sp-keyring = { path = "../../../../../substrate/primitives/keyring" }

[features]
default = ["beacon-spec-mainnet", "std"]
default = ["std"]
std = [
"bp-asset-hub-rococo/std",
"bp-asset-hub-westend/std",
Expand Down Expand Up @@ -223,7 +223,6 @@ std = [
]

runtime-benchmarks = [
"beacon-spec-mainnet",
"bridge-hub-common/runtime-benchmarks",
"bridge-runtime-common/runtime-benchmarks",
"cumulus-pallet-parachain-system/runtime-benchmarks",
Expand Down Expand Up @@ -299,8 +298,8 @@ try-runtime = [
]

experimental = ["pallet-aura/experimental"]
beacon-spec-mainnet = [
"snowbridge-ethereum-beacon-client/beacon-spec-mainnet",
fast-runtime = [
"snowbridge-ethereum-beacon-client/beacon-spec-minimal",
]

# A feature that should be enabled when the runtime should be built for on-chain
Expand Down
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 @@ -99,6 +99,8 @@ use parachains_common::{
HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};

use polkadot_runtime_common::prod_or_fast;

#[cfg(feature = "runtime-benchmarks")]
use crate::xcm_config::benchmark_helpers::DoNothingRouter;
#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -209,7 +211,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("bridge-hub-rococo"),
impl_name: create_runtime_str!("bridge-hub-rococo"),
authoring_version: 1,
spec_version: 1_005_001,
spec_version: 1_005_002,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 4,
Expand Down Expand Up @@ -566,7 +568,7 @@ impl snowbridge_outbound_queue::Config for Runtime {
type Channels = EthereumSystem;
}

#[cfg(not(feature = "beacon-spec-mainnet"))]
#[cfg(feature = "fast-runtime")]
parameter_types! {
pub const ChainForkVersions: ForkVersions = ForkVersions {
genesis: Fork {
Expand All @@ -586,30 +588,32 @@ parameter_types! {
epoch: 0,
},
};
pub const MaxExecutionHeadersToKeep:u32 = 1000;
}

#[cfg(feature = "beacon-spec-mainnet")]
#[cfg(not(feature = "fast-runtime"))]
parameter_types! {
pub const ChainForkVersions: ForkVersions = ForkVersions {
genesis: Fork {
version: [0, 0, 16, 32], // 0x00001020
version: [144, 0, 0, 111], // 0x90000069
epoch: 0,
},
altair: Fork {
version: [1, 0, 16, 32], // 0x01001020
epoch: 36660,
version: [144, 0, 0, 112], // 0x90000070
epoch: 50,
},
bellatrix: Fork {
version: [2, 0, 16, 32], // 0x02001020
epoch: 112260,
version: [144, 0, 0, 113], // 0x90000071
epoch: 100,
},
capella: Fork {
version: [3, 0, 16, 32], // 0x03001020
epoch: 162304,
version: [144, 0, 0, 114], // 0x90000072
epoch: 56832,
},
};
pub const MaxExecutionHeadersToKeep:u32 = 8192 * 2;
}

parameter_types! {
pub const MaxExecutionHeadersToKeep: u32 = prod_or_fast!(8192 * 2, 1000);
}

impl snowbridge_ethereum_beacon_client::Config for Runtime {
Expand All @@ -630,7 +634,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 @@ -383,10 +381,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 Down
3 changes: 3 additions & 0 deletions cumulus/polkadot-parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ try-runtime = [
"shell-runtime/try-runtime",
"sp-runtime/try-runtime",
]
fast-runtime = [
"bridge-hub-rococo-runtime/fast-runtime",
]
Comment on lines +170 to +172
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fast-runtime = [
"bridge-hub-rococo-runtime/fast-runtime",
]
fast-runtime = []

I think it should work just like this (without defaulting "bridge-hub-rococo-runtime/fast-runtime"),
@alistair-singh @claravanstaden could you, please, try it if it works for you local testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bkontur it doesn't work, it seems. The fast-runtime feature should be propagated to the bridge hub rococo runtime for it to work.