Skip to content

DO NOT MERGE: feat(ledger): upgrade ledger 8 to 8.2.0-rc.1#1869

Draft
gilescope wants to merge 4 commits into
mainfrom
giles-ledger-8-2-upgrade
Draft

DO NOT MERGE: feat(ledger): upgrade ledger 8 to 8.2.0-rc.1#1869
gilescope wants to merge 4 commits into
mainfrom
giles-ledger-8-2-upgrade

Conversation

@gilescope

@gilescope gilescope commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

UPDATE: We'd prefer to move HF onwards and get to ledger 9 rather than upgrade 8.1.

Overview

Bumps the ledger-8 stack from 8.1.0 to midnight-ledger 8.2.0-rc.1 (picking up apply_guaranteed_only, infallible post_block_update, split-phase execution with deferred events, and the segment-type refactor), keeping ledger 9 as-is.

8.2.0-rc.1 is not published to crates.io, so the ledger-8 crates are sourced from the ledger-8.2.0-rc.1 git tag. Because the tag carries path deps, ledger 8 no longer shares companion crates with ledger 7 — each companion gets a dedicated -ledger-8 workspace entry pinned to the tag (a git-sourced 2.0.1 is a distinct type family from the crates.io 2.0.1, hence the separate conversion impl set in builders/mod.rs).

Notable mechanics:

  • Per-generation storage code uses each ledger's own DefaultHasher instead of hardcoded sha2::Sha256, so it tracks the git-8.2 storage-core's sha2 0.11 bump automatically.
  • Hard-fork state-migration helpers serialize-round-trip across the now-distinct L7/L8/L9 storage arenas instead of reinterpreting arena keys in place.
  • SerializedTx is generic over the BlockContext version (SerializedTx<C = ledger_9::BlockContext>); extract_tx_with_context_ledger_8 deserializes directly into an L8 context (the JSON wire shape is version-agnostic via SerdeBlockContext), replacing the field-by-field rebuild.
  • Will sync with ledger 8 geneses.

Follow up PRs:

  • Enable unit and E2E tests for ledger 8

🗹 TODO before merging

  • Ready

📌 Submission Checklist

  • All commits are signed off (git commit -s) for the DCO
  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason: changes/node/changed/ledger-8-2-upgrade.md
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • Updated AGENTS.md if build commands, architecture, or workflows changed
  • No new todos introduced

🧪 Testing Evidence

  • cargo test -p midnight-node-ledger -p pallet-midnight — 93 + 28 ledger_8::common::api tests green, including should_validate_transaction/should_apply_transaction which parse the real DEPLOY_TX fixture through the new direct SerializedTx<ledger_8::BlockContext> deserialization and apply it to genesis state.

  • cargo clippy clean across midnight-node-ledger-helpers (--features can-panic) and midnight-node-toolkit.

  • Additional tests are provided (if possible)

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other:
  • N/A

Assisted-by: Claude:claude-fable-5

Signed-off-by: Giles Cope <gilescope@gmail.com>
@gilescope gilescope added skip-changes-check-issue ai-assisted AI (LLM) assisted contribution labels Jul 13, 2026
@datadog-official

This comment has been minimized.

Signed-off-by: Giles Cope <gilescope@gmail.com>
@gilescope
gilescope marked this pull request as ready for review July 13, 2026 17:20
@gilescope
gilescope requested a review from a team as a code owner July 13, 2026 17:20
@gilescope
gilescope marked this pull request as draft July 13, 2026 17:21
@gilescope

Copy link
Copy Markdown
Contributor Author

Now that's green, let's add in being able to sync with a ledger8 genesis blockchain...

@jina-simulation jina-simulation Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Content removed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd43e007d6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Cargo.toml
# like midnight-storage-core 1.2.0 into two source-incompatible copies (E0277: trait `DB` not
# satisfied). Consequently L8 no longer shares coin-structure/base-crypto/transient-crypto/
# serialize with L7 — each gets a dedicated `-ledger-8` entry pinned to the tag.
mn-ledger-8 = { git = "https://github.com/midnightntwrk/midnight-ledger", tag = "ledger-8.2.0-rc.1", package = "midnight-ledger" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Wire Ledger 8 to guaranteed-only validation

This bump brings Ledger 8 to the 8.2 split-phase API, but the version-specific validation shim is still on the old path: ledger/src/versions/guaranteed_validation/ledger_8.rs:16-35 says Ledger 8 has no apply_guaranteed_only and dry-runs the full state.apply(...). When a node/runtime is still using the Ledger8 bridge, mempool and pre-dispatch validation of a transaction with an expensive or failing fallible segment will still execute that fallible work even though acceptance only depends on the guaranteed segment, undermining the purpose of the 8.2 upgrade and leaving a avoidable validation-cost/DoS path. Please switch the Ledger8 shim to the new apply_guaranteed_only API as part of this dependency bump.

Useful? React with 👍 / 👎.

@gilescope
gilescope marked this pull request as ready for review July 14, 2026 08:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e99718e5b9

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// L8 (git-8.2 storage-core) and L9 (crates.io storage-core) no longer share a storage arena,
// so the old in-place arena-key reinterpret is invalid. Move the value across by serializing in
// the L8 format and deserializing in L9, then allocate it into L9 storage.
let value: T2 = old_to_new_ser(&*t1)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use untagged conversion for L8→L9 forked state

When fork_context_8_to_9 calls this for the ledger state, this now serializes with ledger-8's tagged format and deserializes with ledger-9's tagged format. The state tags are intentionally different (ledger-state[v13] vs ledger-state[v18], as documented in ledger/src/versions/common/storage.rs), so any toolkit path that forks an L8 context to L9 will return a deserialization error before migration instead of producing the new context; this replacement for the old arena-key copy needs an untagged or otherwise version-aware conversion for types whose tag changed.

Useful? React with 👍 / 👎.

@jina-simulation jina-simulation Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Content removed.

@gilescope
gilescope marked this pull request as draft July 15, 2026 09:13
@gilescope gilescope changed the title feat(ledger): upgrade ledger 8 to 8.2.0-rc.1 DO NOT MERGE: feat(ledger): upgrade ledger 8 to 8.2.0-rc.1 Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 15, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
@midnightntwrk midnightntwrk deleted a comment from jina-simulation Bot Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted AI (LLM) assisted contribution skip-changes-check-issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant