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

(OraklNode) Update Klaytn -> Kaia #1606

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Conversation

nick-bisonai
Copy link
Collaborator

Description

Update variable and function names including Klaytn

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Deployment

  • Should publish npm package
  • Should publish Docker image

@nick-bisonai nick-bisonai self-assigned this Jun 12, 2024
@nick-bisonai nick-bisonai requested a review from a team as a code owner June 12, 2024 08:33
Copy link
Contributor

coderabbitai bot commented Jun 12, 2024

Warning

Review failed

The pull request is closed.

Walkthrough

Walkthrough

The changes across the codebase involve renaming everything associated with the Klaytn blockchain to Kaia. This includes constants, functions, variables, environment variables, and tests. The code now consistently uses Kaia for blockchain interactions, provider URLs, and reporter private keys, reflecting a migration from the Klaytn blockchain to Kaia.

Changes

Files & Paths Change Summary
.../helper/helper.go Updated blockchain type constants, environment variables, and secret keys from Klaytn to Kaia.
.../helper/types.go Renamed BlockchainType values from Klaytn to Kaia. Updated related functions, constants, and environment variables.
.../tests/chain_test.go Renamed references from klaytnHelper to kaiaHelper in tests.
.../app.go Modified blockchain type and functions from Klaytn to Kaia.
.../por/por_test.go Updated test case references from KlaytnHelper to KaiaHelper.
.../por/types.go Changed App struct field from KlaytnHelper to KaiaHelper.
.../reporter/app.go Updated function calls from KlaytnHelper to KaiaHelper in startReporter and stopReporter functions.
.../reporter/reporter.go Renamed functions and variables from KlaytnHelper to KaiaHelper. Updated references in methods of Reporter struct.
.../reporter/reporter_test.go Renamed function call from SetKlaytnHelper to SetKaiaHelper in tests.
.../script/test_submission/main.go Changed variable name and method calls from klaytnHelper to kaiaHelper in test functions.

Poem

Amid the code in bytes they roam,
From Klaytn fields to Kaia's home,
Constants changed, functions too,
A blockchain shift, like morning dew.
Kaia leads with data's story,
In every line, a coder's glory.
🎉🐇✨


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>.
    • 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 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.
    • @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 as 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.

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/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
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: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f0381e1 and 75733bc.

Files selected for processing (15)
  • node/.env.example (2 hunks)
  • node/.env.local (1 hunks)
  • node/README.md (3 hunks)
  • node/pkg/chain/helper/helper.go (2 hunks)
  • node/pkg/chain/helper/types.go (2 hunks)
  • node/pkg/chain/tests/chain_test.go (10 hunks)
  • node/pkg/error/sentinel.go (1 hunks)
  • node/pkg/por/app.go (6 hunks)
  • node/pkg/por/por_test.go (1 hunks)
  • node/pkg/por/types.go (1 hunks)
  • node/pkg/reporter/app.go (2 hunks)
  • node/pkg/reporter/reporter.go (3 hunks)
  • node/pkg/reporter/reporter_test.go (1 hunks)
  • node/pkg/reporter/types.go (1 hunks)
  • node/script/test_submission/main.go (1 hunks)
Files skipped from review due to trivial changes (3)
  • node/.env.local
  • node/pkg/error/sentinel.go
  • node/pkg/reporter/types.go
Additional context used
golangci-lint
node/pkg/chain/helper/helper.go

60-60: Function 'NewChainHelper' has too many statements (46 > 40) (funlen)

LanguageTool
node/README.md

[uncategorized] ~41-~41: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...oose coupling between packages: - cmd: Holds entry points to run basic functio...


[uncategorized] ~42-~42: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...un basic functionalities. - migrations: Migration files to initialize PostgreSQ...


[uncategorized] ~43-~43: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...to initialize PostgreSQL tables. - pkg: Implementation packages for off-chain a...


