Skip to content

test(e2e): add a runner for gov proposals in the e2e test#3591

Merged
kingpinXD merged 16 commits intodevelopfrom
gov-e2e-test
Feb 28, 2025
Merged

test(e2e): add a runner for gov proposals in the e2e test#3591
kingpinXD merged 16 commits intodevelopfrom
gov-e2e-test

Conversation

@kingpinXD
Copy link
Member

@kingpinXD kingpinXD commented Feb 26, 2025

Description

The PR adds a runner to easily test gov proposals.
Any governace proposals can be executed in the E2E tests. There are two options for the sequence of the proposal execution.

  1. Start of E2E tests: The proposal json needs to be placed in the contrib/localnet/orchestrator/proposal_e2e_start directory.All proposals in this directory will be executed before running the e2e tests
  2. End of E2E tests: The proposal json needs to be placed in the contrib/localnet/orchestrator/proposal_e2e_end directory.All proposals in this directory will be executed after running the e2e tests

Closes: #3518
The required proposals can now easily be added into the e2e tests . We might need to decide on which ones to add ,or we could use this on a as needed basis

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features

    • Introduced an automated governance proposals runner in the end-to-end testing suite, enabling proposal creation and voting at distinct test stages.
    • Adjusted governance settings for quicker voting cycles.
    • Enhanced key management to support smoother proposal execution.
  • Documentation

    • Added a section to the testing guide detailing how to execute governance proposals before or after tests.
  • Chores

    • Updated container configurations and startup scripts to include new proposal resources and improved connectivity for key operations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This pull request enhances the end-to-end testing suite by introducing a governance proposals runner. The changes add new JSON proposal files, update orchestration scripts and Docker configurations, and modify the test runner to create and vote on governance proposals at the start and end of tests. Additionally, key management and governance parameter adjustments have been implemented, and documentation has been updated to detail the governance proposal workflow.

Changes

File(s) Change Summary
changelog.md Added a new changelog entry for the governance proposals runner ([3591]).
cmd/zetae2e/local/local.go Introduced two calls to CreateGovProposals to execute proposals at the start and end of the E2E tests.
contrib/localnet/orchestrator/Dockerfile.fastbuild Added two new COPY commands to include proposal directories (proposals_e2e_start and proposals_e2e_end) in the Docker image.
contrib/localnet/orchestrator/proposals_e2e_start/emissions_params.json
contrib/localnet/orchestrator/proposals_e2e_end/max_gas.json
Added new JSON proposal files for emissions parameter changes and max gas update.
contrib/localnet/orchestrator/start-zetae2e.sh Added SSH daemon startup and keyring management code to handle operator keys from remote containers.
contrib/localnet/scripts/start-zetacored.sh Modified governance parameters in the genesis JSON (reduced voting periods) using jq.
e2e/TESTING_GUIDE.md Appended a new "Gov proposal" section detailing where to place proposal JSON files for execution.
e2e/runner/gov_propsoals.go Introduced a new runner with methods to submit proposals and cast votes, including error handling and key management.
e2e/txserver/zeta_tx_server.go Added a new validatorsKeyring field and associated methods (UpdateKeyring, GetValidatorsKeyring) to enhance key management.

Sequence Diagram(s)

sequenceDiagram
  participant E2E as E2E Test Runner
  participant Gov as Gov Proposal Runner
  participant Zeta as Zeta TX Server
  participant Validator as Validator Keyring

  E2E->>Gov: Invoke CreateGovProposals(Start/End)
  Gov->>Gov: Read proposal JSON files
  Gov->>Zeta: Submit proposal transaction
  Zeta-->>Gov: Return proposal ID / confirmation
  Gov->>Validator: Iterate through validators and cast votes
  Validator-->>Gov: Return vote confirmations
  Gov-->>E2E: Report execution status
Loading

Possibly related PRs

Suggested labels

UPGRADE_TESTS, ADMIN_TESTS, no-changelog

Suggested reviewers

  • gartnera
  • lumtis
  • swift1337
  • ws4charlie

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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this 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.

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.

# Conflicts:
#	e2e/txserver/zeta_tx_server.go
@kingpinXD kingpinXD changed the title test : add runner for gov proposal in e2e test test : add a runner for gov proposals in the e2e test Feb 26, 2025
@kingpinXD kingpinXD marked this pull request as ready for review February 26, 2025 03:54
@kingpinXD kingpinXD requested a review from a team as a code owner February 26, 2025 03:54
@kingpinXD kingpinXD changed the title test : add a runner for gov proposals in the e2e test test: add a runner for gov proposals in the e2e test Feb 26, 2025
@kingpinXD kingpinXD changed the title test: add a runner for gov proposals in the e2e test test(e2e): add a runner for gov proposals in the e2e test Feb 26, 2025
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

