Skip to content

chore(cli): fix commitment to new issue #33

Merged
sphamjoli merged 2 commits intomainfrom
spha/commitment-issue
Mar 25, 2026
Merged

chore(cli): fix commitment to new issue #33
sphamjoli merged 2 commits intomainfrom
spha/commitment-issue

Conversation

@sphamjoli
Copy link
Copy Markdown
Member

@sphamjoli sphamjoli commented Mar 17, 2026

Description

Replace the hardcoded 6-second wall-clock wait after commitment submission with on-chain polling verification. After the initial wait (minCommitmentAge + buffer), the CLI now reads the commitments(hash) contract function to confirm the chain timestamp has actually advanced past the minimum age before attempting registration. The buffer is configurable via --commitment-buffer / --cb flag or DOTNS_COMMITMENT_BUFFER env variable (defaults to 6 seconds).

Type

  • Bug fix
  • Feature
  • Breaking change
  • Documentation
  • Chore

Package

  • @dotns/cli
  • Root/monorepo
  • Documentation

Related Issues

Fixes

https://github.com/paritytech/dotns/issues/38

Checklist

Code

  • Follows project style
  • bun run lint passes
  • bun run format passes
  • bun run typecheck passes

Documentation

  • README updated if needed
  • Types updated if needed

Breaking Changes

  • No breaking changes
  • Breaking changes documented below

Breaking changes:

Testing

How to test:

  1. bun test packages/cli/tests/unit/register/registerHelp.test.ts - 22 unit tests for help text, option parsing, commitment buffer defaults, and env variable override
  2. dotns register domain --name testname123 -k //Alice - full registration should complete without CommitmentTooNew
  3. dotns register domain --name testname456 -k //Alice --cb 12 - verify custom buffer is applied (spinner shows longer wait)
  4. DOTNS_COMMITMENT_BUFFER=15 dotns register domain --name testname789 -k //Alice - verify env variable override
  5. dotns register domain --help - verify --commitment-buffer and DOTNS_COMMITMENT_BUFFER appear in help output

Notes

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 17, 2026

CI Summary

Check Result
Lint Passed
Format Passed
Typecheck Passed
Build Passed
Test Passed
Release Passed
Deploy Example Failed
PR Title Passed
Labels Passed

Release - Passed

Test this PR

Download artifact (GitHub CLI required):

gh run download 23412528320 -n cli-preview-0.0.0-pr.33 -R paritytech/dotns-sdk

Install globally:

Package Manager Command
npm npm install -g ./dotns-cli-0.0.0-pr.33.tgz
yarn yarn global add ./dotns-cli-0.0.0-pr.33.tgz
bun (macOS/Linux) bun add -g "$(pwd)/dotns-cli-0.0.0-pr.33.tgz"
bun (Windows) bun add -g "$PWD\dotns-cli-0.0.0-pr.33.tgz"

Verify:

dotns --help
Deploy Example — Failed

Failed at: Deploy — Deploy workflow failed — see run logs for upload/register/contenthash details

Stage Status
✓ Site validation Site validated
✗ Deploy Deploy workflow failed — see run logs for upload/register/contenthash details

View run

Labels

pkg: cli, type: test

@sphamjoli sphamjoli changed the title bug: fix commitment to new issue bug(cli): fix commitment to new issue Mar 17, 2026
@sphamjoli sphamjoli changed the title bug(cli): fix commitment to new issue chore(cli): fix commitment to new issue Mar 17, 2026
? Number(currentCommitTimestamp)
: currentCommitTimestamp;

const nowOnChain = Math.floor(Date.now() / 1000);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this called nowOnChain when it is just the wall time and not a current timestamp from onchain?

export const OPERATION_TIMEOUT_MILLISECONDS = 300_000;

export function getCommitmentBufferSeconds(): number {
return Number(process.env.DOTNS_COMMITMENT_BUFFER ?? 6);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get NaNs here which might cause some weirdness

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No quite see ?? @andrew-ifrita

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user inputs "nonsense" it becomes Number("nonesense") => NaN which will get passed into something later and break with potentially hard to track errors

merged.__statusProvided = allOpts?.status != null;

if (allOpts?.commitmentBuffer != null) {
process.env[ENV.COMMITMENT_BUFFER] = String(allOpts.commitmentBuffer);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit weird tbh. Can't we just pass the options around instead of using ENV as a sidechannel? Doing this with env may introduce some hard to replicate bugs and also isn't fantastic for readability/understandability of the code when only looking at an isolated segment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-ifrita I see, your perspective we have that already do you suggest we remove setting this in an ENV?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. It is fine to read the settings from ENV, but then we should just pass the settings object around. We shouldn't set an ENV just to read it later.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-ifrita whats the final verdict here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read from ENV but don't write to ENV and use it as a side channel

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sphamjoli sphamjoli requested a review from andrew-ifrita March 17, 2026 12:39
@sphamjoli sphamjoli merged commit e2c82ce into main Mar 25, 2026
11 of 12 checks passed
@sphamjoli sphamjoli deleted the spha/commitment-issue branch March 25, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants