Skip to content

EVM-4: extend IndexerConfig with EVM environment variables#164

Merged
Puneethkumarck merged 2 commits intomainfrom
feature/EVM-4-extend-indexer-config
Apr 12, 2026
Merged

EVM-4: extend IndexerConfig with EVM environment variables#164
Puneethkumarck merged 2 commits intomainfrom
feature/EVM-4-extend-indexer-config

Conversation

@Puneethkumarck
Copy link
Copy Markdown
Owner

@Puneethkumarck Puneethkumarck commented Apr 12, 2026

EVM Issue

Closes #111

Changes

  • Add 9 new fields to IndexerConfig record: chainMode, evmRpcHttpEndpoint, evmRpcWsEndpoint, finalityMode, confirmationBlocks, maxReorgDepth, maxBackfillBlocks, largeTransferThreshold, blockFetchDelayMs
  • Add CHAIN_MODE validation against allowed values (solana, ethereum, polygon, arbitrum, base) with case-insensitive parsing
  • Enforce EVM_RPC_HTTP_ENDPOINT and EVM_RPC_WS_ENDPOINT as required when CHAIN_MODE is any EVM chain
  • Add FINALITY_MODE validation (latest, finalized) with case-insensitive parsing
  • Add chain-dependent defaults for CONFIRMATION_BLOCKS (ETH:12, Polygon:128, L2s:0) and MAX_REORG_DEPTH (ETH:64, Polygon:128, L2s:0)
  • Add isEvmMode() and isSolanaMode() helper methods
  • Add parseBigDecimal, parseNonNegativeInt, parseNonNegativeLong parsing utilities with fail-fast error messages
  • Update IndexerConfigFixtures with new required fields and add evmConfigBuilder() convenience method
  • Add comprehensive unit tests across FromEnv, ChainMode, ChainDefaults, HelperMethods, Defaults, and Validation nested classes

Checklist

  • ./gradlew build passes
  • Unit tests added/updated
  • Integration tests added/updated (if applicable)
  • ArchUnit rules pass
  • Spotless formatting applied

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added multi-chain support with configurable selection between EVM and Solana networks.
    • Introduced EVM-specific RPC endpoint configuration options.
    • Added advanced indexing tuning parameters: confirmation blocks, reorg depth, backfill limits, transfer thresholds, and block fetch delays.
    • New finality mode configuration for chain-specific block finality handling.
  • Tests

    • Expanded test coverage for multi-chain configuration and validation scenarios.

Add chain selection (CHAIN_MODE), EVM RPC endpoints, finality mode,
confirmation depth, reorg protection, backfill limit, large transfer
threshold, and block fetch delay to IndexerConfig. EVM endpoints are
validated as required when CHAIN_MODE is an EVM chain; existing Solana
configuration is unaffected when CHAIN_MODE defaults to solana.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Puneethkumarck Puneethkumarck added enhancement New feature or request phase:0-scaffolding Project scaffolding labels Apr 12, 2026
@Puneethkumarck Puneethkumarck self-assigned this Apr 12, 2026
@Puneethkumarck Puneethkumarck added enhancement New feature or request phase:0-scaffolding Project scaffolding labels Apr 12, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

📝 Walkthrough

Walkthrough

Extended IndexerConfig record with EVM chain support by introducing chainMode, EVM RPC endpoints (evmRpcHttpEndpoint, evmRpcWsEndpoint), finalityMode, and indexing parameters (confirmationBlocks, maxReorgDepth, maxBackfillBlocks, largeTransferThreshold, blockFetchDelayMs). Added compact constructor validation, environment variable parsing with chain-specific defaults, and helper methods isEvmMode() and isSolanaMode(). Updated test suite and fixtures to cover EVM configurations.

Changes

Cohort / File(s) Summary
Config Record Expansion
prism/src/main/java/com/stablebridge/prism/application/config/IndexerConfig.java
Added 9 new fields for EVM support with chain-mode-driven defaults. Enhanced compact constructor with validation for non-null/non-blank strings and non-negative numeric values. Expanded fromEnv(...) to parse CHAIN_MODE, EVM_RPC_HTTP_ENDPOINT, EVM_RPC_WS_ENDPOINT, FINALITY_MODE, and new indexing parameters with chain-specific constraints. Made GRPC validation conditional on Solana+GRPC mode. Added isEvmMode() and isSolanaMode() predicates and helper validators for mode/finality parsing.
Test Coverage
prism/src/test/java/com/stablebridge/prism/application/config/IndexerConfigTest.java
Added 538 lines of test cases covering new environment variables, mode-specific defaults, validation of malformed/out-of-range values, chain-mode-dependent requirements (EVM RPC endpoint validation), and mode predicate methods. Updated existing tests to account for new fields and defaults.
Test Fixtures
prism/src/testFixtures/java/com/stablebridge/prism/fixtures/IndexerConfigFixtures.java
Added EVM RPC endpoint constants and introduced evmConfigBuilder() factory method for EVM configuration testing. Updated default indexerConfigBuilder() to set Solana chainMode explicitly and configure finality/backfill/reorg/transfer/delay parameters.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 A rabbit hops through configs new,
EVM chains and Solana too!
Chain modes dance, RPC endpoints gleam,
Validation rules ensure the dream,
Bridges built with care and grace! 🌉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: extending IndexerConfig with EVM environment variables as specified in issue #111.
Linked Issues check ✅ Passed The PR implements all required objectives from issue #111: nine new fields, CHAIN_MODE/FINALITY_MODE validation, EVM endpoint validation, helper methods, chain-dependent defaults, and comprehensive tests.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #111 requirements: IndexerConfig expansion, validation logic, test coverage, and test fixtures. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/EVM-4-extend-indexer-config

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.

