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

ci: add rpcimportable test #2817

Merged
merged 13 commits into from
Sep 27, 2024
Merged

ci: add rpcimportable test #2817

merged 13 commits into from
Sep 27, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Sep 3, 2024

Add a CI check that the RPC package is importable. This check should eventually check the import tree to ensure that the required dependencies are minimal.

Will move required status check to ci-ok to make the required status checks easier too.

Also fix issues causing import:

  • move GetAllOutboundTrackerByChain back to zetaclient as it imports zetaclient
  • use github.com/btcsuite/btcd/btcutil in pkg/chains

Update: the btcd deps are just too complex. Blocked by #2728. Update: unblocked now.

Closes #2798

Currently failing with:

go: github.com/zeta-chain/node/contrib/rpcimportable tested by
	github.com/zeta-chain/node/contrib/rpcimportable.test imports
	github.com/zeta-chain/node/pkg/rpc imports
	github.com/zeta-chain/node/pkg/chains imports
	github.com/btcsuite/btcutil imports
	github.com/btcsuite/btcd/btcec: module github.com/btcsuite/btcd@latest found (v0.24.2), but does not contain package github.com/btcsuite/btcd/btcec
go: github.com/zeta-chain/node/contrib/rpcimportable tested by
	github.com/zeta-chain/node/contrib/rpcimportable.test imports
	github.com/zeta-chain/node/pkg/rpc imports
	github.com/zeta-chain/node/x/authority/types tested by
	github.com/zeta-chain/node/x/authority/types.test imports
	github.com/zeta-chain/node/app imports
	github.com/zeta-chain/node/x/observer imports
	github.com/zeta-chain/node/x/observer/client/cli imports
	gitlab.com/thorchain/tss/go-tss/blame imports
	gitlab.com/thorchain/tss/go-tss/conversion imports
	gitlab.com/thorchain/tss/tss-lib/crypto imports
	github.com/decred/dcrd/dcrec/edwards/v2 imports
	github.com/agl/ed25519: module github.com/agl/ed25519@latest found (v0.0.0-20200225211852-fd4d107ace12), but does not contain package github.com/agl/ed25519
go: github.com/zeta-chain/node/contrib/rpcimportable tested by
	github.com/zeta-chain/node/contrib/rpcimportable.test imports
	github.com/zeta-chain/node/pkg/rpc imports
	github.com/zeta-chain/node/x/authority/types tested by
	github.com/zeta-chain/node/x/authority/types.test imports
	github.com/zeta-chain/node/app imports
	github.com/zeta-chain/node/x/observer imports
	github.com/zeta-chain/node/x/observer/client/cli imports
	gitlab.com/thorchain/tss/go-tss/blame imports
	gitlab.com/thorchain/tss/go-tss/conversion imports
	gitlab.com/thorchain/tss/tss-lib/crypto imports
	github.com/decred/dcrd/dcrec/edwards/v2 imports
	github.com/agl/ed25519/edwards25519: module github.com/agl/ed25519@latest found (v0.0.0-20200225211852-fd4d107ace12), but does not contain package github.com/agl/ed25519/edwards25519

https://go.dev/ref/mod#go-mod-tidy

go mod tidy works by loading all of the packages in the main module and all of the packages they import, recursively. This includes packages imported by tests (including tests in other modules). go mod tidy acts as if all build tags are enabled, so it will consider platform-specific source files and files that require custom build tags, even if those source files wouldn’t normally be built. There is one exception: the ignore build tag is not enabled, so a file with the build constraint // +build ignore will not be considered. Note that go mod tidy will not consider packages in the main module in directories named testdata or with names that start with . or _ unless those packages are explicitly imported by other packages.

We should try ensure there is minimal internal logic in the types package as all that will be imported when a user tries to import the package.

Ok now we're hitting:

➜  rpcimportable git:(rpc-importable-test) go mod tidy
go: found github.com/zeta-chain/node/pkg/rpc in github.com/zeta-chain/node v0.0.0-00010101000000-000000000000
➜  rpcimportable git:(rpc-importable-test) ✗ go test -v .
# github.com/zeta-chain/ethermint/x/evm/types
/home/alex/go/pkg/mod/github.com/zeta-chain/[email protected]/x/evm/types/tracer.go:48:21: undefined: vm.DefaultActivePrecompiles
FAIL	github.com/zeta-chain/node/contrib/rpcimportable [build failed]
FAIL

We definitely cannot force external users to use our ethereum/client-go fork. I will try to move that logic to keeper.

zeta-chain/ethermint#126

Summary by CodeRabbit

  • New Features

    • Introduced a new function to retrieve outbound trackers by blockchain, allowing users to access and sort this data.
  • Bug Fixes

    • Removed outdated methods and tests related to outbound tracker functionality to streamline operations.
  • Tests

    • Added new tests for the outbound tracker retrieval function, enhancing test coverage and reliability.
  • Chores

    • Updated configuration management across various tests to use a centralized configuration package.

Copy link
Contributor

coderabbitai bot commented Sep 3, 2024

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

Walkthrough

