datahaven/contracts
2025-11-05 09:57:33 +01:00
..
config feat: Datahaven contracts deployment on public testnet (#123) 2025-08-21 10:02:31 +00:00
deployments need anvil files 2025-11-04 15:23:48 +01:00
lib feat: update eigenlayer contracts to v1.8.0 (#270) 2025-11-04 16:30:18 +01:00
resources docs: 📝 Update contracts diagram (#45) 2025-04-17 12:26:25 -03:00
script feat: update eigenlayer contracts to v1.8.0 (#270) 2025-11-04 16:30:18 +01:00
src misc: simplify Dockerfile to speed up build (#216) 2025-10-22 13:36:30 +02:00
test feat: update eigenlayer contracts to v1.8.0 (#270) 2025-11-04 16:30:18 +01:00
.gitignore test: Native token transfer e2e tests (#120) 2025-08-22 18:27:14 +02:00
foundry.toml fix: Resolve Foundry build errors and apply code formatting (#241) 2025-10-20 11:20:59 +03:00
README.md chore: ♻️ Update README files (#206) 2025-10-06 18:12:55 +02:00

DataHaven AVS Smart Contracts 📜

This directory contains the smart contracts for the DataHaven Actively Validated Service (AVS) built on EigenLayer.

Overview

DataHaven is an EVM-compatible Substrate blockchain secured by EigenLayer. These contracts implement the AVS Service Manager, middleware, and associated utilities that integrate with EigenLayer's operator registration, slashing, and rewards infrastructure.

Project Structure

contracts/
├── src/                           # Smart contract source code
│   ├── DataHavenServiceManager.sol   # Core AVS service manager
│   ├── RewardsRegistry.sol           # Validator performance & rewards tracking
│   ├── VetoableSlasher.sol          # Slashing with veto period
│   ├── interfaces/                   # Contract interfaces
│   ├── libraries/                    # Utility libraries
│   └── middleware/                   # EigenLayer middleware integration
├── script/                        # Deployment & setup scripts
│   └── deploy/                    # Environment-specific deployment
├── test/                          # Foundry test suites
└── foundry.toml                   # Foundry configuration

Key Contracts

  • DataHavenServiceManager: Manages operator lifecycle, registration, and deregistration with EigenLayer
  • RewardsRegistry: Tracks validator performance metrics and handles reward distribution via Snowbridge
  • VetoableSlasher: Implements slashing mechanism with dispute resolution veto period
  • Middleware: Integration layer with EigenLayer's core contracts (based on eigenlayer-middleware)

Prerequisites

Build

To build the contracts:

cd contracts
forge build

This will compile all contracts and generate artifacts in the out directory.

Test

Run the test suite with:

forge test

For more verbose output including logs:

forge test -vv

For maximum verbosity including stack traces:

forge test -vvvv

Run specific test contracts:

forge test --match-contract RewardsRegistry

Run specific test functions:

forge test --match-test test_newRewardsMessage

Exclude specific tests:

forge test --no-match-test test_newRewardsMessage_OnlyRewardsAgent

Deployment

Local Deployment

  1. In a separate terminal, start a local Anvil instance:
anvil
  1. Deploy to local Anvil:
forge script script/deploy/DeployLocal.s.sol --rpc-url anvil --broadcast

Network Deployment

To deploy to a network configured in foundry.toml:

forge script script/deploy/DeployLocal.s.sol --rpc-url $NETWORK_RPC_URL --private-key $PRIVATE_KEY --broadcast

Replace $NETWORK_RPC_URL with the RPC endpoint and $PRIVATE_KEY with your deployer's private key.

Or using a network from foundry.toml:

forge script script/deploy/DeployLocal.s.sol --rpc-url mainnet --private-key $PRIVATE_KEY --broadcast

Configuration

The deployment configuration can be modified in:

  • script/deploy/Config.sol: Environment-specific configuration
  • script/deploy/DeployParams.s.sol: Deployment parameters

Code Generation

After making changes to contracts, regenerate TypeScript bindings for the test framework:

cd ../test
bun generate:wagmi

This generates type-safe contract interfaces used by the E2E test suite.

Integration with DataHaven

These contracts integrate with the DataHaven Substrate node through:

  1. Operator Registration: Validators register on-chain via DataHavenServiceManager
  2. Performance Tracking: Node submits validator metrics to RewardsRegistry
  3. Cross-chain Rewards: Rewards distributed from Ethereum to DataHaven via Snowbridge
  4. Slashing: Misbehavior triggers slashing through VetoableSlasher with veto period

For full network integration testing, see the test directory.