datahaven/operator/runtime/common/Cargo.toml
undercover-cactus ac28323e7d
feat : Slashing integration in EigenLayer and Datahaven AVS (#345)
## Summary

This PR integrate the slashing feature with EigenLayer. With this PR,
slashing can now be relayed to our Datahaven AVS and then executed
within EigenLayer. In addition some refactoring of the original slashing
pallet has been done.

## Motivation 

To avoid misbehaving actor in the network, Datahaven has implemented a
slashing pallet in which offenses can be reported and then if adequate
can lead to a sanction on the misbehaving node. It incentive nodes to
only follow good behavior in addition to the reward incentive. The
rewards flow is managed directly into EigenLayer (see
https://github.com/datahaven-xyz/datahaven/pull/351).

## Slashing flow


<img width="2355" height="946" alt="Slashing Flow"
src="https://github.com/user-attachments/assets/c1ddc3dc-2a7e-429d-94e0-1e02a3f65246"
/>

## What changes

* Implemented `slashValidatorsOperator` in `DataHavenServiceManager`. It
received all the slashing requests batched (every new era the queued
slashing are being relayed from substrate to Ethereum). It handle the
slashing of the operators reported into the Validator set.
* Added a `slashes_adapter.rs` utility file to remove the duplication
for each runtime. In addition, we made use of the `sol!` macro from
alloy to encode the calldata for the Ethereum call. This avoid rewriting
encoding logic and allow to remove the hardcoded selector value used to
call the slashing function.
* Added some tests in solidity to test the registering and slashing of
an operator in Ethereum via Eigen Layer.
* Added e2e tests that test the injection of a slash request, it being
relayed via the snowbridge relayer and executed by our Datahaven AVS.

## What could be better

* We are only deploying one strategy for now so it is hardcoded in the
slashing flow. We should be able to update the pallet in case we are
adding a new strategy. So communication from Ethereum should be relayed.
* We don't have error being return in case the slashing fail. Which
could happen if we don't have the right number of strategy or the
validator is not registered... etc.
* More tests for the unhappy path
2026-01-16 20:49:45 +01:00

89 lines
2.7 KiB
TOML

[package]
authors = { workspace = true }
description = "Common code used through the DataHaven network"
edition = { workspace = true }
name = "datahaven-runtime-common"
version = { workspace = true }
[dependencies]
alloy-core = { workspace = true, features = ["sol-types"] }
codec = { workspace = true }
fp-account = { workspace = true, features = ["serde"] }
frame-support = { workspace = true }
frame-system = { workspace = true }
log = { workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-external-validators-rewards = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-external-validator-slashes = { workspace = true }
pallet-evm = { workspace = true }
pallet-evm-chain-id = { workspace = true }
pallet-evm-precompile-proxy = { workspace = true }
pallet-migrations = { workspace = true }
pallet-safe-mode = { workspace = true }
pallet-tx-pause = { workspace = true }
pallet-treasury = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-runtime-common = { workspace = true }
precompile-utils = { workspace = true }
scale-info = { workspace = true }
snowbridge-outbound-queue-primitives = { workspace = true }
sp-core = { workspace = true, features = ["serde"] }
sp-io = { workspace = true }
sp-runtime = { workspace = true, features = ["serde"] }
sp-std = { workspace = true }
xcm = { workspace = true }
[features]
default = ["std"]
std = [
"alloy-core/std",
"codec/std",
"frame-support/std",
"log/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-external-validators-rewards/std",
"pallet-timestamp/std",
"pallet-evm/std",
"pallet-evm-chain-id/std",
"pallet-evm-precompile-proxy/std",
"pallet-migrations/std",
"pallet-safe-mode/std",
"pallet-tx-pause/std",
"pallet-treasury/std",
"polkadot-primitives/std",
"polkadot-runtime-common/std",
"precompile-utils/std",
"scale-info/std",
"snowbridge-outbound-queue-primitives/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"xcm/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"pallet-migrations/runtime-benchmarks",
"pallet-safe-mode/runtime-benchmarks",
"pallet-tx-pause/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"pallet-migrations/try-runtime",
"pallet-safe-mode/try-runtime",
"pallet-tx-pause/try-runtime",
"pallet-timestamp/try-runtime",
"polkadot-runtime-common/try-runtime",
"sp-runtime/try-runtime",
]
# Set timing constants (e.g. session period) to faster versions to speed up testing.
fast-runtime = []