The pull request introduces significant changes to the CI workflow, adds new modules and test files, updates dependencies, and modifies existing code by removing outdated functions and tests. Key updates include the introduction of a new sdkconfig package for managing address prefixes, the removal of the GetAllOutboundTrackerByChain function, and the addition of new test cases for cross-chain transaction functionalities. The changes aim to enhance the code structure and improve testing coverage while ensuring the project remains importable.

Changes

Files Change Summary
.github/workflows/ci.yml Workflow renamed and updated; added rpcimportable and ci-ok jobs.
contrib/rpcimportable/go.mod New go.mod file created with specific module settings and dependency replacements.
contrib/rpcimportable/rpcimportable_test.go New test file added with a placeholder test function.
go.mod Updated dependency version for github.com/zeta-chain/ethermint.
pkg/rpc/clients_crosschain.go Removed GetAllOutboundTrackerByChain function.
pkg/rpc/clients_test.go Removed TestZetacore_GetAllOutboundTrackerByChain test function and related imports.
pkg/sdkconfig/sdkconfig.go New file introduced to manage address prefix configurations.
testutil/keeper/config.go Removed address prefix constants and SetConfig function.
testutil/keeper/emissions.go Updated configuration setting to use sdkconfig.SetDefault.
x/authority/types/genesis_test.go Updated configuration setup in the test function to use sdkconfig.SetDefault.
x/crosschain/keeper/cctx_test.go Added new test functions for cross-chain transaction functionalities.
x/crosschain/types/cctx_test.go Removed existing test functions related to cross-chain transactions.
x/crosschain/types/message_* Updated import statements and configuration setup to use sdkconfig.
zetaclient/zetacore/client_crosschain.go Introduced a new function to retrieve outbound trackers by chain.
zetaclient/zetacore/client_test.go Added a new test function to validate the new outbound tracker retrieval method.

Assessment against linked issues

Objective Addressed Explanation
Remove go-tss and btcd dependencies in the types directories (2798) The changes do not address the removal of these dependencies.
Add a CI check that ensures the project remains importable (2798)

Suggested labels

UPGRADE_TESTS

Suggested reviewers

  • fbac
  • kingpinXD
  • swift1337
  • lumtis
  • skosito
  • brewmaster012

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

@gartnera gartnera added the no-changelog Skip changelog CI check label Sep 3, 2024
@github-actions github-actions bot added ci Changes to CI pipeline or github actions and removed no-changelog Skip changelog CI check labels Sep 3, 2024
@gartnera gartnera force-pushed the rpc-importable-test branch 2 times, most recently from 4a56ae5 to c556bc4 Compare September 3, 2024 18:29
@gartnera gartnera added no-changelog Skip changelog CI check blocked labels Sep 3, 2024
@gartnera gartnera force-pushed the rpc-importable-test branch 4 times, most recently from e96a13e to f95066d Compare September 24, 2024 17:37
@gartnera gartnera removed the blocked label Sep 24, 2024
Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 54.28571% with 16 lines in your changes missing coverage. Please review.

Project coverage is 66.39%. Comparing base (3eeb78a) to head (600e504).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
pkg/sdkconfig/sdkconfig.go 38.46% 7 Missing and 1 partial ⚠️
zetaclient/zetacore/client_crosschain.go 63.63% 5 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2817      +/-   ##
===========================================
- Coverage    66.76%   66.39%   -0.37%     
===========================================
  Files          387      389       +2     
  Lines        21745    21758      +13     
===========================================
- Hits         14517    14447      -70     
- Misses        6500     6584      +84     
+ Partials       728      727       -1     
Files with missing lines Coverage Δ
pkg/rpc/clients_crosschain.go 55.07% <ø> (-2.08%) ⬇️
pkg/sdkconfig/sdkconfig.go 38.46% <38.46%> (ø)
zetaclient/zetacore/client_crosschain.go 63.63% <63.63%> (ø)

... and 1 file with indirect coverage changes

@gartnera gartnera marked this pull request as ready for review September 24, 2024 18:15
go.mod Show resolved Hide resolved
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: 17

Outside diff range and nitpick comments (13)
contrib/rpcimportable/go.mod (1)

12-13: Enhance documentation for local development replace directive.

The commented-out replace directive for local development is a useful feature. To improve clarity and ease of use, consider adding a brief note explaining when and how to use this directive. For example:

// For local development/testing/debugging:
// 1. Uncomment the line below
// 2. Ensure the relative path is correct
// 3. Run `go mod tidy` after uncommenting
// replace github.com/zeta-chain/node => ../..

This additional context will help developers quickly understand how to leverage this feature when needed.

pkg/sdkconfig/sdkconfig.go (1)

7-17: Constants and variables are well-defined and consistent.

The use of a constant AccountAddressPrefix as the base for deriving other prefixes ensures consistency and makes future modifications easier. The naming convention is clear and follows Go standards.

Consider grouping related prefixes together for improved readability:

var (
	AccountPubKeyPrefix    = AccountAddressPrefix + "pub"
	ValidatorAddressPrefix = AccountAddressPrefix + "valoper"
	ValidatorPubKeyPrefix  = AccountAddressPrefix + "valoperpub"
	ConsNodeAddressPrefix  = AccountAddressPrefix + "valcons"
	ConsNodePubKeyPrefix   = AccountAddressPrefix + "valconspub"
)
zetaclient/zetacore/client_crosschain.go (1)

14-19: Enhance function documentation for clarity and completeness.

