Skip to content

feat!(ssz): finish ASM serialization migration#8

Merged
prajwolrg merged 21 commits intomainfrom
STR-1912
Mar 25, 2026
Merged

feat!(ssz): finish ASM serialization migration#8
prajwolrg merged 21 commits intomainfrom
STR-1912

Conversation

@storopoli
Copy link
Copy Markdown
Member

@storopoli storopoli commented Mar 17, 2026

Summary

This PR finishes the remaining ASM-side SSZ migration work and updates the pinned alpen dependency to the helper commit needed to complete it.

It does these things:

  • bumps moho to the non-Borsh SSZ version
  • bumps alpen/typed-sled for the SSZ + rkyv-compatible dependency set
  • converts the remaining ASM-local payloads, messages, and subprotocol state from Borsh-first encodings to native SSZ
  • replaces the last direct ASM calls to legacy Borsh decoding in the checkpoint-v0 path with helper APIs exposed from alpen
  • removes stale Borsh-based decoding in the runner and drops now-unused Borsh dependencies from migrated crates

Remaining Borsh

This branch no longer uses Borsh directly for ASM-local bridge/admin/checkpoint payloads, messages, or state.

The only remaining Borsh in this repo is compatibility glue for:

  • AnchorState
  • AuxData
  • ASM manifest/log wrapper types

Those shims still exist because the current alpen storage/state layer still uses Borsh-backed DB codecs for ASM values. Removing them entirely requires a follow-up in alpen storage/state rather than more local ASM migration.

Dependency Note

This PR now pins alpen to commit ee8ab446f26ee451e2f7b878b4acad3f95c3339d from refactor/ssz-asm, which adds the helper APIs needed for:

  • raw RawBitcoinTx byte access
  • legacy SignedCheckpoint / Checkpoint decoding
  • legacy checkpoint proof output decoding
  • legacy Chainstate decoding

Notes To Reviewers

Reviewing commit-by-commit is still the easiest path through this PR. The key milestones are:

  • af2804b bumps moho to the non-Borsh SSZ version
  • a32d2c3 bumps alpen and typed-sled for the current serialization stack
  • a872b3b finishes the main ASM serialization migration
  • 464fc53 pins alpen to the helper follow-up needed for legacy decode paths
  • 6fb53c3 removes the remaining ASM-local Borsh usage and switches the legacy checkpoint-v0 callers to Alpen helpers

Validation

I verified that the current branch passes:

  • cargo fmt --all
  • cargo check

Type Of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature/Enhancement (non-breaking change which adds functionality or enhances an existing one)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor
  • New or updated tests
  • Dependency update
  • Security fix

Checklist

  • I have performed a self-review of my code.
  • I have commented my code where necessary.
  • I have updated the documentation if needed.
  • My changes do not introduce new warnings.
  • I have added tests that prove my changes are effective or that my feature works.
  • New and existing tests pass with my changes.

Related Issues

STR-1912

Copy link
Copy Markdown
Collaborator

@prajwolrg prajwolrg left a comment

Choose a reason for hiding this comment

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

In a lot of places we are making borsh the canonical encoding and SSZ just a wrapper for borsh. The goal should be to make SSZ the canonical encoding.

Also in SSZ schemas, we are missing out on the existing docstrings. It is be helpful to add them.

Comment thread crates/common/src/aux/data.rs Outdated
Comment thread crates/common/src/aux/data.rs
Comment thread crates/common/ssz/pow.ssz
Comment thread crates/logs/src/asm_stf.rs Outdated
Comment thread crates/logs/src/checkpoint.rs Outdated
Comment thread crates/proof/statements/src/moho_program/program.rs Outdated
Comment thread crates/subprotocols/admin/src/state.rs Outdated
Comment thread crates/subprotocols/checkpoint-v0/src/types.rs Outdated
Comment thread crates/subprotocols/checkpoint/src/state.rs Outdated
Comment thread crates/txs/admin/src/parser.rs Outdated
@prajwolrg
Copy link
Copy Markdown
Collaborator

prajwolrg commented Mar 18, 2026

