Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add UniswapV4DeployerCompetition #117

Merged
merged 31 commits into from
Nov 8, 2024
Merged

feat: add UniswapV4DeployerCompetition #117

merged 31 commits into from
Nov 8, 2024

Conversation

marktoda
Copy link
Contributor

@marktoda marktoda commented Jun 4, 2024

this commit adds a contract that creates a competition to generate the
vanity address for Uniswap V4. It does so using CREATE2 salts,
pre-calculating the address at which the contract will be deployed and
applying a score to the address based on its vanity.

Related Issue

Which issue does this pull request resolve?

Description of changes

this commit adds a contract that creates a competition to generate the
vanity address for Uniswap V4. It does so using CREATE2 salts,
pre-calculating the address at which the contract will be deployed and
applying a score to the address based on its vanity. leading 0's are
weighted most heavily, followed by other 0's and 4's. The winner
receives an NFT, a bounty, and deployer privileges
@marktoda
Copy link
Contributor Author

marktoda commented Jun 4, 2024

hackathon project :D

uint256 public immutable exclusiveDeployDeadline = competitionDeadline + 1 days;
bytes32 public immutable initCodeHash;

constructor(bytes32 _initCodeHash, address _v4Owner) payable ERC721("UniswapV4 Deployer", "V4D") {
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmmmmm trying to think through how we can get everything to do the same address on every chain. we would definitely love to not have params here 🤔

@Philogy
Copy link

Philogy commented Oct 28, 2024

Probably want to add some frontrunning protection to updateBestAddress e.g. by adding require(msg.sender == address(bytes20(salt)), "Not original miner"); this still leaves 96-bits of entropy for mining

Comment on lines 20 to 25
// Requirement: The first nonzero nibble must be 4
// 10 points for every leading 0 nibble
// 40 points if the first 4 is followed by 3 more 4s
// 20 points if the first nibble after the 4 4s is NOT a 4
// 20 points if the last 4 nibbles are 4s
// 1 point for every 4

Choose a reason for hiding this comment

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

Confirming a design decision, but from the PR description:

leading 0's are weighted most heavily, followed by other 0's and 4's

While the most optimal address has many leading 0s (0x000000000000000000000000000000000000004444 with 360 points), 0x4444000000000000000000000000000000000000 gets a score of 64 whereas 0x0004000000000000000000000000000000000000 would only get a score of 31 pts.

The implemented scoring system optimizes for:

  1. Leading 0s only if there are more than 6 of them. (> 60pts)
  2. a group of 4s after the first zero (or at the beginning if there is no leading 0) (60 pts)
  3. fewer than 6 leading 0s (10-60 pts)
  4. 4 4s at the end (20 pts)
  5. Other 4s that don't qualify for 2 or 4
    It does not give any weight to "other 0's" after the leading ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea that sounds right. do you have any suggestions here?

marktoda and others added 9 commits November 5, 2024 21:36
This commit removes the storage variable for bestAddres, calculating it
on-the-fly instead. It also just takes the initial `salt = 0` value as
a default score-to-beat rather than a sentinel for any salt is allowed
as a simplification
- comparison strictness match comments
- unchecked vanity math
31728
Copy link
Contributor

Choose a reason for hiding this comment

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

WHYYYYYYY 😂

@hensha256 hensha256 merged commit 0a97fda into main Nov 8, 2024
3 checks passed
@hensha256 hensha256 deleted the add-deployer branch November 8, 2024 13:50
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.

8 participants