Skip to content

feat: toolkit hard-fork support#711

Merged
ozgb merged 50 commits into
mainfrom
ozgb-toolkit-hf-support
Feb 27, 2026
Merged

feat: toolkit hard-fork support#711
ozgb merged 50 commits into
mainfrom
ozgb-toolkit-hf-support

Conversation

@ozgb

@ozgb ozgb commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

Overview

  • Modified the fetching stage to be version-agnostic - handles serialized data only, outputs RawBlockData
  • Added a new ForkAwareContext struct that forks between ledger 7 and ledger 8

Testing:

  • moved toolkit-e2e tests into an integration test using testcontainers

🗹 TODO before merging

  • Ready
  • Toolkit e2e test - parallise
  • Either:
  • Simple integration test for hard-fork
    • Tested manually - will add an integration test in a new PR

📌 Submission Checklist

  • 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:
  • 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

Please describe any additional testing aside from CI:

  • Additional tests are provided (if possible)

🔱 Fork Strategy

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

Links

ozgb added 4 commits February 17, 2026 16:13
Introduce version-agnostic block handling so the toolkit can replay
blocks from a chain that started on ledger 7 and forked to ledger 8,
building correct context state across the version boundary.

Core changes:

- Add RawBlockData/RawTransaction types that store transactions as raw
  serialized bytes with a spec_version field, deferring deserialization
  until the ledger version is known.
- Add ForkAwareLedgerContext enum wrapping ledger 7/8 LedgerContext,
  with update_from_block() that deserializes using the correct version's
  types and auto-forks via fork_context_7_to_8 when transitioning.
- Remove S, P, D generic parameters from the entire fetch pipeline:
  FetchStorage, ComputeTask, FetchTask, fetch_all now all operate on
  RawBlockData.
- Make SourceTransactions non-generic, holding Vec<RawBlockData> with
  version-aware network_id extraction.
- Replace all inline LedgerContext construction + update_from_block
  loops with a shared build_fork_aware_context helper, used by both
  builders and command files.

Phase 1 assumes the chain always ends at ledger 8 for transaction
building. Pure ledger 7 transaction building is deferred to Phase 2.
…ding

Remove S, P generic parameters from Sender, SendTxs, and TxGenerator by
introducing SerializedTx/BuiltTransactions types that pre-serialize
transactions in the builder. Externalize context building from individual
builders to TxGenerator::build_txs via relevant_wallet_seeds().
- Restructure builders into common/ + version wrappers (ledger_8.rs,
  ledger_7.rs) using ledger_helpers_local module alias for explicit
  version-specific imports
- build_fork_aware_context and build_context_with_cache now return
  Result<_, ContextNotLedger8Error> instead of panicking
- Update all callers to propagate errors with ?
- Delete unused fork_aware_block_data.rs
Builders now dispatch to the correct ledger version at construction time
via Builder::to_versioned_builder(). Cross-version type conversion uses
raw bytes for hash types, bech32 for addresses, and try_from for seeds.
Version-local tx serialization replaces the ledger-8-bound
DeserializedTransactionsWithContext. contract_custom is excluded from
ledger 7 as EncodedOutputInfo only implements ledger 8 BuildOutput.
@github-actions

github-actions Bot commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

kics-logo

KICS version: v2.1.16

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 99
LOW LOW 12
INFO INFO 83
TRACE TRACE 0
TOTAL TOTAL 194
Metric Values
Files scanned placeholder 30
Files parsed placeholder 30
Files failed to scan placeholder 0
Total executed queries placeholder 73
Queries failed to execute placeholder 0
Execution time placeholder 10

Comment thread util/toolkit/test-images.docker-compose.yml
Comment thread util/toolkit/test-images.docker-compose.yml Dismissed
Comment thread util/toolkit/test-images.docker-compose.yml Dismissed
ozgb added 4 commits February 24, 2026 15:07
Pass --build to docker compose up so that locally-built images
(e.g. contract-compiler) are rebuilt when their Dockerfile changes,
preventing stale images from being reused.
local-env uses a different chain network id to the network id encoded
in the ledger transactions - this is non-standard, but the toolkit should
not break because of this.
ozgb added 10 commits February 25, 2026 15:58
…ion support

Move version-dependent logic from command files into fork/common/commands/,
compiled against both ledger_7 and ledger_8 types via the existing #[path]
pattern.

Context-building commands (contract_state, show_wallet, dust_balance,
generate_intent, generate_sample_intent) dispatch based on
ForkAwareLedgerContext::version(). Deserialization commands
(show_transaction, contract_address, get_tx_from_context) use try-both
dispatch: attempt ledger_8 first, fall back to ledger_7.
The top-level fork/ module mixed concerns (commands, builders,
transactions) under a single umbrella. Move version-specific command
implementations into commands/fork/ where they colocate with the
dispatch logic, and consolidate the shared from_serde_tx into the
existing tx_generator builders via a transactions.rs module. The
duplicate fork/builders/ is removed since tx_generator/builder/builders/
already provides the same functionality.
Comment thread ledger/helpers/src/fork/fork_aware_context.rs Outdated
Comment thread util/toolkit/src/commands/contract_state.rs Outdated
Comment thread util/toolkit/src/serde_def/transactions.rs Outdated
Comment thread ledger/helpers/src/fork/raw_block_data.rs Outdated
Comment thread util/toolkit/src/tx_generator/builder/builders/ledger_7.rs
Comment thread util/toolkit/src/fetcher/runtimes.rs Outdated
Comment thread util/toolkit/src/tx_generator/builder/builders/common/replace_initial_tx.rs Outdated
Comment thread util/toolkit/src/serde_def/transactions.rs Outdated

@gilescope gilescope left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good aside from a few nits - love the bonfire of generic args!

ozgb added 3 commits February 26, 2026 17:54
Replace the manual PartialEq/Eq/Ord/PartialOrd impls that only compared
tblock_secs with derived PartialEq/Eq. The single sort call site now
uses sort_by_key instead.
@ozgb ozgb enabled auto-merge February 26, 2026 20:11
ozgb added 2 commits February 26, 2026 20:14
The reusable sbom-scan-image workflow requires attestations:write, but
the caller workflow did not include it in top-level permissions.
@ozgb ozgb added this pull request to the merge queue Feb 26, 2026
Merged via the queue into main with commit fcb3d97 Feb 27, 2026
37 of 39 checks passed
@ozgb ozgb deleted the ozgb-toolkit-hf-support branch February 27, 2026 00:11
gilescope pushed a commit that referenced this pull request Apr 8, 2026
m2ux added a commit that referenced this pull request Apr 23, 2026
Signed-off-by: Mike Clay <mike.clay@shielded.io>
m2ux added a commit that referenced this pull request Apr 23, 2026
Signed-off-by: Mike Clay <mike.clay@shielded.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants