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

polkadot-parachain: Add omni-node variant with u64 block number #5269

Merged
merged 12 commits into from
Aug 28, 2024

Conversation

serban300
Copy link
Contributor

@serban300 serban300 commented Aug 7, 2024

Related to #4787

The main changes in this PR are the following:

  • making the NodeSpec logic generic on the Block type
  • adding an omni-node variant with u64 block number

Apart from this, the PR also moves some of the logic in service.rs to the common subfolder

The omni-node variant with u64 block number is not used yet. We have to either expose the option in the CLI or to read the block number from the chain spec somehow. Will do it in a future PR.

@serban300 serban300 added R0-silent Changes should not be mentioned in any release notes T0-node This PR/Issue is related to the topic “node”. labels Aug 7, 2024
@serban300 serban300 self-assigned this Aug 7, 2024
@serban300 serban300 marked this pull request as ready for review August 7, 2024 07:30
cmd: &BlockCmd,
) -> SyncCmdResult;

#[cfg(any(feature = "runtime-benchmarks"))]
Copy link
Contributor

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.

Copy link
Contributor

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 or build-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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have one called polkadot-omni-node?

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.

Copy link
Member

@ggwpez ggwpez Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why things like omni-bencher and chain-spec-builder cannot be part of the omni-node again.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

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.

Keeping it also sounds good.

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally think the best way to expose this is neither CLI nor chain-spec, and instead the pattern introduced in #5288, so I would wait for that to be merged first.

CLI and/or chain-spec and/or env variable and all indeed work, but the most meta and un-opinionated way is 5288.

@serban300
Copy link
Contributor Author

I personally think the best way to expose this is neither CLI nor chain-spec, and instead the pattern introduced in #5288, so I would wait for that to be merged first.

Sounds good. I will come back to this after #5288 is merged

@serban300 serban300 removed the R0-silent Changes should not be mentioned in any release notes label Aug 22, 2024
@serban300
Copy link
Contributor Author

I personally think the best way to expose this is neither CLI nor chain-spec, and instead the pattern introduced in #5288, so I would wait for that to be merged first.

Sounds good. I will come back to this after #5288 is merged

Done. @kianenigma can you please take a look ?

pub use parachains_common::{AccountId, Balance, Hash, Nonce};

type Header<BlockNumber> = generic::Header<BlockNumber, BlakeTwo256>;
pub type CustomBlock<BlockNumber> = generic::Block<Header<BlockNumber>, UncheckedExtrinsic>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub type CustomBlock<BlockNumber> = generic::Block<Header<BlockNumber>, UncheckedExtrinsic>;
pub type BlockOf<BlockNumber> = generic::Block<Header<BlockNumber>, UncheckedExtrinsic>;

nit, but usually we called such aliases in substrate like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed CustomBlock. Now it's just called Block.

I saw this kind of naming in substrate but I think it was for things like: HeaderOf<Block> which is an alias for Block::Header. I wouldn't use BlockOf here since we're not accessing a property Block of something. We are referencing a Block that uses a certain number. But I don't know. I don't have strong preferences.

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks broadly good, I will approve after another quick pass.

Would be great if the second review is from a node-sdk expert.

Beyond "the code compiles", what steps do you perform to make sure the scenario we have in mind in every step of the way is correct?

we should work towards a number of network setups where we can quickly test relevant scenarios. Even if they are not tested in CI (for now), they are great help for us to ensure correctness of what we are doing.

For example, as with this PR, I should expect to quickly run a zombienet network with a U64 block number, and see it work in action.

This setup would then also help us verify some questions in the code. For example, at some point I had the guess that the types passed into FakeRuntime in impl_runtime_apis really don't matter AT ALL. As in, I think I got a node working with totally fake/dumb types. Having a simple test setup will help us test this kind of hypothesis, without risk breaking anything.

@serban300
Copy link
Contributor Author

Beyond "the code compiles", what steps do you perform to make sure the scenario we have in mind in every step of the way is correct?

we should work towards a number of network setups where we can quickly test relevant scenarios. Even if they are not tested in CI (for now), they are great help for us to ensure correctness of what we are doing.

For this PR, personally I tested, asset hub polkadot, asset hub rococo and peregrine

