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

feature: bulk fund crypto wallets #159

Merged
merged 10 commits into from
Nov 20, 2023
Merged

feature: bulk fund crypto wallets #159

merged 10 commits into from
Nov 20, 2023

Conversation

rebelArtists
Copy link
Contributor

@rebelArtists rebelArtists commented Nov 15, 2023

Description

give users dead-simple ability to bulk fund X many crypto wallets for testing purposes

Jira / Linear Tickets

https://polygon.atlassian.net/browse/DVT-1022

Follow-up Tickets (additional features)

https://polygon.atlassian.net/browse/DVT-1115
4:20
https://polygon.atlassian.net/browse/DVT-1114
4:20
https://polygon.atlassian.net/browse/DVT-1116

Testing

fully tested locally:
image

try it yourself:
polycli fund \ --wallet-count=5 \ --funding-wallet-pk="0xe79a26e98ad10db36e8d31cd0bcf93114d53f8acf99b0440d6a3ffb176a9cd98" \ --chain-id=100 \ --concurrency=5 \ --rpc-url="https://rootchain-devnetsub.zkevmdev.net" \ --wallet-funding-amt=0.00015 \ --wallet-funding-gas=50000 \ --output-file="/tmp/generated_keys.json" \ --verbosity=true

cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/usage.md Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
Copy link
Member

@leovct leovct left a comment

Choose a reason for hiding this comment

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

lgtm! a few nits but I tested against a local anvil chain and it works great, it may be a little bit slow though.

Copy link
Member

@praetoriansentry praetoriansentry left a comment

Choose a reason for hiding this comment

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

Tested this out and it seems to work. A few high level thoughts:

  1. The addresses it's funding are random and we're not keeping the private key. So essentially all of the funds are being lost
  2. I'd prefer to stick with same log package along with using the same web3 libraries just for the sake of consistency and maintainability.
  3. I would plan ahead here to think about how you would handle funding of an erc20 (you don't need to implement it, but just making sure your design is flexible enough)
  4. Funding random addresses is okay, but that seems like it should be a mode (and we 100% need to save the private keys in this mode). Two other modes I would consider in priority order. 1 is funding based on a a mnemonic. We already have the libraries intetegrated for deriving the keys. 2 is funding based on an input list of keys.

cmd/fund/fund.go Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
@rebelArtists rebelArtists marked this pull request as ready for review November 17, 2023 22:33
Copy link
Member

@leovct leovct left a comment

Choose a reason for hiding this comment

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

Re-tested and it looks like it doesn't work anymore?

Screenshot 2023-11-20 at 11 26 24

edit: my bad, didn't set the chain-id... 🤦‍♂️

Screenshot 2023-11-20 at 17 35 38

cmd/fund/fund.go Outdated Show resolved Hide resolved
cmd/fund/fund.go Outdated Show resolved Hide resolved
@rebelArtists
Copy link
Contributor Author

Re-tested and it looks like it doesn't work anymore?

Screenshot 2023-11-20 at 11 26 24

thanks for the re-review @leovct confident the insufficient funds error you ran into is because you leveraged default gasLimit by not setting that flag in your cmd, i've gone ahead and bumped the default gas value and confirmed all is till working as expected:
➜ polygon-cli git:(dan/bulk_fund_wallets) ✗ polycli fund \ --wallet-count=5 \ --funding-wallet-pk="0xe79a26e98ad10db36e8d31cd0bcf93114d53f8acf99b0440d6a3ffb176a9cd98" \ --chain-id=100 \ --concurrency=5 \ --rpc-url="https://rootchain-devnetsub.zkevmdev.net" \ --wallet-funding-amt=0.00015 \ --output-file="/Users/dmoore/generated_keys.json" 9:59AM INF Starting to fund loadtest wallets... 9:59AM INF Funded with 150000000000000 wei wallet=0xe9692514Bc35312df5A3ea208B790c05b5E26559 9:59AM INF Funded with 150000000000000 wei wallet=0xA0E52c5604E5DDD708DA822D8a684A0DBEf1a59d 9:59AM INF Funded with 150000000000000 wei wallet=0xcfa212E06a3Cb87c357854b8EDe6739bf0A35e80 9:59AM INF Funded with 150000000000000 wei wallet=0xF5f7EC6daF2206dbeA2F69f7d29c27883e7aDA29 9:59AM INF Funded with 150000000000000 wei wallet=0xcAa8A222c06090971C9244f949c46c175D434bDD 9:59AM INF Wallet details have been saved to /Users/dmoore/generated_keys.json 9:59AM INF Total execution time: 6.232435583s

Copy link
Member

@leovct leovct left a comment

Choose a reason for hiding this comment

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

lgtm

@rebelArtists rebelArtists merged commit 48044b8 into main Nov 20, 2023
1 check passed
@rebelArtists rebelArtists deleted the dan/bulk_fund_wallets branch November 20, 2023 16:58
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.

4 participants