datahaven/test
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
..
.papi fix: 🐛 set initial reward registry address to avoid solochain relayer error (#111) 2025-07-02 09:48:49 +00:00
cli Fix: 🏗️ Message encoding / decoding (#113) 2025-07-16 07:38:58 +00:00
configs Fix: 🏗️ Message encoding / decoding (#113) 2025-07-16 07:38:58 +00:00
contract-bindings Fix: 🏗️ Message encoding / decoding (#113) 2025-07-16 07:38:58 +00:00
docker perf(CLI): Add option to use local Docker build in CLI for faster iteration (#77) 2025-05-16 18:04:40 -03:00
docs feat: Deployment improvements & environmental overrides (#103) 2025-06-26 13:48:33 +02:00
resources fix: 🐛 Use lodestar instead of lighthouse CL client (#91) 2025-06-09 12:29:31 -03:00
scripts feat: set rewards info as parameters in runtime (#99) 2025-06-16 12:20:18 +02:00
suites/e2e fix: 🚨 Add error in TS for missing awaits (#81) 2025-05-19 22:28:43 +00:00
utils feat: Deployment improvements & environmental overrides (#103) 2025-06-26 13:48:33 +02:00
.gitignore test: ⚙️ Add Kurtosis Launch Script (#34) 2025-04-08 15:42:45 +00:00
biome.json fix: 🚨 Add error in TS for missing awaits (#81) 2025-05-19 22:28:43 +00:00
bun.lock ci: 👷 Add CI to check PAPI metadata (#107) 2025-06-19 19:12:04 -03:00
bun.lockb feat: 🏗️ run execution relayer (#73) 2025-06-05 15:00:03 +00:00
bunfig.toml test: 🧙 Generate Type Bindings for Contracts (#58) 2025-05-01 11:14:19 +01:00
package.json test: 🏗️ small cli fixes (#108) 2025-06-30 14:51:46 +00:00
README.md feat: add Bun version check to CLI dependencies (#101) 2025-06-18 21:01:22 -03:00
tsconfig.json refactor: 🐳 Improve docker caching (again) (#86) 2025-05-27 16:14:15 +00:00
wagmi.config.ts test: 🧙 Generate Type Bindings for Contracts (#58) 2025-05-01 11:14:19 +01:00

End-to-End Test Environment

Contents

.
├── README.md
├── configs                 # Configurations for test networks
└── scripts                 # Helper scripts for interacting with the network

Pre-requisites

  • Kurtosis: For launching test networks
  • Bun v1.2 or higher: TypeScript runtime and package manager
  • Docker: For container management
MacOS

Important

If you are running this on a Mac, zig is a pre-requisite for crossbuilding the node. Instructions for installation can be found here.

QuickStart

Run:

bun i
bun cli

Manual Deployment

Follow these steps to set up and interact with your test environment:

  1. Deploy a minimal test environment

    bun cli
    

    This script will:

    1. Check for required dependencies.
    2. Launch a DataHaven solochain.
    3. Start a Kurtosis network which includes:
      • 2 Ethereum Execution Layer clients (reth)
      • 2 Ethereum Consensus Layer clients (lodestar)
      • Blockscout Explorer services for EL (if enabled with --blockscout)
      • Dora Explorer service for CL
    4. Deploy DataHaven smart contracts to the Ethereum network. This can optionally include verification on Blockscout if the --verified flag is used (requires Blockscout to be enabled).
    5. Perform validator setup and funding operations.
    6. Launch Snowbridge relayers.

    Note

    If you want to also have the contracts verified on blockscout, you can run bun start:e2e:verified instead. This will do all the previous steps, but also verify the contracts on blockscout. However, note that this takes some time to complete.

  2. Explore the network

    • Block Explorer: http://127.0.0.1:3000.
    • Kurtosis Dashboard: Run kurtosis web to access. From it you can see all the services running in the network, as well as their ports, status and logs.

Network Management

  • Stop the test environment

    bun stop:e2e
    
  • Stop the Kurtosis engine completely

    bun stop:kurtosis-engine
    

Blockscout

Can be accessed at: http://127.0.0.1:3000.

You can also access the backend via REST API, documented here: http://127.0.0.1:3000/api-docs

API DOCS

Testing

E2E Tests

Tip

Remember to run the network with bun cli before running the tests.

bun test:e2e

Note

You can increase the logging level by setting LOG_LEVEL=debug before running the tests.

Wagmi Bindings Generation

To ensure contract bindings are up-to-date, run the following command after modifying smart contracts or updating ABIs:

bun generate:wagmi

This command generates TypeScript bindings for interacting with the deployed smart contracts using Wagmi.

Troubleshooting

E2E Network Launch doesn't work

Script halts unexpectedly

When running bun cli the script appears to halt after the following:

## Setting up 1 EVM.

==========================

Chain 3151908

Estimated gas price: 2.75 gwei

Estimated total gas used for script: 71556274

Estimated amount required: 0.1967797535 ETH

==========================

This is due to how forge streams output to stdout, but is infact still deploying contracts to the chain. You should be able to see in blockscout the deploy script is indeed still working.

Errors with deploying forge scripts on kurtosis network

Try running forge clean to clear any spurious build artefacts, and running forge build again. Also try deploying manually to the still running kurtosis network.

Blockscout is empty

If you look at the browser console, if you see the following:

Content-Security-Policy: The page's settings blocked the loading of a resource (connect-src) at http://127.0.0.1:3000/node-api/proxy/api/v2/stats because it violates the following directive: "connect-src ' ...

this is a result of CORS and CSP errors due to running this as a local docker network.

Make sure you are connected directly to http://127.0.0.1:3000 (not localhost).

Alternatively, you can try installing a browser addon such as anti-CORS / anti-CSP to circumvent this problem.

Weird forge Errors

In the /contracts directory, you can try to run forge clean and forge build to see if it fixes the issue.

Linux: See if disabling ipV6 helps

I have found that ipV6 on Arch Linux does not play very nicely with Kurtosis networks. Disabling it completely fixed the issue for me.

macOS: Verify Docker networking settings

Docker Network Settings

If using Docker Desktop, make sure settings have permissive networking enabled.

Polkadot-API types don't match expected runtime types

If you've made changes to the runtime types, you need to re-generate the TS types for the Polkadot-API. Don't worry, this is fully automated.

From the ./test directory run the following command:

bun generate:types

This script will:

  1. Compile the runtime using cargo build --release in the ../operator directory.
  2. Re-generate the Polkadot-API types using the newly built WASM binary.

Note

The script uses the --release flag by default, meaning it uses the WASM binary from ./operator/target/release. If you need to use a different build target, you may need to adjust the script or run the steps manually.

Further Information

  • Kurtosis: Used for launching a full Ethereum network
  • Zombienet: Used for launching a Polkadot-SDK based network
  • Bun: TypeScript runtime and ecosystem tooling