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

chore: improve polycli fund #167

Merged
merged 50 commits into from
Nov 29, 2023
Merged

chore: improve polycli fund #167

merged 50 commits into from
Nov 29, 2023

Conversation

leovct
Copy link
Member

@leovct leovct commented Nov 27, 2023

Description

  • chore: migrate from web3 library to go-ethereum.
  • feat: Implement a Funder smart contract to be able to bulk fund wallets in one transaction. It speeds up the funding process by a lot. 🚀
  • chore: refactor flags, check flags in PreRunE and move flag logic to app.
  • feat: enable to fund wallets specified by user
  • feat: enable to derive wallets from private key
  • chore: use RunE instead of RunE when running the fund command.
  • chore: update --eth-amount in polycli loadtest. Users can now specify the amount in eth instead of having to specify the hexadecimal representation of the amount in wei.

Jira / Linear Tickets

  • DVT-1114 - migrate to go-ethereum lib.
  • DVT-1116 - enable to fund wallets specified by user.
  • DVT-1115 - enable to fund wallets derived from private key.

Testing

# Fund wallets specified by the user.
$ polycli fund --addresses=0x5eD3BE7a1cDafd558F88a673345889dC75837aA2,0x1Ec6efdBd371D6444779eAE7B7e16907e0c8eC27
3:58PM INF Starting bulk funding wallets
3:58PM INF Using addresses provided by the user
3:58PM INF Wallet(s) funded! 💸
3:58PM INF Total execution time: 1.020693583s

# Fund 20 random wallets using a pre-deployed contract address.
$ polycli fund --number=20 --contract-address=0xf5a73e7cfcc83b7e8ce2e17eb44f050e8071ee60
3:58PM INF Starting bulk funding wallets
3:58PM INF Deriving wallets from the default mnemonic
3:58PM INF Wallet(s) derived count=20
3:58PM INF Wallet(s) funded! 💸
3:58PM INF Total execution time: 396.814917ms

# Fund 20 random wallets.
$ polycli fund --number 20 --hd-derivation=false
3:58PM INF Starting bulk funding wallets
3:58PM INF Generating random wallets
3:58PM INF Wallet(s) generated count=20
3:58PM INF Wallets' address(es) and private key(s) saved to file fileName=wallets.json
3:58PM INF Wallet(s) funded! 💸
3:58PM INF Total execution time: 1.027506s

Extract from wallets.json.

[
  {
    "Address": "0xc1A44B1e37EE1fca4C6Fd5562c730d5b8525e4C6",
    "PrivateKey": "c1a8f737fd9f78aee361bfd856f9b2e99f853a5fe5efa2131fb030acdcee762b"
  },
  {
    "Address": "0x5D8121cf716B70d3e345adB58157752304eED5C3",
    "PrivateKey": "fbc57de542cef10fdcdf99e5578ffb5508992e9a8623ea4a39ab957d77e9b849"
  },
  ...
]

Check the balances of the wallets.

$ cast balance 0xc1A44B1e37EE1fca4C6Fd5562c730d5b8525e4C6
50000000000000000

$ cast balance 0x5D8121cf716B70d3e345adB58157752304eED5C3
50000000000000000
...

Send funds on behalf on one of the funded account.

$ cast send --private-key e211490bcaae916e6cdbf58877e7fc697a51c6e11cfe591b0b2b72e6123e4d12 --value 0.01ether 0x469838206407A001B7086F102fe35b62967170d3

blockHash               0xd9dbd1b377d75cb3704c2e1ca27b3054e18afe692abed8eb621a4a231446adfb
blockNumber             8
contractAddress         
cumulativeGasUsed       21000
effectiveGasPrice       3401058594
gasUsed                 21000
logs                    []
logsBloom               0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
root                    
status                  1
transactionHash         0x530d68a9f705e02fcf02362e1e75cdeb76e49f2bd9df165f6c447df512652367
transactionIndex        0
type                    2

@leovct leovct requested a review from rebelArtists November 27, 2023 18:14
@leovct leovct requested a review from rebelArtists November 28, 2023 08:48
@leovct
Copy link
Member Author

leovct commented Nov 28, 2023

@rebelArtists A couple of changes since last review.

  • Modified the amount flag.
  • Enabled to fund addresses specified by user.
  • Enabled to derive wallets from mnemonic (used by default).
  • Minor stuff (clean up, refactor, etc.)

cmd/fund/usage.md Outdated Show resolved Hide resolved
rebelArtists
rebelArtists previously approved these changes Nov 28, 2023
Copy link
Contributor

@IdrisHanafi IdrisHanafi left a comment

Choose a reason for hiding this comment

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

nice job, lgtm 🔥

tried testing it out with the sample commands in the PR description:

polycli fund --wallets 20 --verbosity 500

but realized, the flag has been changed from wallets to number lol.

@leovct leovct merged commit afcaed6 into main Nov 29, 2023
@leovct leovct deleted the chore/improve-fund branch November 29, 2023 14:46
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.

3 participants