datahaven/contracts
2026-02-09 00:18:46 -03:00
..
.changesets fix: add contracts changeset 2026-02-09 00:18:46 -03:00
config feat: Add DH-AVS stagenet/testnet Hoodi deployment support (#422) 2026-02-02 16:41:15 +01:00
deployments chore: update contract version tracking artifacts 2026-02-08 21:15:04 -03: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 feat: thread version updater through deploy scripts 2026-02-08 21:15:03 -03:00
scripts test: Add storage layout checks for upgradeable contracts (#420) 2026-02-05 11:08:35 +00:00
src fix: remove testing comments 2026-02-09 00:08:11 -03:00
storage-snapshots fix: update artifacts 2026-02-09 00:18:35 -03:00
test Merge remote-tracking branch 'origin/main' into feat/upgrade-contracts 2026-02-05 12:36:18 -03:00
.gitignore fix: delete obsolet scripts and update docs 2026-02-08 23:29:26 -03:00
foundry.toml fix: resolve forge build warnings (#398) 2026-01-22 09:48:27 -03:00
README.md fix: delete obsolet scripts and update docs 2026-02-08 23:29:26 -03:00
VERSION chore: update contract version tracking artifacts 2026-02-08 21:15:04 -03:00
versions-matrix.json chore: update contract version tracking artifacts 2026-02-08 21:15:04 -03: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.

Contract versioning (version)

DataHaven uses a changeset-based versioning system with centralized tracking:

  • contracts/VERSION is the single source of truth for the code version.
  • contracts/versions-matrix.json tracks the code version and per-chain deployments.
  • contracts/deployments/<network>.json contains addresses only (no version field).
  • Version is passed as a parameter during contract deployment (not hardcoded by chain ID).
  • Version management is changeset-driven:
    • bun cli contracts bump --type [major|minor|patch] creates a changeset
    • CI applies changesets and updates VERSION + versions-matrix.json
  • Multiple environments can share the same deployment file:
    • stagenet-hoodi and testnet-hoodi both write to hoodi.json (chainId: 560048)
  • For validation, run bun cli contracts version-check --chain <chain> and bun cli contracts validate-changesets.

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.