-
Notifications
You must be signed in to change notification settings - Fork 690
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
polkadot-parachain: Add omni-node variant with u64 block number #5269
Merged
serban300
merged 12 commits into
paritytech:master
from
serban300:polkadot-parachain-u64
Aug 28, 2024
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a915b44
Define macro for generating fake runtime APIs
serban300 96ab516
Make NodeSpec generic on Block
serban300 a518bfa
Move NodeSpec related logic to common
serban300 c6eb504
Add omni-node variant with u64 block number
serban300 49c7ffe
Merge remote-tracking branch 'upstream/master' into polkadot-parachai…
serban300 d36c054
Fixes
serban300 1810c24
fix fmt
serban300 6e2bcee
taplo
serban300 34f0b7f
prdoc
serban300 2a8ecbe
prdoc fix
serban300 f46339e
Address CR comments
serban300 b7ce602
Merge remote-tracking branch 'upstream/master' into polkadot-parachai…
serban300 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// This file is part of Cumulus. | ||
|
||
// Cumulus is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Cumulus is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use crate::common::spec::NodeSpec; | ||
use cumulus_client_cli::ExportGenesisHeadCommand; | ||
use frame_benchmarking_cli::BlockCmd; | ||
#[cfg(any(feature = "runtime-benchmarks"))] | ||
use frame_benchmarking_cli::StorageCmd; | ||
use sc_cli::{CheckBlockCmd, ExportBlocksCmd, ExportStateCmd, ImportBlocksCmd, RevertCmd}; | ||
use sc_service::{Configuration, TaskManager}; | ||
use std::{future::Future, pin::Pin}; | ||
|
||
type SyncCmdResult = sc_cli::Result<()>; | ||
|
||
type AsyncCmdResult<'a> = | ||
sc_cli::Result<(Pin<Box<dyn Future<Output = SyncCmdResult> + 'a>>, TaskManager)>; | ||
|
||
pub trait NodeCommandRunner { | ||
fn prepare_check_block_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &CheckBlockCmd, | ||
) -> AsyncCmdResult<'_>; | ||
|
||
fn prepare_export_blocks_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &ExportBlocksCmd, | ||
) -> AsyncCmdResult<'_>; | ||
|
||
fn prepare_export_state_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &ExportStateCmd, | ||
) -> AsyncCmdResult<'_>; | ||
|
||
fn prepare_import_blocks_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &ImportBlocksCmd, | ||
) -> AsyncCmdResult<'_>; | ||
|
||
fn prepare_revert_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &RevertCmd, | ||
) -> AsyncCmdResult<'_>; | ||
|
||
fn run_export_genesis_head_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &ExportGenesisHeadCommand, | ||
) -> SyncCmdResult; | ||
|
||
fn run_benchmark_block_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &BlockCmd, | ||
) -> SyncCmdResult; | ||
|
||
#[cfg(any(feature = "runtime-benchmarks"))] | ||
fn run_benchmark_storage_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &StorageCmd, | ||
) -> SyncCmdResult; | ||
} | ||
|
||
impl<T> NodeCommandRunner for T | ||
where | ||
T: NodeSpec, | ||
{ | ||
fn prepare_check_block_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &CheckBlockCmd, | ||
) -> AsyncCmdResult<'_> { | ||
let partial = T::new_partial(&config).map_err(sc_cli::Error::Service)?; | ||
Ok((Box::pin(cmd.run(partial.client, partial.import_queue)), partial.task_manager)) | ||
} | ||
|
||
fn prepare_export_blocks_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &ExportBlocksCmd, | ||
) -> AsyncCmdResult<'_> { | ||
let partial = T::new_partial(&config).map_err(sc_cli::Error::Service)?; | ||
Ok((Box::pin(cmd.run(partial.client, config.database)), partial.task_manager)) | ||
} | ||
|
||
fn prepare_export_state_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &ExportStateCmd, | ||
) -> AsyncCmdResult<'_> { | ||
let partial = T::new_partial(&config).map_err(sc_cli::Error::Service)?; | ||
Ok((Box::pin(cmd.run(partial.client, config.chain_spec)), partial.task_manager)) | ||
} | ||
|
||
fn prepare_import_blocks_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &ImportBlocksCmd, | ||
) -> AsyncCmdResult<'_> { | ||
let partial = T::new_partial(&config).map_err(sc_cli::Error::Service)?; | ||
Ok((Box::pin(cmd.run(partial.client, partial.import_queue)), partial.task_manager)) | ||
} | ||
|
||
fn prepare_revert_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &RevertCmd, | ||
) -> AsyncCmdResult<'_> { | ||
let partial = T::new_partial(&config).map_err(sc_cli::Error::Service)?; | ||
Ok((Box::pin(cmd.run(partial.client, partial.backend, None)), partial.task_manager)) | ||
} | ||
|
||
fn run_export_genesis_head_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &ExportGenesisHeadCommand, | ||
) -> SyncCmdResult { | ||
let partial = T::new_partial(&config).map_err(sc_cli::Error::Service)?; | ||
cmd.run(partial.client) | ||
} | ||
|
||
fn run_benchmark_block_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &BlockCmd, | ||
) -> SyncCmdResult { | ||
let partial = T::new_partial(&config).map_err(sc_cli::Error::Service)?; | ||
cmd.run(partial.client) | ||
} | ||
|
||
#[cfg(any(feature = "runtime-benchmarks"))] | ||
fn run_benchmark_storage_cmd( | ||
self: Box<Self>, | ||
config: Configuration, | ||
cmd: &StorageCmd, | ||
) -> SyncCmdResult { | ||
let partial = T::new_partial(&config).map_err(sc_cli::Error::Service)?; | ||
let db = partial.backend.expose_db(); | ||
let storage = partial.backend.expose_storage(); | ||
|
||
cmd.run(config, partial.client, db, storage) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've talked about this before, so possibly it is duplicate:
we anticipate omni nodes to not have any benchmarking functionality, so I do encourage you to explore the state of this (e.g. how far we are from omni-bencher being self-sufficient) this and possibly NOT add code that we are going to remove later.
Probably what I am suggesting today is not feasible, because we use the benchmark subcommand in many places in our CI.
I am okay with you making this compromise now, but reminder that we need plan + tracking issue to remove benchmarking subcommand from here. The first step couple be keeping the subcommand but marking it as deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon further thought, I questioned my own opinion.
Keeping
benchmark
,try-runtime
orbuild-spec
subcommand is fine, as long as they don't require a hard dependency to the runtime. In the past they did rely on the runtime being linked as a dependency.Especially now that we have the omni-node library in place (#5288) and teams can abstract away from needing to define these commands in e.g.
struct Commands
, in fact it is beneficial to keep these subcommand in the omni-node, so that teams don't need multiple binaries to do their day-to-day work.Imagine how nicer it is to have, instead of:
polkadot-parachain
frame-omni-bencher
chain-spec-builder
have one called
polkadot-omni-node
?It seems to me that we mainly separated these binaries because we had leaky abstraction in the node side (e.g.
sturct Command
that had to be updated by each and every team to support a new subcommand).TLDR; in light of #5288 which is a step in the direction of the original vision of #5, I don't see why things like omni-bencher and chain-spec-builder cannot be part of the omni-node again.
@michalkucharczyk @ggwpez @bkchr wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah could work. Generally I think doing this to get rid of the included chain specs etc could be a good idea. So, that we have the new binary as you proposed and can remove stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the omni-node can definitely re-expose the benchmark commands with a flag. The advantage of the omni-bencher is faster compile time and smaller binary for CI. Since building a complete node just for benchmarking is a bit of a waste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agree. This is tracked here: #4966 . From what I udnerstand we still need #4405 to be merged, in order to remove the benchmarks from the node.
Keeping it also sounds good.