Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Moves Block to frame_system instead of construct_runtime #7392

Closed
wants to merge 10 commits into from
Closed
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
36 changes: 18 additions & 18 deletions node/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub trait RuntimeApiCollection:
+ ParachainHost<Block>
+ sp_block_builder::BlockBuilder<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ sp_mmr_primitives::MmrApi<Block, <Block as BlockT>::Hash, BlockNumber>
+ sp_mmr_primitives::MmrApi<Block, <Block as sp_runtime::traits::HeaderProvider>::Hash, BlockNumber>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
Expand All @@ -150,7 +150,7 @@ where
+ ParachainHost<Block>
+ sp_block_builder::BlockBuilder<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ sp_mmr_primitives::MmrApi<Block, <Block as BlockT>::Hash, BlockNumber>
+ sp_mmr_primitives::MmrApi<Block, <Block as sp_runtime::traits::HeaderProvider>::Hash, BlockNumber>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
Expand Down Expand Up @@ -328,7 +328,7 @@ impl UsageProvider<Block> for Client {
impl sc_client_api::BlockBackend<Block> for Client {
fn block_body(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
) -> sp_blockchain::Result<Option<Vec<<Block as BlockT>::Extrinsic>>> {
with_client! {
self,
Expand All @@ -341,7 +341,7 @@ impl sc_client_api::BlockBackend<Block> for Client {

fn block(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
) -> sp_blockchain::Result<Option<SignedBlock<Block>>> {
with_client! {
self,
Expand All @@ -352,7 +352,7 @@ impl sc_client_api::BlockBackend<Block> for Client {
}
}

fn block_status(&self, hash: <Block as BlockT>::Hash) -> sp_blockchain::Result<BlockStatus> {
fn block_status(&self, hash: <Block as sp_runtime::traits::HeaderProvider>::Hash) -> sp_blockchain::Result<BlockStatus> {
with_client! {
self,
client,
Expand All @@ -364,7 +364,7 @@ impl sc_client_api::BlockBackend<Block> for Client {

fn justifications(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
) -> sp_blockchain::Result<Option<Justifications>> {
with_client! {
self,
Expand All @@ -378,7 +378,7 @@ impl sc_client_api::BlockBackend<Block> for Client {
fn block_hash(
&self,
number: NumberFor<Block>,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
) -> sp_blockchain::Result<Option<<Block as sp_runtime::traits::HeaderProvider>::Hash>> {
with_client! {
self,
client,
Expand All @@ -390,7 +390,7 @@ impl sc_client_api::BlockBackend<Block> for Client {

fn indexed_transaction(
&self,
id: <Block as BlockT>::Hash,
id: <Block as sp_runtime::traits::HeaderProvider>::Hash,
) -> sp_blockchain::Result<Option<Vec<u8>>> {
with_client! {
self,
Expand All @@ -403,7 +403,7 @@ impl sc_client_api::BlockBackend<Block> for Client {

fn block_indexed_body(
&self,
id: <Block as BlockT>::Hash,
id: <Block as sp_runtime::traits::HeaderProvider>::Hash,
) -> sp_blockchain::Result<Option<Vec<Vec<u8>>>> {
with_client! {
self,
Expand All @@ -428,7 +428,7 @@ impl sc_client_api::BlockBackend<Block> for Client {
impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
fn storage(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
key: &StorageKey,
) -> sp_blockchain::Result<Option<StorageData>> {
with_client! {
Expand All @@ -442,9 +442,9 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {

fn storage_hash(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
key: &StorageKey,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
) -> sp_blockchain::Result<Option<<Block as sp_runtime::traits::HeaderProvider>::Hash>> {
with_client! {
self,
client,
Expand All @@ -456,7 +456,7 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {

fn storage_pairs(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
key_prefix: Option<&StorageKey>,
start_key: Option<&StorageKey>,
) -> sp_blockchain::Result<
Expand All @@ -473,7 +473,7 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {

fn storage_keys(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
prefix: Option<&StorageKey>,
start_key: Option<&StorageKey>,
) -> sp_blockchain::Result<
Expand All @@ -490,7 +490,7 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {

fn child_storage(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
child_info: &ChildInfo,
key: &StorageKey,
) -> sp_blockchain::Result<Option<StorageData>> {
Expand All @@ -505,7 +505,7 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {

fn child_storage_keys(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
child_info: ChildInfo,
prefix: Option<&StorageKey>,
start_key: Option<&StorageKey>,
Expand All @@ -523,10 +523,10 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {

fn child_storage_hash(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
child_info: &ChildInfo,
key: &StorageKey,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Hash>> {
) -> sp_blockchain::Result<Option<<Block as sp_runtime::traits::HeaderProvider>::Hash>> {
with_client! {
self,
client,
Expand Down
14 changes: 7 additions & 7 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ where
/// Obtain the header for a hash.
fn header(
&self,
hash: <Block as BlockT>::Hash,
) -> Result<Option<<Block as BlockT>::Header>, Error>;
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
) -> Result<Option<<Block as sp_runtime::traits::HeaderProvider>::Header>, Error>;
/// Obtain the block number for a hash.
fn number(
&self,
hash: <Block as BlockT>::Hash,
) -> Result<Option<<<Block as BlockT>::Header as HeaderT>::Number>, Error>;
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
) -> Result<Option<<<Block as sp_runtime::traits::HeaderProvider>::Header as HeaderT>::Number>, Error>;
}

impl<Block, T> HeaderProvider<Block> for T
Expand All @@ -158,13 +158,13 @@ where
fn header(
&self,
hash: Block::Hash,
) -> sp_blockchain::Result<Option<<Block as BlockT>::Header>> {
) -> sp_blockchain::Result<Option<<Block as sp_runtime::traits::HeaderProvider>::Header>> {
<Self as sp_blockchain::HeaderBackend<Block>>::header(self, hash)
}
fn number(
&self,
hash: Block::Hash,
) -> sp_blockchain::Result<Option<<<Block as BlockT>::Header as HeaderT>::Number>> {
) -> sp_blockchain::Result<Option<<<Block as sp_runtime::traits::HeaderProvider>::Header as HeaderT>::Number>> {
<Self as sp_blockchain::HeaderBackend<Block>>::number(self, hash)
}
}
Expand Down Expand Up @@ -620,7 +620,7 @@ pub struct NewFull<C> {
pub task_manager: TaskManager,
pub client: C,
pub overseer_handle: Option<Handle>,
pub network: Arc<sc_network::NetworkService<Block, <Block as BlockT>::Hash>>,
pub network: Arc<sc_network::NetworkService<Block, <Block as sp_runtime::traits::HeaderProvider>::Hash>>,
pub sync_service: Arc<sc_network_sync::SyncingService<Block>>,
pub rpc_handlers: RpcHandlers,
pub backend: Arc<FullBackend>,
Expand Down
4 changes: 2 additions & 2 deletions node/test/client/src/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait InitPolkadotBlockBuilder {
/// which should be the parent block of the block that is being build.
fn init_polkadot_block_builder_at(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
) -> sc_block_builder::BlockBuilder<Block, Client, FullBackend>;
}

Expand All @@ -54,7 +54,7 @@ impl InitPolkadotBlockBuilder for Client {

fn init_polkadot_block_builder_at(
&self,
hash: <Block as BlockT>::Hash,
hash: <Block as sp_runtime::traits::HeaderProvider>::Hash,
) -> BlockBuilder<Block, Client, FullBackend> {
let last_timestamp =
self.runtime_api().get_last_timestamp(hash).expect("Get last timestamp");
Expand Down
2 changes: 1 addition & 1 deletion primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub use v5::{
CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog,
CoreIndex, CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet,
DownwardMessage, EncodeAs, ExecutorParam, ExecutorParams, ExecutorParamsHash,
ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, Header,
ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, Hash, HashT, HeadData,
HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage, IndexedVec, InherentData,
InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, OccupiedCore,
OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry,
Expand Down
2 changes: 1 addition & 1 deletion roadmap/implementers-guide/src/runtime/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn configuration() -> HostConfiguration {
///
/// If there is already a pending update for the current session index + 1, then it won't be touched. Otherwise,
/// that would violate the promise of this function that changes will be applied on the second session change (cur + 2).
fn schedule_config_update(updater: impl FnOnce(&mut HostConfiguration<T::BlockNumber>)) -> DispatchResult
fn schedule_config_update(updater: impl FnOnce(&mut HostConfiguration<frame_system::BlockNumberOf<T>>)) -> DispatchResult
```

## Entry-points
Expand Down
4 changes: 2 additions & 2 deletions roadmap/implementers-guide/src/runtime/paras.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ UpgradeRestrictionSignal: map hasher(twox_64_concat) ParaId => Option<UpgradeRes
/// The list of parachains that are awaiting for their upgrade restriction to cooldown.
///
/// Ordered ascending by block number.
UpgradeCooldowns: Vec<(ParaId, T::BlockNumber)>;
UpgradeCooldowns: Vec<(ParaId, frame_system::BlockNumberOf<T>)>;
/// The list of upcoming code upgrades. Each item is a pair of which para performs a code
/// upgrade and at which relay-chain block it is expected at.
///
/// Ordered ascending by block number.
UpcomingUpgrades: Vec<(ParaId, T::BlockNumber)>;
UpcomingUpgrades: Vec<(ParaId, frame_system::BlockNumberOf<T>)>;
/// The actions to perform during the start of a specific session index.
ActionsQueue: map SessionIndex => Vec<ParaId>;
/// Upcoming paras instantiation arguments.
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ where
+ Sync
+ 'static,
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: mmr_rpc::MmrRuntimeApi<Block, <Block as sp_runtime::traits::Block>::Hash, BlockNumber>,
C::Api: mmr_rpc::MmrRuntimeApi<Block, <Block as sp_runtime::traits::HeaderProvider>::Hash, BlockNumber>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BabeApi<Block>,
C::Api: BlockBuilder<Block>,
Expand Down
30 changes: 13 additions & 17 deletions runtime/common/src/assigned_slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ pub struct ParachainTemporarySlot<AccountId, LeasePeriod> {
pub lease_count: u32,
}

type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::Currency as Currency<
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<frame_system::BlockNumberOf<T>>>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::Balance;
type LeasePeriodOf<T> =
<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::LeasePeriod;
<<T as Config>::Leaser as Leaser<frame_system::BlockNumberOf<T>>>::LeasePeriod;

#[frame_support::pallet]
pub mod pallet {
Expand All @@ -91,9 +91,9 @@ pub mod pallet {

/// The type representing the leasing system.
type Leaser: Leaser<
Self::BlockNumber,
frame_system::BlockNumberOf<Self>,
AccountId = Self::AccountId,
LeasePeriod = Self::BlockNumber,
LeasePeriod = frame_system::BlockNumberOf<Self>,
>;

/// The number of lease periods a permanent parachain slot lasts.
Expand Down Expand Up @@ -182,7 +182,7 @@ pub mod pallet {

#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(n: T::BlockNumber) -> Weight {
fn on_initialize(n: frame_system::BlockNumberOf<T>) -> Weight {
if let Some((lease_period, first_block)) = Self::lease_period_index(n) {
// If we're beginning a new lease period then handle that.
if first_block {
Expand Down Expand Up @@ -213,14 +213,14 @@ pub mod pallet {
Error::<T>::SlotAlreadyAssigned
);

let current_lease_period: T::BlockNumber = Self::current_lease_period_index();
let current_lease_period: frame_system::BlockNumberOf<T> = Self::current_lease_period_index();
ensure!(
!T::Leaser::already_leased(
id,
current_lease_period,
// Check current lease & next one
current_lease_period.saturating_add(
T::BlockNumber::from(2u32)
frame_system::BlockNumberOf::<T>::from(2u32)
.saturating_mul(T::PermanentSlotLeasePeriodLength::get().into())
)
),
Expand Down Expand Up @@ -276,14 +276,14 @@ pub mod pallet {
Error::<T>::SlotAlreadyAssigned
);

let current_lease_period: T::BlockNumber = Self::current_lease_period_index();
let current_lease_period: frame_system::BlockNumberOf<T> = Self::current_lease_period_index();
ensure!(
!T::Leaser::already_leased(
id,
current_lease_period,
// Check current lease & next one
current_lease_period.saturating_add(
T::BlockNumber::from(2u32)
frame_system::BlockNumberOf::<T>::from(2u32)
.saturating_mul(T::TemporarySlotLeasePeriodLength::get().into())
)
),
Expand Down Expand Up @@ -548,7 +548,7 @@ mod tests {
use frame_support::{assert_noop, assert_ok, parameter_types};
use frame_system::EnsureRoot;
use pallet_balances;
use primitives::{BlockNumber, Header};
use primitives::BlockNumber;
use runtime_parachains::{
configuration as parachains_configuration, paras as parachains_paras,
shared as parachains_shared,
Expand All @@ -561,13 +561,10 @@ mod tests {
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
type Block = frame_system::mocking::MockBlockU32<Test>;

frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
pub enum Test
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Expand Down Expand Up @@ -597,12 +594,11 @@ mod tests {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type DbWeight = ();
Expand Down
Loading