datahaven/contracts
Gonza Montiel e9fc4f271f
Fix: 🏗️ Message encoding / decoding (#113)
## Summary of changes
- We decided to remove the topics and nonce from the massage encoding
since we don't use them (original commit:
ee2a3f2fd4).
- Besides, we already have a nonce at the Snowbridge message level
f4ab5c2b2e/operator/primitives/snowbridge/inbound-queue/src/v2/message.rs (L105)

- I had to recreate the static test for _encoding_ (happens in
[DataHavenSnowbridgeMessages.sol](d12d40634f/contracts/src/libraries/DataHavenSnowbridgeMessages.sol)
) / _decoding_ (happens in
[operator/primitives/bridge/src/lib.rs)](f9f9cc65fe/operator/primitives/bridge/src/lib.rs).
Now it matches the current structure. The idea is that now we can test
that we don't break the decoding in followup refactoring.
- Fixes a problem with EigenLayer validator addresses. In all our
contracts we were using `bytes32` to refer to a Solochain validator
address. But on our Substrate change we actually expect AccountId20, so
only 20 bytes. This was causing the decoding to fail.
- I opted for the minimal change that would be to take the right-most 20
bytes to send that to our chain. But we might want aswell to limit our
EigenLayer contracts to be only 20 bytes long. @ahmadkaouk showcase this
[here](92a34c273c)
- Adds a bash script to run the static test. The test will compile the
contracts, run the encoding test, compile the operator, and run the
decoding test. This saves a huge amount of time since we don't need to
run the full e2e setup. The way of running it is the following:
```bash
cd operator/test/scripts
./test_message_encoding.sh
```
- As a consequence of this PR, the execution relayer now works properly.

EDIT:

> [!IMPORTANT]
**We decided to use 20-byte addresses in our contracts**. So what is
stated above is not valid anymore.

The change implies that the mapping from Ethereum addresses to bytes32
addresses now it's a mapping as follows:


dd3ba99ac0/contracts/src/DataHavenServiceManager.sol (L51-L52)

I've updated helper functions, tests, etc to be compliant with this
change. The execution relayer and beefy relayer look stable now.

---------

Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com>
Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-07-16 07:38:58 +00:00
..
config Fix: 🏗️ Message encoding / decoding (#113) 2025-07-16 07:38:58 +00:00
deployments feat: set rewards info as parameters in runtime (#99) 2025-06-16 12:20:18 +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: 🏗️ Message encoding / decoding (#113) 2025-07-16 07:38:58 +00:00
src Fix: 🏗️ Message encoding / decoding (#113) 2025-07-16 07:38:58 +00:00
test Fix: 🏗️ Message encoding / decoding (#113) 2025-07-16 07:38:58 +00:00
.gitignore test: ⚙️ Add Kurtosis Launch Script (#34) 2025-04-08 15:42:45 +00:00
foundry.toml feat: Add script to sign up operator to AVS (#37) 2025-04-11 20:54:20 -03:00
README.md feat: Add script to sign up operator to AVS (#37) 2025-04-11 20:54:20 -03: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 AVS that provides secure and decentralised data storage services. The contracts in this repository implement the Service Manager, middleware, and associated utilities required for the DataHaven protocol.

Project Structure

  • src/: Smart contract source code
    • DataHavenServiceManager.sol: Main service manager contract
    • interfaces/: Contract interfaces
    • libraries/: Utility libraries
    • middleware/: Middleware contracts (similar to EigenLayer's middleware contracts)
  • script/: Deployment scripts
  • test/: Test cases
  • foundry.toml: Foundry configuration

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 suites:

forge test --match-contract RewardsRegistry --no-match-contract SnowbridgeIntegration

Run specific tests:

forge test --match-test test_getRewardstest_newRewardsMessage --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