🧹 Nitpick comments (9)
contrib/localnet/scripts/start-zetacored.sh (1)

191-205: Governance Parameters Update in Genesis Configuration
The modifications to the governance parameters—setting voting_period to "30s" and expedited_voting_period to "10s"—are well aligned with the new E2E testing requirements for faster proposal processing. Please verify that these shorter durations are appropriate for all testing scenarios and won’t inadvertently affect stability in environments that might mimic production behavior.

As a nitpick, note that the jq assignments use inconsistent spacing around the equals sign (e.g., line 192 uses no spaces while line 195 does). For clarity and maintainability, consider unifying the style. For example:

-    .app_state.gov.params.expedited_voting_period = "10s" |
+    .app_state.gov.params.expedited_voting_period="10s" |
e2e/TESTING_GUIDE.md (1)

94-98: Documentation for governance proposal execution is clear

The added section clearly explains the two options for executing governance proposals during E2E tests, matching the implementation in the code. This will be valuable for developers wanting to leverage this feature.

Note: There's a minor typo in "governace" (line 96) and a missing space after the period in line 97, but these are trivial.

Suggest fixing the minor typos:

-Any governace proposals can be executed in the E2E tests. There are two options for the sequence of the proposal execution.
+Any governance proposals can be executed in the E2E tests. There are two options for the sequence of the proposal execution.
-1. Start of E2E tests: The proposal json needs to be placed in the `contrib/localnet/orchestrator/proposal_e2e_start` directory.All proposals in this directory will be executed before running the e2e tests
+1. Start of E2E tests: The proposal json needs to be placed in the `contrib/localnet/orchestrator/proposal_e2e_start` directory. All proposals in this directory will be executed before running the e2e tests
contrib/localnet/orchestrator/start-zetae2e.sh (1)

145-158: Improve error handling and directory existence checks.
Within the loop, an error log is printed if the keyring-test directory is missing on the remote container, but the script continues to execute. Consider explicitly failing early when a container's keyring directory is missing to avoid partial or inconsistent key copy states.

 for i in 0 1; do
     ssh root@zetacore$i "test -d /root/.zetacored/keyring-test/" && \
     (echo "Source directory found in zetacore$i, copying operator keys" && \
-    mkdir -p /root/zetacore$i/ && \
+    if ! mkdir -p /root/zetacore$i/; then
+      echo "Failed to create local directory /root/zetacore$i/"
+      exit 1
+    fi
     scp -r root@zetacore$i:/root/.zetacored/keyring-test/ /root/zetacore$i/keyring-test/ && \
     echo "Files copied successfully from zetacore$i") || \
     (echo "Error: keyring-test directory not found in zetacore$i container" && exit 1)
 
     zetacored keys rename operator operator$i --home=/root/zetacore$i/ --keyring-backend=test --yes
     cp -r /root/zetacore$i/keyring-test/* /root/.zetacored/keyring-test/
 done
e2e/txserver/zeta_tx_server.go (2)

138-151: Externalize hard-coded paths for portability.
When creating the validatorsKeyring, consider using an environment variable or config file reference instead of the hard-coded "/root/.zetacored/" path. This helps ensure maintainability across diverse deployment environments.


166-171: Avoid non-pointer receivers if updating shared state is intended.
Returning a copy of ZetaTxServer on keyring update may be confusing if your usage pattern expects changes to be reflected across the original instance. Consider using a pointer receiver if the same instance needs to be updated in-place.

e2e/runner/gov_propsoals.go (4)

113-114: Re-evaluate the assumption that the first proposal ID is always 1.

Although this might be true on a fresh chain, the comment here can be misleading if the chain already contains proposals. Consider removing or adjusting the comment.


127-128: Adjust the docstring to match actual functionality.

The comment states "Vote yes on the proposal from both the validators," but the function iterates over all validator keys. Update the docstring if more than two validators may exist.


127-143: Consider renaming for clarity.

Currently, the function name voteGovProposals is plural while it handles a single proposal ID at a time. Renaming it to voteGovProposal or adding support for multiple proposals could align it better with actual usage.


156-186: Validate proposal JSON structure more thoroughly.

While this function successfully parses and unmarshals JSON, it might be beneficial to perform business-level validations (e.g., ensuring the proposal has the required fields) before broadcasting. This could prevent partial or invalid proposals from being processed.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 79ec10c and 2265640.

📒 Files selected for processing (10)
  • changelog.md (1 hunks)
  • cmd/zetae2e/local/local.go (2 hunks)
  • contrib/localnet/orchestrator/Dockerfile.fastbuild (1 hunks)
  • contrib/localnet/orchestrator/proposals_e2e_end/max_gas.json (1 hunks)
  • contrib/localnet/orchestrator/proposals_e2e_start/emissions_params.json (1 hunks)
  • contrib/localnet/orchestrator/start-zetae2e.sh (2 hunks)
  • contrib/localnet/scripts/start-zetacored.sh (1 hunks)
  • e2e/TESTING_GUIDE.md (1 hunks)
  • e2e/runner/gov_propsoals.go (1 hunks)
  • e2e/txserver/zeta_tx_server.go (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • changelog.md
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.sh`: Review the shell scripts, point out issues relati...

**/*.sh: Review the shell scripts, point out issues relative to security, performance, and maintainability.

  • contrib/localnet/scripts/start-zetacored.sh
  • contrib/localnet/orchestrator/start-zetae2e.sh