…iance

Split ChainDefaults dual-action tests into one test per method call and
add explicit // when sections to HelperMethods tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

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

Caution

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

⚠️ Outside diff range comments (1)
prism/src/main/java/com/stablebridge/prism/application/config/IndexerConfig.java (1)

63-107: ⚠️ Potential issue | 🟠 Major

Enforce allowed chainMode/finalityMode and EVM endpoint requirements in the record constructor.

fromEnv(...) enforces these rules, but direct builder/constructor usage can still create invalid config objects. This weakens fail-fast guarantees and can produce inconsistent runtime behavior.

🔧 Proposed fix
 public IndexerConfig {
         Objects.requireNonNull(chainMode, "chainMode must not be null");
         Objects.requireNonNull(streamMode, "streamMode must not be null");
         Objects.requireNonNull(rpcWsEndpoint, "rpcWsEndpoint must not be null");
         Objects.requireNonNull(databaseUrl, "databaseUrl must not be null");
         Objects.requireNonNull(benchLog, "benchLog must not be null");
         Objects.requireNonNull(finalityMode, "finalityMode must not be null");
         Objects.requireNonNull(largeTransferThreshold, "largeTransferThreshold must not be null");
+        chainMode = chainMode.toLowerCase(Locale.ROOT);
+        finalityMode = finalityMode.toLowerCase(Locale.ROOT);
         if (chainMode.isBlank()) {
             throw new IllegalArgumentException("chainMode must not be blank");
         }
+        if (!ALLOWED_CHAIN_MODES.contains(chainMode)) {
+            throw new IllegalArgumentException("chainMode must be one of " + ALLOWED_CHAIN_MODES + ", got: " + chainMode);
+        }
         if (streamMode.isBlank()) {
             throw new IllegalArgumentException("streamMode must not be blank");
         }
@@
         if (finalityMode.isBlank()) {
             throw new IllegalArgumentException("finalityMode must not be blank");
         }
+        if (!ALLOWED_FINALITY_MODES.contains(finalityMode)) {
+            throw new IllegalArgumentException("finalityMode must be one of " + ALLOWED_FINALITY_MODES + ", got: " + finalityMode);
+        }
+        if (!CHAIN_MODE_SOLANA.equals(chainMode)) {
+            Objects.requireNonNull(evmRpcHttpEndpoint, "evmRpcHttpEndpoint must not be null");
+            Objects.requireNonNull(evmRpcWsEndpoint, "evmRpcWsEndpoint must not be null");
+            if (evmRpcHttpEndpoint.isBlank()) {
+                throw new IllegalArgumentException("evmRpcHttpEndpoint must not be blank");
+            }
+            if (evmRpcWsEndpoint.isBlank()) {
+                throw new IllegalArgumentException("evmRpcWsEndpoint must not be blank");
+            }
+        }

Based on learnings: Configuration must be managed via IndexerConfig record and System.getenv() instead of ConfigurationProperties.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@prism/src/main/java/com/stablebridge/prism/application/config/IndexerConfig.java`
around lines 63 - 107, The IndexerConfig record constructor currently only
checks non-null/blank and numeric ranges but must also enforce the same domain
rules as fromEnv: validate that chainMode and finalityMode are one of the
allowed values used in fromEnv (reject unknown modes) and enforce EVM-specific
endpoint rules (when chainMode equals the EVM identifier used in fromEnv, ensure
rpcWsEndpoint is a valid EVM RPC endpoint — e.g. non-blank and uses ws:// or
wss:// or matches the same validation logic from fromEnv); update the
IndexerConfig constructor to perform these checks (referencing IndexerConfig,
chainMode, finalityMode, rpcWsEndpoint and the same allowed-values set/constants
used by fromEnv) so direct builder/constructor usage fails fast on invalid
configs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@prism/src/main/java/com/stablebridge/prism/application/config/IndexerConfig.java`:
- Around line 63-107: The IndexerConfig record constructor currently only checks
non-null/blank and numeric ranges but must also enforce the same domain rules as
fromEnv: validate that chainMode and finalityMode are one of the allowed values
used in fromEnv (reject unknown modes) and enforce EVM-specific endpoint rules
(when chainMode equals the EVM identifier used in fromEnv, ensure rpcWsEndpoint
is a valid EVM RPC endpoint — e.g. non-blank and uses ws:// or wss:// or matches
the same validation logic from fromEnv); update the IndexerConfig constructor to
perform these checks (referencing IndexerConfig, chainMode, finalityMode,
rpcWsEndpoint and the same allowed-values set/constants used by fromEnv) so
direct builder/constructor usage fails fast on invalid configs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3f819d1c-10a4-4c47-9d63-f9910d5c1d2c

📥 Commits

Reviewing files that changed from the base of the PR and between fc1e9a8 and 05ad485.

📒 Files selected for processing (3)
  • prism/src/main/java/com/stablebridge/prism/application/config/IndexerConfig.java
  • prism/src/test/java/com/stablebridge/prism/application/config/IndexerConfigTest.java
  • prism/src/testFixtures/java/com/stablebridge/prism/fixtures/IndexerConfigFixtures.java

@Puneethkumarck Puneethkumarck merged commit dbec531 into main Apr 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request phase:0-scaffolding Project scaffolding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EVM-4: Extend IndexerConfig with EVM environment variables

1 participant