Allow local-env mocked nodes to sync from genesis via marked fork blocks - #2149
Open
justinfrevert wants to merge 5 commits into
Open
justinfrevert wants to merge 5 commits into
justinfrevert wants to merge 5 commits into
Conversation
Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd0015fba0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…sition-runtime Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
Bypassing Executive for the fork block also bypassed its final_checks. The client still checks the state root, but nothing tied the executed body to the header's extrinsics root, and unrecognised body entries were silently skipped. Assert the extrinsics root, require exactly one well-formed delta blob, and reject delta blobs with trailing bytes. Also fill in the change file's PR and issue links, and fix clippy lints from the Rust 1.98 bump. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
|
An empty MIDNIGHT_FORK_HEIGHT parsed as height 0, so a build with the variable set but blank looked configured instead of inert. Parse it with str::parse, which rejects empty input, and drop the incorrect comment claiming str::parse was unavailable. Also untangle a module-doc paragraph that had been merged into the spec_version failure-mode section. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
Resolves #2071. Works with new
mock-authoritieschanges that mark fork blocks, so a node can sync a locally forked chain from true genesis.A chain forked by
mock-authorities convertcontains one block that no honest proposer could have produced. Its seal is signed by a key that is not in the parent's authority set, and its state root reflects a hand-built delta. A node syncing from genesis therefore stops at the fork point.This adds an off-by-default
fork-transitioncargo feature. It builds a runtime, supplied to the syncing node via the chain spec'scodeSubstitutes, that relaxes exactly three things at exactly one compile-time height (MIDNIGHT_FORK_HEIGHT):AuraApi::authoritiesreports the fork's mock set (MIDNIGHT_FORK_AURA_AUTHORITIES) at the fork block's parent, so the fork block's seal verifies.check_inherentsis skipped for the fork block only.Core::execute_blockapplies the magic-prefixed storage delta carried in the block body, instead of runningExecutive. It still asserts the header's extrinsics root, requires the body to be exactly one well-formed delta blob, and the client checks the resulting state root against the header.Without the feature (or without the env vars), the runtime is identical to stock: no pallet, call or metadata changes. A runtime built with this feature must never be released.
🗹 TODO before merging
📌 Submission Checklist
git commit -s) for the DCO🧪 Testing Evidence
cargo test -p midnight-node-runtime --features fork-transition --lib fork_transition— 6 passed. These cover inertness without configuration, parsing, strict delta decoding (including trailing bytes), and a golden blob shared byte-for-byte withmock-authorities'fork::GOLDEN_FORK_BLOB.cargo clippy -p midnight-node-runtime --features fork-transition --lib --tests— clean.Additional tests are provided (if possible)
🔱 Fork Strategy
codeSubstitutesruntime for local test forks.Links
🤖 Generated with Claude Code