datahaven/contracts
Ahmad Kaouk edcb13dbbc
fix: add era replay guard for rewards submissions (#477)
## Summary
- guard `DataHavenServiceManager.submitRewards` by `(startTimestamp,
duration, token)` so each reward window can only be submitted once per
token
- expose the replay-guard state and error in the interface, add Foundry
coverage, wire the missing runtime `std` features, and regenerate the
Wagmi/storage/state-diff artifacts
- fix the local slash E2E path by aligning the `anvil` Snowbridge
`messageOrigin` with `stagenet-local`, refreshing the tracked anvil
deployment metadata, and waiting for `ServiceManager.SlashingComplete`

## Testing
- `cargo fmt --all -- --check`
- `forge test --match-contract RewardsSubmitterTest`
- `forge test --match-contract StorageLayoutTest -vvv`
- `./scripts/check-storage-layout.sh`
- `./scripts/check-storage-layout-negative.sh`
- `bun ./scripts/check-generated-state.ts`
- `bun generate:wagmi`
- `bun test ./e2e/suites/slash.test.ts --timeout 1200000
--test-name-pattern "verify we have the agent origin set|Activate
slashing|use sudo to slash operator"`

## Notes
- Slash E2E verification reran the previously failing sudo slash path;
the long liveness scenario was not rerun end to end.
2026-04-17 14:27:09 +02:00
..
config fix: add era replay guard for rewards submissions (#477) 2026-04-17 14:27:09 +02:00
deployments fix: add era replay guard for rewards submissions (#477) 2026-04-17 14:27:09 +02: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: rename rewardsInitiator to snowbridgeInitiator (#476) 2026-03-24 12:41:36 +01:00
scripts feat: implement weighted top-32 validator selection (#443) 2026-02-24 09:23:57 +01:00
src fix: add era replay guard for rewards submissions (#477) 2026-04-17 14:27:09 +02:00
storage-snapshots fix: add era replay guard for rewards submissions (#477) 2026-04-17 14:27:09 +02:00
test fix: add era replay guard for rewards submissions (#477) 2026-04-17 14:27:09 +02:00
.gitignore Fix: command cli deploy contracts (#319) 2025-11-27 15:06:04 +01:00
foundry.lock feat: automated validator set submission with era targeting (#433) 2026-02-20 10:31:44 +01:00
foundry.toml fix: resolve forge build warnings (#398) 2026-01-22 09:48:27 -03:00
README.md refactor: clean old veto committee (#434) 2026-02-09 14:28:34 +01:00
VERSION feat: Bump contracts version to v0.20.0 (#464) 2026-03-03 10:54:31 +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.

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.

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