[uncategorized] ~44-~44: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...ges for off-chain aggregator. - script: Scripts for testing purposes, such as s...


[uncategorized] ~45-~45: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... tests or temporary usage. - taskfiles: Taskfile holding commands to run the ap...

Markdownlint
node/README.md

307-307: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


3-3: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading

Additional comments not posted (18)
node/.env.example (2)

6-6: Renaming of KLAYTN_PROVIDER_URL to KAIA_PROVIDER_URL aligns with the PR objectives. Ensure this change is consistently applied across all configuration files and code references.

Verification successful

The renaming of KLAYTN_PROVIDER_URL to KAIA_PROVIDER_URL has been consistently applied across the codebase.

  • node/README.md: KAIA_PROVIDER_URL=<Your Provider URL>
  • node/pkg/por/app.go: providerUrl = os.Getenv("KAIA_PROVIDER_URL")
  • node/pkg/chain/helper/types.go: KaiaProviderUrl = "KAIA_PROVIDER_URL"
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `KAIA_PROVIDER_URL` across the codebase.

# Test: Search for the old and new variable names. Expect: Only occurrences of the new variable name.
rg --type all $'KAIA_PROVIDER_URL|KLAYTN_PROVIDER_URL'

Length of output: 245


31-31: Renaming of KLAYTN_REPORTER_PK to KAIA_REPORTER_PK is consistent with the blockchain transition. Verify that this change is reflected wherever the reporter PK is used.

Verification successful

The renaming of KLAYTN_REPORTER_PK to KAIA_REPORTER_PK has been consistently applied across the codebase.

  • node/README.md
  • node/pkg/chain/tests/chain_test.go
  • node/pkg/chain/helper/types.go
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `KAIA_REPORTER_PK` across the codebase.

# Test: Search for the old and new variable names. Expect: Only occurrences of the new variable name.
rg --type all $'KAIA_REPORTER_PK|KLAYTN_REPORTER_PK'

Length of output: 428

node/pkg/por/types.go (1)

46-46: The addition of KaiaHelper to the App struct aligns with the blockchain transition. Ensure that KaiaHelper is properly integrated and utilized in the application logic.

Verification successful

The integration of KaiaHelper appears to be thorough, with multiple references across the codebase. Here are the key points of interest:

  • Initialization: Ensure KaiaHelper is properly initialized in node/pkg/reporter/app.go and node/pkg/por/app.go.
  • Usage: Verify its usage in transaction creation, contract reading, and error handling in node/pkg/reporter/reporter.go and node/pkg/por/app.go.
  • Testing: Confirm that the unit tests in node/pkg/reporter/reporter_test.go and node/pkg/por/por_test.go cover the necessary scenarios.

Key Locations:

  • node/pkg/reporter/app.go
  • node/pkg/reporter/reporter.go
  • node/pkg/por/app.go
  • node/pkg/reporter/reporter_test.go
  • node/pkg/por/por_test.go

The integration of KaiaHelper seems consistent and well-covered in the codebase. However, manual verification of the initialization and usage in the mentioned files is recommended to ensure completeness.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of `KaiaHelper` in the application logic.

# Test: Search for the usage of `KaiaHelper`. Expect: Proper initialization and usage in the application logic.
rg --type all $'KaiaHelper'

Length of output: 2341

node/script/test_submission/main.go (3)

15-29: The function testContractDirectCall correctly initializes KaiaHelper, makes a transaction, and submits it. Good use of error handling and logging.


33-50: The function testContractFeeDelegatedCall correctly handles the initialization of KaiaHelper and performs fee-delegated transactions. Proper error handling and logging are maintained.


50-50: The main function orchestrates contract testing effectively, with appropriate error handling and initialization of helpers.

node/pkg/por/app.go (3)

Line range hint 31-88: The New function has been updated to use KaiaHelper and handles the initialization and error scenarios appropriately.


