Skip to content
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
4,918 changes: 3,241 additions & 1,677 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ parachain-info = { git = "https://github.com/paritytech/polkadot-sdk.git", packa
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "81a3af9830ea8b6ff64b066b73b04bb3b675add5", default-features = false }
polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk.git", rev = "81a3af9830ea8b6ff64b066b73b04bb3b675add5", default-features = false }
scale-info = { version = "2.11.6", default-features = false }
smallvec = { version = "1.11.0", default-features = false }
serde = { version = "1.0.126" }
serde_json = { version = "1.0.132", default-features = false }
smallvec = { version = "1.11.0", default-features = false }
static_assertions = { version = "1.1" }
testnet-parachains-constants = { git = "https://github.com/paritytech/polkadot-sdk.git", package = "testnet-parachains-constants", rev = "81a3af9830ea8b6ff64b066b73b04bb3b675add5", default-features = false }
tracing = { version = "0.1.41", default-features = false }
westend-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk.git", package = "westend-runtime-constants", rev = "b2bcb74b13f1a1e082f701e3e05ce1be44d16790", default-features = false }

# Local workspace members
bulletin-polkadot-runtime = { path = "runtimes/bulletin-polkadot" }
bulletin-polkadot-parachain-runtime = { path = "runtimes/bulletin-polkadot-parachain" }
bulletin-polkadot-runtime = { path = "runtimes/bulletin-polkadot" }
bulletin-westend-runtime = { path = "runtimes/bulletin-westend" }
pallet-relayer-set = { path = "pallets/relayer-set", default-features = false }
pallet-transaction-storage = { path = "pallets/transaction-storage", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions runtimes/bulletin-polkadot-parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ std = [
"sp-core/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-io/std",
"sp-keyring/std",
"sp-offchain/std",
"sp-runtime/std",
Expand Down Expand Up @@ -168,6 +169,7 @@ runtime-benchmarks = [
"pallet-balances/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-session/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
Expand Down
10 changes: 5 additions & 5 deletions runtimes/bulletin-polkadot-parachain/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ pub mod polkadot_constants {
impl WeightToFeePolynomial for RefTimeToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
// In Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
// The standard system parachain configuration is 1/20 of that, as in 1/200 CENT.
// In Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10
// CENT: The standard system parachain configuration is 1/20 of that, as in
// 1/200 CENT.
let p = super::currency::CENTS;
let q = 200 * Balance::from(ExtrinsicBaseWeight::get().ref_time());

Expand Down Expand Up @@ -138,8 +139,8 @@ pub mod polkadot_constants {
/// Change this to adjust the block time.
pub const MILLISECS_PER_BLOCK: u64 = 6000;

// NOTE: Currently it is not possible to change the slot duration after the chain has started.
// Attempting to do so will brick block production.
// NOTE: Currently it is not possible to change the slot duration after the chain has
// started. Attempting to do so will brick block production.
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;

// Time is measured by number of blocks.
Expand All @@ -151,4 +152,3 @@ pub mod polkadot_constants {
/// XCM version to use in genesis.
pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
}

42 changes: 20 additions & 22 deletions runtimes/bulletin-polkadot-parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

mod genesis_config_presets;
pub mod constants;
mod genesis_config_presets;
pub mod storage;
mod weights;
pub mod xcm_config;
Expand Down Expand Up @@ -83,8 +83,10 @@ use xcm_runtime_apis::{
pub use constants::polkadot_constants;

use polkadot_constants::{
consensus::*, currency::deposit, currency::CENTS, currency::EXISTENTIAL_DEPOSIT,
currency::MILLICENTS, fee::WeightToFee, time::*,
consensus::*,
currency::{deposit, CENTS, EXISTENTIAL_DEPOSIT, MILLICENTS},
fee::WeightToFee,
time::*,
};
// Re-export for benchmarks
pub use polkadot_constants::currency::UNITS;
Expand Down Expand Up @@ -909,6 +911,7 @@ impl_runtime_apis! {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;
use codec::Encode;

use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {
Expand All @@ -923,7 +926,12 @@ impl_runtime_apis! {
}

use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
impl cumulus_pallet_session_benchmarking::Config for Runtime {
fn generate_session_keys_and_proof(owner: Self::AccountId) -> (Self::Keys, Vec<u8>) {
let keys = SessionKeys::generate(&owner.encode(), None);
(keys.keys, keys.proof.encode())
}
}

use xcm::latest::prelude::*;
use xcm_config::TokenRelayLocation;
Expand All @@ -950,28 +958,18 @@ impl_runtime_apis! {
}

fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
// Relay/native token can be teleported between AH and Relay.
Some((
Asset {
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
Parent.into(),
))
// Non-system parachains do not support teleports.
None
}

fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
// None due to https://github.com/paritytech/polkadot-sdk/issues/9054
None
}

fn set_up_complex_asset_transfer() -> Option<(Assets, u32, Location, alloc::boxed::Box<dyn FnOnce()>)> {
let native_location = Parent.into();
let dest = Parent.into();

pallet_xcm::benchmarking::helpers::native_teleport_as_asset_transfer::<Runtime>(
native_location,
dest,
)
// None due to https://github.com/paritytech/polkadot-sdk/issues/9054
None
}

fn get_asset() -> Asset {
Expand Down Expand Up @@ -1024,12 +1022,12 @@ impl_runtime_apis! {
}

parameter_types! {
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
pub const TrustedTeleporter: Option<(Location, Asset)> = None;
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
pub const TrustedReserve: Option<(Location, Asset)> = Some((
TokenRelayLocation::get(),
Asset { fun: Fungible(UNITS), id: AssetId(TokenRelayLocation::get()) },
));
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
pub const TrustedReserve: Option<(Location, Asset)> = None;
}

impl pallet_xcm_benchmarks::fungible::Config for Runtime {
Expand Down
2 changes: 1 addition & 1 deletion runtimes/bulletin-polkadot-parachain/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl pallet_transaction_storage::Config for Runtime {
crate::EnsureRoot<Self::AccountId>,
// People chain can also handle authorizations.
EnsureXcm<Equals<PeopleLocation>>,
// TODO: Open this to other origins or locations (e.g., a smart contract on AH).
// TODO: Open this to other origins or locations (e.g., a smart contract on AH).
// First we need to determine the proper incentives
>;
type StoreRenewPriority = StoreRenewPriority;
Expand Down
60 changes: 37 additions & 23 deletions runtimes/bulletin-polkadot-parachain/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! XCM Configuration for Bulletin Polkadot Parachain
//!
//! As a non-system parachain, this runtime:
//! - Uses Asset Hub as the reserve location for DOT (no teleports)
//! - Trusts Asset Hub as the governance location (not the relay)

use super::{
AccountId, AllPalletsWithSystem, Balance, Balances, BaseDeliveryFee, FeeAssetId, ParachainInfo,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeHoldReason,
Expand All @@ -32,11 +38,10 @@ use pallet_xcm::{AuthorizedAliasers, XcmPassthrough};
use parachains_common::{
xcm_config::{
AliasAccountId32FromSiblingSystemChain, AllSiblingSystemParachains,
ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains,
},
TREASURY_PALLET_ID,
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use sp_runtime::traits::AccountIdConversion;
use xcm::latest::prelude::*;
Expand All @@ -46,11 +51,10 @@ use xcm_builder::{
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal,
DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter,
HashedDescription, IsConcrete, LocationAsSuperuser, ParentAsSuperuser, ParentIsPreset,
RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents,
HashedDescription, IsConcrete, LocationAsSuperuser, RelayChainAsNative, SendXcmFeeToAccount,
SiblingParachainAsNative, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
};
use xcm_executor::XcmExecutor;

Expand Down Expand Up @@ -86,17 +90,13 @@ parameter_types! {
pub const MaxAssetsIntoHolding: u32 = 64;
pub FellowshipLocation: Location = Location::new(1, Parachain(COLLECTIVES_ID));
pub PeopleLocation: Location = Location::new(1, Parachain(PEOPLE_ID));
pub GovernanceLocation: Location = Location::parent();
pub GovernanceLocation: Location = AssetHubLocation::get();
}

/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
/// `Transact` in order to determine the dispatch Origin.
pub type LocationToAccountId = (
// The parent (Relay-chain) origin converts to the parent `AccountId`.
ParentIsPreset<AccountId>,
// Sibling parachain origins convert to AccountId via the `ParaId::into`.
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.
Expand Down Expand Up @@ -137,9 +137,6 @@ pub type XcmOriginToTransactDispatchOrigin = (
// Native converter for sibling Parachains; will convert to a `SiblingPara` origin when
// recognized.
SiblingParachainAsNative<cumulus_pallet_xcm::Origin, RuntimeOrigin>,
// Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a
// transaction from the Root origin.
ParentAsSuperuser<RuntimeOrigin>,
// Native signed account converter; this just converts an `AccountId32` origin into a normal
// `RuntimeOrigin::Signed` origin of the same 32-byte value.
SignedAccountId32AsNative<RelayNetwork, RuntimeOrigin>,
Expand Down Expand Up @@ -183,7 +180,7 @@ pub type Barrier = TrailingSetTopicAsId<
ParentOrParentsPlurality,
FellowsPlurality,
Equals<GovernanceLocation>,
// Let's allow a People chain for PoP authorizations.
// People chain has free execution for PoP authorizations.
Equals<PeopleLocation>,
)>,
// Subscriptions for version tracking are OK.
Expand Down Expand Up @@ -211,9 +208,28 @@ pub type WaivedLocations = (
Equals<RelayTreasuryLocation>,
);

/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
/// - DOT with the parent Relay Chain and sibling parachains.
pub type TrustedTeleporters = ConcreteAssetFromSystem<TokenRelayLocation>;
/// Helper type to match DOT (relay native token) from Asset Hub.
pub struct IsRelayTokenFrom<Origin>(core::marker::PhantomData<Origin>);
impl<Origin> frame_support::traits::ContainsPair<Asset, Location> for IsRelayTokenFrom<Origin>
where
Origin: frame_support::traits::Get<Location>,
{
fn contains(asset: &Asset, origin: &Location) -> bool {
let loc = Origin::get();
&loc == origin &&
matches!(
asset,
Asset { id: AssetId(asset_id_location), fun: Fungible(_) }
if *asset_id_location == TokenRelayLocation::get()
)
}
}

/// Reserve locations for assets (Asset Hub for DOT).
pub type Reserves = IsRelayTokenFrom<AssetHubLocation>;

/// No trusted teleporters.
pub type TrustedTeleporters = ();

/// Defines origin aliasing rules for this chain.
///
Expand All @@ -235,9 +251,7 @@ impl xcm_executor::Config for XcmConfig {
type XcmEventEmitter = PolkadotXcm;
type AssetTransactor = AssetTransactors;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
// Bulletin chain does not recognize a reserve location for any asset. Users must teleport DOT
// where allowed (e.g. with the Relay Chain).
type IsReserve = ();
type IsReserve = Reserves;
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
Expand Down Expand Up @@ -308,7 +322,7 @@ impl pallet_xcm::Config for Runtime {
type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Everything;
type Weigher = WeightInfoBounds<
crate::weights::xcm::BulletinPolkadotXcmWeight<RuntimeCall>,
Expand Down
15 changes: 8 additions & 7 deletions runtimes/bulletin-polkadot-parachain/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

use bulletin_polkadot_parachain_runtime::{
polkadot_constants::fee::WeightToFee,
xcm_config::{polkadot_system_parachain, GovernanceLocation, LocationToAccountId, PeopleLocation},
xcm_config::{
polkadot_system_parachain, GovernanceLocation, LocationToAccountId, PeopleLocation,
},
AllPalletsWithoutSystem, Block, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, SessionKeys,
System, TxExtension, UncheckedExtrinsic,
};
Expand Down Expand Up @@ -202,7 +204,8 @@ fn transaction_storage_runtime_sizes() {
}

/// Test maximum write throughput: 8 transactions of 1 MiB each in a single block (8 MiB data).
/// A 9th transaction should fail with ExhaustsResources due to overhead on the 8 transactions pushing the 9th above 9 MiB.
/// A 9th transaction should fail with ExhaustsResources due to overhead on the 8 transactions
/// pushing the 9th above 9 MiB.
#[test]
fn transaction_storage_max_throughput() {
use bulletin_polkadot_parachain_runtime as runtime;
Expand All @@ -221,10 +224,9 @@ fn transaction_storage_max_throughput() {
.execute_with(|| {
let account = Sr25519Keyring::Alice;
let who: AccountId = account.to_account_id();
// fund Alice to cover length-based tx fees
let initial: Balance = 10_000_000_000_000_000_000u128;
<pallet_balances::Pallet<Runtime> as FungibleMutate<_>>::set_balance(&who, initial);

// fund Alice to cover length-based tx fees
let initial: Balance = 10_000_000_000_000_000_000u128;
<pallet_balances::Pallet<Runtime> as FungibleMutate<_>>::set_balance(&who, initial);

// Authorize 8 + 1 transactions (one extra for the overflow test)
assert_ok!(runtime::TransactionStorage::authorize_account(
Expand Down Expand Up @@ -256,7 +258,6 @@ fn transaction_storage_max_throughput() {
assert_ok!(res.unwrap());
}


// Try to store a 9th transaction - should fail because block is full
// (10 MiB block * 90% NORMAL_DISPATCH_RATIO = 9 MiB limit, minus ~1 MiB overhead for 8 txs)
tracing::info!("Attempting 9th transaction - should fail with ExhaustsResources");
Expand Down