datahaven/contracts
undercover-cactus eced179b09
misc: simplify Dockerfile to speed up build (#216)
This PR remove the `cargo chef` step used to build the docker image used
in deployment. We noticed that `cargo chef` was adding more time to the
build and that removing it was saving us 40min.

Also in this PR, we removed the base image from parity which was really
heavy and was filling the rest of the disk space. This broke the build.
After some investigation it doesn't seem to add a lot to the build. It
has been replace with the official rust image as a base to build our
node.

The image used to run the image has been replaced with
`debian:trixie-slim`.

In the end those changed **should not** break any of the current
behavior and makes save a bit of CI time.
2025-10-22 13:36:30 +02:00
..
config feat: Datahaven contracts deployment on public testnet (#123) 2025-08-21 10:02:31 +00:00
deployments feat: support updating the AVS dashboard metadata (#136) 2025-09-02 15:54:47 +02:00
lib chore: update snowbridge submodule (#109) 2025-07-01 13:52:17 +00:00
resources docs: 📝 Update contracts diagram (#45) 2025-04-17 12:26:25 -03:00
script fix: Resolve Foundry build errors and apply code formatting (#241) 2025-10-20 11:20:59 +03:00
src misc: simplify Dockerfile to speed up build (#216) 2025-10-22 13:36:30 +02:00
test fix: Resolve Foundry build errors and apply code formatting (#241) 2025-10-20 11:20:59 +03: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.