213-219: The report function correctly uses KaiaHelper for blockchain interactions, maintaining consistency with the updated blockchain references.


Line range hint 247-271: The functions GetRoundID and GetLastInfo effectively use KaiaHelper to interact with the blockchain, handling errors and type casting appropriately.

node/pkg/chain/helper/helper.go (2)

23-33: The function setProviderAndReporter correctly handles the setup for Kaia using environment variables and secret management. Good error handling and logging practices are observed.


Line range hint 23-62: The NewChainHelper function has been correctly updated to initialize with Kaia settings. It handles additional wallets and provider URLs effectively.

node/pkg/reporter/app.go (2)

Line range hint 262-290: The function startReporter correctly initializes KaiaHelper and handles errors effectively. Good logging practices are observed.


290-290: The function stopReporter correctly handles the closure of KaiaHelper and manages the reporter's lifecycle effectively.

node/README.md (2)

99-100: Update environment variable names to reflect the blockchain change.

The renaming of environment variables from KLAYTN_PROVIDER_URL and KLAYTN_REPORTER_PK to KAIA_PROVIDER_URL and KAIA_REPORTER_PK aligns with the PR's objective to transition from Klaytn to Kaia. Ensure that all references to these variables in the codebase are updated accordingly.

Also applies to: 120-121


196-196: Ensure the .env file is updated with the correct variable names.

Verification successful

The search results indicate that the environment variables DATABASE_URL, KAIA_PROVIDER_URL, SIGNER_PK, and KAIA_REPORTER_PK are present in the codebase, including in the node/README.md file. This confirms that the README file is instructing users to update the correct variable names in the .env file.

  • node/README.md contains instructions to update these variables.
  • The variables are also referenced in various parts of the codebase, indicating their usage.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the .env file contains the new variable names.

# Test: Search for the old and new variable names in the .env file. Expect: Only new variable names should be present.
rg --type env $'KAIA_PROVIDER_URL|KAIA_REPORTER_PK' .env

Length of output: 85



Script:

#!/bin/bash
# Description: Verify that the .env file contains the correct variable names.

# Test: Search for the old and new variable names in the .env file. Expect: Only new variable names should be present.
rg 'KAIA_PROVIDER_URL|KAIA_REPORTER_PK|DATABASE_URL|SIGNER_PK' .env

Length of output: 114



Script:

#!/bin/bash
# Description: Verify that the repository contains a sample .env file with the correct variable names.

# Test: Search for .env.example or similar files and check for the variable names.
fd -e example -e sample -e env | xargs rg 'KAIA_PROVIDER_URL|KAIA_REPORTER_PK|DATABASE_URL|SIGNER_PK'

Length of output: 2767

node/pkg/reporter/reporter.go (1)

198-198: Update function calls to use the new KaiaHelper.

The changes correctly update the helper references from KlaytnHelper to KaiaHelper, aligning with the PR's objective. Ensure that all instances where these helpers are used have been updated to prevent runtime errors.

Also applies to: 252-253, 277-277, 283-283, 288-288, 296-296, 304-304, 307-316

node/pkg/chain/tests/chain_test.go (1)

24-24: Ensure the test cases are updated to use KaiaHelper.

The renaming in the test cases from KlaytnHelper to KaiaHelper is consistent with the changes throughout the codebase. This is crucial for maintaining the integrity of the tests post-renaming.

Also applies to: 45-45, 99-99, 113-113, 161-161, 208-208, 265-265, 291-291, 543-543

node/pkg/reporter/reporter_test.go (1)

88-88: The update from SetKlaytnHelper to SetKaiaHelper aligns with the PR's objectives. Ensure that all instances of the old helper are updated across the project.

Verification successful

The verification confirms that all instances of SetKlaytnHelper have been replaced with SetKaiaHelper in the codebase.

  • node/pkg/reporter/app.go
  • node/pkg/reporter/reporter.go
  • node/pkg/reporter/reporter_test.go
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all function calls to `SetKlaytnHelper` are replaced with `SetKaiaHelper`.

