Skip to content

Verify commitment onchain at reveal and validate register inputs - #5

Draft
gskril wants to merge 2 commits into
mainfrom
fix/register-reveal-safety
Draft

Verify commitment onchain at reveal and validate register inputs#5
gskril wants to merge 2 commits into
mainfrom
fix/register-reveal-safety

Conversation

@gskril

@gskril gskril commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixes resolver-drift footgun on reveal: register reveal previously re-resolved default parameters independently of commit (notably the v2 owned-resolver lookup). If a user deployed their resolver between commit and reveal, the commitment hash would no longer match and the onchain register call would revert after they had already paid gas for commit and ERC-20 approval. Commit and reveal now share the same parameter-resolution helpers in src/lib/register.ts.
  • Onchain commitment verification at reveal (v1): Recomputes the commitment via makeCommitment, reads commitments(bytes32) on the controller, and validates min/max commitment age. Fails early with a clear error when no matching commitment exists or timing is wrong. Includes commitment hash and committed-at timestamp in successful output.
  • v2 graceful degradation: Probed the Sepolia v2 registrar (0x8c2E866B439358c41AE05De9cbE8A00BFEFafFcA) — it does not expose commitments / minCommitmentAge / maxCommitmentAge. Reveal still recomputes and outputs the commitment, but skips onchain verification with a warning field.
  • Input validation: --duration must be a positive integer; --secret must be exactly 32 bytes; --value must be a base-10 wei string. --skip-commitment-check preserves offline calldata generation.

Test plan

  • bun run typecheck passes
  • ens register commit sometestname12345.eth --owner 0xd8dA… --json (mainnet v1) produces commit calldata + secret
  • ens register reveal … --secret … --value … without prior onchain commit fails with "No matching commitment found"
  • Same reveal with --skip-commitment-check produces calldata
  • Sepolia v2 commit/reveal pair works; reveal includes recomputed commitment + verification skipped warning
  • --duration 1.5 → validation error; --value abc → validation error

Made with Cursor

gskril and others added 2 commits July 2, 2026 15:22
Co-authored-by: Cursor <cursoragent@cursor.com>
Prevent commit/reveal parameter drift (especially v2 resolver defaults) by
deduplicating parameter resolution and checking v1 commitments onchain before
generating reveal calldata.

Co-authored-by: Cursor <cursoragent@cursor.com>
@pkg-pr-new

pkg-pr-new Bot commented Jul 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/ensdomains/ens-cli/@ensdomains/cli@5

commit: 6349056

@gskril
gskril marked this pull request as draft July 2, 2026 20:42
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