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

Problem: bulk-add-genesis-account is not used in testground #1582

Merged
merged 9 commits into from
Sep 16, 2024

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Sep 16, 2024

Solution:

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Summary by CodeRabbit

  • New Features

    • Updated dependencies to the latest versions of the Cosmos SDK, enhancing performance and stability.
    • Introduced new methods for account generation and conversion between Ethereum and Bech32 formats, improving flexibility in blockchain interactions.
    • Added functionality for bulk processing of genesis accounts, streamlining account management.
    • Enhanced node initialization and execution logic with global sequence tracking for better management of node identities.
    • Added a new Balance class for improved representation of account balances.
  • Bug Fixes

    • Removed outdated functions to simplify account creation processes.
  • Documentation

    • Improved clarity on account initialization and transaction handling processes.

Solution:
- extract standalone changes from crypto-org-chain#1575
- use a simple and deterministic way to generate test accounts
@yihuang yihuang requested a review from a team as a code owner September 16, 2024 09:57
@yihuang yihuang requested review from devashishdxt and thomas-nguy and removed request for a team September 16, 2024 09:57
@yihuang yihuang marked this pull request as draft September 16, 2024 09:57
@yihuang yihuang requested a review from mmsqe September 16, 2024 09:57
Copy link
Contributor

coderabbitai bot commented Sep 16, 2024

Walkthrough

The pull request includes updates to the go.mod and gomod2nix.toml files, reflecting new versions and hashes for several Cosmos SDK dependencies. Additionally, modifications are made to several Python files in the testground/benchmark/benchmark directory, enhancing functions related to account generation, load testing, and node initialization. Notably, new parameters for global sequencing are introduced, improving the management of accounts and transactions across the testing framework.

Changes

Files Change Summary
go.mod, gomod2nix.toml Updated versions and hashes for Cosmos SDK dependencies to reflect the latest commits.
testground/benchmark/benchmark/main.py, sendtx.py Modified generate_load function to include a new parameter global_seq for enhanced load generation.
testground/benchmark/benchmark/peer.py Updated init_node to accept global_seq, improved account generation, and streamlined genesis account handling.
testground/benchmark/benchmark/stateless.py Enhanced node initialization and execution logic by including a global_seq parameter across functions.
testground/benchmark/benchmark/types.py Added a new Balance class and modified GenesisAccount to use a list of Balance instances.
testground/benchmark/benchmark/utils.py Introduced functions for address conversion and deterministic account generation based on global sequence.

Possibly related PRs

🐰 In the meadow, changes bloom,
Dependencies updated, dispelling gloom.
With sequences global, accounts align,
Testing flows smoothly, like sweet, fine wine.
A hop and a skip, the code's in its prime,
Hooray for the changes, it's testing time! 🌼


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e741745 and 2843901.

Files selected for processing (1)
  • testground/benchmark/benchmark/utils.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • testground/benchmark/benchmark/utils.py

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai generate interesting stats about this repository and render them as a table.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.12%. Comparing base (559d7a7) to head (2843901).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1582       +/-   ##
===========================================
+ Coverage   15.24%   36.12%   +20.88%     
===========================================
  Files          67       97       +30     
  Lines        4874     7725     +2851     
===========================================
+ Hits          743     2791     +2048     
- Misses       4037     4585      +548     
- Partials       94      349      +255     

see 47 files with indirect coverage changes

@yihuang yihuang marked this pull request as ready for review September 16, 2024 10:16
Copy link
Collaborator

@mmsqe mmsqe left a comment

Choose a reason for hiding this comment

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

seems validator doesnt generate when validator_generate_load is false?

@yihuang
Copy link
Collaborator Author

yihuang commented Sep 16, 2024

seems validator doesnt generate when validator_generate_load is false?

WDYM?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bac77b1 and e741745.

Files selected for processing (3)
  • testground/benchmark/benchmark/peer.py (6 hunks)
  • testground/benchmark/benchmark/types.py (1 hunks)
  • testground/benchmark/benchmark/utils.py (4 hunks)
Additional context used
Ruff
testground/benchmark/benchmark/utils.py

4-4: itertools.dropwhile imported but unused

Remove unused import

(F401)


4-4: itertools.takewhile imported but unused

Remove unused import

(F401)

GitHub Check: Lint python
testground/benchmark/benchmark/utils.py

[failure] 4-4:
./testground/benchmark/benchmark/utils.py:4:1: F401 'itertools.dropwhile' imported but unused


[failure] 4-4:
./testground/benchmark/benchmark/utils.py:4:1: F401 'itertools.takewhile' imported but unused

Additional comments not posted (8)
testground/benchmark/benchmark/types.py (3)

8-13: LGTM!

The Balance class is well-structured and provides a clear representation of a balance with amount and denomination. The use of pydantic's BaseModel ensures proper validation and serialization. The __str__ method is a nice addition for convenient string formatting.


18-18: Improved data modeling with the coins attribute.

The change from balance to coins is a significant improvement in the data modeling of the GenesisAccount class. It allows for a more flexible and accurate representation of account balances by supporting multiple denominations. The use of a list of Balance instances provides a structured and type-safe approach.


18-18: Verify the usage of the coins attribute in the codebase.

Ensure that all references to the balance attribute are updated to use the new coins attribute and handle the list of Balance instances appropriately.

Run the following script to verify the usage of the coins attribute:

testground/benchmark/benchmark/utils.py (3)

14-15: LGTM!

Defining the Cronos address prefix as a constant is a good practice. It improves code readability and maintainability.


98-100: LGTM!

The eth_to_bech32 function provides a useful utility for converting Ethereum addresses to Bech32 format. The implementation looks correct and follows the Bech32 encoding process.


137-142: LGTM!

The gen_account function provides a deterministic way to generate test accounts based on a global sequence and an index. This is useful for testing and benchmarking purposes. Reserving index 0 for a validator account is a good practice to ensure consistency across tests.

testground/benchmark/benchmark/peer.py (2)

Line range hint 64-87: LGTM! The changes improve account management efficiency.

The updates to the init_node function enhance the efficiency and adaptability of account management during node initialization:

  • The global_seq parameter ensures unique accounts are generated for each participant.
  • The gen_account function generates Ethereum-compatible addresses for additional accounts.

However, please note that the unsafe import method used for the validator account provides greater flexibility but may have security implications. Ensure that the risks associated with this approach are carefully considered and mitigated.


120-128: Excellent optimization! The use of a temporary file for bulk account addition significantly improves efficiency.

The modification to the gen_genesis function to utilize a temporary file for bulk account addition is a great optimization. This change streamlines the process of adding multiple genesis accounts in a single command, reducing the number of CLI calls required during the genesis block creation.

This enhancement significantly improves the efficiency of the genesis block generation process.

testground/benchmark/benchmark/utils.py Outdated Show resolved Hide resolved
@yihuang yihuang added this pull request to the merge queue Sep 16, 2024
Merged via the queue into crypto-org-chain:main with commit f474ac2 Sep 16, 2024
35 checks passed
@yihuang yihuang deleted the test-accounts-genesis branch September 18, 2024 02:13
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.

2 participants