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

Inherents and empty block production overhaul #86

Merged
merged 33 commits into from
May 26, 2024

Conversation

liamaharon
Copy link
Member

@liamaharon liamaharon commented May 7, 2024

A pre-requisite to producing empty blocks for MBMs is fixing inherents for relay and parachains, and moving block production logic from being tied to fast_forward to common logic.

It will also be very beneficial to allow producing blocks based on a snapshot, without any live node (--block-ws-uri).

Based on the changes in this PR, I'll add MBM support to the on-runtime-upgrade subcommand.

  • Fixes inherent providers for relay and parachains
  • Introduces a SMART inherent provider designed to work across different chains, removing the requirement for a cli arg to specify which inherents to use
  • Moves inherent and block production to a common utils dir
  • Removes requirement for a remote node to produce empty blocks
  • Closes Reduce unnecessary dependencies #32 (no longer compiles kitchensink runtime)

@liamaharon liamaharon added the enhancement New feature or request label May 7, 2024
@liamaharon liamaharon marked this pull request as draft May 7, 2024 17:49
@liamaharon liamaharon changed the title Inherents overhaul Inherents and empty block production overhaul May 10, 2024
@liamaharon liamaharon marked this pull request as ready for review May 14, 2024 11:05
@kianenigma
Copy link
Collaborator

Based on the changes in this PR, I'll add MBM support to the on-runtime-upgrade subcommand.

How do you imagine the interface for this to look like?

also, I wonder after this, how different on-runtime-upgrade is vs. fast-forward -n 1? or in the case of MBMs fast-forward -n until-all-ext-inclusion (which produces empty blocks until ExtrinsicInclusionMode::All is reached)

serde_json::Value::String(format!("0x{}", hex::encode(value))),
)
})
.collect(),
Copy link
Member

Choose a reason for hiding this comment

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

Is this sorted?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why does it need to be sorted?

Copy link
Member

@ggwpez ggwpez left a comment

Choose a reason for hiding this comment

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

Looks pretty good

core/src/common/empty_block/inherents/pre_apply.rs Outdated Show resolved Hide resolved
core/src/common/empty_block/inherents/providers.rs Outdated Show resolved Hide resolved
core/src/common/empty_block/inherents/providers.rs Outdated Show resolved Hide resolved
core/src/common/empty_block/inherents/providers.rs Outdated Show resolved Hide resolved
})
.encode(),
),
DigestItem::PreRuntime(AURA_ENGINE_ID, slot.encode()),
Copy link
Member

Choose a reason for hiding this comment

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

Could you try with some ecosystem runtimes? I assume that moonbeam would not work, but maybe some others could be used to test it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added --blocktime arg to make this work for other runtimes like Aleph Zero that have blocktime other than 6s.

Copy link
Member Author

Choose a reason for hiding this comment

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

Disapointingly, more ecosystem runtimes I tried than not failed to even compile with the try-runtime feature 😅

Out of those that did compile:

Success

  • Aleph Zero
  • Polimec
  • Zeitgeist

Failed

  • HydraHX - Digest issue

Unknown

  • Acala - couldn't find a public node that would serve the on-chain data
  • Astar - couldn't find a public node that would serve the on-chain data

Findings

HydraDX issue seems specific to them, I think best to work out later when in contact with their devs who hopefully know what's up with their digest.

Parachains are 12s, relay chain 6s, Aleph Zero 1s. If you get the blocktime wrong, you get a potentially confusing error. So I'm going to remove the default for --blocktime so it must be included explicitly.

Copy link
Member

Choose a reason for hiding this comment

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

Yea a lot of parachains also dont compile with the benchmark features 🙈

But at least it shows that it can work. I think that is good enough for now 👍

core/src/common/empty_block/production.rs Outdated Show resolved Hide resolved
core/src/common/empty_block/production.rs Outdated Show resolved Hide resolved
@liamaharon
Copy link
Member Author

liamaharon commented May 14, 2024

Based on the changes in this PR, I'll add MBM support to the on-runtime-upgrade subcommand.

How do you imagine the interface for this to look like?

also, I wonder after this, how different on-runtime-upgrade is vs. fast-forward -n 1? or in the case of MBMs fast-forward -n until-all-ext-inclusion (which produces empty blocks until ExtrinsicInclusionMode::All is reached)

I'm imagining that there's a new --mbms flag for on-runtime-upgrade, which by default is enabled. When enabled, after the migrations are executed, empty blocks will be mined continuously until MBMs are completed.

ExtrinsicInclusionMode::All is not enough to signify successful MBMs, because it's possible to configure your chain to go back into that mode when MBMs fail. Instead, we can

  1. Try to decode frame-system events (probably won't work because we don't know how to decode them)
  2. Create a try-runtime variant of execute block that returns MBM progress.

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@kianenigma
Copy link
Collaborator

I'm imagining that there's a new --mbms flag for on-runtime-upgrade, which by default is enabled. When enabled, after the migrations are executed, empty blocks will be mined continuously until MBMs are completed.

I don't want to be too picky and ack that we need something quick here, but for the sake of a pedantic argument, what argument is making you lean towards this design, as opposed to making everything be a variant of fast-forward?

it's possible to configure your chain to go back into that mode when MBMs fail

Can you elaborate on the scenario here? I am not familiar, and anticipated that at least for successful MBMs, this return type would be enough.

@liamaharon
Copy link
Member Author

liamaharon commented May 16, 2024

I don't want to be too picky and ack that we need something quick here, but for the sake of a pedantic argument, what argument is making you lean towards this design, as opposed to making everything be a variant of fast-forward?

fast-forward

  1. won't tell you about whether your MBMs succeeded, it just fast forwards blocks
  2. does not have any of the migration safety checks that we have implemented in the on-runtime-upgrade subcommand, such as idempotency or spec version checks

Can you elaborate on the scenario here? I am not familiar, and anticipated that at least for successful MBMs, this return type would be enough.

There is no 'return type' for MBMs. If the runtime specifies ForceUnstuck as the action to take on failure, then ExtrinsicInclusionMode::All will be set regardless of whether the MBMs completed successfully or encountered a critical error.

@liamaharon liamaharon merged commit 251438f into main May 26, 2024
5 checks passed
@ggwpez ggwpez deleted the liam-inherent-overhaul branch May 28, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce unnecessary dependencies
3 participants