### Context The function `v2_sendMessage()` on Snowbridge Gateway contract is **permissionless** (I'm shocked this is the design choice). Any EOA/contract on Ethereum can build a message and send it through our DH bridge. While we don't change our Snowbridge fork, then this will continue to be the case. ### Problem We use `v2_sendMessage()` to send **permissioned** operations to our chain. For instance: update our validator set message (coming next, _slashing-related_ messages). So we do need to restrict the processing of the incoming messages on the Substrate side. ### Fix - I've added a check to `EigenLayerMessageProcessor` that enforces `message.origin` to be only a configured `AuthorisedOrigin`. - I've added an `AuthorisedOrigin` to `pallet_external_validators::Config` - I've configured the `AuthorisedOrigin` to be `DatahavenServiceManagerAddress` in all three runtimes ### Stages - [x] Implementation - [x] Runtime integration tests - [x] Collect `DatahavenServiceManagerAddress` parameter for e2e tests to work Fixes https://github.com/datahaven-xyz/sr-datahaven/issues/12 --------- Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| config | ||
| deployments | ||
| lib | ||
| resources | ||
| script | ||
| src | ||
| test | ||
| .gitignore | ||
| foundry.toml | ||
| README.md | ||
DataHaven AVS Smart Contracts
Implements the Actively Validated Service (AVS) logic for DataHaven, secured by EigenLayer. These contracts manage operator registration, handle cross-chain rewards via Snowbridge, and enforce slashing with a veto period.
Project Structure
contracts/
├── src/
│ ├── DataHavenServiceManager.sol # Core AVS service manager
│ ├── middleware/ # RewardsRegistry, VetoableSlasher, Snowbridge helpers
│ ├── interfaces/ # Contract interfaces
│ └── libraries/ # Utility libraries
├── script/ # Deployment & setup scripts
├── lib/ # External dependencies (EigenLayer, Snowbridge, OpenZeppelin)
└── test/ # Foundry test suites
Key Components
- DataHavenServiceManager (
src/DataHavenServiceManager.sol): Core contract for operator lifecycle; inheritsServiceManagerBase. - RewardsRegistry (
src/middleware/RewardsRegistry.sol): Tracks validator performance and distributes rewards via Snowbridge. - VetoableSlasher (
src/middleware/VetoableSlasher.sol): Handles slashing requests with a dispute resolution veto window.
Development
Requires Foundry.
# Build and Test
forge build
forge test
# Regenerate TS bindings (after contract changes)
cd ../test && bun generate:wagmi
Configuration
Deployment parameters (EigenLayer addresses, initial validators, owners) are defined in contracts/config/<network>.json.
- Do not edit
Config.solorDeployParams.s.soldirectly; they only load the JSON. - Ensure
contracts/config/hoodi.jsonmatches your target environment before deploying.
Deployment
Two deployment paths exist: Local (Anvil) and Testnet (Hoodi). Both install the DataHaven AVS contracts (ServiceManager, RewardsRegistry, VetoableSlasher) and Snowbridge (BeefyClient, Gateway, Agent). They differ in EigenLayer setup:
Local (Anvil)
DeployLocal.s.sol bootstraps a full EigenLayer core deployment (DelegationManager, StrategyManager, AVSDirectory, etc.) alongside DataHaven AVS and Snowbridge.
anvil
forge script script/deploy/DeployLocal.s.sol --rpc-url anvil --broadcast
Testnet (Hoodi)
DeployTestnet.s.sol references existing EigenLayer contracts (addresses from contracts/config/<network>.json) and only deploys DataHaven AVS + Snowbridge.
NETWORK=hoodi forge script script/deploy/DeployTestnet.s.sol \
--rpc-url hoodi \
--private-key $PRIVATE_KEY \
--broadcast
Supported networks: hoodi (no mainnet config yet). Artifacts → contracts/deployments/<network>.json.
How It Works
- Registration: Validators register with EigenLayer via
DataHavenServiceManager. - Performance Tracking: DataHaven computes reward points and sends a Merkle root to
RewardsRegistryon Ethereum via Snowbridge. - Rewards Claims: Validators claim rewards on Ethereum from
RewardsRegistryusing Merkle proofs. - Slashing: Misbehavior triggers
VetoableSlasher(subject to veto period).
See test/README.md for full network integration tests.