Skip to content

Commit

Permalink
Nonzero minimum period (#380)
Browse files Browse the repository at this point in the history
* init evm template changes

* works in evm-template

* works in generic-template

* point to latest release
  • Loading branch information
4meta5 authored Dec 13, 2024
1 parent f50de6b commit 035e52a
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 21 deletions.
5 changes: 3 additions & 2 deletions evm-template/Cargo.lock

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

4 changes: 2 additions & 2 deletions evm-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ serde_json = "1.0.121"
smallvec = "1.11.0"

# TODO: update to release
openzeppelin-pallet-abstractions = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc2" }
openzeppelin-pallet-abstractions-proc = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc2" }
openzeppelin-pallet-abstractions = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }
openzeppelin-pallet-abstractions-proc = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
Expand Down
21 changes: 14 additions & 7 deletions evm-template/runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod asset_config;
pub mod governance;
pub mod weight;
pub mod xcm_config;

use asset_config::*;
Expand Down Expand Up @@ -30,15 +31,18 @@ pub use governance::origins::pallet_custom_origins;
use governance::{origins::Treasurer, tracks, Spender, WhitelistedCaller};
#[cfg(feature = "tanssi")]
use nimbus_primitives::NimbusId;
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::impl_openzeppelin_tanssi;
use openzeppelin_pallet_abstractions::{
impl_openzeppelin_assets, impl_openzeppelin_evm, impl_openzeppelin_governance,
impl_openzeppelin_system, impl_openzeppelin_xcm, AssetsConfig, EvmConfig, GovernanceConfig,
SystemConfig, XcmConfig,
impl_openzeppelin_system, impl_openzeppelin_xcm, AssetsConfig, AssetsWeight, EvmConfig,
EvmWeight, GovernanceConfig, GovernanceWeight, SystemConfig, SystemWeight, XcmConfig,
XcmWeight,
};
#[cfg(not(feature = "tanssi"))]
use openzeppelin_pallet_abstractions::{impl_openzeppelin_consensus, ConsensusConfig};
use openzeppelin_pallet_abstractions::{
impl_openzeppelin_consensus, ConsensusConfig, ConsensusWeight,
};
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::{impl_openzeppelin_tanssi, TanssiConfig, TanssiWeight};
use pallet_ethereum::PostLogContent;
use pallet_evm::{EVMCurrencyAdapter, EnsureAccountId20, IdentityAddressMapping};
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
Expand Down Expand Up @@ -79,15 +83,15 @@ use crate::{
constants::{
currency::{deposit, CENTS, EXISTENTIAL_DEPOSIT, MICROCENTS, MILLICENTS},
AVERAGE_ON_INITIALIZE_RATIO, DAYS, MAXIMUM_BLOCK_WEIGHT, MAX_BLOCK_LENGTH,
NORMAL_DISPATCH_RATIO, WEIGHT_PER_GAS,
NORMAL_DISPATCH_RATIO, SLOT_DURATION, WEIGHT_PER_GAS,
},
opaque,
types::{
AccountId, AssetId, AssetKind, Balance, Beneficiary, Block, Hash,
MessageQueueServiceWeight, Nonce, PrecompilesValue, PriceForSiblingParachainDelivery,
ProxyType, TreasuryInteriorLocation, TreasuryPalletId, TreasuryPaymaster, Version,
},
weights::{self, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
weights::{BlockExecutionWeight, ExtrinsicBaseWeight},
AllPalletsWithSystem, AssetManager, Balances, BaseFee, EVMChainId, Erc20XcmBridge,
MessageQueue, OpenZeppelinPrecompiles, OriginCaller, PalletInfo, ParachainInfo,
ParachainSystem, PolkadotXcm, Preimage, Referenda, Runtime, RuntimeCall, RuntimeEvent,
Expand All @@ -113,8 +117,11 @@ impl SystemConfig for OpenZeppelinRuntime {
type ProxyType = ProxyType;
type SS58Prefix = ConstU16<42>;
type ScheduleOrigin = EnsureRoot<AccountId>;
type SlotDuration = ConstU64<SLOT_DURATION>;
type Version = Version;
}
#[cfg(feature = "tanssi")]
impl TanssiConfig for OpenZeppelinRuntime {}
#[cfg(not(feature = "tanssi"))]
impl ConsensusConfig for OpenZeppelinRuntime {
type CollatorSelectionUpdateOrigin = CollatorSelectionUpdateOrigin;
Expand Down
62 changes: 62 additions & 0 deletions evm-template/runtime/src/configs/weight.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#[cfg(not(feature = "tanssi"))]
use openzeppelin_pallet_abstractions::ConsensusWeight;
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::TanssiWeight;
use openzeppelin_pallet_abstractions::{
AssetsWeight, EvmWeight, GovernanceWeight, SystemWeight, XcmWeight,
};

use crate::{
configs::OpenZeppelinRuntime,
weights::{self, RocksDbWeight},
Runtime,
};

impl SystemWeight for OpenZeppelinRuntime {
type Balances = weights::pallet_balances::WeightInfo<Runtime>;
type DbWeight = RocksDbWeight;
type Multisig = weights::pallet_multisig::WeightInfo<Runtime>;
type ParachainSystem = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
type Preimage = weights::pallet_preimage::WeightInfo<Runtime>;
type Proxy = weights::pallet_proxy::WeightInfo<Runtime>;
type Scheduler = weights::pallet_scheduler::WeightInfo<Runtime>;
type Timestamp = weights::pallet_timestamp::WeightInfo<Runtime>;
type Utility = weights::pallet_utility::WeightInfo<Runtime>;
}

#[cfg(not(feature = "tanssi"))]
impl ConsensusWeight for OpenZeppelinRuntime {
type CollatorSelection = weights::pallet_collator_selection::WeightInfo<Runtime>;
type Session = weights::pallet_session::WeightInfo<Runtime>;
}

impl AssetsWeight for OpenZeppelinRuntime {
type AssetManager = weights::pallet_asset_manager::WeightInfo<Runtime>;
type Assets = weights::pallet_assets::WeightInfo<Runtime>;
}

impl GovernanceWeight for OpenZeppelinRuntime {
type ConvictionVoting = weights::pallet_conviction_voting::WeightInfo<Runtime>;
type Referenda = weights::pallet_referenda::WeightInfo<Runtime>;
type Sudo = weights::pallet_sudo::WeightInfo<Runtime>;
type Treasury = weights::pallet_treasury::WeightInfo<Runtime>;
type Whitelist = weights::pallet_whitelist::WeightInfo<Runtime>;
}

impl XcmWeight for OpenZeppelinRuntime {
type MessageQueue = weights::pallet_message_queue::WeightInfo<Runtime>;
type Xcm = weights::pallet_xcm::WeightInfo<Runtime>;
type XcmTransactor = weights::pallet_xcm_transactor::WeightInfo<Runtime>;
type XcmWeightTrader = weights::pallet_xcm_weight_trader::WeightInfo<Runtime>;
type XcmpQueue = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
}

impl EvmWeight for OpenZeppelinRuntime {
type Evm = weights::pallet_evm::WeightInfo<Runtime>;
}

#[cfg(feature = "tanssi")]
impl TanssiWeight for OpenZeppelinRuntime {
type AuthorInherent = pallet_author_inherent::weights::SubstrateWeight<Runtime>;
type AuthoritiesNoting = pallet_cc_authorities_noting::weights::SubstrateWeight<Runtime>;
}
5 changes: 3 additions & 2 deletions generic-template/Cargo.lock

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

4 changes: 2 additions & 2 deletions generic-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ serde_json = "1.0.121"
smallvec = "1.11.0"

# TODO: update to release
openzeppelin-pallet-abstractions = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc2" }
openzeppelin-pallet-abstractions-proc = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc2" }
openzeppelin-pallet-abstractions = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }
openzeppelin-pallet-abstractions-proc = { git = "https://github.com/OpenZeppelin/openzeppelin-pallet-abstractions", default-features = false, tag = "v0.1-rc3" }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
Expand Down
17 changes: 11 additions & 6 deletions generic-template/runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod asset_config;
pub use asset_config::AssetType;
pub mod governance;
pub mod weight;
pub mod xcm_config;

use asset_config::*;
Expand Down Expand Up @@ -29,14 +30,17 @@ use frame_system::{
};
pub use governance::origins::pallet_custom_origins;
use governance::{origins::Treasurer, tracks, Spender, WhitelistedCaller};
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::impl_openzeppelin_tanssi;
use openzeppelin_pallet_abstractions::{
impl_openzeppelin_assets, impl_openzeppelin_governance, impl_openzeppelin_system,
impl_openzeppelin_xcm, AssetsConfig, GovernanceConfig, SystemConfig, XcmConfig,
impl_openzeppelin_xcm, AssetsConfig, AssetsWeight, GovernanceConfig, GovernanceWeight,
SystemConfig, SystemWeight, XcmConfig, XcmWeight,
};
#[cfg(not(feature = "tanssi"))]
use openzeppelin_pallet_abstractions::{impl_openzeppelin_consensus, ConsensusConfig};
use openzeppelin_pallet_abstractions::{
impl_openzeppelin_consensus, ConsensusConfig, ConsensusWeight,
};
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::{impl_openzeppelin_tanssi, TanssiConfig, TanssiWeight};
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
#[cfg(not(feature = "tanssi"))]
Expand Down Expand Up @@ -70,14 +74,14 @@ use crate::{
constants::{
currency::{deposit, CENTS, EXISTENTIAL_DEPOSIT, MICROCENTS},
AVERAGE_ON_INITIALIZE_RATIO, DAYS, MAXIMUM_BLOCK_WEIGHT, MAX_BLOCK_LENGTH,
NORMAL_DISPATCH_RATIO,
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
},
types::{
AccountId, AssetId, AssetKind, Balance, Beneficiary, Block, Hash,
MessageQueueServiceWeight, Nonce, PriceForSiblingParachainDelivery, ProxyType,
TreasuryAccount, TreasuryInteriorLocation, TreasuryPalletId, TreasuryPaymaster, Version,
},
weights::{self, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
weights::{BlockExecutionWeight, ExtrinsicBaseWeight},
AllPalletsWithSystem, AssetManager, Balances, MessageQueue, OriginCaller, PalletInfo,
ParachainInfo, ParachainSystem, PolkadotXcm, Preimage, Referenda, Runtime, RuntimeCall,
RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask, Scheduler,
Expand All @@ -104,6 +108,7 @@ impl SystemConfig for OpenZeppelinRuntime {
type ProxyType = ProxyType;
type SS58Prefix = ConstU16<42>;
type ScheduleOrigin = EnsureRoot<AccountId>;
type SlotDuration = ConstU64<SLOT_DURATION>;
type Version = Version;
}
#[cfg(not(feature = "tanssi"))]
Expand Down
56 changes: 56 additions & 0 deletions generic-template/runtime/src/configs/weight.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#[cfg(not(feature = "tanssi"))]
use openzeppelin_pallet_abstractions::ConsensusWeight;
#[cfg(feature = "tanssi")]
use openzeppelin_pallet_abstractions::TanssiWeight;
use openzeppelin_pallet_abstractions::{AssetsWeight, GovernanceWeight, SystemWeight, XcmWeight};

use crate::{
configs::OpenZeppelinRuntime,
weights::{self, RocksDbWeight},
Runtime,
};

impl SystemWeight for OpenZeppelinRuntime {
type Balances = weights::pallet_balances::WeightInfo<Runtime>;
type DbWeight = RocksDbWeight;
type Multisig = weights::pallet_multisig::WeightInfo<Runtime>;
type ParachainSystem = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
type Preimage = weights::pallet_preimage::WeightInfo<Runtime>;
type Proxy = weights::pallet_proxy::WeightInfo<Runtime>;
type Scheduler = weights::pallet_scheduler::WeightInfo<Runtime>;
type Timestamp = weights::pallet_timestamp::WeightInfo<Runtime>;
type Utility = weights::pallet_utility::WeightInfo<Runtime>;
}

#[cfg(not(feature = "tanssi"))]
impl ConsensusWeight for OpenZeppelinRuntime {
type CollatorSelection = weights::pallet_collator_selection::WeightInfo<Runtime>;
type Session = weights::pallet_session::WeightInfo<Runtime>;
}

impl AssetsWeight for OpenZeppelinRuntime {
type AssetManager = weights::pallet_asset_manager::WeightInfo<Runtime>;
type Assets = weights::pallet_assets::WeightInfo<Runtime>;
}

impl GovernanceWeight for OpenZeppelinRuntime {
type ConvictionVoting = weights::pallet_conviction_voting::WeightInfo<Runtime>;
type Referenda = weights::pallet_referenda::WeightInfo<Runtime>;
type Sudo = weights::pallet_sudo::WeightInfo<Runtime>;
type Treasury = weights::pallet_treasury::WeightInfo<Runtime>;
type Whitelist = weights::pallet_whitelist::WeightInfo<Runtime>;
}

impl XcmWeight for OpenZeppelinRuntime {
type MessageQueue = weights::pallet_message_queue::WeightInfo<Runtime>;
type Xcm = weights::pallet_xcm::WeightInfo<Runtime>;
type XcmTransactor = weights::pallet_xcm_transactor::WeightInfo<Runtime>;
type XcmWeightTrader = weights::pallet_xcm_weight_trader::WeightInfo<Runtime>;
type XcmpQueue = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
}

#[cfg(feature = "tanssi")]
impl TanssiWeight for OpenZeppelinRuntime {
type AuthorInherent = pallet_author_inherent::weights::SubstrateWeight<Runtime>;
type AuthoritiesNoting = pallet_cc_authorities_noting::weights::SubstrateWeight<Runtime>;
}

0 comments on commit 035e52a

Please sign in to comment.