# Test: Search for the function usage. Expect: No occurrences of the old function.
rg --type go $'SetKlaytnHelper'

Length of output: 30



Script:

#!/bin/bash
# Description: Verify all function calls to `SetKaiaHelper` are present in the codebase.

# Test: Search for the function usage. Expect: Occurrences of the new function.
rg --type go $'SetKaiaHelper'

Length of output: 245

node/pkg/por/por_test.go Show resolved Hide resolved
node/pkg/chain/helper/helper.go Show resolved Hide resolved
node/pkg/chain/helper/types.go Show resolved Hide resolved
@nick-bisonai nick-bisonai force-pushed the feat/rename-klaytn-inside-node branch from 03d98a4 to 0a9492a Compare June 14, 2024 04:34
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: 4

Outside diff range and nitpick comments (7)
node/pkg/por/app.go (1)

Line range hint 22-22: Consider refactoring the New function to reduce complexity and improve readability.

node/pkg/reporter/app.go (1)

Line range hint 38-38: The function setReporters is overly complex and lengthy. Consider refactoring to simplify and enhance clarity.

node/README.md (2)

Line range hint 99-121: Please update the environment variable names in the troubleshooting section to reflect the change from Klaytn to Kaia.

- ### `Klaytn` package compile error
+ ### `Kaia` package compile error

