EVM-4: extend IndexerConfig with EVM environment variables#164
EVM-4: extend IndexerConfig with EVM environment variables#164Puneethkumarck merged 2 commits intomainfrom
Conversation
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>
📝 WalkthroughWalkthroughExtended Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
…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>
There was a problem hiding this comment.
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 | 🟠 MajorEnforce allowed
chainMode/finalityModeand 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
IndexerConfigrecord andSystem.getenv()instead ofConfigurationProperties.🤖 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
📒 Files selected for processing (3)
prism/src/main/java/com/stablebridge/prism/application/config/IndexerConfig.javaprism/src/test/java/com/stablebridge/prism/application/config/IndexerConfigTest.javaprism/src/testFixtures/java/com/stablebridge/prism/fixtures/IndexerConfigFixtures.java
EVM Issue
Closes #111
Changes
IndexerConfigrecord:chainMode,evmRpcHttpEndpoint,evmRpcWsEndpoint,finalityMode,confirmationBlocks,maxReorgDepth,maxBackfillBlocks,largeTransferThreshold,blockFetchDelayMsCHAIN_MODEvalidation against allowed values (solana,ethereum,polygon,arbitrum,base) with case-insensitive parsingEVM_RPC_HTTP_ENDPOINTandEVM_RPC_WS_ENDPOINTas required whenCHAIN_MODEis any EVM chainFINALITY_MODEvalidation (latest,finalized) with case-insensitive parsingCONFIRMATION_BLOCKS(ETH:12, Polygon:128, L2s:0) andMAX_REORG_DEPTH(ETH:64, Polygon:128, L2s:0)isEvmMode()andisSolanaMode()helper methodsparseBigDecimal,parseNonNegativeInt,parseNonNegativeLongparsing utilities with fail-fast error messagesIndexerConfigFixtureswith new required fields and addevmConfigBuilder()convenience methodFromEnv,ChainMode,ChainDefaults,HelperMethods,Defaults, andValidationnested classesChecklist
./gradlew buildpasses🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Tests