Commit graph

39 commits

Author SHA1 Message Date
Tim B
7ac340e465
ci: 🪓 Cutting BS (#43)
Due to our constrained CI resources available to us, this PR disables
`blockscout` from running in the CI.

This PR makes it so `minimal` runs don't use blockscout, and changes the
CI to use this instead of the verified network.
2025-04-15 20:06:17 +01:00
Facundo Farall
6310f0d3fc
feat: 🧑‍💻 Turn scripts into an interactive CLI (#41)
WARNING: This PR changes the kurtosis package to use the one from
upstream, not our fork, as it was not working at the moment. This should
be changed when fixed.

In this PR:
1. Turn `launch-kurtosis` script into a CLI, which parses parameters and
can interactively run multiple steps.
2. Separate steps of such CLI into their own scripts.
1. New script created `launch-kurtosis`, which detects if an enclave is
running and prompts to relaunch it if it is.
2. New script created `deploy-contracts` to deploy all contracts. It can
optionally verify them as well.
3. Each step can be interactively opted in/out, or choose whether to run
it via CLI params.
4. The CLI offers a help command as well.
5. Cleanup logs of CLI. Logs of internal commands ran can be printed
with LOG_LEVEL=debug. In case of error, they are always printed out.
2025-04-15 11:01:24 -03:00
Tim B
b621f1c04a
test: Add E2E Tests (#36)
This PR adds the basic framework for E2E and the greater typescript
testing framework for the repo.

### Contents

- CI workflow for running E2E tests on push to main, PRs and manual
- Test suite for E2E
  - Currently only read-only tests
  - Using `bun:test` for time being but we can always change in future
- We are using the logging library `pino` so we can help with debugging
- set environment variable `LOG_LEVEL` to get extra information on
helpers
- Local `utils` namespace for all our test suites for easy importing
- Has helpers which interact with both the docker driver and also
blockscout backend
- Allows us to fetch deployed smart contracts by their name or address
and interact with them

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-04-14 16:22:43 -03:00
Steve Degosserie
a2d6bb1071
Use Genesis config presets (#35)
Based on https://github.com/paritytech/polkadot-sdk/pull/5868.

Note: this (somehow) breaks the ability to run a local network with the
zombienet config. It seems that the config generated by Zombienet that
automatically set the balance of validators is leading to an issue
(because of the address type).

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-04-14 18:38:55 +00:00
Gonza Montiel
535c38de6a
feat(operator): 🏗️ add frontier client (#13)
- [x] Add frontier client dependencies
- [x] Add ethereum client config
- [x] Add changes to cli.rs
- [x] Add changes to service.rs
- [x] Add runtime apis
- [x] Add changes to chain spec
- [ ] Add tests

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-04-14 13:40:24 +02:00
Facundo Farall
7e0f043d7f
feat: Add script to sign up operator to AVS (#37) 2025-04-11 20:54:20 -03:00
Gonza Montiel
c10b05e5f3
style(node): sort Cargo.toml alphabetically (#33) 2025-04-09 11:59:05 -03:00
Tim B
b99e47da95
test: ⚙️ Add Kurtosis Launch Script (#34)
This PR adds a script one-liner to spin up an ethereum network, with
attached explorers and deploys our `/contracts` folder into there.

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-04-08 15:42:45 +00:00
Steve Degosserie
2a1c61673a
Set EVM chain ID & token metadata (#31) 2025-04-07 12:58:14 +02:00
Gonza Montiel
5e0ad4a59c
style(node): 🎨 fix cargo clippy (#30)
I noticed `cargo clippy` was failing in CI, I fixed it. I still think we
should tweak the lints.
For example, clippy complains at things like `1 * HOURS ` because it's
redundant to multiply by 1, buy maybe we want it explicitly that way, so
it's more evident it can be changed. In this PR I don't tweak the rule
but try to make clippy happy.
2025-04-04 16:14:05 +02:00
Facundo Farall
c7cf6cead8
chore(contracts): 🗑️ Remove unused contracts (#29) 2025-04-03 14:43:25 -03:00
Facundo Farall
75e39ff98f
feat(contracts): 🚀 Implement deployment scripts for all contracts (#28)
In this PR:
1. Implement deployment script for all contracts involved. This includes
    1. EigenLayer core contracts.
    2. Snowbridge contracts.
    3. Our custom contracts to interact with both protocols.
4. Update README to document functionalities of `contracts` directory.

Future work:
1. Deployment of EigenLayer contracts should be conditional, as we
wouldn't deploy them in testnet or mainnet, but we would do it in an
internal stagenet.
5. Cleaning up unused smart contracts.
2025-04-03 14:06:32 -03:00
Steve Degosserie
c9f3427ad5
feat(operator): 🏗️ Add Identity pallet (#25) 2025-04-02 22:52:18 +00:00
Steve Degosserie
5616d9e449
feat(operator): 🏗️ Add Authorship, ImOnline & Offences pallets (#27)
Track validator availability and reports offences which lead to exclusion of the misbehaving validator from the validator set.
2025-04-02 21:49:47 +00:00
Steve Degosserie
313ec724d8
feat(operator): 🏗️ Add Scheduler pallet (#24) 2025-04-02 19:28:30 +00:00
Facundo Farall
8e05572222
feat(contracts): Snowbridge and AVS contracts integration (#26)
This PR:
1. Adds some missing functionalities to connect the Snowbridge contracts
to the RewardsRegistry contract, through an Agent.
2. Adds a test suite for this integration, with a happy and unhappy
path. The former being with a valid and honest update of rewards, which
then a validator uses to claim them. The latter with a malicious message
that tries to update the rewards root, but it's not allowed.
2025-04-02 14:31:51 -03:00
Steve Degosserie
841e8bca9e
feat(operator): 🏗️ Add Preimage pallet (#23)
Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-04-02 17:14:23 +00:00
Steve Degosserie
35a80814ba
feat(operator): 🏗️ Add Multisig pallet (#22)
Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-04-02 14:22:53 +00:00
Steve Degosserie
8c2c2a351e
feat(operator): 🏗️ Add Utility pallet (#21)
Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-04-02 13:42:47 +00:00
Steve Degosserie
e0d2aac93f
fix(operator): 🔧 Fix Address type (#20)
Align `Address` type on Moonbeam's implementation, which doesn't use a
`MultiAddress` but a plain `AccountId20`.
2025-04-02 10:15:15 -03:00
Tobi Demeco
13fafcf2b7
feat: initial rewards registry (#17)
This PR adds an initial implementation for a rewards registry, which
will be the contract in charge of allowing DataHaven validators to claim
the rewards they earned for being validators in the previous epoch. The
logic behind it is as follows:
- Whenever an epoch finishes, the corresponding BEEFY block gets relayed
to Ethereum through Snowbridge. This BEEFY block contains, in its
`extra` field, the merkle root of the tree that contains as leafs all
the message commitments of the messages of corresponding block, one of
which is the rewards distribution message.
- The rewards distribution message commitment is the root of the merkle
tree where each leaf is a tuple of the operator ID and the obtained era
points in the finished epoch. In this case, the operator ID is the
corresponding validator's Ethereum address.
- When the rewards distribution message is received, Snowbridge
validates it using the aforementioned BEEFY block and then dispatches
it. The dispatch invokes the `callContract` function of the
`RewardsAgent` agent, with the corresponding parameters so that this
agent calls the `updateRewardsMerkleRoot` function of the
`RewardsRegistry` contract with the new rewards distribution message
commitment.
- After this root is updated, any validator/operator can submit a proof
that it is in a leaf of the merkle tree that produced that root, which
means it has pending rewards to claim, through the
`ServiceManagerBase`'s `claimOperatorRewards` function.
- Each operator set of the AVS can have an assigned `RewardsRegistry`
contract. Operator sets that do not have an assigned `RewardsRegistry`
contract won't be able to received rewards.

This PR also adds two separate unit-test suites: one for the added
functionality to the `ServiceManagerBase` contract and one specific to
the new `RewardsRegistry` contract.

> [!CAUTION]
The `RewardsAgent` agent is the only one allowed to update the rewards'
merkle root, which means if a malicious user could get access to it it
could set the pending rewards to be claimed to an arbitrary tree that
benefits it. Extreme caution must be taken in the Substrate side so only
validated messages are sent to the Ethereum side, as to not allow any
users to impersonate being this agent.

### TODO:
Ideally, we would use the `RewardsCoordinator` contract from the
EigenLayer core to distribute the rewards, but currently that adds a
huge overhead for Operators since they'd have to wait for EigenLayer's
SideCar to snapshot state and update the distribution root (which
happens once a day), generate a proof that they belong to the tree of
that distribution root, store it while waiting for the `activationDelay`
(currently a week) to pass, and just then they would be able to claim
their earned rewards.

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-03-31 19:54:23 +00:00
Steve Degosserie
2cabedc223
Fix FindAuthorAdapter (#19)
Current implementation was incorrect as `Babe::find_author` returns an
index, not the author's account.
Deferred the logic of looking up the author's account based on the index
to the `pallet_session::FindAccountFromAuthorIndex` function, and use
the existing conversion from `AccountId20` to `H160`.
2025-03-31 15:37:59 -03:00
undercover-cactus
b2031f4d00
misc: remove cargo fmt setup action as it is already available (#15)
This PR remove the unneeded action that install rustfmt as it is now
already available. It remove a step in the CI.

The action removed is `dtolnay/rust-toolchain@stable`

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-03-31 14:46:03 -03:00
Facundo Farall
8cd695676a
build: Change Snowbridge contracts dependency from upstream to fork (#18) 2025-03-28 15:49:43 -03:00
Facundo Farall
4a955e504b
ci: 👷 Add CI job to check rust tests results if they run (#16)
This PR adds a new job at the end of the `DataHave Operator Rust Tests`
(`rust-tests.yml`) that checks:
- If the tests were skipped (no changes in the `operator/` directory),
it succeeds.
- If the tests run and succeeded, it succeeds.
- If the tests run and failed, it fails.

This is useful to set this job as required in our merging ruleset, and
account for cases where the tests are skipped.
2025-03-27 16:28:37 -03:00
Tobi Demeco
d8d792874c
feat: initial slasher implementation (#10)
This PR:
- Sets up the slasher infrastructure with the base functionality
required (in `ISlasher.sol`, `SlasherBase.sol` and
`SlasherBaseStorage.sol`) and adds the tests for it (in
`SlasherBase.t.sol`).
- Adds an implementation of a more complex slasher (in
`IVetoableSlasher.sol` and `VetoableSlasher.sol`) and tests for it (in
`VetoableSlasher.t.sol`).
- Modifies the `ServiceManagerBase` contract to use the new
`VetoableSlasher` contract to manage slashing.
- Updates mocks and tests to reflect the newly added functionality.

---------

Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
2025-03-27 15:20:15 +00:00
Facundo Farall
e412500e61
docs: 📝 Update proofs Substrate > Ethereum diagram (#14) 2025-03-26 21:52:26 -03:00
undercover-cactus
98fe03ea1a
misc: add rust audit action to the workflow (#12)
This PR add a github action that check for reported vulnerabilities in
dependencies. It can be triggered by two ways :
* Change in Cargo.toml or Crago.lock
* Once a week

Because it checks dependencies of dependencies it should not be required
to pass a PR.
2025-03-26 15:38:49 +01:00
Gonza Montiel
18aa57757a
fix: 🔧 replace pallet_author_inherent with Babe find_author impl (#11)
The pallet_author_inherent was used for finding the author of the
current block, used in pallet_evm, among others, but it was tightly
coupled to the Nimbus protocol. Luckily, Babe also provides a
find_author that we can use for the same purpose.
2025-03-25 11:36:53 +01:00
Facundo Farall
55a1ef26b7
ci: 👷 Improve CI job for rust tests and format (#9) 2025-03-19 20:30:03 -03:00
Facundo Farall
70a034fab7
feat: 🏗️ Setup smart contracts structure for messages Substrate->Eth (#8)
This PR:
- Sets up an interface for message passing from a Substrate chain to the
Ethereum.
- Adds a diagram for understanding how messages are validated.
2025-03-19 10:23:20 -03:00
Gonza Montiel
7a4d441fd9
build: 🏗️ DataHaven operator setup (#6)
Adds the `Substrate` node and runtime, as well as configuration and test
files, from https://github.com/Moonsong-Labs/flamingo to the `operator`
folder in DataHaven
2025-03-17 17:57:14 +01:00
Facundo Farall
b4797cceef
build: Add Snowbridge contracts dependency to Foundry project (#5) 2025-03-14 10:47:33 -03:00
Facundo Farall
a78cb3ce41
feat: 🏗️ Setup basic AVS contract (#4)
* forge install: eigenlayer-contracts

v1.1.1

* fix: 🗑️ Cleanup dependencies from init

* forge install: forge-std

v1.9.6

* forge install: openzeppelin-contracts

v5.2.0

* forge install: openzeppelin-contracts-upgradeable

v5.2.0

* chore: 🙈 Ignore IDE directories

* chore: 🏗️ Modify config in `foundry.toml` based on EigenLayer's example

* feat: 🚧 Add `ServiceManagerBase` contract and dependencies based on eigenlayer-middleware

* feat: 🚧 Naive implementation of missing functions replacing AVSDirectory for AllocationManager

* docs: 📝 Add first draft of contracts diagram

* refactor: 🔥 Remove unnecessary functions and refactor most important ones to the top

* docs: 📝 Update contracts diagram

* docs: 📝 Update contracts diagram

* feat:  Implement basic mocked Service Manager

* test: 🚧 Cleanup and start testing setup for mock ServiceManagerBase

* test: 🤡 Add mocks to setup tests

* test: 🤡 Add deployment of RewardsCoordinator

* test:  Deploy EigenLayer mocked contracts in test

* revert:  Remove proglematic submodules

* revert:  Remove forge-std dependency

* forge install: forge-std

v1.9.6

* forge install: openzeppelin-contracts

v5.2.0

* forge install: openzeppelin-contracts-upgradeable

v5.2.0

* forge install: eigenlayer-contracts

v1.3.0

* revert:  Remove faulty dependency

* forge install: eigenlayer-contracts

v1.3.0

* revert:  remove added dependency

* forge install: eigenlayer-contracts

v1.3.0

* revert:  Remove openzeppelin dependencies from root project

* test: 🚧 Make test run after dependency mayhem

* test:  Add passing createOperatorSets test with empty params

* style: 🎨 Apply forge fmt
2025-03-11 17:16:16 -03:00
Facundo Farall
0071951421
ci: Test CI checks for merging with minor change (#3) 2025-03-06 14:54:31 -03:00
Facundo Farall
56be4006a3
refactor: 🚚 Rename CI job (#2) 2025-03-06 14:49:38 -03:00
Facundo Farall
25160cd9b2
chore: 🏗️ Setup Foundry project for AVS contracts (#1)
* forge install: forge-std

v1.9.6

* chore: 🏗️ Add `forge-std` submodule

* chore: 🏗️ Setup foundry project for AVS contracts

* ci: 👷 Restrict push execution of CI to `main` branch

* ci: 💚 Put restriction to `main` branch in `push` not in `pull_request`
2025-03-06 14:35:05 -03:00
Facundo Farall
7e823603f0
chore: 🏗️ Structure repo 2025-03-06 11:44:55 -03:00
Facundo Farall
1e3fe67148
Initial commit 2025-03-06 11:36:00 -03:00