[Reference](https://github.com/klaytn/klaytn/issues/197#issuecomment-612597933)

1. Install C compilers

```sh
# use the appropriate command depending on the instance environment
sudo apt-get install -y g++-x86-64-linux-gnu libc6-dev-amd64-cross
  1. Set variables
set CGO_ENABLED=1
set CC=[c cross compiler]
set GOOS=linux
set GOARCH=amd64

---

Line range hint `316-316`: Consider using only one top-level heading in the document to adhere to best markdown practices.

```diff
- # POR
+ ## POR
node/pkg/reporter/reporter.go (1)

Line range hint 294-294: Consider refactoring deviationJob to reduce its complexity and improve maintainability.

node/pkg/chain/tests/chain_test.go (2)

Line range hint 24-51: Consider using table-driven tests to consolidate these similar test cases, which will improve readability and maintainability.

tests := []struct{
    chainID   int
    url       string
    priority  int
    wantError bool
}{
    {1001, "https://public-en.kairos.node.kaia.io", 1, false},
    {1001, "https://public-en.kairos.node.kaia.io", 2, false},
}

for _, tc := range tests {
    err := db.QueryWithoutResult(ctx, InsertProviderUrlQuery, map[string]any{
        "chain_id": tc.chainID,
        "url": tc.url,
        "priority": tc.priority,
    })
    if (err != nil) != tc.wantError {
        t.Errorf("Unexpected error: %v", err)
    }
}

Line range hint 304-304: Refactor to simplify nested if statements, which will enhance code clarity and maintainability.

Also applies to: 331-331

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 75733bc and 0a9492a.

Files selected for processing (16)
  • .github/workflows/node.test.yaml (1 hunks)
  • node/.env.example (2 hunks)
  • node/.env.local (1 hunks)
  • node/README.md (3 hunks)
  • node/pkg/chain/helper/helper.go (2 hunks)
  • node/pkg/chain/helper/types.go (2 hunks)
  • node/pkg/chain/tests/chain_test.go (10 hunks)
  • node/pkg/error/sentinel.go (1 hunks)
  • node/pkg/por/app.go (6 hunks)
  • node/pkg/por/por_test.go (1 hunks)
  • node/pkg/por/types.go (1 hunks)
  • node/pkg/reporter/app.go (2 hunks)
  • node/pkg/reporter/reporter.go (3 hunks)
  • node/pkg/reporter/reporter_test.go (1 hunks)
  • node/pkg/reporter/types.go (1 hunks)
  • node/script/test_submission/main.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • node/.env.example
Files skipped from review as they are similar to previous changes (8)
  • node/.env.local
  • node/pkg/chain/helper/types.go
  • node/pkg/error/sentinel.go
  • node/pkg/por/por_test.go
  • node/pkg/por/types.go
  • node/pkg/reporter/reporter_test.go
  • node/pkg/reporter/types.go
  • node/script/test_submission/main.go
Additional context used
Gitleaks
.github/workflows/node.test.yaml

96-97: Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches. (hashicorp-tf-password)

golangci-lint
node/pkg/por/app.go

22-22: Function 'New' is too long (68 > 60) (funlen)

node/pkg/chain/helper/helper.go

60-60: Function 'NewChainHelper' has too many statements (46 > 40) (funlen)

node/pkg/reporter/app.go

38-38: Function 'setReporters' is too long (73 > 60) (funlen)

node/pkg/reporter/reporter.go

294-294: Function 'deviationJob' has too many statements (42 > 40) (funlen)

node/pkg/chain/tests/chain_test.go

304-304: if ok has complex nested blocks (complexity: 5) (nestif)


331-331: if ok has complex nested blocks (complexity: 5) (nestif)

LanguageTool
node/README.md

[uncategorized] ~41-~41: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...oose coupling between packages: - cmd: Holds entry points to run basic functio...


[uncategorized] ~42-~42: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...un basic functionalities. - migrations: Migration files to initialize PostgreSQ...


[uncategorized] ~43-~43: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...to initialize PostgreSQL tables. - pkg: Implementation packages for off-chain a...


[uncategorized] ~44-~44: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...ges for off-chain aggregator. - script: Scripts for testing purposes, such as s...


[uncategorized] ~45-~45: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ... tests or temporary usage. - taskfiles: Taskfile holding commands to run the ap...

Markdownlint
node/README.md

316-316: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


3-3: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading

Additional comments not posted (9)
.github/workflows/node.test.yaml (1)

98-99: Update to use KAIA_PROVIDER_URL and KAIA_REPORTER_PK is consistent with the renaming strategy from Klaytn to Kaia.

node/pkg/por/app.go (5)

31-31: Correctly falls back to KAIA_PROVIDER_URL if POR_PROVIDER_URL is not set.


73-73: Properly injects Kaia as the blockchain type during the creation of a ChainHelper.


88-88: Use of KaiaHelper in the App struct aligns with the renaming objective.


213-219: The transaction submission functions correctly reference KaiaHelper, ensuring consistency with the renaming.


247-252: Proper use of KaiaHelper in contract interaction methods.

Also applies to: 271-271

node/pkg/chain/helper/helper.go (2)

23-33: Updated environmental variable and secret fetching to use Kaia references is correctly implemented.


62-62: Correct default setting for BlockchainType to Kaia reflects the renaming strategy.

node/pkg/reporter/app.go (1)

262-264: Correctly sets and utilizes KaiaHelper within the reporter logic.

Also applies to: 290-290

.github/workflows/node.test.yaml Outdated Show resolved Hide resolved
node/pkg/chain/helper/helper.go Show resolved Hide resolved
node/pkg/reporter/reporter.go Show resolved Hide resolved
node/pkg/reporter/reporter.go Show resolved Hide resolved
@martinkersner
Copy link
Member

@nick-bisonai I guess the same has to be done orakl-helm-charts at https://github.com/search?q=repo%3ABisonai%2Forakl-helm-charts%20KLAYTN&type=code

@nick-bisonai nick-bisonai force-pushed the feat/rename-klaytn-inside-node branch from dc6805c to 8d55950 Compare June 19, 2024 01:00
@nick-bisonai nick-bisonai merged commit da491f3 into master Jun 19, 2024
4 checks passed
@nick-bisonai nick-bisonai deleted the feat/rename-klaytn-inside-node branch June 19, 2024 01:06
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