In a lot of places we are making borsh the canonical encoding and SSZ just a wrapper for borsh. The goal should be to make SSZ the canonical encoding.

I realized that we had to do it this way because a lot of the types are defined outside of this repo. In that case, we'd first need to update the existing types in Alpen to be SSZ compatible.

@storopoli
Copy link
Copy Markdown
Member Author

Moving to draft since it needs alpenlabs/alpen#1513

@storopoli storopoli marked this pull request as draft March 18, 2026 19:59
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 19, 2026

Commit: e6de5f9
SP1 Execution Results

program cycles success
ASM STF 917,801,070 yes

@storopoli storopoli marked this pull request as ready for review March 20, 2026 11:11
@storopoli
Copy link
Copy Markdown
Member Author

Ok I think this is ready @prajwolrg

Comment thread crates/common/src/aux/data.rs Outdated
Comment thread crates/common/src/aux/data.rs
Comment thread crates/msgs/checkpoint/src/lib.rs Outdated
Comment thread crates/params/src/subprotocols/admin.rs Outdated
Comment thread crates/params/src/subprotocols/admin.rs Outdated
Collapse mirror SSZ wrapper types into the primary protocol-owned message and state structs so SSZ is the visible canonical encoding. Keep only field-level adapters for upstream or legacy payloads that cannot be made SSZ-native inside this repo.
Replace the handwritten Borsh-through-SSZ implementations on ASM common types with the shared compatibility macro and document that SSZ remains canonical. This keeps downstream compatibility without implying that Borsh owns the wire format.
Switch the ASM proof commitment to the SSZ tree root and make repeated block decoding explicit in the Moho input helpers. Restore the missing SSZ schema docstrings so the proof-side state representation stays documented alongside the new commitment semantics.
Replace the manual SSZ implementation for `Role` with a derived tag enum so the admin parameter types stay consistently derive-first. This closes out the remaining direct-derive review feedback in the admin params module.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 70.42062% with 218 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/msgs/bridge/src/lib.rs 13.43% 58 Missing ⚠️
crates/params/src/subprotocols/admin.rs 0.00% 24 Missing ⚠️
crates/common/src/aux/data.rs 70.49% 18 Missing ⚠️
crates/subprotocols/checkpoint-v0/src/types.rs 81.33% 14 Missing ⚠️
crates/common/src/state.rs 89.09% 12 Missing ⚠️
crates/logs/src/asm_stf.rs 0.00% 10 Missing ⚠️
crates/subprotocols/checkpoint/src/state.rs 73.68% 10 Missing ⚠️
...tes/subprotocols/bridge-v1/src/state/assignment.rs 76.66% 7 Missing ⚠️
crates/subprotocols/bridge-v1/src/state/bitmap.rs 77.41% 7 Missing ⚠️
crates/subprotocols/bridge-v1/src/state/deposit.rs 73.07% 7 Missing ⚠️
... and 23 more
Files with missing lines Coverage Δ
bin/asm-runner/src/rpc_server.rs 87.50% <100.00%> (ø)
crates/btc-verification/src/header_verification.rs 98.23% <100.00%> (+0.13%) ⬆️
crates/btc-verification/src/timestamp_store.rs 91.56% <100.00%> (+0.89%) ⬆️
crates/btc-verification/src/work.rs 84.61% <100.00%> (+4.61%) ⬆️
crates/common/src/aux/provider.rs 95.87% <100.00%> (ø)
crates/common/src/mmr.rs 87.09% <100.00%> (+0.43%) ⬆️
crates/common/src/msg.rs 86.04% <ø> (+8.15%) ⬆️
crates/common/src/subprotocol.rs 100.00% <ø> (ø)
crates/logs/src/export.rs 50.00% <100.00%> (ø)
...rates/proof/statements/src/moho_program/program.rs 78.04% <100.00%> (+1.12%) ⬆️
... and 45 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@storopoli
Copy link
Copy Markdown
Member Author

@prajwolrg rebased take a look please.

@prajwolrg prajwolrg enabled auto-merge March 25, 2026 02:03
@prajwolrg prajwolrg added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit fd57abb Mar 25, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants