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 12 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.

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.

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

@tomip01 tomip01 added the L2 Rollup client 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                 | 435   | +5   |
+----------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/cmd/ethrex_l2/src/commands/wallet.rs | 617   | -1   |
+----------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/blockchain/dev/dev.rs         | 2     | +1   |
+----------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/blockchain/dev/utils.rs       | 50    | +50  |
+----------------------------------------------------------------------+-------+------+

Total lines added: +56
Total lines removed: 1
Total lines changed: 57

@tomip01 tomip01 changed the title feat(l1, l2): Show rich wallets on startup feat(l1, l2): show rich wallets on startup Feb 20, 2025
@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

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi Tomi, quick question. Doesn't that mean that if you change the .txt you have to recompile the program?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's correct. This file is for testing purposes. it's expected to be recompiled

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
@@ -497,3 +508,52 @@ fn read_known_peers(file_path: PathBuf) -> Result<Vec<Node>, serde_json::Error>

serde_json::from_reader(file)
}

fn show_rich_accounts(genesis: &Genesis, contents: &str) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is only for --dev, can we move this to the dev crate? We're polluting this file with all kinds of random stuff.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this should be in the dev crate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing it out, changed here 37e2093

Copy link
Collaborator

@mpaulucci mpaulucci left a comment

Choose a reason for hiding this comment

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

let me talk to the creator of the ticket

Copy link
Contributor

@ilitteri ilitteri left a comment

Choose a reason for hiding this comment

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

  1. Let's do a separate PR for the L2 CLI feature
  2. As printing the rich wallets is a dev feature, let's move the code there

Copy link
Contributor

@lima-limon-inc lima-limon-inc left a comment

Choose a reason for hiding this comment

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

The only thing I'm hesitant about is include_str!

Besides that, looks good to me~!

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

Choose a reason for hiding this comment

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

Hi Tomi, quick question. Doesn't that mean that if you change the .txt you have to recompile the program?

@tomip01
Copy link
Contributor Author

tomip01 commented Feb 24, 2025

  1. Let's do a separate PR for the L2 CLI feature
  2. As printing the rich wallets is a dev feature, let's move the code there
  1. Created this PR
  2. Done here 6d137cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L2 Rollup client
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
4 participants