While the function signature is well-structured, the documentation could be more comprehensive. Consider expanding the comment to include details about the parameters and return values.

Suggested improvement:

// GetAllOutboundTrackerByChain retrieves all outbound trackers for a specified chain.
// It accepts a context, the chainID of the target chain, and an order parameter to
// determine the sorting of the results.
//
// Parameters:
//   - ctx: The context for the operation
//   - chainID: The ID of the chain to query
//   - order: The sorting order for the results (Ascending or Descending)
//
// Returns:
//   - A slice of OutboundTracker objects sorted by Nonce
//   - An error if the operation fails
func (c *Client) GetAllOutboundTrackerByChain(
	ctx context.Context,
	chainID int64,
	order interfaces.Order,
) ([]types.OutboundTracker, error) {
x/crosschain/types/message_update_tss_address_test.go (1)

15-15: Approve configuration setup modification.

The change from keeper.SetConfig(false) to sdkconfig.SetDefault(false) reflects the new approach to configuration management introduced by the sdkconfig package. This modification aligns with the overall goal of improving the project's structure.

Consider adding a brief comment explaining the purpose of sdkconfig.SetDefault(false) to enhance code readability. For example:

// Set default SDK configuration for testing
sdkconfig.SetDefault(false)

Additionally, ensure that the sdkconfig.SetDefault function is well-documented in its package, explaining its parameters and effects on the SDK configuration.

x/observer/types/message_vote_blame_test.go (1)

16-16: Approve configuration setup change and suggest documentation.

The modification from keeper.SetConfig(false) to sdkconfig.SetDefault(false) is consistent with the import statement change and likely improves the modularity of the configuration management.

To enhance code clarity and maintainability, consider adding a brief comment explaining the purpose of sdkconfig.SetDefault(false) and its impact on the test environment. For example:

// Set default SDK configuration for testing environment
sdkconfig.SetDefault(false)

Additionally, ensure that the SetDefault function in the sdkconfig package is well-documented, explaining its parameters and effects on the system configuration.

x/crosschain/types/message_whitelist_erc20_test.go (1)

15-15: Approve function call change with documentation suggestion.

The replacement of keeper.SetConfig(false) with sdkconfig.SetDefault(false) is consistent with the import changes and reflects the shift in configuration management. This modification enhances code modularity and aligns with the PR objectives.

Consider updating the documentation for the sdkconfig.SetDefault function to clarify its purpose and usage, especially if it differs from the previous keeper.SetConfig function. This will ensure that developers understand the implications of this configuration setting in the context of these tests.

x/crosschain/types/message_update_erc20_custody_pause_status_test.go (1)

16-16: Approve function call change and suggest documentation.

The replacement of keeper.SetConfig(false) with sdkconfig.SetDefault(false) is consistent with the import changes and likely improves the modularity of the configuration management.

Consider adding a comment explaining the purpose of sdkconfig.SetDefault(false) in this context, especially if it's setting a global configuration that affects multiple tests. For example:

// Set default SDK configuration to ensure consistent behavior across tests
sdkconfig.SetDefault(false)
.github/workflows/ci.yml (3)

1-1: Consider a more descriptive workflow name.

The workflow name has been changed from "PR Testing" to "ci", which is concise but less descriptive. A more informative name could better convey the workflow's purpose.

Consider renaming the workflow to "Continuous Integration" or "CI Pipeline" to maintain clarity while keeping it concise:

-name: ci
+name: Continuous Integration

The concurrency group identifier has been appropriately updated to align with the new workflow name.

Also applies to: 12-12


96-115: Approve new rpcimportable job with a minor suggestion.

The new rpcimportable job effectively addresses the PR objective of ensuring RPC package importability. It sets up the correct Go version, fetches the appropriate node module version, and runs tests in the contrib/rpcimportable directory.

Consider removing the GOPROXY: direct environment variable unless it's specifically required:

 - name: go get node
   working-directory: contrib/rpcimportable
   run: go get github.com/zeta-chain/node@${{github.event.pull_request.head.sha || github.sha}}
-  env: 
-    GOPROXY: direct

This allows the use of Go module proxies, which can improve build performance and reliability.


116-126: Approve new ci-ok job with a suggestion for improved clarity.

The new ci-ok job effectively serves as a final check to ensure all CI steps have passed, aligning with the PR objective of simplifying required status checks.

To improve clarity, consider adding a success message when all jobs pass:

 steps:
   - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
     run: |
       echo "One of the jobs failed or was cancelled"
       exit 1
+  - if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
+    run: echo "All CI jobs completed successfully"

This addition provides explicit confirmation when all checks pass, enhancing the workflow's readability.

testutil/keeper/emissions.go (1)

36-36: Approve the configuration update with a minor suggestion.

The change from SetConfig(false) to sdkconfig.SetDefault(false) appears to be a positive step towards more modular configuration management. This update aligns with best practices by utilizing a dedicated package for SDK configuration.

To enhance code clarity and maintainability, consider extracting the boolean parameter into a named constant or variable with a descriptive name. This would improve readability and make the purpose of the false value more explicit.

Consider refactoring the line as follows:

const useTestConfig = false
sdkconfig.SetDefault(useTestConfig)

This change would make the intent of the configuration setting more apparent to future readers of the code.

x/observer/types/message_vote_block_header_test.go (1)

Line range hint 1-214: Summary of changes and recommendations.

The modifications to this test file are minimal and focused on improving the import structure and configuration management. These changes align well with the project's objectives of simplifying imports and reducing dependencies. The core test logic remains unchanged, which is appropriate.

Recommendations:

  1. Ensure that all tests pass with the new sdkconfig.SetDefault function.
  2. Consider adding a comment explaining the purpose of sdkconfig.SetDefault(false) to improve code readability.
  3. If not already done, update any related documentation to reflect these changes in configuration management.
x/authority/types/policies_test.go (1)

Further Action Required: setConfig Function is Still in Use

The setConfig function removal cannot be approved at this time as it is still referenced in cmd/zetacored/parse_genesis_test.go. Please ensure that all usages of setConfig are addressed before proceeding with its removal.

Analysis chain

Line range hint 1-258: Removal of setConfig function is appropriate.

The elimination of the setConfig function aligns with the PR objectives of simplifying imports and reducing internal logic in the types package. This change contributes to a more streamlined and maintainable codebase.

To ensure that no other tests or files depended on the removed setConfig function, please run the following verification script:

If the script returns no results, it confirms that the setConfig function was not used elsewhere in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that setConfig is not used elsewhere in the codebase

# Test: Search for any remaining usage of setConfig function
rg --type go 'func setConfig\(' .
rg --type go 'setConfig\(' .

Length of output: 414

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3eba701 and 50db18b.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (23)
  • .github/workflows/ci.yml (3 hunks)
  • contrib/rpcimportable/go.mod (1 hunks)
  • contrib/rpcimportable/rpcimportable_test.go (1 hunks)
  • go.mod (1 hunks)
  • pkg/rpc/clients_crosschain.go (0 hunks)
  • pkg/rpc/clients_test.go (0 hunks)
  • pkg/sdkconfig/sdkconfig.go (1 hunks)
  • testutil/keeper/config.go (0 hunks)
  • testutil/keeper/emissions.go (2 hunks)
  • x/authority/types/genesis_test.go (1 hunks)
  • x/authority/types/policies_test.go (1 hunks)
  • x/crosschain/keeper/cctx_test.go (2 hunks)
  • x/crosschain/types/cctx_test.go (0 hunks)
  • x/crosschain/types/message_migrate_erc20_custody_funds_test.go (1 hunks)
  • x/crosschain/types/message_migrate_tss_funds_test.go (1 hunks)
  • x/crosschain/types/message_update_erc20_custody_pause_status_test.go (1 hunks)
  • x/crosschain/types/message_update_tss_address_test.go (1 hunks)
  • x/crosschain/types/message_whitelist_erc20_test.go (1 hunks)
  • x/emissions/abci_test.go (2 hunks)
  • x/observer/types/message_vote_blame_test.go (1 hunks)
  • x/observer/types/message_vote_block_header_test.go (1 hunks)
  • zetaclient/zetacore/client_crosschain.go (1 hunks)
  • zetaclient/zetacore/client_test.go (2 hunks)
Files not reviewed due to no reviewable changes (4)
  • pkg/rpc/clients_crosschain.go
  • pkg/rpc/clients_test.go
  • testutil/keeper/config.go
  • x/crosschain/types/cctx_test.go
Additional context used
Path-based instructions (16)
contrib/rpcimportable/rpcimportable_test.go (1)

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

pkg/sdkconfig/sdkconfig.go (1)

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

testutil/keeper/emissions.go (1)

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

x/authority/types/genesis_test.go (1)

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

x/authority/types/policies_test.go (1)

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

x/crosschain/keeper/cctx_test.go (1)

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

x/crosschain/types/message_migrate_erc20_custody_funds_test.go (1)

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

x/crosschain/types/message_migrate_tss_funds_test.go (1)

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

x/crosschain/types/message_update_erc20_custody_pause_status_test.go (1)

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

x/crosschain/types/message_update_tss_address_test.go (1)

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

x/crosschain/types/message_whitelist_erc20_test.go (1)

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

x/emissions/abci_test.go (1)

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

x/observer/types/message_vote_blame_test.go (1)

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

x/observer/types/message_vote_block_header_test.go (1)

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

zetaclient/zetacore/client_crosschain.go (1)

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

zetaclient/zetacore/client_test.go (1)

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

GitHub Check: codecov/patch
pkg/sdkconfig/sdkconfig.go

[warning] 25-25: pkg/sdkconfig/sdkconfig.go#L25
Added line #L25 was not covered by tests


[warning] 29-34: pkg/sdkconfig/sdkconfig.go#L29-L34
Added lines #L29 - L34 were not covered by tests

zetaclient/zetacore/client_crosschain.go

[warning] 33-33: zetaclient/zetacore/client_crosschain.go#L33
Added line #L33 was not covered by tests


[warning] 38-39: zetaclient/zetacore/client_crosschain.go#L38-L39
Added lines #L38 - L39 were not covered by tests


[warning] 42-43: zetaclient/zetacore/client_crosschain.go#L42-L43
Added lines #L42 - L43 were not covered by tests

Additional comments not posted (25)
contrib/rpcimportable/rpcimportable_test.go (1)

1-7: Package declaration and imports are appropriate.

The package name rpcimportable aligns with the directory structure, and the imports are correctly formatted and necessary for the test function.

contrib/rpcimportable/go.mod (1)

8-10: Appropriate use of replace directive.

The replace directive for github.com/gogo/protobuf is correctly implemented. This is a common practice in Cosmos SDK-based projects to ensure compatibility with the forked version maintained by Regen Network.

pkg/sdkconfig/sdkconfig.go (1)

1-5: Package declaration and imports are appropriate.

The package name sdkconfig accurately reflects its purpose, and the import of the Cosmos SDK types package is correctly aliased. This structure promotes clean and maintainable code.

x/crosschain/types/message_update_tss_address_test.go (2)

Line range hint 1-124: Overall impact assessment: Minimal with potential for improvement.

The changes to the import statement and configuration setup appear to be part of a larger refactoring effort to improve the project's structure and importability. The test cases themselves remain unchanged, suggesting that the underlying functionality being tested is not affected.

To ensure that these changes haven't introduced any regressions, please run the entire test suite and verify that all tests pass. You can use the following command:

#!/bin/bash
# Description: Run the entire test suite for the crosschain package

# Test: Run all tests in the crosschain package. Expect: All tests pass.
go test ./x/crosschain/...

Additionally, consider adding more comprehensive tests to cover the new sdkconfig package and its integration with the existing codebase. This will help ensure the robustness of the new configuration management approach.


9-9: Approve import statement modification.

The change from keeper to sdkconfig aligns with the PR objectives of improving the project's structure and importability. This modification suggests a more focused approach to managing SDK configurations.

To ensure consistency across the codebase, please run the following script to check for any remaining references to the old import:

x/observer/types/message_vote_blame_test.go (2)

Line range hint 1-138: Verify test coverage and behavior consistency.

While the changes to the configuration setup appear localized, it's crucial to ensure that the new sdkconfig.SetDefault(false) provides the same testing environment as the previous keeper.SetConfig(false).

To maintain the integrity of the test suite, please:

  1. Run the entire test suite for the observer module to verify that all tests still pass with the new configuration setup.
  2. Review the test coverage to ensure it hasn't been inadvertently affected by the configuration change.

You can use the following commands to assist with this verification:

#!/bin/bash
# Description: Verify test coverage and consistency for the observer module

# Run tests for the observer module
go test ./x/observer/... -v

# Generate and view test coverage report
go test ./x/observer/... -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html
echo "Coverage report generated: coverage.html"

# Check for any test files that might need updating due to the configuration change
echo "Test files that might need review:"
rg --type go 'keeper\.SetConfig' ./x/observer/...

Ensure that the test results and coverage remain consistent with the previous implementation.


10-10: Approve import statement change and verify sdkconfig usage.

The change from keeper to sdkconfig aligns with the PR objectives of improving the project's importability. This modification suggests a more modular approach to configuration management.

To ensure consistency across the project, please run the following script to verify the usage of the sdkconfig package:

x/authority/types/genesis_test.go (2)

10-10: Import addition is appropriate.

The addition of the sdkconfig package import is correct and aligns with the subsequent usage in the test setup.


10-16: Changes align with PR objectives and improve code standardization.

The modifications to the import statement and test setup are consistent with the pull request's objectives of enhancing importability and simplifying the codebase. By standardizing the configuration setup through the sdkconfig package, these changes contribute to a more consistent and maintainable test suite. This approach should facilitate easier imports for external users and simplify the management of configuration across the project.

x/crosschain/types/message_whitelist_erc20_test.go (1)

9-9: Approve import change with verification suggestion.

The replacement of the keeper package import with sdkconfig aligns with the PR objectives of improving code structure and importability. This change suggests a shift in configuration management, which is a positive step towards better modularity.

To ensure this change is consistent across the codebase, please run the following verification script:

x/crosschain/types/message_update_erc20_custody_pause_status_test.go (1)

Line range hint 1-138: Summarize overall impact and suggest comprehensive testing.

The changes to this file are part of a larger refactoring effort to improve the project's structure and importability. While the modifications are minimal and don't affect the test cases directly, it's crucial to ensure that these changes don't introduce any unintended side effects.

To validate the changes:

  1. Run the entire test suite to confirm that all tests still pass:

    go test ./...
  2. If you have a CI/CD pipeline, ensure that all stages complete successfully, including any integration or end-to-end tests that might be affected by configuration changes.

  3. Manually verify that the behavior of the MsgUpdateERC20CustodyPauseStatus message remains consistent with the expected functionality in a test environment.

x/crosschain/types/message_migrate_tss_funds_test.go (2)

17-17: Approve function call change and suggest documentation update.

The replacement of keeper.SetConfig(false) with sdkconfig.SetDefault(false) is consistent with the import statement change and appears to maintain the same functionality. The new function name, SetDefault, is more descriptive and aligns with best practices for clear and self-explanatory method naming.

To ensure clarity for other developers, consider updating any relevant documentation to reflect this change in configuration management approach. If there's a README or documentation file for this package, it would be beneficial to mention the transition from keeper.SetConfig to sdkconfig.SetDefault.


Line range hint 1-138: Summary of changes and suggestion for comprehensive testing.

The modifications to this test file, namely the import statement change and the function call update, appear to be part of a larger refactoring effort to improve the project's structure and importability. These changes align well with the PR objectives of addressing dependency issues and ensuring the project remains importable.

While the core functionality of the test cases remains unchanged, it's crucial to ensure that these modifications haven't introduced any unintended side effects.

To validate the changes:

  1. Run the entire test suite to ensure no regressions:

  2. Verify that the new sdkconfig.SetDefault(false) function behaves identically to the previous keeper.SetConfig(false):

Review the results to ensure consistent usage and behavior across the project.

.github/workflows/ci.yml (1)

Line range hint 1-127: Approve overall workflow structure.

The updated workflow structure effectively incorporates the new rpcimportable job and the final ci-ok check while maintaining existing functionality. This aligns well with the PR objectives of adding an importability check and simplifying status checks.

The dependency structure ensures that all checks are completed before the final status is determined, providing a comprehensive CI process.

The workflow now provides a robust and comprehensive CI pipeline that addresses the project's needs.

Tools
actionlint

95-95: shellcheck reported issue in this script: SC2035:info:1:8: Use ./glob or -- glob so names with dashes won't become options

(shellcheck)

x/observer/types/message_vote_block_header_test.go (1)

15-15: Import change approved.

The replacement of the keeper package with sdkconfig aligns with the project's goal of simplifying imports and reducing dependencies. This change contributes to a cleaner and more maintainable codebase.

x/crosschain/types/message_migrate_erc20_custody_funds_test.go (3)

Line range hint 1-170: Comprehensive test coverage with room for enhancement.

The test file provides thorough coverage for the MsgMigrateERC20CustodyFunds message type, including various scenarios for message validation and signer verification. The recent changes in import statements and configuration setup appear to be isolated and don't directly affect the existing test cases.

To further improve the test suite, consider the following suggestions:

  1. Add test cases that specifically verify the behavior affected by the new sdkconfig.SetDefault(false) configuration.
  2. Include edge cases for the Amount field, such as testing with the maximum allowed value.
  3. Consider adding benchmarks for performance-critical operations, if applicable.
  4. Enhance documentation by adding comments explaining the purpose of each test case group.

17-17: Verify the equivalence of the new configuration setup.

The change from keeper.SetConfig(false) to sdkconfig.SetDefault(false) aligns with the import statement modification. However, it's crucial to ensure that this new setup provides equivalent functionality for the test cases.

To confirm that the new configuration setup maintains the intended test behavior, please run the following verification:

#!/bin/bash
# Description: Verify the usage and impact of the new sdkconfig.SetDefault function

# Test 1: Check for any remaining usage of the old keeper.SetConfig function
echo "Searching for any remaining usage of keeper.SetConfig:"
rg --type go 'keeper\.SetConfig'

# Test 2: Verify the usage of the new sdkconfig.SetDefault function
echo "Verifying usage of sdkconfig.SetDefault:"
rg --type go 'sdkconfig\.SetDefault'

# Test 3: Check for any test failures that might be related to this change
echo "Running tests to check for any failures:"
go test ./x/crosschain/types/... -v

Please review the test results to ensure that the new configuration setup maintains the intended test behavior and doesn't introduce any regressions.


11-11: Evaluate the impact of the configuration management change.

The replacement of the keeper package with sdkconfig indicates a shift in the configuration management approach. This change may have implications for other parts of the codebase that rely on the previous keeper package for configuration.

To ensure this change doesn't introduce unintended side effects, please run the following verification:

Verification successful

Further Verification Required for Configuration Management Changes

The previous verification attempt encountered an error when executing go test, which is unsupported in the current environment. To ensure that the keeper package has been entirely removed and that the sdkconfig package is correctly implemented, please execute the following shell scripts:


Configuration Management Change Verified Successfully

The old keeper package has been completely removed, and the new sdkconfig package is correctly imported and utilized across all relevant test files. No issues were found regarding the configuration management changes.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to the old keeper package and verify the usage of the new sdkconfig package.

# Test 1: Search for any remaining imports of the old keeper package
echo "Searching for remaining keeper package imports:"
rg --type go 'import.*"github\.com/zeta-chain/node/x/crosschain/keeper"'

# Test 2: Verify the usage of the new sdkconfig package
echo "Verifying usage of the new sdkconfig package:"
rg --type go 'import.*"github\.com/zeta-chain/node/pkg/sdkconfig"'
rg --type go 'sdkconfig\.SetDefault'

Length of output: 1310


Script:

#!/bin/bash
# Description: Verify the removal of the old keeper package and the proper usage of the new sdkconfig package.

# Test 1: Ensure no imports of the old keeper package remain
echo "Checking for any remaining imports of 'github.com/zeta-chain/node/x/crosschain/keeper':"
rg --type go 'import.*"github\.com/zeta-chain/node/x/crosschain/keeper"'

# Test 2: Confirm the new sdkconfig package is correctly imported
echo "Verifying imports of 'github.com/zeta-chain/node/pkg/sdkconfig':"
rg --type go 'import.*"github\.com/zeta-chain/node/pkg/sdkconfig"'

# Test 3: Check for usage of sdkconfig.SetDefault
echo "Searching for usage of 'sdkconfig.SetDefault':"
rg --type go 'sdkconfig\.SetDefault'

Length of output: 1454

x/authority/types/policies_test.go (3)

8-8: Import change is appropriate.

The addition of the sdkconfig package import aligns with the modifications in the test setup, replacing the previous setConfig function.


Line range hint 1-258: Summary of changes and their impact.

The modifications in this file effectively simplify the test setup process by replacing the setConfig function with a direct call to sdkconfig.SetDefault(false). These changes align with the PR objectives of streamlining imports and reducing internal logic in the types package. The existing test cases remain intact, maintaining the overall test coverage and functionality.

The improvements contribute to a more maintainable and cleaner codebase, which should facilitate easier imports for external users. However, it is crucial to verify that the new configuration setup provides equivalent functionality to the previous approach and that the removal of setConfig does not impact other parts of the codebase.


14-14: Test setup simplification is appropriate.

The replacement of setConfig with sdkconfig.SetDefault(false) streamlines the test setup process. This change eliminates the need for error handling related to configuration sealing, resulting in a more concise and maintainable test setup.

To ensure the new setup provides equivalent configuration, please verify that sdkconfig.SetDefault(false) sets the same bech32 prefixes for Zeta Chain accounts as the previous setConfig function. You can run the following script to check the configuration:

Verification successful

Configuration Verification Successful.

The usage of sdkconfig.SetDefault(false) in place of setConfig has been verified across the codebase. This change consistently sets the necessary Bech32 prefixes without sealing the configuration, ensuring a flexible and reliable test setup similar to the previous implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the configuration set by sdkconfig.SetDefault(false)

# Test: Search for the SetDefault function usage and its surrounding context
rg --type go -A 10 -B 10 'SetDefault\(false\)' pkg/sdkconfig

Length of output: 62


Script:

#!/bin/bash
# Description: Search the entire codebase for all usages of the SetDefault function

# Search for any occurrence of SetDefault in Go files with context lines
rg --type go 'SetDefault\(' -A 5 -B 5

Length of output: 9662

zetaclient/zetacore/client_test.go (1)

12-12: Import statements are correctly added and necessary.

The new import statements for query, chains, and interfaces are appropriately placed and required for the new test function. They contribute to the enhanced functionality without introducing unnecessary dependencies.

Also applies to: 19-20

go.mod (1)

60-60: Approve dependency update with verification recommendation.

The update to github.com/zeta-chain/ethermint appears to be a minor version change. This aligns with the PR objectives of addressing import issues and improving the project's importability.

To ensure compatibility, please run the following verification script:

x/emissions/abci_test.go (2)

Line range hint 1-524: LGTM: Comprehensive test coverage for emissions module.

The existing test cases in this file provide thorough coverage for the emissions module, particularly for observer rewards distribution. The various scenarios tested, including different voting patterns and reward calculations, contribute to a robust test suite.


315-315: Verify the impact of configuration change across the codebase.

The change from keepertest.SetConfig(false) to sdkconfig.SetDefault(false) appears to be a refactoring of the configuration setup. While this change is likely part of a larger effort to standardize configuration management, it's crucial to ensure consistency across the entire codebase.

To assess the impact of this change, please run the following script:

This script will help identify any inconsistencies in configuration management across the project.

Verification successful

Configuration refactoring successfully verified across the codebase.

The replacement of keepertest.SetConfig(false) with sdkconfig.SetDefault(false) has been consistently applied throughout the project. No instances of keepertest.SetConfig remain, and sdkconfig.SetDefault(false) is uniformly used in relevant test files, ensuring standardized configuration management.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of keepertest.SetConfig and identify other occurrences of sdkconfig.SetDefault

echo "Checking for remaining usage of keepertest.SetConfig:"
rg --type go "keepertest\.SetConfig"

echo "\nChecking for other occurrences of sdkconfig.SetDefault:"
rg --type go "sdkconfig\.SetDefault"

echo "\nChecking for any potential imports of keepertest that might be related to SetConfig:"
rg --type go "import.*keepertest"

Length of output: 1365

contrib/rpcimportable/rpcimportable_test.go Show resolved Hide resolved
contrib/rpcimportable/rpcimportable_test.go Show resolved Hide resolved
contrib/rpcimportable/go.mod Show resolved Hide resolved
contrib/rpcimportable/go.mod Show resolved Hide resolved
pkg/sdkconfig/sdkconfig.go Show resolved Hide resolved
zetaclient/zetacore/client_test.go Show resolved Hide resolved
x/crosschain/keeper/cctx_test.go Show resolved Hide resolved
x/crosschain/keeper/cctx_test.go Show resolved Hide resolved
x/crosschain/keeper/cctx_test.go Show resolved Hide resolved
@gartnera gartnera added this pull request to the merge queue Sep 27, 2024
Merged via the queue into develop with commit f789138 Sep 27, 2024
33 of 34 checks passed
@gartnera gartnera deleted the rpc-importable-test branch September 27, 2024 16:56
morde08 pushed a commit that referenced this pull request Oct 2, 2024
* ci: add rpcimportable test

* add ci

* fmt

* use github.com/btcsuite/btcd/btcutil in pkg/chains

* remove app imports types tests

* use standalone sdkconfig package

* fix policies test

* move crosschain keeper tests from types to keeper

* never seal config in tests

* use zeta-chain/ethermint#126

* add some comments

* use merged ethermint hash

* show resulting go.mod
github-merge-queue bot pushed a commit that referenced this pull request Oct 3, 2024
…guration (#2953)

* update artillery config

* more fixes

* feat: integrate authenticated calls smart contract functionality into protocol (#2904)

* e2e tests and modifications for authenticated call

* extend test with sender check and revert case

* separate tests into separate files

* cleanup

* withdraw and call support and tests

* bump protocol contracts

* split tests into separate files

* small cleanup

* fmt

* generate

* lint

* changelog

* PR  comments

* fix case in proto

* bump vote inbound gas limit in zetaclient

* fix test

* generate

* fixing tests

* call options non empty

* generate

* test fix

* rename gateway caller

* pr comments rename tests

* PR comment

* generate

* tests

* update tests fixes

* tests fixes

* fix

* test fix

* feat!: bank precompile (#2860)

* feat: bank precompile

* feat: add deposit

* feat: extend deposit

* PoC: spend amount on behalf of EOA

* feat: expand deposit with transferFrom

* use CallEVM instead on ZRC20 bindings

* divide the contract into different files

* initialize e2e testing

* remove duplicated funding

* add codecov

* expand e2e

* fix: wait for deposit tx to be mined

* apply first round of reviews

* cover al error types test

* fixes using time.Since

* Include CallContract interface

* fix eth events in deposit precompile method

* emit Deposit event

* add withdraw function

* finalize withdraw

* pack event arguments generically

* add high level event function

* first round of review fixes

* second round of reviews

* create bank account when instantiating bank

* e2e: add good and bad scenarios

* modify fmt

* chore: group input into eventData struct

* docs: document bank's methods

* chore: generate files with suffix .gen.go

* chore: assert errors with errorIs

* chore: reset e2e test by resetting allowance

* test: add first batch of unit test

* test: cover all cases

* test: complete unit test cases

* include review suggestions

* include e2e through contract

* test: add e2e through contract complete

* test: revert balance between tests

* Update precompiles/bank/const.go

Co-authored-by: Lucas Bertrand <[email protected]>

* fix: changed coin denom

---------

Co-authored-by: skosito <[email protected]>
Co-authored-by: Lucas Bertrand <[email protected]>

* feat: add sender to revert context (#2919)

* e2e tests and modifications for authenticated call

* extend test with sender check and revert case

* separate tests into separate files

* cleanup

* withdraw and call support and tests

* bump protocol contracts

* split tests into separate files

* small cleanup

* fmt

* generate

* lint

* changelog

* PR  comments

* fix case in proto

* bump vote inbound gas limit in zetaclient

* fix test

* generate

* fixing tests

* call options non empty

* generate

* test fix

* rename gateway caller

* pr comments rename tests

* PR comment

* generate

* tests

* add sender in test contract

* extend e2e tests

* generate

* changelog

* PR comment

* generate

* update tests fixes

* tests fixes

* fix

* test fix

* gas limit fixes

* PR comment fix

* fix bad merge

* ci: add option to enable monitoring stack (#2927)

* ci: add option to enable monitoring stack

* start prometheus faster

* update

* ci: add rpcimportable test (#2817)

* ci: add rpcimportable test

* add ci

* fmt

* use github.com/btcsuite/btcd/btcutil in pkg/chains

* remove app imports types tests

* use standalone sdkconfig package

* fix policies test

* move crosschain keeper tests from types to keeper

* never seal config in tests

* use zeta-chain/ethermint#126

* add some comments

* use merged ethermint hash

* show resulting go.mod

* ci: Add SARIF upload to GitHub Security Dashboard (#2929)

* add semgrep sarif upload to GHAS

* added comment to clairfy the usage of the utility script

* use ghcr.io instead

* add tag to image

* bad org name

---------

Co-authored-by: jkan2 <[email protected]>

* fix: add recover to InitChainer to diplay informative message when starting a node from block 1 (#2925)

* add recover to InitChainer

* generate files

* add docs link to error message

* move InitChainErrorMessage to app.go

* Update app/app.go

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>

* use const for message

---------

Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>

* test: add wait for block to tss migration test (#2931)

* add wait for block to tss migration test

* add comments

* refactor identifiers

* rename checkNumberOfTssGenerated to checkNumberOfTSSGenerated

* chore: allow full zetaclient config overlay (#2945)

* test(e2e): add gateway upgrade in upgrade test (#2932)

* add gateway upgrade

* change reference

* add v2 setup for all tests

* test v2 in light upgrade

* refactor setup to use custody v2 directly

* chore: improve localnet build performance (#2928)

* chore: improve localnet build performance

* propagate NODE_VERSION and NODE_COMMIT

* update hashes

---------

Co-authored-by: skosito <[email protected]>
Co-authored-by: Francisco de Borja Aranda Castillejo <[email protected]>
Co-authored-by: Lucas Bertrand <[email protected]>
Co-authored-by: Alex Gartner <[email protected]>
Co-authored-by: jkan2 <[email protected]>
Co-authored-by: jkan2 <[email protected]>
Co-authored-by: Tanmay <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Changes to CI pipeline or github actions no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing zeta-chain/node from another go module fails
4 participants