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

fix: genesis account creation in e2e tests #3243

Merged
merged 2 commits into from
Apr 3, 2024
Merged

Conversation

cmwaters
Copy link
Contributor

@cmwaters cmwaters commented Apr 2, 2024

Closes: #3240

This is an attempt at fixing the problem @staheri14 pointed out with the creation of the validator accounts in the genesis file.

It differentiates between a KeyringAccount which corresponds to the keyring of the genesis struct and the Account which is required in Document() to actually generate the genesis. This way users don't have to use the genesis' keyring if they don't want to

Note: This also includes a small fix in Document() whereby the InitialTokens was actually not being used and the default was being used instead

Copy link
Collaborator

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

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

Thanks, Callum. After reviewing the new logic, I believe it addresses the issue with the SimpleE2ETest and duplicate accounts. However, I haven't tested it yet.Once it's merged, I'll run the e2e test and provide you with an update.
I ran the e2e test, and it worked with no error 👍 all good!

test/e2e/node.go Show resolved Hide resolved
@@ -20,40 +19,28 @@ const (
DefaultInitialBalance = 1e15 // 1 billion TIA
)

// Account represents a user account on the Celestia network.
// KeyringAccount represents a user account on the Celestia network.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps this part of the comment does not apply anymore:

or an address needs to be provided

Copy link
Collaborator

Choose a reason for hiding this comment

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

[suggestion] The name account in KeyringAccount is a bit confusing, as it is more of some info about the account not the actual account. I'd suggest using an alternative name like KeyringAccountInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I tried to distinguish KeyringAccount as an Account that is paired with a Keyring belonging to the Genesis struct. If you don't want to use the keyring provided by the Genesis struct then you use an Account and therefore must include the public key

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, your explanation has made things clearer. I think it would be helpful to also add these explanations as a comment to both structs.

Copy link
Contributor

coderabbitai bot commented Apr 3, 2024

Walkthrough

The changes revolve around a significant refactor in how accounts and validators are managed within the test environment. The updates include a transition from direct public key access to utilizing a KeyringAccount structure, removal of unnecessary cosmos-sdk crypto imports, and an overhaul in account and validator setup processes. This refactor aims to streamline the creation and management of accounts and validators, addressing issues related to account duplication and the addition of validators already present in the genesis keyring.

Changes

File Pattern Change Summary
app/test/priority_test.go Changed address retrieval method for accounts.
test/e2e/... Removed cosmos-sdk crypto imports, refactored Node struct and functions, and updated function arguments and struct fields.
test/util/genesis/... Renamed Account to KeyringAccount, removed PubKey, introduced new Account type with PubKey and Balance, and updated account and validator management logic.

Assessment against linked issues

Objective Addressed Explanation
Address failure in adding validators due to account duplication in the genesis keyring (#3240) The refactor includes changes that streamline account and validator management, such as the introduction of KeyringAccount and adjustments in account addition logic, which should resolve the issue of account duplication when adding validators.

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:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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/coderabbit-overrides.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.

Comment on lines +22 to +25
// KeyringAccount represents a user account on the Celestia network.
// Either the name, if using the genesis keyring, or an address
// needs to be provided
type Account struct {
type KeyringAccount struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider revising the comment for KeyringAccount to reflect the removal of the address requirement.

// KeyringAccount represents a user account on the Celestia network.
// Either the name, if using the genesis keyring

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// KeyringAccount represents a user account on the Celestia network.
// Either the name, if using the genesis keyring, or an address
// needs to be provided
type Account struct {
type KeyringAccount struct {
// KeyringAccount represents a user account on the Celestia network.
// Either the name, if using the genesis keyring
type KeyringAccount struct {

Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

LGTM

@celestia-bot celestia-bot requested a review from a team April 3, 2024 16:10
@cmwaters cmwaters merged commit a62ac1e into main Apr 3, 2024
33 checks passed
@cmwaters cmwaters deleted the cal/genesis-account-e2e branch April 3, 2024 16:25
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.

Validators fail to be added since their accounts are already part of the testnet genesis keyring
3 participants