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

uplift to stable2407 #1372

Merged
merged 12 commits into from
Oct 23, 2024
3,467 changes: 1,617 additions & 1,850 deletions Cargo.lock

Large diffs are not rendered by default.

310 changes: 155 additions & 155 deletions Cargo.toml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions bin/collator/src/parachain/fake_runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ impl_runtime_apis! {
fn pending_block(_xts: Vec<<Block as BlockT>::Extrinsic>) -> (Option<pallet_ethereum::Block>, Option<Vec<fp_rpc::TransactionStatus>>) {
unimplemented!()
}

fn initialize_pending_block(_header: &<Block as BlockT>::Header) {
unimplemented!()
}
}

impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {
Expand Down
3 changes: 1 addition & 2 deletions bin/collator/src/parachain/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ fn start_aura_consensus(
.map(|c| ValidationCode::from(c).hash())
}
},
sync_oracle: sync_oracle.clone(),
ipapandinas marked this conversation as resolved.
Show resolved Hide resolved
keystore,
collator_key,
para_id,
Expand All @@ -634,7 +633,7 @@ fn start_aura_consensus(

let fut = async move {
wait_for_aura(client).await;
aura::run::<Block, AuraPair, _, _, _, _, _, _, _, _, _>(params).await
aura::run::<Block, AuraPair, _, _, _, _, _, _, _, _>(params).await
};

task_manager
Expand Down
2 changes: 1 addition & 1 deletion bin/collator/src/parachain/shell_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ where
Client::Api: AuraApi<Block, AuraId>,
{
async fn verify(
&mut self,
&self,
block_import: BlockImportParams<Block>,
) -> Result<BlockImportParams<Block>, String> {
if self
Expand Down
1 change: 1 addition & 0 deletions chain-extensions/pallet-assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ impl pallet_contracts::Config for Test {
type UploadOrigin = EnsureSigned<AccountId32>;
type InstantiateOrigin = EnsureSigned<AccountId32>;
type ApiVersion = ();
type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>;
}

impl RegisteredChainExtension<Test> for AssetsExtension<Test> {
Expand Down
12 changes: 6 additions & 6 deletions pallets/vesting-mbm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ fn migrate_to_new_block_time() {
assert_eq!(Vesting::vesting_balance(&DAVE), Some(300)); // starts vesting at block 5, 20 per block

assert_eq!(
Vesting::vesting(&BOB).unwrap().to_vec(),
Vesting::vesting(BOB).unwrap().to_vec(),
vec![VestingInfo::new(100, 10, 10)]
);
assert_eq!(
Vesting::vesting(&CHARLIE).unwrap().to_vec(),
Vesting::vesting(CHARLIE).unwrap().to_vec(),
vec![VestingInfo::new(1000, 100, 20)]
);
assert_eq!(
Vesting::vesting(&DAVE).unwrap().to_vec(),
Vesting::vesting(DAVE).unwrap().to_vec(),
vec![VestingInfo::new(400, 20, 5)]
);

Expand All @@ -67,15 +67,15 @@ fn migrate_to_new_block_time() {
assert_eq!(Vesting::vesting_balance(&DAVE), Some(290)); // 10 unlocked

assert_eq!(
Vesting::vesting(&BOB).unwrap().to_vec(),
Vesting::vesting(BOB).unwrap().to_vec(),
vec![VestingInfo::new(100, 5, 10)]
);
assert_eq!(
Vesting::vesting(&CHARLIE).unwrap().to_vec(),
Vesting::vesting(CHARLIE).unwrap().to_vec(),
vec![VestingInfo::new(1000, 50, 30)]
);
assert_eq!(
Vesting::vesting(&DAVE).unwrap().to_vec(),
Vesting::vesting(DAVE).unwrap().to_vec(),
vec![VestingInfo::new(300, 10, 10)]
);

Expand Down
9 changes: 5 additions & 4 deletions pallets/xc-asset-config/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn register_asset_location_and_units_per_sec_is_ok() {
));
System::assert_last_event(mock::RuntimeEvent::XcAssetConfig(Event::AssetRegistered {
asset_location: asset_location.clone().into_versioned(),
asset_id: asset_id,
asset_id,
}));

// Assert storage state after registering asset
Expand Down Expand Up @@ -182,7 +182,7 @@ fn change_asset_location_is_ok() {
System::assert_last_event(mock::RuntimeEvent::XcAssetConfig(
Event::AssetLocationChanged {
previous_asset_location: asset_location.clone().into_versioned(),
asset_id: asset_id,
asset_id,
new_asset_location: new_asset_location.clone().into_versioned(),
},
));
Expand Down Expand Up @@ -275,7 +275,7 @@ fn remove_asset_is_ok() {
assert_ok!(XcAssetConfig::remove_asset(RuntimeOrigin::root(), asset_id,));
System::assert_last_event(mock::RuntimeEvent::XcAssetConfig(Event::AssetRemoved {
asset_location: asset_location.clone().into_versioned(),
asset_id: asset_id,
asset_id,
}));

// Assert that storage is empty after successful removal
Expand Down Expand Up @@ -351,7 +351,7 @@ fn public_interfaces_are_ok() {
);
assert!(XcAssetConfig::get_units_per_second(asset_location.clone()).is_none());

// Register ups and expect value value to be returned
// Register ups and expect value to be returned
assert_ok!(XcAssetConfig::set_asset_units_per_second(
RuntimeOrigin::root(),
Box::new(asset_location.clone().into_versioned()),
Expand Down Expand Up @@ -388,6 +388,7 @@ fn different_xcm_versions_are_ok() {
}

#[test]
#[allow(deprecated)]
fn incompatible_versioned_multilocations_are_not_ok() {
ExternalityBuilder::build().execute_with(|| {
// Location that cannot be converted from v2 to v4
Expand Down
5 changes: 4 additions & 1 deletion primitives/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use crate::AccountId;
use frame_support::traits::EitherOfDiverse;
use frame_system::EnsureRoot;
use frame_system::{EnsureRoot, EnsureWithSuccess};

pub type OracleMembershipInst = pallet_membership::Instance1;
pub type MainCouncilMembershipInst = pallet_membership::Instance2;
Expand All @@ -44,6 +44,9 @@ pub type EnsureRootOrTwoThirdsMainCouncil = EitherOfDiverse<
pallet_collective::EnsureProportionAtLeast<AccountId, MainCouncilCollectiveInst, 2, 3>,
>;

pub type TreasurySpender<EnsureOrigin, Balance> =
EnsureWithSuccess<EnsureOrigin, AccountId, Balance>;

pub type EnsureRootOrHalfMainCouncil = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, MainCouncilCollectiveInst, 1, 2>,
Expand Down
6 changes: 3 additions & 3 deletions runtime/astar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-fee-payment-runtime-api = { workspace = true }
xcm-runtime-apis = { workspace = true }

# orml dependencies
orml-oracle = { workspace = true }
Expand Down Expand Up @@ -172,7 +172,7 @@ std = [
"pallet-balances/std",
"pallet-proxy/std",
"pallet-dapp-staking/std",
"xcm-fee-payment-runtime-api/std",
"xcm-runtime-apis/std",
"dapp-staking-runtime-api/std",
"pallet-inflation/std",
"pallet-evm-precompile-dapp-staking/std",
Expand Down Expand Up @@ -285,7 +285,7 @@ runtime-benchmarks = [
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm-fee-payment-runtime-api/runtime-benchmarks",
"xcm-runtime-apis/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"orml-oracle/runtime-benchmarks",
Expand Down
18 changes: 14 additions & 4 deletions runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use xcm::{
v4::{AssetId as XcmAssetId, Location as XcmLocation},
IntoVersion, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
};
use xcm_fee_payment_runtime_api::{
use xcm_runtime_apis::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
fees::Error as XcmPaymentApiError,
};
Expand Down Expand Up @@ -726,6 +726,7 @@ impl pallet_contracts::Config for Runtime {
type UploadOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type InstantiateOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type ApiVersion = ();
type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>;
}

// These values are based on the Astar 2.0 Tokenomics Modeling report.
Expand Down Expand Up @@ -1211,6 +1212,11 @@ impl pallet_migrations::Config for Runtime {
type WeightInfo = pallet_migrations::weights::SubstrateWeight<Runtime>;
}

impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime {
// This must be the same as the `ChannelInfo` from the `Config`:
type ChannelList = ParachainSystem;
}

construct_runtime!(
pub struct Runtime
{
Expand Down Expand Up @@ -1332,7 +1338,7 @@ parameter_types! {
pub type Migrations = (Unreleased, Permanent);

/// Unreleased migrations. Add new ones here:
pub type Unreleased = ();
pub type Unreleased = (cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,);

/// Migrations/checks that do not need to be versioned and can run on every upgrade.
pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,);
Expand Down Expand Up @@ -1812,6 +1818,10 @@ impl_runtime_apis! {
pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()
)
}

fn initialize_pending_block(header: &<Block as BlockT>::Header) {
Executive::initialize_block(header);
}
}

impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {
Expand Down Expand Up @@ -1910,7 +1920,7 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::fees::XcmPaymentApi<Block> for Runtime {
impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
if !matches!(xcm_version, xcm::v3::VERSION | xcm::v4::VERSION) {
return Err(XcmPaymentApiError::UnhandledXcmVersion);
Expand Down Expand Up @@ -1962,7 +1972,7 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
}
Expand Down
35 changes: 14 additions & 21 deletions runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ use astar_primitives::{
EnsureRootOrTwoThirdsCommunityCouncil, EnsureRootOrTwoThirdsMainCouncil,
EnsureRootOrTwoThirdsTechnicalCommittee, MainCouncilCollectiveInst,
MainCouncilMembershipInst, MainTreasuryInst, TechnicalCommitteeCollectiveInst,
TechnicalCommitteeMembershipInst,
TechnicalCommitteeMembershipInst, TreasurySpender,
},
Address, AssetId, Balance, BlockNumber, Hash, Header, Nonce,
};
Expand All @@ -96,6 +96,7 @@ pub use pallet_timestamp::Call as TimestampCall;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

#[cfg(feature = "std")]
/// Wasm binary unwrapped. If built with `BUILD_DUMMY_WASM_BINARY`, the function panics.
pub fn wasm_binary_unwrap() -> &'static [u8] {
Expand Down Expand Up @@ -748,6 +749,7 @@ impl pallet_contracts::Config for Runtime {
type UploadOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type InstantiateOrigin = EnsureSigned<<Self as frame_system::Config>::AccountId>;
type ApiVersion = ();
type MaxTransientStorageSize = ConstU32<{ 1 * 1024 * 1024 }>;
}

impl pallet_sudo::Config for Runtime {
Expand Down Expand Up @@ -1018,23 +1020,18 @@ impl pallet_democracy::Config for Runtime {
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub MainTreasuryAccount: AccountId = Treasury::account_id();
pub const MaxBalance: Balance = Balance::MAX;
vedhavyas marked this conversation as resolved.
Show resolved Hide resolved
}

impl pallet_treasury::Config<MainTreasuryInst> for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
type RuntimeEvent = RuntimeEvent;

// Two origins which can either approve or reject the spending proposal
type ApproveOrigin = EnsureRootOrTwoThirdsMainCouncil;
// Origin to reject the spending proposal
type RejectOrigin = EnsureRootOrTwoThirdsMainCouncil;

type OnSlash = Treasury;
type ProposalBond = ProposalBond;
vedhavyas marked this conversation as resolved.
Show resolved Hide resolved
type ProposalBondMinimum = ConstU128<{ 10 * AST }>;
type ProposalBondMaximum = ConstU128<{ 100 * AST }>;
type SpendPeriod = ConstU32<{ 1 * MINUTES }>;

// We don't do periodic burns of the treasury
Expand All @@ -1049,10 +1046,8 @@ impl pallet_treasury::Config<MainTreasuryInst> for Runtime {
type Paymaster = PayFromAccount<Balances, MainTreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;

// New approach to using treasury, useful for OpenGov but not necessarily for us.
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
// Only used by 'spend' approach which is disabled
type PayoutPeriod = ConstU32<0>;
type SpendOrigin = TreasurySpender<EnsureRootOrTwoThirdsMainCouncil, MaxBalance>;
type PayoutPeriod = ConstU32<{ 30 * MINUTES }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
Expand All @@ -1067,14 +1062,9 @@ impl pallet_treasury::Config<CommunityTreasuryInst> for Runtime {
type Currency = Balances;
type RuntimeEvent = RuntimeEvent;

// Two origins which can either approve or reject the spending proposal
type ApproveOrigin = EnsureRootOrTwoThirdsCommunityCouncil;
// Origin to reject the spending proposal
type RejectOrigin = EnsureRootOrTwoThirdsCommunityCouncil;

type OnSlash = CommunityTreasury;
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ConstU128<{ 10 * AST }>;
type ProposalBondMaximum = ConstU128<{ 100 * AST }>;
type SpendPeriod = ConstU32<{ 1 * MINUTES }>;

// We don't do periodic burns of the community treasury
Expand All @@ -1090,9 +1080,8 @@ impl pallet_treasury::Config<CommunityTreasuryInst> for Runtime {
type BalanceConverter = UnityAssetBalanceConversion;

// New approach to using treasury, useful for OpenGov but not necessarily for us.
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
// Only used by 'spend' approach which is disabled
type PayoutPeriod = ConstU32<0>;
type SpendOrigin = TreasurySpender<EnsureRootOrTwoThirdsMainCouncil, MaxBalance>;
type PayoutPeriod = ConstU32<{ 30 * MINUTES }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
Expand Down Expand Up @@ -1698,6 +1687,10 @@ impl_runtime_apis! {
pallet_ethereum::CurrentTransactionStatuses::<Runtime>::get()
)
}

fn initialize_pending_block(header: &<Block as BlockT>::Header) {
Executive::initialize_block(header);
}
}

impl fp_rpc::ConvertTransactionRuntimeApi<Block> for Runtime {
Expand Down
6 changes: 3 additions & 3 deletions runtime/shibuya/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-fee-payment-runtime-api = { workspace = true }
xcm-runtime-apis = { workspace = true }

# orml dependencies
orml-oracle = { workspace = true }
Expand Down Expand Up @@ -205,7 +205,7 @@ std = [
"pallet-evm-precompile-assets-erc20/std",
"pallet-evm-precompile-xcm/std",
"pallet-evm-precompile-unified-accounts/std",
"xcm-fee-payment-runtime-api/std",
"xcm-runtime-apis/std",
"pallet-evm-precompile-dispatch-lockdrop/std",
"pallet-dapp-staking/std",
"orml-oracle/std",
Expand Down Expand Up @@ -320,7 +320,7 @@ runtime-benchmarks = [
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm-fee-payment-runtime-api/runtime-benchmarks",
"xcm-runtime-apis/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"orml-oracle/runtime-benchmarks",
Expand Down
Loading
Loading