Skip to content

feat(transaction): default generation to unix millis, allow override#71

Merged
0xtristan merged 1 commit into
mainfrom
feat/generation-override
May 14, 2026
Merged

feat(transaction): default generation to unix millis, allow override#71
0xtristan merged 1 commit into
mainfrom
feat/generation-override

Conversation

@0xtristan
Copy link
Copy Markdown
Contributor

@0xtristan 0xtristan commented May 14, 2026

Summary

  • Reverts the microsecond default from fix(transaction): use microseconds for UniquenessData::Generation, not milliseconds #65; milliseconds are now the default, giving a ~5-second deduplication window with the sequencer's 5000-generation window
  • Both UnsignedTransaction::builder() and Transaction::builder() accept an optional generation: u64 — omit it for the millis default, or pass any value (micros, a counter, a fixed test value)
  • WASM builder exposes the same via .generation(bigint)

Rationale

With a 5000-generation window, microseconds gives a ~5ms deduplication window (too tight); milliseconds gives ~5s (practical). If the sequencer ever requires micros again, callers can pass duration.as_micros() as u64 / BigInt(Date.now()) * 1000n explicitly.

Test plan

  • just check / just lint / just test (72/72 pass)

🤖 Generated with Claude Code


Summary by cubic

Default uniqueness generation now uses unix milliseconds, giving a ~5s deduplication window with the sequencer’s 5000-generation window. Added an optional override so callers can supply any generation value when needed.

  • New Features
    • Rust: UnsignedTransaction::builder() and Transaction::builder() accept generation: u64 (optional). Omit to use current unix ms.
    • WASM: Added .generation(bigint) to override the default. README updated with an example.

Written for commit 5cedebd. Summary will update on new commits.

Reverts the micros default from #65 and instead defaults to unix
milliseconds (giving a ~5s deduplication window with the sequencer's
5000-generation window). Both `UnsignedTransaction::builder()` and
`Transaction::builder()` now accept an optional `generation: u64` for
callers that need a different value (e.g. micros, a counter, or a
fixed value for tests). The WASM builder exposes the same via
`.generation(bigint)`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="wasm/README.md">

<violation number="1" location="wasm/README.md:119">
P2: The example is missing `await` before the builder chain, so `tx` is a `Promise` instead of the resolved result from `send(client)`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread wasm/README.md
value — for example a microsecond timestamp for a ~5ms window:

```typescript
const tx = Transaction.builder()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The example is missing await before the builder chain, so tx is a Promise instead of the resolved result from send(client).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At wasm/README.md, line 119:

<comment>The example is missing `await` before the builder chain, so `tx` is a `Promise` instead of the resolved result from `send(client)`.</comment>

<file context>
@@ -111,6 +111,18 @@ const tx = Transaction.builder()
+value — for example a microsecond timestamp for a ~5ms window:
+
+```typescript
+const tx = Transaction.builder()
+    .callMessage(msg)
+    .generation(BigInt(Date.now()) * 1000n)  // microseconds
</file context>
Suggested change
const tx = Transaction.builder()
const response = await Transaction.builder()

@0xtristan 0xtristan merged commit 807afc6 into main May 14, 2026
8 checks passed
This was referenced May 14, 2026
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