datahaven/contracts
Ahmad Kaouk a0ab11afec
refactor: Remove eigenlayer-middleware and flatten ServiceManagerBase (#389)
## Summary

- Flatten `ServiceManagerBase` middleware layer directly into
`DataHavenServiceManager`
- Remove all unused EigenLayer integration code to keep the contract
minimal
- Fix access control on `deregisterOperatorFromOperatorSets` (was
missing `onlyOwner`)

  ## Motivation

The `ServiceManagerBase` from eigenlayer-middleware was designed for the
old `AVSDirectory` model and included many generic functions DataHaven
doesn't use. This refactor:

  - Reduces code complexity and contract size
  - Removes ~200 lines of unused code
  - Makes the codebase easier to audit and maintain
  - Keeps only what DataHaven actually needs

  ## Changes

  ### Architecture
Before: DataHavenServiceManager → ServiceManagerBase →
ServiceManagerBaseStorage → OwnableUpgradeable
After: DataHavenServiceManager → OwnableUpgradeable, IAVSRegistrar,
IDataHavenServiceManager

  ### Removed (unused)
- `IServiceManager` and `IServiceManagerUI` interfaces (old AVSDirectory
model)
  - `ServiceManagerBase` and `ServiceManagerBaseStorage` middleware
  - `PermissionController` integration (5 proxy functions)
  - `createOperatorSets()` - only needed at initialization
  - `avs()` - never called

  ### Kept (with fixes)
- `deregisterOperatorFromOperatorSets()` - added `onlyOwner` modifier
(security fix)
  - `updateAVSMetadataURI()` - needed for EigenLayer registration

  ### Files Deleted
  - `src/interfaces/IServiceManager.sol`
  - `src/interfaces/IServiceManagerUI.sol`
  - `src/middleware/ServiceManagerBase.sol`
  - `src/middleware/ServiceManagerBaseStorage.sol`
  - `test/mocks/ServiceManagerMock.sol`
  - `test/ServiceManagerBase.t.sol`

  ## Test Plan

  - [x] `forge build` passes
  - [x] `forge test` - all 10 tests pass
  - [x] Contract bindings regenerated
  - [x] State diff regenerated
2026-01-13 15:03:10 +01:00
..
config fix: 🛡️ Check origin for validator set messages (#343) 2025-12-15 14:11:08 +01:00
deployments refactor: Remove eigenlayer-middleware and flatten ServiceManagerBase (#389) 2026-01-13 15:03:10 +01:00
lib chore: update snowbridge submodule to latest solochain (#361) 2025-12-19 11:31:45 +01:00
resources docs: 📝 Update contracts diagram (#45) 2025-04-17 12:26:25 -03:00
script refactor: Remove eigenlayer-middleware and flatten ServiceManagerBase (#389) 2026-01-13 15:03:10 +01:00
src refactor: Remove eigenlayer-middleware and flatten ServiceManagerBase (#389) 2026-01-13 15:03:10 +01:00
test refactor: Remove eigenlayer-middleware and flatten ServiceManagerBase (#389) 2026-01-13 15:03:10 +01:00
.gitignore Fix: command cli deploy contracts (#319) 2025-11-27 15:06:04 +01:00
foundry.toml refactor: Remove Holesky testnet support (#334) 2025-12-04 11:32:13 +01:00
README.md misc: remove slasher middleware solidity contracts (#366) 2025-12-29 14:55:21 +01:00

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, 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; inherits ServiceManagerBase.
  • RewardsRegistry (src/middleware/RewardsRegistry.sol): Tracks validator performance and distributes rewards via Snowbridge.

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.sol or DeployParams.s.sol directly; they only load the JSON.
  • Ensure contracts/config/hoodi.json matches your target environment before deploying.

Deployment

Two deployment paths exist: Local (Anvil) and Testnet (Hoodi). Both install the DataHaven AVS contracts (ServiceManager, RewardsRegistry) 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

  1. Registration: Validators register with EigenLayer via DataHavenServiceManager.
  2. Performance Tracking: DataHaven computes reward points and sends a Merkle root to RewardsRegistry on Ethereum via Snowbridge.
  3. Rewards Claims: Validators claim rewards on Ethereum from RewardsRegistry using Merkle proofs.
  4. Slashing: Misbehavior triggers slashing (subject to veto period).

See test/README.md for full network integration tests.