datahaven/contracts
Steve Degosserie 387c056912
fix: Resolve Foundry build errors and apply code formatting (#241)
## Summary

Fixes the CI build failure in the `task-ts-build` workflow caused by
Foundry v1.4.2's Solar linter not being able to resolve Snowbridge's
context-specific import remappings.

## Problem

The Snowbridge submodule uses context-specific remappings (prefixed with
`:`) for its dependencies:
- `lib/snowbridge/contracts/:openzeppelin/` → OpenZeppelin contracts
- `lib/snowbridge/contracts/:prb/math/` → PRB Math library

Foundry v1.4.2's Solar linter doesn't understand these context-specific
remappings and fails with errors like:
```
error: file openzeppelin/utils/cryptography/MerkleProof.sol not found
error: file prb/math/src/UD60x18.sol not found
```

## Solution

Added global remappings that the linter can understand:
```toml
"openzeppelin/=lib/snowbridge/contracts/lib/openzeppelin-contracts/contracts/",
"prb/math/=lib/snowbridge/contracts/lib/prb-math/",
```

### Why This Works
- The linter can now resolve `openzeppelin/` and `prb/math/` imports
globally
- These global remappings take **lower precedence** than
context-specific ones during compilation
- The compiler still uses the context-specific remappings (with `:`)
when compiling Snowbridge contracts
- The linter uses the global remappings when checking all files

## Changes

### Commit 1: Add global remappings
- `contracts/foundry.toml`: Added 2 global remapping entries

### Commit 2: Apply forge fmt
- Applied automatic formatting via `forge fmt` to ensure code style
consistency
- Multi-line formatting for long import statements and function
signatures
- No functional changes - purely formatting updates

## Testing

 Local build succeeds with `forge build`
 No Snowbridge import resolution errors
 `forge fmt --check` passes with no formatting issues
 Only linting notes/warnings remain (not errors)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-20 11:20:59 +03: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 fix: Resolve Foundry build errors and apply code formatting (#241) 2025-10-20 11:20:59 +03: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.