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(l1, l2): show rich wallets on startup #2045

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

tomip01
Copy link
Contributor

@tomip01 tomip01 commented Feb 20, 2025

Motivation

In this PR we show the top 10 rich accounts on startup. Also, we add to the cli and option to parse a private key to an address.

Description

  • When Genesis file is read, sort the accounts initialized by their balance and print the top 10. We show their private keys by calculating the address from it.
  • In the ethrex_l2 cli we add the utils subcommand to calculate the address from the private key.

The print of the addresses set in the genesis block is show this way:

Showing first 10 accounts
-------------------------------------------------------------------------------
Private Key: 0xe4f7dc8b199fdaac6693c9c412ea68aed9e1584d193e1c3478d30a6f01f26057
Address:     0x0000bd19f707ca481886244bdd20bd6b8a81bd3e (Ξ 1000000000000000000)
-------------------------------------------------------------------------------
Private Key: 0xb142300756f21d04354cd336fb01138767825d50c1d91cf751236bdd7cf522ab
Address:     0x000cd1537a823ae7609e3897da8d95801b557a8a (Ξ 1000000000000000000)
-------------------------------------------------------------------------------
Private Key: 0xba73c72b16553dbba5a275f541c06e77dcf7773514898dc0f3ddfe13c44f9e11
Address:     0x0006d77295a0260ceac113c5aa15cff0d28d9723 (Ξ 1000000000000000000)
-------------------------------------------------------------------------------
Private Key: 0x7a738a3a8ee9cdbb5ee8dfc1fc5d97847eaba4d31fd94f89e57880f8901fa029
Address:     0x000ea2e72065a2ceca7f677bc5e648279c2d843d (Ξ 1000000000000000000)
-------------------------------------------------------------------------------
Private Key: 0x8cfe380955165dd01f4e33a3c68f4e08881f238fbbea71a2ab407f4a3759705b
Address:     0x000a52d537c4150ec274dce3962a0d179b7e71b0 (Ξ 1000000000000000000)
-------------------------------------------------------------------------------
Private Key: 0x5bb463c0e64039550de4f95b873397b36d76b2f1af62454bb02cf6024d1ea703
Address:     0x0009aeff154de37c8e02e83f93d2fec5ec96f8a3 (Ξ 1000000000000000000)
-------------------------------------------------------------------------------
Private Key: 0x3c0924743b33b5f06b056bed8170924ca12b0d52671fb85de1bb391201709aaf
Address:     0x000f1eb7f258d4a7683e5d0fc3c01058841ddc6f (Ξ 1000000000000000000)
-------------------------------------------------------------------------------
Private Key: 0x6aeeda1e7eda6d618de89496fce01fb6ec685c38f1c5fccaa129ec339d33ff87
Address:     0x000ac79590dcc656c00c4453f123acbf10dbb086 (Ξ 1000000000000000000)
-------------------------------------------------------------------------------
Private Key: 0xe88d9382e5e4914469a23dcc27271e05aa7715ddeaee66b857a455c1fd51104a
Address:     0x0002bf507275217c9e5ee250bc1b5ca177bb4f74 (Ξ 1000000000000000000)
-------------------------------------------------------------------------------
Private Key: 0x78ccd4d2698c9967804a23b8e5df6ac980cfc4480c0be9c6d0ab07538f062b7f
Address:     0x000a3fc3bfd55b37025e6f4f57b0b6121f54e5bf (Ξ 1000000000000000000)
-------------------------------------------------------------------------------

Closes #1981
Links to #2034

@tomip01 tomip01 added the L2 label Feb 20, 2025
@tomip01 tomip01 self-assigned this Feb 20, 2025
@tomip01 tomip01 requested a review from a team as a code owner February 20, 2025 20:27
Copy link

github-actions bot commented Feb 20, 2025

| File                                                                 | Lines | Diff |
+----------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex/ethrex.rs                 | 484   | +54  |
+----------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex_l2/src/cli.rs             | 56    | +3   |
+----------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex_l2/src/commands/mod.rs    | 8     | +1   |
+----------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex_l2/src/commands/utils.rs  | 26    | +26  |
+----------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex_l2/src/commands/wallet.rs | 617   | -1   |
+----------------------------------------------------------------------+-------+------+

Total lines added: +84
Total lines removed: 1
Total lines changed: 85

@tomip01 tomip01 changed the title feat(l1, l2): Show rich wallets on startup feat(l1, l2): show rich wallets on startup Feb 20, 2025
@@ -174,6 +177,23 @@ async fn main() {
};

let genesis = read_genesis_file(&network);

// Show top rich accounts
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't want this when running an L1 node. This seems for testing purposed, dunno why this is here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I move it to only print the accounts if we are in dev_mode for the L1.

@tomip01 tomip01 marked this pull request as draft February 21, 2025 19:25
Comment on lines +302 to +303
let l2_pks = include_str!("../../test_data/private_keys.txt");
show_rich_accounts(&genesis, l2_pks);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use this so we can run the print independent where we execute it

Comment on lines +527 to +529
let Ok(pk_h256) = pk_str.parse::<H256>() else {
return;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is any error, don't print the addresses so we don't stop the ethrex client

@tomip01 tomip01 marked this pull request as ready for review February 21, 2025 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Status: No status
Development

Successfully merging this pull request may close these issues.

L2: Print L2 and L1 rich wallet list at startup
2 participants