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

Dedicated Parachain Runtime #198

Merged
merged 24 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9d20ad0
bring in old deidicated runtime from first attempt
JoshOrndorff Mar 21, 2024
294e3dc
update to newer tuxedo
JoshOrndorff Mar 21, 2024
2511bda
Remove parachain feature from original runtime (this leaves the node …
Nov 22, 2023
f2a7060
point parachain node to new runtime
JoshOrndorff Mar 21, 2024
9c7a6ed
Start hacking wallet
JoshOrndorff Mar 21, 2024
11abe45
warning
JoshOrndorff Mar 21, 2024
cf0d901
fix genesis
JoshOrndorff Mar 21, 2024
1b6de3d
note about the wallet only works with parachain right now
JoshOrndorff Mar 21, 2024
10f0299
remove overly complex and redundant test code
JoshOrndorff Mar 21, 2024
539c13d
The inherent adapter again :facepalm:
JoshOrndorff Mar 21, 2024
925a123
fmt
JoshOrndorff Mar 21, 2024
f9d3ab2
Make more wallet stuff generic. Not sure this is the way...
JoshOrndorff Mar 21, 2024
9dd40d1
fmt
JoshOrndorff Mar 21, 2024
c6c5026
Wallet works for parachain again. Make functions generic over constra…
JoshOrndorff Mar 23, 2024
120d2c0
Wallet works for both para and standalone again, but needs a little c…
JoshOrndorff Mar 23, 2024
4eb48ba
unused dependency
JoshOrndorff Apr 2, 2024
1c0b5be
fix up duplicated comment
JoshOrndorff Apr 2, 2024
fe75ada
reuse opaque types
JoshOrndorff Apr 2, 2024
015f156
Remove aparently unnecessary `GetNodeBlockType` and `GetRuntimeBlockT…
JoshOrndorff Apr 2, 2024
a2583a4
side effect: improve chain-info subcommand to use opaque block.
JoshOrndorff Apr 2, 2024
df91015
remove outdated comment
JoshOrndorff Apr 2, 2024
a502ac8
cleanup wallet
JoshOrndorff Apr 2, 2024
789d174
wallet comment cleanup
JoshOrndorff Apr 2, 2024
94f63b9
reuse existing `transform` method for wrapping transactions
JoshOrndorff Apr 2, 2024
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
38 changes: 34 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"tuxedo-core/no_bound",
"tuxedo-parachain-core/register_validate_block",
"tuxedo-parachain-core",
"tuxedo-parachain-runtime",
"wallet",
"wardrobe/amoeba",
"wardrobe/money",
Expand Down
8 changes: 2 additions & 6 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
cli::{Cli, Subcommand},
service,
};
use node_template_runtime::Runtime;
use node_template_runtime::opaque::Block as OpaqueBlock;
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;

Expand Down Expand Up @@ -121,11 +121,7 @@ pub fn run() -> sc_cli::Result<()> {
}
Some(Subcommand::ChainInfo(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
cmd.run::<<Runtime as sp_runtime::traits::GetRuntimeBlockType>::RuntimeBlock>(
&config,
)
})
runner.sync_run(|config| cmd.run::<OpaqueBlock>(&config))
}
Some(Subcommand::Custom(_)) => {
todo!()
Expand Down
2 changes: 1 addition & 1 deletion parachain-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ parity-scale-codec = { workspace = true }
serde = { features = [ "derive" ], workspace = true }

# Local
parachain-template-runtime = { features = [ "parachain" ], package = "tuxedo-template-runtime", path = "../tuxedo-template-runtime" }
parachain-template-runtime = { package = "tuxedo-parachain-runtime", path = "../tuxedo-parachain-runtime" }
tuxedo-core = { path = "../tuxedo-core" }

# Substrate
Expand Down
72 changes: 72 additions & 0 deletions tuxedo-parachain-runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[package]
description = "An example and template runtime built with Tuxedo."
edition = "2021"
license = "Apache-2.0"
name = "tuxedo-parachain-runtime"
repository = "https://github.com/Off-Narative-Labs/Tuxedo"
version = "1.0.0-dev"

[dependencies]
log = { workspace = true }
parity-scale-codec = { features = [ "derive" ], workspace = true }
parity-util-mem = { optional = true, workspace = true }
scale-info = { features = [ "derive", "serde" ], workspace = true }
serde = { features = [ "derive" ], workspace = true }

sp-api = { default_features = false, workspace = true }
sp-block-builder = { default_features = false, workspace = true }
sp-core = { features = [ "serde" ], default_features = false, workspace = true }
sp-debug-derive = { features = [ "force-debug" ], default_features = false, workspace = true }
sp-inherents = { default_features = false, workspace = true }
sp-io = { features = [ "with-tracing" ], default_features = false, workspace = true }
sp-runtime = { features = [ "serde" ], default_features = false, workspace = true }
sp-session = { default_features = false, workspace = true }
sp-std = { default_features = false, workspace = true }
sp-storage = { default_features = false, workspace = true }
sp-timestamp = { default_features = false, workspace = true }
sp-transaction-pool = { default_features = false, workspace = true }
sp-version = { default_features = false, workspace = true }

# The inner runtime
inner-runtime = { default-features = false, package = "tuxedo-template-runtime", path = "../tuxedo-template-runtime" }

# These were added for Aura / Grandpa API support
hex-literal = { workspace = true }
sp-application-crypto = { default_features = false, workspace = true }
sp-consensus-aura = { default_features = false, workspace = true }
sp-consensus-grandpa = { default_features = false, workspace = true }

# Parachain related ones
cumulus-primitives-core = { default-features = false, workspace = true }
parachain-piece = { default-features = false, path = "../wardrobe/parachain" }
tuxedo-parachain-core = { default-features = false, path = "../tuxedo-parachain-core" }

[build-dependencies]
substrate-wasm-builder = { workspace = true }

[features]
default = [ "std" ]
std = [
"sp-debug-derive/std",
"sp-block-builder/std",
"sp-inherents/std",
"parity-scale-codec/std",
"sp-core/std",
"sp-std/std",
"serde/std",
"sp-api/std",
"sp-session/std",
"sp-io/std",
"sp-runtime/std",
"sp-transaction-pool/std",
"sp-version/std",
"parity-util-mem",
"sp-storage/std",
"sp-consensus-aura/std",
"sp-application-crypto/std",
"sp-consensus-grandpa/std",
"inner-runtime/std",
"cumulus-primitives-core/std",
"parachain-piece/std",
"tuxedo-parachain-core/std",
]
13 changes: 13 additions & 0 deletions tuxedo-parachain-runtime/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#[cfg(feature = "std")]
fn main() {
substrate_wasm_builder::WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}

/// The wasm builder is deactivated when compiling
/// this crate for wasm to speed up the compilation.
#[cfg(not(feature = "std"))]
fn main() {}
51 changes: 51 additions & 0 deletions tuxedo-parachain-runtime/src/genesis.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//! Helper module to build a genesis configuration for the template runtime.

use super::{OuterConstraintChecker, OuterVerifier, WASM_BINARY};
use hex_literal::hex;
use inner_runtime::{money::Coin, OuterConstraintChecker as InnerConstraintChecker};
use tuxedo_parachain_core::tuxedo_core::{
genesis::TuxedoGenesisConfig,
verifier::{Sr25519Signature, ThresholdMultiSignature},
ConstraintChecker,
};

/// Helper type for the ChainSpec.
pub type RuntimeGenesisConfig = TuxedoGenesisConfig<OuterVerifier, OuterConstraintChecker>;

const SHAWN_PUB_KEY_BYTES: [u8; 32] =
hex!("d2bf4b844dfefd6772a8843e669f943408966a977e3ae2af1dd78e0f55f4df67");
const ANDREW_PUB_KEY_BYTES: [u8; 32] =
hex!("baa81e58b1b4d053c2e86d93045765036f9d265c7dfe8b9693bbc2c0f048d93a");

pub fn development_genesis_config() -> RuntimeGenesisConfig {
let signatories = vec![SHAWN_PUB_KEY_BYTES.into(), ANDREW_PUB_KEY_BYTES.into()];

let user_genesis_transactions = [
// Money Transactions
Coin::<0>::mint::<_, _, InnerConstraintChecker>(
100,
Sr25519Signature::new(SHAWN_PUB_KEY_BYTES),
)
.transform(),
Coin::<0>::mint::<_, _, InnerConstraintChecker>(
100,
ThresholdMultiSignature::new(1, signatories),
)
.transform(),
// No Kitty or anything else in this one. Keep it simple.
]
.into_iter()
.map(Into::into);

// The inherents are computed using the appropriate method, and placed before the user transactions.
// Ideally this will get better upstream eventually.
let mut genesis_transactions = OuterConstraintChecker::genesis_transactions();
genesis_transactions.extend(user_genesis_transactions);

RuntimeGenesisConfig::new(
WASM_BINARY
.expect("Runtime WASM binary must exist.")
.to_vec(),
genesis_transactions,
)
}
Loading
Loading