Skip to content

YNU-140: rename infura_url var to blockchain_rpc#354

Merged
dimast-x merged 2 commits intomainfrom
feat/rename-infura-url
Sep 25, 2025
Merged

YNU-140: rename infura_url var to blockchain_rpc#354
dimast-x merged 2 commits intomainfrom
feat/rename-infura-url

Conversation

@dimast-x
Copy link
Contributor

@dimast-x dimast-x commented Sep 23, 2025

Summary by CodeRabbit

  • New Features
    • Added per-network BlockStep configuration via BLOCK_STEP.
  • Refactor
    • Standardized RPC variable names from *_INFURA_URL to *_BLOCKCHAIN_RPC across app and configs.
    • Generalized mainnet prefixes to ETHEREUM_, LINEA_, XRPL_EVM_*.
  • Chores
    • Updated Docker Compose and deployment configs (prod/sandbox/uat) to use new variable names and secret keys.
  • Documentation
    • README and Quick Start updated to reflect BLOCKCHAIN_RPC and revised network variable names.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Renames Infura-related env vars and struct field to BlockchainRPC across code, tests, charts, docs, and docker-compose. Adds BlockStep to NetworkConfig with default/env parse, and threads BlockchainRPC and BlockStep into custody initialization and eth client dials. No control-flow changes.

Changes

