Skip to content

feat(cast): mine TIP20 virtual address master salt#14365

Merged
zerosnacks merged 6 commits intomasterfrom
rus/tip20-mine-virtual-master
Apr 17, 2026
Merged

feat(cast): mine TIP20 virtual address master salt#14365
zerosnacks merged 6 commits intomasterfrom
rus/tip20-mine-virtual-master

Conversation

@0xrusowsky
Copy link
Copy Markdown
Contributor

@0xrusowsky 0xrusowsky commented Apr 17, 2026

this PR adds cast tip20 mine (alias: m) — a multi-threaded CPU miner for https://docs.tempo.xyz/protocol/tip1022 proof-of-work salts required to register a virtual master address on Tempo.

  # Mine a salt for <ADDRESS> (uses all CPU cores by default)
  cast tip20 m <ADDRESS>

  # Mine and immediately register on-chain
  cast tip20 m <ADDRESS> --register --private-key <PK> --rpc-url <URL>

  # Validate a known salt without mining
  cast tip20 m <ADDRESS> --salt <HEX>

  # Reproducible mining (fixed seed + thread count)
  cast tip20 m <ADDRESS> --seed <HEX> -j 4

  Output:
  Mining TIP-1022 salt for 0xabc... with 8 threads...
  Found salt in 312ms

  Salt:              0x...
  Registration hash: 0x...
  Master ID:         0x...
  Zero-tag address:  0x...

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@0xrusowsky 0xrusowsky marked this pull request as ready for review April 17, 2026 09:10
Comment thread crates/cast/src/cmd/tip20/mine.rs Outdated
Comment on lines +159 to +161
let salt_word = unsafe {
&mut *salt.0.as_mut_ptr().add(32 - usize::BITS as usize / 8).cast::<usize>()
};
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.

Can we get rid of this unsafe block by just reading/writing the last 8 bytes as a u64 via u64::from_le_bytes / to_le_bytes?

It's one extra copy per iteration, negligible versus the keccak cost I believe.

Copy link
Copy Markdown
Contributor Author

@0xrusowsky 0xrusowsky Apr 17, 2026

Choose a reason for hiding this comment

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

i copied this from crates/cast/src/cmd/create2.rs, didn't think much about it and assumed it was optimal perf-wise

Comment thread crates/cast/src/cmd/tip20/virtual_master.rs Outdated
Comment thread crates/cast/src/cmd/tip20/mod.rs
Comment thread crates/cast/src/tx.rs
DaniPopes
DaniPopes previously approved these changes Apr 17, 2026
mablr
mablr previously approved these changes Apr 17, 2026
@0xrusowsky 0xrusowsky dismissed stale reviews from mablr and DaniPopes via 66b9998 April 17, 2026 10:40
@0xrusowsky 0xrusowsky requested review from DaniPopes and mablr April 17, 2026 10:41
Copy link
Copy Markdown
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

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

lgtm!

@zerosnacks zerosnacks enabled auto-merge (squash) April 17, 2026 10:45
@zerosnacks zerosnacks merged commit 970588f into master Apr 17, 2026
16 checks passed
@zerosnacks zerosnacks deleted the rus/tip20-mine-virtual-master branch April 17, 2026 11:23
@github-project-automation github-project-automation Bot moved this to Done in Foundry Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants