Skip to content

Commit

Permalink
Rename macro to parachainify!
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshOrndorff committed Apr 12, 2024
1 parent 8d9fa0b commit a6c9aec
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 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
4 changes: 2 additions & 2 deletions tuxedo-parachain-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ serde = { features = [ "derive" ], workspace = true }

# Local
tuxedo-core = { default-features = false, path = "../tuxedo-core" }
tuxedo-register-validate-block = { default_features = false, path = "register_validate_block" }
tuxedo-parachainify = { default_features = false, path = "parachainify" }

# Substrate
sp-api = { default_features = false, workspace = true }
Expand Down Expand Up @@ -67,5 +67,5 @@ std = [
"polkadot-parachain-primitives/std",
"trie-db/std",
"tuxedo-core/std",
"tuxedo-register-validate-block/std",
"tuxedo-parachainify/std",
]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
description = "Proc macro to register Polkadot's validate_block entrypoint in your Tuxedo Runtime. Inspired by cumulus-pallet-parachain-system-proc-macro"
description = "Proc macro to make a Tuxedo tuntime Parachain Compatible. Inspired by cumulus-pallet-parachain-system-proc-macro"
edition = "2021"
name = "tuxedo-register-validate-block"
name = "tuxedo-parachainify"
version = "0.1.0"

[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ impl Parse for RegisterValidateBlockInput {
}
}

//TODO rename the macro
#[proc_macro]
pub fn register_validate_block(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
pub fn parachainify(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
// Extract the paths to the parts from the runtime developer's input
// I will likely need to revise or simplify the fields that are passed in.
// I hope to only use the exposed runtime APIs here, not some custom trait impls. (if possible)
Expand Down
19 changes: 10 additions & 9 deletions tuxedo-parachain-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
//! are quite heavy to compile, and sovereign chains are able to completely avoid it.
//!
//! It's primary jobs are to
//! * Manage transiet storage details for the parachain inherent, specifically the relay
//! * Manage transient storage details for the parachain inherent, specifically the relay
//! parent block number.
//! * Provide collation information to the client side collator service.
//! * Implement the `validate_block` funtion required by relay chain validators.
//! * Implement the `validate_block` function required by relay chain validators.
//! This task is achieved through the `register_validate_block!` macro.
//!
//! This code is inspired by, cumulus pallet parachain system
Expand Down Expand Up @@ -123,22 +123,23 @@ pub struct MemoryOptimizedValidationParams {
pub relay_parent_storage_root: cumulus_primitives_core::relay_chain::Hash,
}

/// Register the `validate_block` function that is used by parachains to validate blocks on a
/// validator.
/// Prepares a Tuxedo runtime to be parachain compatible by doing two main tasks.
///
/// Does *nothing* when `std` feature is enabled.
/// 1. Wraps the provided constraint checker in another layer of aggregation including the parachain
/// inherent piece
/// 2. Registers the `validate_block` function that is used by parachains to validate blocks on a
/// validator when building to wasm. This is skipped when building to std.
///
/// Expects as parameters the Block type, the OuterVerifier, and the OuterConstraintChecker.
pub use tuxedo_register_validate_block::register_validate_block;
/// Expects as parameters a Verifier, a non-yet-parachain-ready ConstraintChecker, and a ParaId.
pub use tuxedo_parachainify::parachainify;

// Having to do this wrapping is one more reason to abandon this UtxoData trait,
// and go for a more strongly typed aggregate type approach.
// Tracking issue: https://github.com/Off-Narrative-Labs/Tuxedo/issues/153
/// A wrapper type around Cumulus's ParachainInherentData type that can be stored.
#[derive(Encode, Decode, DebugNoBound, CloneNoBound, scale_info::TypeInfo)]

/// A wrapper type around Cumulus's ParachainInherentData type.
/// This type is convertable Into and From the inner type.
/// This type is convertible Into and From the inner type.
/// This is necessary so that we can implement the `UtxoData` trait.
pub struct ParachainInherentDataUtxo(ParachainInherentData);

Expand Down
5 changes: 2 additions & 3 deletions tuxedo-parachain-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ pub fn native_version() -> NativeVersion {
/// The Aura slot duration. When things are working well, this will also be the block time.
const BLOCK_TIME: u64 = 3000;

//TODO Maybe rename the macro to eg tuxedo_parachain_runtime!.
// This creates an enum `ParachainConstraintChecker`
tuxedo_parachain_core::register_validate_block!(OuterVerifier, InnerConstraintChecker, 2000);
// This creates an enum `ParachainConstraintChecker` that implements `ParachainConstraintChecker`
tuxedo_parachain_core::parachainify!(OuterVerifier, InnerConstraintChecker, 2000);

pub type Block = TuxedoBlock<OuterVerifier, ParachainConstraintChecker>;
pub type Executive = tuxedo_core::Executive<OuterVerifier, ParachainConstraintChecker>;
Expand Down
6 changes: 3 additions & 3 deletions zombienet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[relaychain]
default_image = "docker.io/parity/polkadot:latest"
default_command = "polkadot"
default_command = "../polkadot-sdk/target/release/polkadot"
default_args = [ "-lparachain=debug" ]

chain = "rococo-local"
Expand All @@ -27,12 +27,12 @@ id = 2000
[[parachains.collators]]
name = "alice"
image = "ghcr.io/off-narrative-labs/tuxedo-parachain:latest"
command = "parachain-template-node"
command = "./target/debug/parachain-template-node"
args = ["--alice"]

[[parachains.collators]]
name = "tuxedo-full-node"
image = "ghcr.io/off-narrative-labs/tuxedo-parachain:latest"
command = "parachain-template-node"
command = "./target/debug/parachain-template-node"
# This makes this node a full node instead of a collator (despite the schema name)
validator = false

0 comments on commit a6c9aec

Please sign in to comment.