feat(sentinel): add bridge chain monitor for on-chain event surveillance#646
Merged
Lchangliang merged 5 commits intomainfrom Apr 9, 2026
Merged
feat(sentinel): add bridge chain monitor for on-chain event surveillance#646Lchangliang merged 5 commits intomainfrom
Lchangliang merged 5 commits intomainfrom
Conversation
keanji-x
approved these changes
Apr 8, 2026
Add a new chain_monitor module that monitors bridge contract events via Ethereum JSON-RPC (eth_getLogs polling). Implements 5 security monitoring rules: 1. Large Withdrawal: Alert when TokensLocked exceeds configurable threshold 2. Vault Balance: Monitor ERC20 vault balance for abnormal drops 3. Bridge Timeout: Track cross-chain nonce correlation (ETH→Gravity) 4. Owner Activity: Alert on privileged function calls (EmergencyWithdraw, etc.) 5. Timelock/Ownership: Monitor Ownable2Step ownership transfers and governance bypass detection Key design decisions: - Uses alloy v1.0.37 (consistent with gravity_cli) - eth_getLogs polling over WebSocket for reliability - JSON checkpoint persistence for block cursor recovery - Independent tokio tasks per rule (same pattern as Probe) - Fully backward-compatible: chain_monitor config section is optional Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…too_many_arguments Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a295379 to
40160fe
Compare
Lchangliang
approved these changes
Apr 9, 2026
keanji-x
approved these changes
Apr 9, 2026
Lchangliang
approved these changes
Apr 9, 2026
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.
Summary
Add a new
chain_monitormodule to Sentinel that monitors bridge contract events via Ethereum JSON-RPC (eth_getLogspolling). Implements 5 security monitoring rules:TokensLockedexceeds configurable thresholdEmergencyWithdraw,ERC20Recovered,FeeConfigUpdated, etc.)Ownable2Stepownership transfers and governance bypass detectionArchitecture
Key Design Decisions
gravity_cli, ethers-rs is in maintenance modeeth_getLogsProbemodule, no changes to main event loopMinimal Integration Points
config.rs: Addedchain_monitor: Option<ChainMonitorConfig>(fully backward-compatible)main.rs: Addedmod chain_monitor+ 4-line spawn block after probe startupCargo.toml: Added alloy dependencies, upgraded reqwest 0.11→0.12How Has This Been Tested
End-to-End Test with Mock RPC Server
Tested using a lightweight Python mock JSON-RPC server that simulates both Ethereum and Gravity chains, returning pre-crafted event logs at specific block numbers. No real contracts or EVM needed.
Test scenario:
TokensLocked(100 tokens, nonce=1)TokensLocked(100 tokens, nonce=2)NativeMinted(nonce=1 only)EmergencyWithdrawOwnershipTransferredSentinel stdout output:
Webhook alerts received (Feishu):
Verified behaviors:
sol!macro +decode_log_data)Bridge E2E Cluster Integration
Also validated against the live bridge E2E cluster (
python3 gravity_e2e/runner.py bridge):TOML Configuration Example
Type of Change
Which Components or Systems Does This Change Impact?
Checklist