Repository navigation
Conversation
|
Is this ready for review? @Marchhill PS: Also, we recently merged the |
gurukamath
left a comment
There was a problem hiding this comment.
Partial review of the spec changes. Will do a deeper review later
…t with proof frames Implement PROOF frames per ethereum/EIPs#12714: leading proof frames prove claims with a verifier called in the pure context, the canonical signature hash elides their proofs, and the SECP256K1, P256 and leanSPHINCS verifier precompiles (placeholder addresses 0x81a1-0x81a3) replace the signature schemes. Add PROOFPARAM, the PROOF_COMMIT and PROOF_READ flags, the readable-proof rule for FRAMEDATALOAD and FRAMEDATACOPY, and the default code's proof_index. Move the test types and the existing EIP-8141 tests onto proof frames: a sender holding a key gets a leading proof frame by default.
Cover the proof frame static constraints, each verifier precompile with valid and invalid proofs and its gas edges, contract verifiers (cold access, empty and delegated targets, calldata), every instruction the pure context bans, the canonical signature hash with committed and uncommitted proofs, readable proofs, PROOFPARAM, FRAMEPARAM of proof frames, the default code's proof_index, and receipts charging each proof frame its full budget.
Re-port `ethereum.crypto.lean_sphincs` from the Cryptography/Sphincs module of ethereum/EthLib at f0e41b61, which EIP-8141 names as the normative scheme, in place of leanVM's crate. Each section follows one EthLib module (Constants, Types, Address, TweakableHash, Encoding, Ots, Tree, Fors, Digest, Verify, Serialization) with its names, and verification takes a decoded public key and signature. Add EthLib's KeyGen and Sign to the testing package with a `LeanSphincsSigner`, so proof frames can carry leanSPHINCS signatures over the canonical signature hash. Vendor all 35 EthLib sphincs vectors, rebuilt and checked against EthLib's SHA256SUMS: key generation, signing and verification reproduce every one byte for byte.
Replace the pure-Python leanSPHINCS port with a thin wrapper around py-lean-pq 0.11.1, leanVM's bindings (leanVM 28368657, after its FIPS 205 layout at 5e3ade21), and pin the scheme in the docstring to EthLib's Cryptography/Sphincs at f0e41b61, as EIP-8141 does. Sign in the testing framework with a `LeanSphincsKey` grown from a 32-byte seed, which proof frames take as a signer, and drop the pure-Python signer, the vendored vectors and the precomputed signature JSON. One test checks the key against EthLib's known answer through EthLib's SHA256SUMS.
`resolve_frames` treated a proof frame whose empty target resolves to the sender as warm. A proof frame's own access sets hold only the precompiles, so its entry access charge for the sender is cold.
Port the account scenarios of the signature-list draft onto proof frames, parametrized over the secp256k1, P-256 and leanSPHINCS verifier precompiles and a contract verifier: counterfactual deployment with `[proof, deploy, self_verify]`, self-paid or sponsored; rejection of another key's claim and of the owner's key under an accept-all verifier; EIP-1271-style attestations read with PROOFPARAM; and an EOA migrated with an EIP-7702 delegation. Add the uncovered rules: a proof frame with an empty target runs the sender as its verifier, charged cold, with PROOFPARAM reporting it; and a readable proof stays readable from a call a VERIFY frame makes.
Raise the halt after the instruction's OpStart trace, so it is attributed to the instruction, and use a dedicated ExceptionalHalt for both a banned instruction and a STATICCALL to a non-precompile.
An instruction a later EIP introduces then halts in the pure context unless that EIP admits it, as EIP-8141 requires.
…kage Give each verifier precompile a module with a Markdown docstring, and drop the RST contents block from the leanSPHINCS module's docstring.
e96626d to
1b44a7a
Compare
|
core implementation looks solid and matches a few blockers and test bugs to fix before merge:
|
…nputs The with_all_precompiles suites called the verifier precompiles with empty or zeroed input, which halts them. Sign a valid claim for each through proof_verifier_input, and list the verifiers among the precompiles that reject empty input.
… the BAL The frame_tx rewrite proves the sender in a proof frame that calls the secp256k1 verifier, which EIP-7928 records. Turn an expected absence of that verifier into an expected read, rather than leaving each test to work around it.
…t calls A P-256 variant replacing the public key now names the new key in its claim, so the coordinate range, infinity and on-curve checks are reached instead of the key mismatch. Add the r and s boundaries on both curves, including a valid signature with s = N // 2 and an r with no curve point. Cover CALL, CALLCODE and DELEGATECALL to an active precompile, STATICCALL to unassigned precompile-range addresses and to an account delegated to a precompile, and the EIP-8024 stack instructions and RETURNDATACOPY.
Expect each verifier precompile, a contract verifier, and a precompile the contract verifier STATICCALLs in the block access list, alongside the existing absence of ecrecover and P256VERIFY.
Pin from a contract, in a plain and a frame transaction, that a call consumes exactly the verifier's cost and returns the word 1, that one short of the cost or an invalid proof burns the call's gas and returns nothing, and that a zero msg is verified literally.
…ATA reads With no proof frame, TXPARAM counts zero and PROOFPARAM on frame 0 halts. A VERIFY frame reading a readable proof gets the key at offset 0 and zero-padded words past the data's end.
…NATURE Proof frames replaced the signature list: a proof that does not hold invalidates execution and a malformed one is a format failure, so no fixture expects a signature exception any more.
…es and claim length once Tie the verifier precompile costs and the proof frame entry charge that Frame.proof budgets to the fork's gas costs with a unit test.
A zero msg on the wire stands for the canonical signature hash, so a proof over the zero digest could never hold.
A zero msg with a proof over the zero digest, and an explicit msg with a proof over the canonical signature hash, must both fail the claim.
Derive the admitted side from fork.valid_opcodes() so that refusing any admitted instruction fails the fill, and halt LOG1-LOG4 as well as LOG0.
|
@Marchhill The proposal spec has moved towards protocol verifiers instead of precompiles and |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## forks/bogota #4108 +/- ##
================================================
+ Coverage 95.31% 95.40% +0.08%
================================================
Files 677 682 +5
Lines 41907 41992 +85
Branches 3939 3945 +6
================================================
+ Hits 39944 40061 +117
+ Misses 1370 1354 -16
+ Partials 593 577 -16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bt-recneps
left a comment
There was a problem hiding this comment.
Ran five spec mutants against the 8141 suite: proof_index shape, FRAMEPARAM gating, access sets, the cap and legacy v all survive :(
Reviewed in 1h 02m
| case "index_past_proofs": | ||
| data = b"\x02" |
There was a problem hiding this comment.
index_past_proofs names the one-byte VERIFY frame, which never matches the claim, so default code that skips the proof-mode check on proof_index still passes.
| case "index_past_proofs": | |
| data = b"\x02" | |
| case "index_past_proofs": | |
| own = Frame.default( | |
| target=Spec.SECP256K1_VERIFIER, | |
| data=bytes(sender).rjust(32, b"\x00") + bytes(32), | |
| ) | |
| data = b"\x01" |
| verifier, proof=b"\x01" * 10, gas_limit=50_000, read=True | ||
| ) | ||
| params = { | ||
| Spec.FRAMEPARAM_RESOLVED_TARGET: verifier, | ||
| Spec.FRAMEPARAM_EXECUTION_GAS_LIMIT: 50_000, | ||
| Spec.FRAMEPARAM_MODE: int(Spec.MODE_PROOF), | ||
| Spec.FRAMEPARAM_FLAGS: int(Spec.PROOF_READ_FLAG), |
There was a problem hiding this comment.
The only FRAMEPARAM read of a proof frame sets PROOF_READ_FLAG, so a client that gates FRAMEPARAM behind that flag still passes, though the EIP lets every frame read it.
| verifier, proof=b"\x01" * 10, gas_limit=50_000, read=True | |
| ) | |
| params = { | |
| Spec.FRAMEPARAM_RESOLVED_TARGET: verifier, | |
| Spec.FRAMEPARAM_EXECUTION_GAS_LIMIT: 50_000, | |
| Spec.FRAMEPARAM_MODE: int(Spec.MODE_PROOF), | |
| Spec.FRAMEPARAM_FLAGS: int(Spec.PROOF_READ_FLAG), | |
| verifier, proof=b"\x01" * 10, gas_limit=50_000, commit=True | |
| ) | |
| params = { | |
| Spec.FRAMEPARAM_RESOLVED_TARGET: verifier, | |
| Spec.FRAMEPARAM_EXECUTION_GAS_LIMIT: 50_000, | |
| Spec.FRAMEPARAM_MODE: int(Spec.MODE_PROOF), | |
| Spec.FRAMEPARAM_FLAGS: int(Spec.PROOF_COMMIT_FLAG), |
| sender = pre.deploy_contract(account_code(owner), balance=10**18) | ||
| target = pre.deploy_contract(BODY_CODE) | ||
| if forger == "other_key": | ||
| proof = make_owner(scheme, pre, 2).proof() |
There was a problem hiding this comment.
For scheme_contract, make_owner(scheme, pre, 2) deploys a second verifier, so the account rejects on the verifier and the key check this case names is never reached.
| proof = make_owner(scheme, pre, 2).proof() | |
| other = make_owner(scheme, pre, 2).signer | |
| proof = Owner(other, owner.verifier).proof() |
| case "v_2": | ||
| proof = tampered_secp256k1(proof, v=2) | ||
| case "v_27": | ||
| proof = tampered_secp256k1(proof, v=27) |
There was a problem hiding this comment.
With this signer, v = 27 maps to the other recovery id and fails on the key, so a verifier that accepts legacy v values of 27 and 28 still passes.
| proof = tampered_secp256k1(proof, v=27) | |
| proof = tampered_secp256k1(proof, v=27 + proof[0]) |
| address = pre.fund_eoa(amount=0, delegation=Address(0x04)) | ||
| case _: | ||
| raise ValueError(callee) | ||
| code = Op.POP(Op.STATICCALL(gas=50_000, address=address)) + Op.STOP |
There was a problem hiding this comment.
No test pins the warm charge of a contract verifier's STATICCALL to a precompile, so add exact and one-short budget cases next to test_pure_context_staticcall.
| # The gas boundary tests use a contract sender: contract senders carry | ||
| # no signature entries, so the transaction's intrinsic cost reduces to | ||
| # no proof frames, so the transaction's intrinsic cost reduces to | ||
| # the base and per-frame constants plus its data tokens, keeping the | ||
| # boundary arithmetic exact and content-independent. |
There was a problem hiding this comment.
The EIP-7825 cap tests use only proof-less contract senders, so add at-cap and above-cap cases whose excess comes from a proof frame's limits.execution.
|
CIFO #4123 |
Description
Implements EIP-8141 PROOF frames (
ethereum/EIPs#12714at9c7074e01b), replacing the signature list, with tests.Spec:
PROOFmode 4 withPROOF_COMMIT_FLAG(0x8) andPROOF_READ_FLAG(0x10), and the static constraints: proof frames lead, no state gas, a 64-byte claim with a nonzero key, and a committed proof names an explicitmsg.STATICCALLonly to active precompiles, a 7702 delegation halts, its own EIP-2929 access sets, and the fulllimits.executioncharged.0x81a1/0x81a2/0x81a3: SECP256K1 (3000), P256 (6900), LEANSPHINCS (13200).PROOFPARAM(0xb4),TXPARAM_PROOF_COUNT, the readable-proof rule forFRAMEDATALOAD/FRAMEDATACOPY, the default code'sproof_index, the proof elision incompute_sig_hash, and proofs priced by length.Tests:
Frame.proof(...); a sender holding a key gets a leading proof frame, and default-codeVERIFYframes point at it. The existing EIP-8141 tests move onto proof frames.PROOFPARAM/FRAMEPARAM, and receipts.[proof, deploy, self_verify]deployment, self-paid or sponsored; rejection of another key's claim and of the owner's key under an accept-all verifier; EIP-1271-style attestations read withPROOFPARAM; an EOA migrated with a 7702 delegation.LeanSphincsKeysigns proof frames withpy-lean-pq.Notes:
Cryptography/Sphincsatf0e41b61, as the EIP pins it.ethereum.crypto.lean_sphincsverifies throughpy-lean-pq0.19.2 (built from leanVM'sbindings/atbindings-v0.19.2,17cb5cc6), which reproduces all 35 of EthLib's sphincs vectors; a unit test checks EthLib's known answer.fillpasses for the EIP-8141 suite (1906 fixtures).NethermindEth/nethermind#16461passes all of them (state, blockchain and engine), leanSPHINCS included.Checklist
just static<type>(<area>): <description>, where<type>and<area>come from an appropriateC-<type>, respectivelyA-<area>, label. The title should match the target squash commit message.