`**/*.go`: Review the Go code, point out issues relative to ...

**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

  • cmd/zetae2e/local/local.go
  • e2e/txserver/zeta_tx_server.go
  • e2e/runner/gov_propsoals.go
🔇 Additional comments (11)
contrib/localnet/orchestrator/Dockerfile.fastbuild (1)

11-12: COPY commands for governance proposal directories added correctly

The added COPY commands appropriately transfer governance proposal files from their source directories to the Docker image's working directory, enabling the governance proposal execution feature described in the PR objectives.

cmd/zetae2e/local/local.go (2)

211-212: Governance proposal execution at test start implemented

This code correctly implements the start-of-test execution of governance proposals, aligning with the PR objectives. The placement is logical - after funding the emissions pool but before the main test execution.


495-495: Governance proposal execution at test end implemented

This code correctly implements the end-of-test execution of governance proposals, as described in the PR objectives. The placement is appropriate - after all tests have been run and verified, but before the final success message.

contrib/localnet/orchestrator/proposals_e2e_end/max_gas.json (1)

1-26: Example governance proposal is well-structured

The JSON structure properly follows the expected format for governance proposals. The proposal correctly includes:

  1. A properly typed consensus parameter update message
  2. Authority address
  3. Appropriate block parameters (max_bytes, max_gas)
  4. Necessary evidence and validator configurations
  5. Required metadata, deposit, title, and summary fields

This serves as a good example proposal and will be useful for demonstrating the end-of-test proposal execution feature.

contrib/localnet/orchestrator/start-zetae2e.sh (1)

13-14: Ensure intended SSH usage.
Starting an SSH daemon in this container can pose a security risk if not locked down properly. Confirm that SSH access is truly required, and if so, configure secure credentials and limit inbound connections to avoid unauthorized access.

e2e/txserver/zeta_tx_server.go (4)

80-88: Struct extension looks good.
Adding validatorsKeyring and other fields provides centralized control and usage clarity. Keep in mind concurrency or reentrancy scenarios if multiple goroutines use this store of credentials at once.


156-163: Object construction is consistent.
Combining all required fields at initialization time is clear and consistent. Ensure that authorityClient is set later using SetAuthorityClient if needed before usage.


182-185: Simple getter is fine.
This straightforward accessor cleanly exposes the underlying codec. No issues to report.


223-226: Keyring accessor suffices.
Exposing validatorsKeyring through this method is clear and maintains encapsulation. If concurrency or dynamic re-initialization is needed, ensure appropriate locks or usage patterns.

contrib/localnet/orchestrator/proposals_e2e_start/emissions_params.json (1)

1-20: Validate large numeric fields.
Ensure that the specified block reward amount ("9620949074074074074.074070733466756687") and percentages reflect intended economic parameters. High-precision values can cause unexpected behavior if not handled consistently across the codebase.

e2e/runner/gov_propsoals.go (1)

27-31: Ensure consistency of directory paths and documentation.

The comments in lines 27-31 mention directory paths under /contrib/orchestrator/… while the actual code uses /work/proposals_e2e_.... This discrepancy can lead to confusion if contributors rely on the comment instead of the actual directory path.

Would you like to clarify one standardized directory path or keep a distinction between these two references?

Copy link
Contributor

@swift1337 swift1337 left a comment

Choose a reason for hiding this comment

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

LGTM

@kingpinXD kingpinXD requested a review from lumtis February 26, 2025 16:49
@kingpinXD kingpinXD requested a review from gartnera February 27, 2025 21:58
@github-actions
Copy link

!!!WARNING!!!
nosec detected in the following files: e2e/runner/gov_proposals.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Feb 28, 2025
@kingpinXD kingpinXD enabled auto-merge February 28, 2025 16:37
@kingpinXD kingpinXD added this pull request to the merge queue Feb 28, 2025
Merged via the queue into develop with commit 9e2c8e1 Feb 28, 2025
45 checks passed
@kingpinXD kingpinXD deleted the gov-e2e-test branch February 28, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests e2e : add e2e tes for most comonly used gov proposals

4 participants