Skip to content

Commit

Permalink
parachainify! macro (#199)
Browse files Browse the repository at this point in the history
* Introduce `parachainify!` macro.
* Introduce `ParachainConstraintChecker` trait.
* Persist block number in storage under new dedicated key.
* Remove generic block parameter from Executive. It is now just Executive<V, C>.
* Create and use some type aliases like Header and Block<V, C> in core.
* Reduce definitions in parachain runtime, instead re-using more stuff from the original template.
  • Loading branch information
JoshOrndorff authored Apr 12, 2024
1 parent 2a241a4 commit c03a33d
Show file tree
Hide file tree
Showing 27 changed files with 232 additions and 371 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [
"tuxedo-core",
"tuxedo-core/aggregator",
"tuxedo-core/no_bound",
"tuxedo-parachain-core/register_validate_block",
"tuxedo-parachain-core/parachainify",
"tuxedo-parachain-core",
"tuxedo-parachain-runtime",
"wallet",
Expand Down
2 changes: 1 addition & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::{
cli::{Cli, Subcommand},
service,
};
use node_template_runtime::opaque::Block as OpaqueBlock;
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;
use tuxedo_core::types::OpaqueBlock;

impl SubstrateCli for Cli {
fn impl_name() -> String {
Expand Down
2 changes: 1 addition & 1 deletion node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use std::sync::Arc;

use jsonrpsee::RpcModule;
use node_template_runtime::opaque::Block;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use tuxedo_core::types::OpaqueBlock as Block;

pub use sc_rpc_api::DenyUnsafe;

Expand Down
4 changes: 2 additions & 2 deletions node/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use crate::rpc;
use node_template_runtime::{self, opaque::Block, RuntimeApi};
use node_template_runtime::{self, RuntimeApi};
use sc_client_api::BlockBackend;
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
use sc_consensus_grandpa::SharedVoterState;
Expand All @@ -11,7 +11,7 @@ use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use std::{sync::Arc, time::Duration};
use tuxedo_core::genesis::TuxedoGenesisBlockBuilder;
use tuxedo_core::{genesis::TuxedoGenesisBlockBuilder, types::OpaqueBlock as Block};

// Our native executor instance.
pub struct ExecutorDispatch;
Expand Down
4 changes: 2 additions & 2 deletions parachain-node/src/dev_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
//! but without a backing relay chain. This allows developers to quickly and easily spin up parachain
//! nodes using the --dev flag, for example. It can also be used in integration tests.
use parachain_template_runtime::{self, opaque::Block, RuntimeApi};
use parachain_template_runtime::{self, RuntimeApi};
use sc_client_api::BlockBackend;
use sc_consensus_manual_seal::consensus::aura::AuraConsensusDataProvider;
pub use sc_executor::NativeElseWasmExecutor;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use std::{sync::Arc, time::Duration};
use tuxedo_core::genesis::TuxedoGenesisBlockBuilder;
use tuxedo_core::{genesis::TuxedoGenesisBlockBuilder, types::OpaqueBlock as Block};

use cumulus_primitives_parachain_inherent::MockValidationDataInherentDataProvider;

Expand Down
2 changes: 1 addition & 1 deletion parachain-node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
use std::sync::Arc;

use jsonrpsee::RpcModule;
use parachain_template_runtime::opaque::Block;
pub use sc_rpc::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use tuxedo_core::types::OpaqueBlock as Block;

/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpsee::RpcModule<()>;
Expand Down
11 changes: 3 additions & 8 deletions parachain-node/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
// std
use std::{sync::Arc, time::Duration};

use cumulus_client_cli::CollatorOptions;
// Local Runtime Types
use parachain_template_runtime::{
opaque::{Block, Hash},
RuntimeApi,
};
use parachain_template_runtime::RuntimeApi;
use std::{sync::Arc, time::Duration};
use tuxedo_core::types::{OpaqueBlock as Block, OpaqueHash as Hash};

// Cumulus Imports
use cumulus_client_collator::service::CollatorService;
Expand Down
Loading

0 comments on commit c03a33d

Please sign in to comment.