Skip to content

fix(envelope): split abi.encode to avoid viaIR, add deploy+verify scripts#117

Merged
aliXsed merged 1 commit into
mainfrom
aliX/envelope-deploy-verify
May 22, 2026
Merged

fix(envelope): split abi.encode to avoid viaIR, add deploy+verify scripts#117
aliXsed merged 1 commit into
mainfrom
aliX/envelope-deploy-verify

Conversation

@aliXsed
Copy link
Copy Markdown
Collaborator

@aliXsed aliXsed commented May 22, 2026

Summary

Fixes ZkSync source verification for EnvelopeLinks by eliminating the need for viaIR compilation, and adds reproducible deploy+verify scripts.

Problem

EnvelopeLinks._feeAuthorizationDigest had 15 parameters in a single abi.encode() call, exceeding solc's stack limit without viaIR. The ZkSync verifier cannot handle viaIR contracts:

  • zksolc ≤1.5.1: ignores viaIR flag → stack-too-deep error
  • zksolc ≥1.5.13: passes viaIR through → internal error (verifier crashes)

Solution

Split the abi.encode into two parts joined by abi.encodePacked:

// abi.encodePacked(abi.encode(a..h), abi.encode(i..n)) == abi.encode(a..n)
// because abi.encode pads each value to 32 bytes

This produces byte-identical output and preserves EIP-712 signature compatibility while compiling without viaIR.

Changes

File Change
src/envelope/EnvelopeLinks.sol Split _feeAuthorizationDigest abi.encode (8+7 params)
ops/verify_hardhat_zksync.py New: verification script for Hardhat builds (BFS imports, filtered standard JSON, API submission)
ops/deploy_envelope_zksync.sh New: one-command Hardhat deploy + verify workflow
hardhat-deploy/DeployEnvelope.ts Auto-select .env-prod on mainnet
src/envelope/doc/EnvelopeLinks.md Document fee-on-transfer token restriction
.github/copilot-instructions.md Document Hardhat path, split trick, and verification workflow

Deployed & Verified (ZkSync Era Mainnet)

Contract Address Status
EnvelopeLinks 0xff735c70f33ca4eF1768F527B5f230b76A61A89b ✅ Fully verified
EnvelopePaymaster 0x5396e4F349D863C0AD577bd9E752293524460C36 ✅ Fully verified

Paymaster is not funded — will be funded separately after review.

Testing

  • All 8 EnvelopeLinks unit tests pass
  • All 19 EIP712 tests pass (18 pass, 1 pre-existing fuzz issue unrelated to this change)
  • All 7 integration tests pass
  • yarn spellcheck: 0 issues

…ipts

EnvelopeLinks._feeAuthorizationDigest had 15 parameters in a single
abi.encode() call, which exceeds solc's stack limit without viaIR.
The ZkSync verifier cannot handle viaIR contracts (crashes with
'internal error' on zksolc >=1.5.13, ignores viaIR on <=1.5.1).

Fix: split into abi.encodePacked(abi.encode(8), abi.encode(7)) which
produces byte-identical output (abi.encode pads to 32 bytes) and
compiles without viaIR.

Also adds:
- ops/verify_hardhat_zksync.py: verification script for Hardhat builds
  (BFS import graph, filtered standard JSON, API submission)
- ops/deploy_envelope_zksync.sh: one-command deploy+verify workflow
- hardhat-deploy/DeployEnvelope.ts: auto-select .env-prod on mainnet
- .github/copilot-instructions.md: document Hardhat path and split trick

Deployed & verified on ZkSync Era mainnet:
- EnvelopeLinks: 0xff735c70f33ca4eF1768F527B5f230b76A61A89b
- EnvelopePaymaster: 0x5396e4F349D863C0AD577bd9E752293524460C36
@github-actions
Copy link
Copy Markdown

LCOV of commit fee57f3 during checks #713

Summary coverage rate:
  lines......: 25.7% (771 of 3001 lines)
  functions..: 22.3% (105 of 470 functions)
  branches...: 27.5% (140 of 509 branches)

Files changed coverage rate:
                                                  |Lines       |Functions  |Branches    
  Filename                                        |Rate     Num|Rate    Num|Rate     Num
  ======================================================================================
  src/envelope/EnvelopeLinks.sol                  | 0.0%    355| 0.0%    53| 0.0%     96

@aliXsed aliXsed merged commit 5f63dd6 into main May 22, 2026
3 checks passed
@aliXsed aliXsed deleted the aliX/envelope-deploy-verify branch May 22, 2026 01:14
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