Cohort / File(s) Summary of Changes
Config struct and wiring
clearnode/config.go
Rename InfuraURLBlockchainRPC in NetworkConfig; add BlockStep uint64; parse {PREFIX}_BLOCKCHAIN_RPC and {PREFIX}_BLOCK_STEP (default 10000); require BLOCKCHAIN_RPC for network inclusion.
Custody & constructors
clearnode/custody.go, clearnode/main.go, clearnode/reconcile_cli.go
Change NewCustody parameter from infuraURLblockchainRPC; pass BlockchainRPC and BlockStep; use blockchainRPC for ethclient.Dial.
Tests updated for field rename
clearnode/channel_service_test.go, clearnode/eth_listener_test.go, clearnode/rpc_router_test.go, clearnode/rpc_router_public_test.go
Update test literals and locals: InfuraURLBlockchainRPC; variable renames where dialing or passing RPC endpoint. No logic changes.
Helm chart secrets renames
clearnode/chart/config/prod/secrets.yaml, clearnode/chart/config/uat/secrets.yaml, clearnode/chart/config/sandbox/secrets.yaml
Rename secret keys *_INFURA_URL*_BLOCKCHAIN_RPC (secret references/values unchanged except key names).
Prod chart config key normalizations
clearnode/chart/config/prod/clearnode.yaml
Replace *_MAINNET_* env keys with generalized names (e.g., ETH_MAINNET_*ETHEREUM_*, LINEA_MAINNET_*LINEA_*, XRPL_EVM_MAINNET_*XRPL_EVM_*).
Sandbox/UAT chart config renames
clearnode/chart/config/sandbox/clearnode.yaml, clearnode/chart/config/uat/clearnode.yaml
Rename Sepolia-related keys ETH_SEPOLIA_*ETHEREUM_SEPOLIA_*.
Documentation
clearnode/README.md
Rename env var POLYGON_INFURA_URLPOLYGON_BLOCKCHAIN_RPC in env list and Docker quick-start example.
Docker compose
docker-compose.yml
Rename env var ANVIL_INFURA_URLANVIL_BLOCKCHAIN_RPC (value ws://anvil:8545 unchanged).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as Clearnode App
  participant CFG as LoadConfig
  participant Env as Env Vars
  participant Net as NetworkConfig
  participant Cust as NewCustody
  participant ETH as ethclient

  App->>CFG: LoadConfig()
  CFG->>Env: Read {PREFIX}_BLOCKCHAIN_RPC, {PREFIX}_BLOCK_STEP
  Note right of CFG #d6f5d6: BLOCK_STEP defaults to 10000
  CFG-->>App: NetworkConfig (BlockchainRPC, BlockStep, ...)
  App->>Cust: NewCustody(..., BlockchainRPC, BlockStep, ...)
  Cust->>ETH: Dial(BlockchainRPC)
  ETH-->>Cust: eth client
  Cust-->>App: Custody instance
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • alessio

Poem

I twitch my whiskers at a new RPC name,
Infura rebadged, but the endpoints the same.
BlockStep tucked in, a steady small hop,
I patch YAML burrows and tests do not stop.
Hooray — the network burrow’s tidy again 🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly identifies the primary change—renaming infura_url to blockchain_rpc—and directly corresponds to the changeset which renames fields, environment variables, and constructor parameters across code and configs. It is concise, specific, and clear enough for a teammate scanning history to understand the PR's main purpose.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/rename-infura-url

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dimast-x, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the codebase by standardizing the naming convention for blockchain RPC endpoint variables and configuration keys. The change replaces specific references to 'Infura URL' with the more generic 'Blockchain RPC' to enhance clarity and allow for broader compatibility with various blockchain providers beyond Infura. This improves the maintainability and flexibility of the system's network configuration.

Highlights

  • Variable Renaming: The infura_url variables and fields have been consistently renamed to blockchain_rpc across the codebase for improved abstraction and clarity.
  • Configuration Updates: Environment variables in the README.md and Kubernetes secret configurations (secrets.yaml files) have been updated to reflect the new *_BLOCKCHAIN_RPC naming convention.
  • Codebase Refactoring: The renaming change has been propagated through Go source files (config.go, custody.go, main.go, reconcile_cli.go) and test files, ensuring all references use the new BlockchainRPC terminology.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dimast-x dimast-x changed the title feat: rename infura_url var to blockchain_rpc YNU-140: rename infura_url var to blockchain_rpc Sep 23, 2025
@codecov
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
clearnode/config.go 0.00% 5 Missing ⚠️
clearnode/custody.go 0.00% 2 Missing ⚠️
clearnode/main.go 0.00% 1 Missing ⚠️
clearnode/reconcile_cli.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully renames infura_url and related variables to the more generic blockchain_rpc across the codebase, which is a good improvement for clarity and provider agnosticism. My review focuses on a few minor inconsistencies in comments and configuration files where the old naming convention or provider-specific terms still linger. Addressing these will help fully align the code with the goal of this refactoring.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
clearnode/main.go (1)

88-95: Bug: variable shadowing empties the worker clients map.

You redeclare custodyClients inside the block, iterate over the new empty map, and pass an empty set to the worker.

Apply this fix:

-	if len(custodyClients) > 0 {
-		custodyClients := make(map[uint32]CustodyInterface, len(custodyClients))
-		for chainID, client := range custodyClients {
-			custodyClients[chainID] = client
-		}
-		worker := NewBlockchainWorker(db, custodyClients, logger)
+	if len(custodyClients) > 0 {
+		workerClients := make(map[uint32]CustodyInterface, len(custodyClients))
+		for chainID, client := range custodyClients {
+			workerClients[chainID] = client
+		}
+		worker := NewBlockchainWorker(db, workerClients, logger)
 		go worker.Start(context.Background())
 	}
🧹 Nitpick comments (5)
clearnode/README.md (1)

141-148: Update leftover INFURA_URL mention to BLOCKCHAIN_RPC.

The surrounding doc uses BLOCKCHAIN_RPC; this line still says INFURA_URL.

Apply this doc fix:

- Multiple networks can be added. For each supported network (POLYGON, ETH_SEPOLIA, CELO, BASE, WORLD_CHAIN, LOCALNET), you can specify the corresponding INFURA_URL, CUSTODY_CONTRACT_ADDRESS, ADJUDICATOR_ADDRESS, and BALANCE_CHECKER_ADDRESS environment variables.
+ Multiple networks can be added. For each supported network (POLYGON, ETH_SEPOLIA, CELO, BASE, WORLD_CHAIN, LOCALNET), you can specify the corresponding BLOCKCHAIN_RPC, CUSTODY_CONTRACT_ADDRESS, ADJUDICATOR_ADDRESS, and BALANCE_CHECKER_ADDRESS environment variables.
clearnode/config.go (3)

14-15: Update comment to be provider‑agnostic

Replace “Infura endpoint URL” with “RPC endpoint URL”.

Apply this diff:

-// - {PREFIX}_BLOCKCHAIN_RPC: The Infura endpoint URL for the network
+// - {PREFIX}_BLOCKCHAIN_RPC: The RPC endpoint URL for the network

124-126: *Add legacy fallback for _INFURA_URL to avoid breaking existing envs

Support old envs during the transition (prefer BLOCKCHAIN_RPC when both exist).

Apply this diff:

-			if strings.HasPrefix(key, network+"_BLOCKCHAIN_RPC") {
-				blockchainRPC = value
+			if strings.HasPrefix(key, network+"_BLOCKCHAIN_RPC") {
+				blockchainRPC = value
+			} else if strings.HasPrefix(key, network+"_INFURA_URL") && blockchainRPC == "" {
+				// Backward compatibility with legacy env name
+				blockchainRPC = value

142-152: Clarify validation and message

You’re checking four required fields (RPC, custody, adjudicator, balance checker). Consider updating the nearby comment (“both required variables”) for accuracy. Otherwise, the guard and assignment look correct.

clearnode/custody.go (1)

50-52: Validate node chain ID against configured chain (or remove the param)

The chain parameter isn’t used; you derive chain ID from the node. Either remove chain or verify it matches to prevent misconfiguration.

Apply this diff (add mismatch check after obtaining chainID):

 func NewCustody(signer *Signer, db *gorm.DB, wsNotifier *WSNotifier, blockchainRPC, custodyAddressStr, adjudicatorAddr, balanceCheckerAddr string, chain uint32, blockStep uint64, logger Logger) (*Custody, error) {
 	client, err := ethclient.Dial(blockchainRPC)
 	if err != nil {
 		return nil, fmt.Errorf("failed to connect to blockchain node: %w", err)
 	}
 
 	chainID, err := client.ChainID(context.Background())
 	if err != nil {
 		return nil, fmt.Errorf("failed to get chain ID: %w", err)
 	}
+	if chain != 0 && chain != uint32(chainID.Int64()) {
+		return nil, fmt.Errorf("chain ID mismatch: config=%d node=%s", chain, chainID.String())
+	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70cfa47 and 2050616.

📒 Files selected for processing (13)
  • clearnode/README.md (2 hunks)
  • clearnode/channel_service_test.go (1 hunks)
  • clearnode/chart/config/prod/secrets.yaml (1 hunks)
  • clearnode/chart/config/sandbox/secrets.yaml (1 hunks)
  • clearnode/chart/config/uat/secrets.yaml (1 hunks)
  • clearnode/config.go (5 hunks)
  • clearnode/custody.go (1 hunks)
  • clearnode/eth_listener_test.go (1 hunks)
  • clearnode/main.go (1 hunks)
  • clearnode/reconcile_cli.go (2 hunks)
  • clearnode/rpc_router_public_test.go (1 hunks)
  • clearnode/rpc_router_test.go (1 hunks)
  • docker-compose.yml (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
clearnode/main.go (1)
clearnode/custody.go (1)
  • NewCustody (50-96)
clearnode/custody.go (4)
clearnode/nitrolite/bindings.go (2)
  • NewCustody (147-153)
  • Custody (88-92)
clearnode/signer.go (1)
  • Signer (24-26)
clearnode/notification.go (1)
  • WSNotifier (11-14)
clearnode/log.go (1)
  • Logger (12-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build and Publish (Clearnode)
  • GitHub Check: Test (Integration) / Test Integration
  • GitHub Check: Analyze (go)
🔇 Additional comments (12)
clearnode/README.md (1)

154-161: Example aligns with rename.

Example env now uses POLYGON_BLOCKCHAIN_RPC and looks consistent with the code changes.

clearnode/chart/config/uat/secrets.yaml (1)

6-7: UAT secret key rename is consistent.

Keys switched to *_BLOCKCHAIN_RPC while keeping same secret refs. Looks good.

clearnode/main.go (1)

76-78: LGTM: uses network.BlockchainRPC in NewCustody.

Matches the config field rename and custody constructor.

clearnode/eth_listener_test.go (1)

16-20: LGTM: test now uses blockchainRPC.

Rename is consistent with the rest of the codebase.

clearnode/rpc_router_test.go (1)

118-126: LGTM: NetworkConfig literals updated to BlockchainRPC.

Field rename applied correctly in tests.

clearnode/reconcile_cli.go (2)

45-49: LGTM: dialing via network.BlockchainRPC.

Consistent with the field rename.


60-71: LGTM: NewCustody wired with BlockchainRPC and BlockStep.

Constructor call matches the new signature.

docker-compose.yml (1)

150-151: ANVIL_INFURA_URL not found — INFURA strings remain in tests/charts

No exact "ANVIL_INFURA_URL" occurrences found. INFURA is still referenced in these files:

  • clearnode/rpc_router_test.go
  • clearnode/rpc_router_public_test.go
  • clearnode/channel_service_test.go
  • clearnode/config.go (comment)
  • clearnode/chart/config/sandbox/secrets.yaml
  • clearnode/chart/config/prod/secrets.yaml
  • clearnode/chart/config/uat/secrets.yaml
  • clearnode/README.md

docker-compose.yml contains ANVIL_BLOCKCHAIN_RPC: ws://anvil:8545

clearnode/chart/config/prod/secrets.yaml (1)

6-11: *Prod secret key renames OK — no _INFURA_URL consumers found

Repo-wide searches found no environment variables matching "*_INFURA_URL"; Helm charts/configs use *_BLOCKCHAIN_RPC as expected. README and tests still mention "Infura" or include example Infura URLs (informational only).

clearnode/rpc_router_public_test.go (1)

54-56: LGTM: test config uses BlockchainRPC

Field rename in NetworkConfig literals is correct and aligns with the refactor.

clearnode/channel_service_test.go (1)

83-83: LGTM: NetworkConfig literal updated to BlockchainRPC

Matches the renamed field; no behavioral change in tests.

clearnode/config.go (1)

37-42: LGTM: Added BlockchainRPC and BlockStep

The struct changes look good and match the PR objective. Defaulting BlockStep to 10000 is sensible.

@dimast-x
Copy link
Contributor Author

lets merge it after #346

@dimast-x dimast-x force-pushed the feat/rename-infura-url branch 2 times, most recently from 27fa551 to f145a6a Compare September 23, 2025 11:02
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: 0

🧹 Nitpick comments (1)
clearnode/chart/config/prod/secrets.yaml (1)

6-11: Optional: add transitional aliases for one deploy.

If there’s any risk of missed references, you can temporarily keep old keys pointing to the same secrets:

     POLYGON_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-polygon-infura-url?version=latest
+    POLYGON_INFURA_URL: ref+gcpsecrets://ynet-stage/clearnet-prod-polygon-infura-url?version=latest
     WORLD_CHAIN_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-worldchain-infura-url?version=latest
+    WORLD_CHAIN_INFURA_URL: ref+gcpsecrets://ynet-stage/clearnet-prod-worldchain-infura-url?version=latest
     FLOW_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-flow-infura-url?version=latest
+    FLOW_INFURA_URL: ref+gcpsecrets://ynet-stage/clearnet-prod-flow-infura-url?version=latest
     BASE_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-base-infura-url?version=latest
+    BASE_INFURA_URL: ref+gcpsecrets://ynet-stage/clearnet-prod-base-infura-url?version=latest
     ETH_MAINNET_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-eth-mainnet-infura-url?version=latest
+    ETH_MAINNET_INFURA_URL: ref+gcpsecrets://ynet-stage/clearnet-prod-eth-mainnet-infura-url?version=latest
     LINEA_MAINNET_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-linea-mainnet-infura-url?version=latest
+    LINEA_MAINNET_INFURA_URL: ref+gcpsecrets://ynet-stage/clearnet-prod-linea-mainnet-infura-url?version=latest

Remove the aliases in the next release.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2050616 and f145a6a.

📒 Files selected for processing (13)
  • clearnode/README.md (2 hunks)
  • clearnode/channel_service_test.go (1 hunks)
  • clearnode/chart/config/prod/secrets.yaml (1 hunks)
  • clearnode/chart/config/sandbox/secrets.yaml (1 hunks)
  • clearnode/chart/config/uat/secrets.yaml (1 hunks)
  • clearnode/config.go (5 hunks)
  • clearnode/custody.go (1 hunks)
  • clearnode/eth_listener_test.go (1 hunks)
  • clearnode/main.go (1 hunks)
  • clearnode/reconcile_cli.go (2 hunks)
  • clearnode/rpc_router_public_test.go (1 hunks)
  • clearnode/rpc_router_test.go (1 hunks)
  • docker-compose.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (12)
  • docker-compose.yml
  • clearnode/channel_service_test.go
  • clearnode/custody.go
  • clearnode/rpc_router_public_test.go
  • clearnode/chart/config/sandbox/secrets.yaml
  • clearnode/main.go
  • clearnode/chart/config/uat/secrets.yaml
  • clearnode/rpc_router_test.go
  • clearnode/eth_listener_test.go
  • clearnode/config.go
  • clearnode/README.md
  • clearnode/reconcile_cli.go
🔇 Additional comments (3)
clearnode/chart/config/prod/secrets.yaml (3)

6-11: Rename looks good.

Env var keys updated to *_BLOCKCHAIN_RPC consistently. No YAML issues spotted.


6-11: Align GCP secret names with new convention (follow-up).

Underlying GCP Secret Manager names still use "-infura-url". For long-term consistency and clarity, consider creating new secrets with "-blockchain-rpc" and updating refs.

Example diff once new secrets exist:

-    POLYGON_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-polygon-infura-url?version=latest
+    POLYGON_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-polygon-blockchain-rpc?version=latest
-    WORLD_CHAIN_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-worldchain-infura-url?version=latest
+    WORLD_CHAIN_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-worldchain-blockchain-rpc?version=latest
-    FLOW_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-flow-infura-url?version=latest
+    FLOW_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-flow-blockchain-rpc?version=latest
-    BASE_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-base-infura-url?version=latest
+    BASE_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-base-blockchain-rpc?version=latest
-    ETH_MAINNET_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-eth-mainnet-infura-url?version=latest
+    ETH_MAINNET_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-eth-mainnet-blockchain-rpc?version=latest
-    LINEA_MAINNET_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-linea-mainnet-infura-url?version=latest
+    LINEA_MAINNET_BLOCKCHAIN_RPC: ref+gcpsecrets://ynet-stage/clearnet-prod-linea-mainnet-blockchain-rpc?version=latest

6-11: Sanity-check: leftover INFURA_URL usage

clearnode/chart/config/prod/secrets.yaml still references GCP secret names containing “-infura-url” for several *BLOCKCHAIN_RPC entries; my automated rg run didn’t scan files (ripgrep reported “No files were searched”). Run a repo-wide search for /\b[A-Z0-9]*INFURA_URL\b/ (e.g. rg -nP --hidden -uu '\b[A-Z0-9_]*INFURA_URL\b') and confirm there are no stale INFURA_URL env keys remaining.

@dimast-x dimast-x force-pushed the feat/rename-infura-url branch from f145a6a to e10ee25 Compare September 23, 2025 16:47
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 (4)
clearnode/config.go (3)

39-44: Typo in field name BalanceCHeckerAddress

Consider correcting to BalanceCheckerAddress in a follow‑up to avoid confusion.


110-116: Default block step

Defaulting to 10000 is fine. Consider extracting to a const for discoverability (non‑blocking).


126-141: Match exact env keys instead of HasPrefix

Prevents accidental matches like FOO_BLOCKCHAIN_RPC_BACKUP overriding values.

-			if strings.HasPrefix(key, network+"_BLOCKCHAIN_RPC") {
+			if key == network+"_BLOCKCHAIN_RPC" {
 				blockchainRPC = value
-			} else if strings.HasPrefix(key, network+"_CUSTODY_CONTRACT_ADDRESS") {
+			} else if key == network+"_CUSTODY_CONTRACT_ADDRESS" {
 				custodyAddress = value
-			} else if strings.HasPrefix(key, network+"_ADJUDICATOR_ADDRESS") {
+			} else if key == network+"_ADJUDICATOR_ADDRESS" {
 				adjudicatorAddress = value
-			} else if strings.HasPrefix(key, network+"_BALANCE_CHECKER_ADDRESS") {
+			} else if key == network+"_BALANCE_CHECKER_ADDRESS" {
 				balanceCheckerAddress = value
-			} else if strings.HasPrefix(key, network+"_BLOCK_STEP") {
+			} else if key == network+"_BLOCK_STEP" {
 				if step, err := strconv.ParseUint(value, 10, 64); err == nil && step > 0 {
 					blockStep = step
 				} else {
 					logger.Warn("Invalid BLOCK_STEP value", "network", network, "value", value)
 				}
 			}
clearnode/custody.go (1)

49-56: Use DialContext with timeout to avoid startup hangs on bad RPC URLs

Prevents indefinite blocking if the endpoint is unreachable; this is an internal change to NewCustody (no caller updates required). Add context and time imports.

-// NewCustody initializes the Ethereum client and custody contract wrapper.
-func NewCustody(signer *Signer, db *gorm.DB, wsNotifier *WSNotifier, blockchainRPC, custodyAddressStr, adjudicatorAddr, balanceCheckerAddr string, chain uint32, blockStep uint64, logger Logger) (*Custody, error) {
-	client, err := ethclient.Dial(blockchainRPC)
+// NewCustody initializes the Ethereum client and custody contract wrapper.
+func NewCustody(signer *Signer, db *gorm.DB, wsNotifier *WSNotifier, blockchainRPC, custodyAddressStr, adjudicatorAddr, balanceCheckerAddr string, chain uint32, blockStep uint64, logger Logger) (*Custody, error) {
+	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	defer cancel()
+	client, err := ethclient.DialContext(ctx, blockchainRPC)
 	if err != nil {
 		return nil, fmt.Errorf("failed to connect to blockchain node: %w", err)
 	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f145a6a and e10ee25.

📒 Files selected for processing (13)
  • clearnode/README.md (2 hunks)
  • clearnode/channel_service_test.go (1 hunks)
  • clearnode/chart/config/prod/secrets.yaml (1 hunks)
  • clearnode/chart/config/sandbox/secrets.yaml (1 hunks)
  • clearnode/chart/config/uat/secrets.yaml (1 hunks)
  • clearnode/config.go (5 hunks)
  • clearnode/custody.go (1 hunks)
  • clearnode/eth_listener_test.go (1 hunks)
  • clearnode/main.go (1 hunks)
  • clearnode/reconcile_cli.go (2 hunks)
  • clearnode/rpc_router_public_test.go (1 hunks)
  • clearnode/rpc_router_test.go (1 hunks)
  • docker-compose.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • clearnode/chart/config/uat/secrets.yaml
  • clearnode/main.go
  • clearnode/chart/config/sandbox/secrets.yaml
  • clearnode/reconcile_cli.go
  • clearnode/rpc_router_test.go
  • clearnode/chart/config/prod/secrets.yaml
  • clearnode/README.md
  • clearnode/rpc_router_public_test.go
  • clearnode/eth_listener_test.go
  • clearnode/channel_service_test.go
🧰 Additional context used
🧬 Code graph analysis (1)
clearnode/custody.go (4)
clearnode/nitrolite/bindings.go (2)
  • NewCustody (147-153)
  • Custody (88-92)
clearnode/signer.go (1)
  • Signer (24-26)
clearnode/notification.go (1)
  • WSNotifier (11-14)
clearnode/log.go (1)
  • Logger (12-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build and Publish (Clearnode)
  • GitHub Check: Test (Integration) / Test Integration
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
clearnode/config.go (2)

14-14: Doc now provider‑agnostic (BLOCKCHAIN_RPC) — resolved


143-155: Back‑compat: accept deprecated {PREFIX}_INFURA_URL as a fallback

Smooths migration for existing deployments.

-		// Only add network if both required variables are present
+		// Backwards‑compat: accept deprecated INFURA_URL if BLOCKCHAIN_RPC is not set
+		if blockchainRPC == "" {
+			if v := os.Getenv(network + "_INFURA_URL"); v != "" {
+				blockchainRPC = v
+				logger.Warn("Using deprecated env var; migrate to BLOCKCHAIN_RPC", "env", network+"_INFURA_URL")
+			}
+		}
+		// Only add network if both required variables are present
 		if blockchainRPC != "" && custodyAddress != "" && adjudicatorAddress != "" && balanceCheckerAddress != "" {
 			networkLower := strings.ToLower(network)
 			config.networks[chainID] = &NetworkConfig{
 				Name:                  networkLower,
 				ChainID:               chainID,
 				BlockchainRPC:         blockchainRPC,
 				CustodyAddress:        custodyAddress,
 				AdjudicatorAddress:    adjudicatorAddress,
 				BalanceCHeckerAddress: balanceCheckerAddress,
 				BlockStep:             blockStep,
 			}
 		}

rg search returned no matches for INFURA_URL — confirm CI/deploy/templates/docs for any remaining deprecated env usages before merging.

@dimast-x dimast-x requested a review from philanton September 23, 2025 17:04
@dimast-x dimast-x requested a review from nksazonov September 24, 2025 10:28
Copy link
Contributor

@nksazonov nksazonov left a comment

Choose a reason for hiding this comment

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

Generally LGTM with some nitpicks

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
clearnode/config.go (2)

42-47: Typo breaks public API: BalanceCHeckerAddress should be BalanceCheckerAddress.
This likely causes compile errors where the field is referenced.

Apply this diff:

 type NetworkConfig struct {
   Name                  string
   ChainID               uint32
   BlockchainRPC         string
   CustodyAddress        string
   AdjudicatorAddress    string
-  BalanceCHeckerAddress string // TODO: add balance checker method into our smart contract
+  BalanceCheckerAddress string // TODO: add balance checker method into our smart contract
   BlockStep             uint64
 }

147-158: Field name assignment must match the fixed struct field.
Update the struct literal to use BalanceCheckerAddress.

Apply this diff:

       config.networks[chainID] = &NetworkConfig{
         Name:                  networkLower,
         ChainID:               chainID,
         BlockchainRPC:         blockchainRPC,
         CustodyAddress:        custodyAddress,
         AdjudicatorAddress:    adjudicatorAddress,
-        BalanceCHeckerAddress: balanceCheckerAddress,
+        BalanceCheckerAddress: balanceCheckerAddress,
         BlockStep:             blockStep,
       }
🧹 Nitpick comments (3)
clearnode/config.go (3)

129-143: Use exact key matches instead of HasPrefix when reading env vars.
Prefix matching can unintentionally pick up similarly prefixed keys; exact matches are safer.

Apply this diff:

-      if strings.HasPrefix(key, network+"_BLOCKCHAIN_RPC") {
+      if key == network+"_BLOCKCHAIN_RPC" {
         blockchainRPC = value
-      } else if strings.HasPrefix(key, network+"_CUSTODY_CONTRACT_ADDRESS") {
+      } else if key == network+"_CUSTODY_CONTRACT_ADDRESS" {
         custodyAddress = value
-      } else if strings.HasPrefix(key, network+"_ADJUDICATOR_ADDRESS") {
+      } else if key == network+"_ADJUDICATOR_ADDRESS" {
         adjudicatorAddress = value
-      } else if strings.HasPrefix(key, network+"_BALANCE_CHECKER_ADDRESS") {
+      } else if key == network+"_BALANCE_CHECKER_ADDRESS" {
         balanceCheckerAddress = value
-      } else if strings.HasPrefix(key, network+"_BLOCK_STEP") {
+      } else if key == network+"_BLOCK_STEP" {
         if step, err := strconv.ParseUint(value, 10, 64); err == nil && step > 0 {
           blockStep = step
         } else {
           logger.Warn("Invalid BLOCK_STEP value", "network", network, "value", value)
         }
       }

147-148: Optional: log when a network is skipped due to missing vars.
Helps diagnose misconfigurations in envs.

Example:

} else {
  logger.Debug("skipping network due to missing config",
    "network", network, "rpc", blockchainRPC != "", "custody", custodyAddress != "",
    "adjudicator", adjudicatorAddress != "", "balanceChecker", balanceCheckerAddress != "")
}

1-163: Fix typo 'BalanceCHeckerAddress' and confirm Infura references are intentional

  • Rename BalanceCHeckerAddress → BalanceCheckerAddress and update all usages (found in clearnode/config.go, clearnode/main.go, clearnode/reconcile_cli.go and related assignments).
  • Infura endpoints appear only in tests/docs (clearnode/rpc_router_test.go, clearnode/rpc_router_public_test.go, clearnode/channel_service_test.go, clearnode/README.md); keep for tests/docs or replace/remove before shipping credentials.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e10ee25 and 7369f9a.

📒 Files selected for processing (8)
  • clearnode/README.md (2 hunks)
  • clearnode/chart/config/prod/clearnode.yaml (1 hunks)
  • clearnode/chart/config/prod/secrets.yaml (1 hunks)
  • clearnode/chart/config/sandbox/clearnode.yaml (1 hunks)
  • clearnode/chart/config/sandbox/secrets.yaml (1 hunks)
  • clearnode/chart/config/uat/clearnode.yaml (1 hunks)
  • clearnode/chart/config/uat/secrets.yaml (1 hunks)
  • clearnode/config.go (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • clearnode/README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build and Publish (Clearnode)
  • GitHub Check: Test (Integration) / Test Integration
  • GitHub Check: Analyze (go)
🔇 Additional comments (8)
clearnode/chart/config/uat/secrets.yaml (1)

6-7: Secret paths: consider standardizing “eth-sepolia” → “ethereum-sepolia” for naming consistency.
Env key uses ETHEREUM_SEPOLIA_* while the GCP secret path keeps “eth-sepolia”. Not a blocker, but aligning names reduces confusion.

If you plan to align naming, confirm the new secret names exist before changing charts.

clearnode/chart/config/uat/clearnode.yaml (1)

16-18: LGTM on ETHEREUM_ rename.*
Matches the new convention.

clearnode/config.go (2)

14-14: Provider‑agnostic wording LGTM.
Comment now refers to generic blockchain RPC. Good.


17-36: Known networks table looks consistent.
Chain IDs and prefixes align with the new naming scheme.

clearnode/chart/config/sandbox/secrets.yaml (1)

6-10: *LGTM: secrets moved to _BLOCKCHAIN_RPC and paths updated.
Matches the new env naming; values stay provider-agnostic.

clearnode/chart/config/sandbox/clearnode.yaml (1)

19-21: ETHEREUM_ rename LGTM — no remaining ETH_SEPOLIA_ occurrences found repo-wide.**

clearnode/chart/config/prod/secrets.yaml (1)

6-12: Secrets switched to BLOCKCHAIN_RPC — confirm GCP secrets & remove Infura example.

No INFURA_URL/infura-url variables remain in code; *_BLOCKCHAIN_RPC keys are present in docker-compose and chart configs (clearnode/chart/config/{prod,uat,sandbox}/secrets.yaml, docker-compose.yml, clearnode/config.go). clearnode/README.md still contains an Infura URL example (POLYGON_BLOCKCHAIN_RPC=https://polygon-mainnet.infura.io/v3/your_infura_key).

Action items:

  • Verify these GCP secret names exist in ynet-stage (prod): clearnet-prod-polygon-blockchain-rpc, clearnet-prod-worldchain-blockchain-rpc, clearnet-prod-flow-blockchain-rpc, clearnet-prod-base-blockchain-rpc, clearnet-prod-eth-mainnet-blockchain-rpc, clearnet-prod-linea-mainnet-blockchain-rpc, clearnet-prod-xrpl-evm-mainnet-blockchain-rpc.
  • Update/remove the Infura example in clearnode/README.md if it should no longer be referenced.
  • Approve changes after GCP secret presence is confirmed.
clearnode/chart/config/prod/clearnode.yaml (1)

27-36: Renames validated — config.go reads the new ENV names

clearnode/config.go iterates knownNetworks (includes ETHEREUM, LINEA, XRPL_EVM) and matches prefixes network+"_CUSTODY_CONTRACT_ADDRESS", "_ADJUDICATOR_ADDRESS", "_BALANCE_CHECKER_ADDRESS" and "_BLOCK_STEP", so the envs in clearnode/chart/config/prod/clearnode.yaml will be recognized. Ensure the corresponding network+"_BLOCKCHAIN_RPC" is set if you expect the network to be registered (LoadConfig requires BLOCKCHAIN_RPC plus the three addresses to add a network).

@dimast-x dimast-x merged commit 5e0ddfe into main Sep 25, 2025
11 of 12 checks passed
@dimast-x dimast-x deleted the feat/rename-infura-url branch September 25, 2025 07:12
gabrielantonyxaviour pushed a commit to gabrielantonyxaviour/nitrolite that referenced this pull request Sep 27, 2025
gabrielantonyxaviour pushed a commit to gabrielantonyxaviour/nitrolite that referenced this pull request Sep 27, 2025
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.

3 participants