Merged
Conversation
Implements automatic validation of RPC endpoints to ensure they match the expected chain IDs from CAIP-2 identifiers. This prevents misconfiguration errors where an RPC URL points to the wrong chain. Features: - Validates protocol chain and all indexed chains on startup - Calls eth_chainId on each EVM RPC endpoint - Compares returned chain ID with expected value from CAIP-2 - Fails fast with clear error message on mismatch - Skips validation for non-EVM chains (non-eip155 namespace) Example output on success: ✓ Chain ID validated for eip155:42161: RPC https://arbitrum.example.com correctly returns chain ID 42161 Example output on failure: ERROR Chain ID mismatch for eip155:42161: RPC https://ethereum.example.com returned chain ID 1 (0x1), expected 42161 This addresses the safety requirement from TODO.md section 7. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Added 6 unit tests that verify chain validation logic without requiring real RPC endpoints: - test_validate_chain_id_success: Verifies matching chain IDs pass - test_validate_chain_id_mismatch: Verifies mismatched IDs fail with clear error - test_validate_chain_id_hex_variations: Tests different hex formats (0x1, 0x01, 0xa4b1) - test_validate_chain_id_skips_non_evm: Ensures non-EVM chains are skipped - test_validate_chain_id_invalid_hex: Tests graceful handling of malformed responses - test_caip2_parsing: Verifies CAIP-2 parsing for both EVM and non-EVM chains Implemented a MockTransport that simulates RPC responses, allowing thorough testing of all validation paths without network dependencies. All 20 oracle tests pass. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
d14143f to
7d3640a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.