Skip to content

feat(ethclspecs): make the builder pending-balance sums throw-faithful - #110

Open
IvanAnishchuk wants to merge 4 commits into
feat/fulu-churn-faithfulnessfrom
feat/gloas-builder-pending-balance-faithfulness
Open

IvanAnishchuk wants to merge 4 commits into
feat/fulu-churn-faithfulnessfrom
feat/gloas-builder-pending-balance-faithfulness

Conversation

@IvanAnishchuk

@IvanAnishchuk IvanAnishchuk commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

get_pending_balance_to_withdraw_for_builder adds uint64 amounts into one balance with +=, first the pending withdrawals and then the pending payments, so the SSZ backend raises ValueError past 2^64 - 1. can_builder_cover_bid adds MIN_DEPOSIT_AMOUNT to that total, which can raise the same way. The Lean folds and the addition wrapped. They are now checked and reject with .arithmetic.

Stacked on #105. Next in the stack: #134.

What changed

EthCLSpecs

  • getPendingBalanceToWithdrawForBuilder returns Except. It folds one accumulator through checkedAdd, over the withdrawals and then over the payments.
  • canBuilderCoverBid returns Except and checks its addition. processExecutionPayloadBid binds it inside its assert.
  • processBuilderExitRequest binds the pending balance only after the active and address checks. The spec returns early at each check, so it computes the sum only there.
  • Proofs/Gloas/PendingBalanceForBuilder.lean: below 2^64 the result is the exact Nat total. At 2^64 or more the function rejects with .arithmetic, at the first step that passes the bound.
  • Proofs/Gloas/CanBuilderCoverBid.lean: the existing characterization takes the successful pending balance and the in-range addition as hypotheses. Two new theorems give the two faults.
  • Ledger rows, plus the regenerated coverage files.

Test plan

  • lake build (full monorepo, on the pinned toolchain) is green.
  • Per-package test suites pass:
    • lake build LeanSha256Tests
    • lake build SizzLeanTests
    • just ethcl-test
  • If this touches spec types or cache behaviour:
    just ethcl-pyspec is green.
  • If this touches a bench-measured hot path: included
    before/after lake exe ssz_bench TSV (or relevant rows) in
    the PR description.
  • New SSZ shapes / cache cases come with a native_decide or
    property test that exercises them.

Risk / trust footprint

None.

LICENSE (LGPL version 3)

  • I have read and accepted LICENSE (LGPL version 3), NOTICE and CLA in the root of this project.

@IvanAnishchuk
IvanAnishchuk force-pushed the feat/gloas-builder-pending-balance-faithfulness branch from 7e0890a to 211de3a Compare September 28, 2026 04:48
@IvanAnishchuk
IvanAnishchuk marked this pull request as ready for review September 28, 2026 04:48
@IvanAnishchuk
IvanAnishchuk force-pushed the feat/gloas-builder-pending-balance-faithfulness branch from 211de3a to 0f101e1 Compare October 16, 2026 04:42
@IvanAnishchuk
IvanAnishchuk force-pushed the feat/gloas-builder-pending-balance-faithfulness branch from 0f101e1 to 0f271c4 Compare October 25, 2026 19:52
@IvanAnishchuk
IvanAnishchuk changed the base branch from main to feat/fulu-churn-faithfulness October 25, 2026 19:52
@IvanAnishchuk
IvanAnishchuk force-pushed the feat/gloas-builder-pending-balance-faithfulness branch from 0f271c4 to caa5cbf Compare November 18, 2026 14:21
@IvanAnishchuk
IvanAnishchuk force-pushed the feat/fulu-churn-faithfulness branch from fa52ff0 to 98b4d33 Compare November 18, 2026 14:21
`get_pending_balance_to_withdraw_for_builder` accumulates one `balance` with
`+=` over `uint64` amounts, first the pending withdrawals and then the pending
payments, so the SSZ backend raises a `ValueError` past 2^64 - 1.
`can_builder_cover_bid` then adds `MIN_DEPOSIT_AMOUNT` to that total, which
can raise the same way. The Lean folds and the addition wrapped.

`getPendingBalanceToWithdrawForBuilder` now returns `Except`. It folds one
accumulator through `checkedAdd`, over the withdrawals and then over the
payments. `canBuilderCoverBid` returns `Except` and checks its addition too.
`processBuilderExitRequest` binds the pending balance only after the active
and address checks, which is where the spec's early returns compute it.

The `canBuilderCoverBid` theorems take the successful pending balance and
the in-range addition as hypotheses. Two new theorems give the two faults.
When the natural-number totals of the pending withdrawals and the queued
payments for a builder add to less than 2^64, the function returns that
exact total. At 2^64 or more it rejects with `.arithmetic`, at the first
step that passes the bound, in the withdrawals loop or in the payments
loop. Two private lemmas carry the induction over a checked, filtered
fold from any start value.
The `getPendingBalanceToWithdrawForBuilder` row moves from proposed to
proved. The `canBuilderCoverBid` row states the new hypotheses and the two
faults.
@IvanAnishchuk
IvanAnishchuk force-pushed the feat/fulu-churn-faithfulness branch from 98b4d33 to 73b057e Compare November 21, 2026 07:32
@IvanAnishchuk
IvanAnishchuk force-pushed the feat/gloas-builder-pending-balance-faithfulness branch from caa5cbf to 2a71a57 Compare November 21, 2026 07:32
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.

1 participant