we should work towards a number of network setups where we can quickly test relevant scenarios. Even if they are not tested in CI (for now), they are great help for us to ensure correctness of what we are doing.

For example, as with this PR, I should expect to quickly run a zombienet network with a U64 block number, and see it work in action.

I think that in the CI there are zombienet tests that spawn most of the runtimes suported by polkadot-parachain. The bridges zombienet tests spawn for example, asset hub rococo, asset hub westend, bridge hub rococo, bridge hub westend

But yes, there is no test for a parachain with u64 block number.

I agree it would be good to have a test setup. But also, I think we should do it as part of a separate PR/issue

@bkchr
Copy link
Member

bkchr commented Aug 26, 2024

As in, I think I got a node working with totally fake/dumb types. Having a simple test setup will help us test this kind of hypothesis, without risk breaking anything.

This hypothesis is completely wrong. u32 can not be decoded as u64, as u64 requires 8 bytes versus 4 bytes for u32.

@serban300 serban300 requested a review from skunert August 28, 2024 11:32
@skunert
Copy link
Contributor

skunert commented Aug 28, 2024

I agree it would be good to have a test setup. But also, I think we should do it as part of a separate PR/issue

Also think could be a separate PR, would just be a matter of introducing a new cumulus test runtime like the variants that we have, e.g. here.

Copy link
Contributor

@skunert skunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few iterations have been made here already, looks good!

@kianenigma
Copy link
Contributor

As in, I think I got a node working with totally fake/dumb types. Having a simple test setup will help us test this kind of hypothesis, without risk breaking anything.

This hypothesis is completely wrong. u32 can not be decoded as u64, as u64 requires 8 bytes versus 4 bytes for u32.

I see, so the impl RuntimeApi for FakeRuntime is not fully fully fake, the types that are provided there are still used in wasm execution, despite the fact that the code in the fn bodies are never called. I thought that part is purely a relic of the Native runtime and so on.

But it makes sense, even in wasm we need some reference to decode the types I suppose.

@serban300 serban300 added this pull request to the merge queue Aug 28, 2024
github-merge-queue bot pushed a commit that referenced this pull request Aug 28, 2024
Related to #4787

The main changes in this PR are the following:
- making the NodeSpec logic generic on the Block type
- adding an omni-node variant with u64 block number

Apart from this, the PR also moves some of the logic in `service.rs` to
the `common` subfolder

The omni-node variant with u64 block number is not used yet. We have to
either expose the option in the CLI or to read the block number from the
chain spec somehow. Will do it in a future PR.
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Aug 28, 2024
@serban300 serban300 added this pull request to the merge queue Aug 28, 2024
Merged via the queue into paritytech:master with commit c4ced11 Aug 28, 2024
189 of 192 checks passed
@serban300 serban300 deleted the polkadot-parachain-u64 branch August 28, 2024 18:10
ordian added a commit that referenced this pull request Aug 29, 2024
* master: (39 commits)
  short-term fix for para inherent weight overestimation (#5082)
  CI: Add backporting bot (#4795)
  Fix benchmark failures when using `insecure_zero_ed` flag (#5354)
  Command bot GHA v2 - /cmd <cmd> (#5457)
  Remove pallet::getter usage from treasury (#4962)
  Bump blake2b_simd from 1.0.1 to 1.0.2 (#5404)
  Bump rustversion from 1.0.14 to 1.0.17 (#5405)
  Bridge zombienet tests: remove old command (#5434)
  polkadot-parachain: Add omni-node variant with u64 block number (#5269)
  Refactor verbose test (#5506)
  Use umbrella crate for minimal template (#5155)
  IBP Coretime Polkadot bootnodes (#5499)
  rpc server: listen to `ipv6 socket` if available and `--experimental-rpc-endpoint` CLI option (#4792)
  Update approval-voting-regression-bench (#5504)
  change try-runtime rpc domains (#5443)
  polkadot-parachain-bin: Remove contracts parachain (#5471)
  Add feature to allow Aura collator to use full PoV size (#5393)
  Adding stkd bootnodes (#5470)
  Make `PendingConfigs` storage item public (#5467)
  frame-omni-bencher maintenance (#5466)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T0-node This PR/Issue is related to the topic “node”.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants