← Back to Pull requests

feat(l1): serialize execution witness with ssz instead of rkyv #6797

Open
unknown opened this pull request with 311 lines diff across 3 files
View on GitHub
unknown unknown commented on Jun 05, 2026 13:33 UTC
Author

Motivation
Replace rkyv encoding of ExecutionWitness and ChainConfig with SSZ. This aligns with the encoding in the stateless specification.

The earlier effort in PR #6524 was left behind because of a major change in PR #6550. This PR builds on top of it.

Description
The major change is the new SszExecutionWitness, which stores RPL-nodes and wraps them in an SSZ container. The difference is that everything is flat bytes as opposed to the previous recursive representation as Node. Decoding in the guest reconstructs the embedded trie.

The new SszChainConfig implements SSZ encoding for ChainConfig. Since libssz does not have support for Option, we introduce SszOptionU64, SszOptionU128, and SszOptionBlobSchedule types with #[ssz(enum_behaviour = "union")].

This PR intentionally keeps RpcExecutionWitness to keep the changes atomic. Currently, we cast from canonical witness to rpc witness and finally to execution witness. We could convert directly to execution witness and get rid of RpcExecutionWitness. I would like to open a discussion if it is necessary to maintain RpcExecutionWitness.

Setting ChainConfig Size
Fixed-size fields: chain_id 8B, dao_fork_support 1B, terminal_total_difficulty_passed1B, deposit_contract_address 20B, enable_verkle_at_genesis 1B, 5x SszForkBlobSchedule 16B
Total: 111B

Variable size have each 1B selector and value (assume worst case): 26x SszOptionU64 each 9B, SszOptionU128 17B, 4x SszOptionBlobScheduleeach 17B
Total: 319B

Offsets for variable size types are 4B each, so 31x 4B = 124B. Total space required is 554B, so 1024 is enough, and we keep some buffer.

Profiling
Profiling in ZisK v0.16.1 on mainnet blocks 24949787 - 24949811:

  • Average cost (main 37669b7c3): 45.17852B

  • Average cost (this change): 57.15699B
  • This is ~20% regression. The flat SSZ encoding requires the guest to rebuild the tree as opposed to rkyv, which serialized the tree structure directly. To my understanding, this is inherent in the encoding choice of the specification. This PR is meant to be a transition towards the specification, and further optimizations should be introduced.

    Diff: 311 lines (+233 / -78) across 3 files Reviewer: benbencik Review duration: 245189m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.47) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 311 lines diff across 3 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.344
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #6797"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.3% (MEDIUM) · Higher = larger blast radius
    47.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.2% · Safe to merge
    26.2%