datahaven/operator/runtime/mainnet/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

425 lines
16 KiB
TOML

[package]
authors = { workspace = true }
description = "DataHaven Mainnet runtime"
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
name = "datahaven-mainnet-runtime"
publish = false
repository = { workspace = true }
version = { workspace = true }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
alloy-core = { workspace = true, features = ["sol-types"] }
bridge-hub-common = { workspace = true, optional = true }
codec = { workspace = true, features = ["derive"] }
datahaven-runtime-common = { workspace = true }
dhp-bridge = { workspace = true }
fp-account = { workspace = true, features = ["serde"] }
fp-evm = { workspace = true, features = ["serde"] }
fp-rpc = { workspace = true }
fp-self-contained = { workspace = true, features = ["serde", "try-runtime"] }
frame-benchmarking = { workspace = true, optional = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true, features = ["experimental"] }
frame-system = { workspace = true }
frame-system-benchmarking = { workspace = true, optional = true }
frame-system-rpc-runtime-api = { workspace = true }
frame-try-runtime = { workspace = true, optional = true }
hex = { workspace = true }
hex-literal = { workspace = true }
itoa = { workspace = true }
log = { workspace = true }
num-bigint = { workspace = true }
num_enum = { workspace = true }
pallet-authorship = { workspace = true }
pallet-babe = { workspace = true }
pallet-balances = { workspace = true, features = ["insecure_zero_ed"] }
pallet-beefy = { workspace = true }
pallet-beefy-mmr = { workspace = true }
pallet-collective = { workspace = true }
pallet-conviction-voting = { workspace = true }
pallet-datahaven-native-transfer = { workspace = true }
pallet-ethereum = { workspace = true, features = ["forbid-evm-reentrancy"] }
pallet-evm = { workspace = true, features = ["forbid-evm-reentrancy"] }
pallet-evm-chain-id = { workspace = true }
pallet-evm-precompile-blake2 = { workspace = true }
pallet-evm-precompile-bn128 = { workspace = true }
pallet-evm-precompile-modexp = { workspace = true }
pallet-evm-precompile-sha3fips = { workspace = true }
pallet-evm-precompile-simple = { workspace = true }
pallet-external-validator-slashes = { workspace = true }
pallet-external-validators = { workspace = true }
pallet-external-validators-rewards = { workspace = true }
pallet-grandpa = { workspace = true }
pallet-identity = { workspace = true }
pallet-im-online = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-migrations = { workspace = true }
pallet-mmr = { workspace = true }
pallet-multisig = { workspace = true }
pallet-offences = { workspace = true }
pallet-outbound-commitment-store = { workspace = true }
pallet-parameters = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-referenda = { workspace = true }
pallet-safe-mode = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-session = { workspace = true }
pallet-session-benchmarking = { workspace = true, optional = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-treasury = { workspace = true }
pallet-tx-pause = { workspace = true }
pallet-utility = { workspace = true }
pallet-whitelist = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-runtime-common = { workspace = true }
precompile-utils = { workspace = true }
scale-info = { workspace = true, features = ["derive", "serde"] }
serde_json = { workspace = true, default-features = false, features = [
"alloc",
] }
smallvec = { workspace = true }
snowbridge-beacon-primitives = { workspace = true }
snowbridge-core = { workspace = true }
snowbridge-inbound-queue-primitives = { workspace = true }
snowbridge-merkle-tree = { workspace = true }
snowbridge-outbound-queue-primitives = { workspace = true }
snowbridge-outbound-queue-v2-runtime-api = { workspace = true }
snowbridge-pallet-ethereum-client = { workspace = true }
snowbridge-pallet-ethereum-client-fixtures = { workspace = true, optional = true }
snowbridge-pallet-inbound-queue-v2 = { workspace = true }
snowbridge-pallet-outbound-queue-v2 = { workspace = true }
snowbridge-pallet-system = { workspace = true }
snowbridge-pallet-system-v2 = { workspace = true }
snowbridge-system-v2-runtime-api = { workspace = true }
snowbridge-verification-primitives = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-babe = { workspace = true, features = ["serde"] }
sp-consensus-beefy = { workspace = true, features = ["serde"] }
sp-consensus-grandpa = { workspace = true, features = ["serde"] }
sp-core = { workspace = true, features = ["serde"] }
sp-genesis-builder = { workspace = true }
sp-inherents = { workspace = true }
sp-io = { workspace = true }
sp-keyring = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true, features = ["serde"] }
sp-session = { workspace = true }
sp-staking = { workspace = true }
sp-std = { workspace = true }
sp-storage = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-version = { workspace = true, features = ["serde"] }
strum = { workspace = true }
strum_macros = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
# DataHaven precompiles
pallet-evm-precompile-balances-erc20 = { workspace = true }
pallet-evm-precompile-batch = { workspace = true }
pallet-evm-precompile-call-permit = { workspace = true }
pallet-evm-precompile-collective = { workspace = true }
pallet-evm-precompile-conviction-voting = { workspace = true }
pallet-evm-precompile-datahaven-native-transfer = { workspace = true }
pallet-evm-precompile-identity = { workspace = true }
pallet-evm-precompile-preimage = { workspace = true }
pallet-evm-precompile-proxy = { workspace = true }
pallet-evm-precompile-referenda = { workspace = true }
pallet-evm-precompile-registry = { workspace = true }
# StorageHub
pallet-bucket-nfts = { workspace = true }
pallet-cr-randomness = { workspace = true }
pallet-evm-precompile-file-system = { workspace = true }
pallet-file-system = { workspace = true }
pallet-file-system-runtime-api = { workspace = true }
pallet-nfts = { workspace = true }
pallet-payment-streams = { workspace = true }
pallet-payment-streams-runtime-api = { workspace = true }
pallet-proofs-dealer = { workspace = true }
pallet-proofs-dealer-runtime-api = { workspace = true }
pallet-randomness = { workspace = true }
pallet-storage-providers = { workspace = true }
pallet-storage-providers-runtime-api = { workspace = true }
shc-common = { workspace = true, optional = true }
shp-constants = { workspace = true }
shp-data-price-updater = { workspace = true }
shp-file-key-verifier = { workspace = true }
shp-file-metadata = { workspace = true }
shp-forest-verifier = { workspace = true }
shp-traits = { workspace = true }
shp-treasury-funding = { workspace = true }
shp-tx-implicits-runtime-api = { workspace = true }
sp-trie = { workspace = true }
[build-dependencies]
substrate-wasm-builder = { workspace = true, optional = true, default-features = true }
[dev-dependencies]
# Test utilities
frame-support-test = { workspace = true }
sp-io = { workspace = true }
sp-tracing = { workspace = true }
precompile-utils = { workspace = true, features = ["std", "testing"] }
# Snowbridge testing
snowbridge-core = { workspace = true }
snowbridge-outbound-queue-primitives = { workspace = true }
snowbridge-pallet-system = { workspace = true }
snowbridge-pallet-system-v2 = { workspace = true }
[features]
default = ["std"]
std = [
"codec/std",
"datahaven-runtime-common/std",
"fp-account/std",
"fp-evm/std",
"frame-benchmarking?/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-benchmarking?/std",
"pallet-session-benchmarking?/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime?/std",
"pallet-authorship/std",
"pallet-babe/std",
"pallet-balances/std",
"pallet-beefy-mmr/std",
"pallet-beefy/std",
"pallet-collective/std",
"pallet-conviction-voting/std",
"pallet-ethereum/std",
"pallet-evm-chain-id/std",
"pallet-evm/std",
"pallet-evm-precompile-balances-erc20/std",
"pallet-evm-precompile-batch/std",
"pallet-evm-precompile-call-permit/std",
"pallet-evm-precompile-preimage/std",
"pallet-evm-precompile-collective/std",
"pallet-evm-precompile-conviction-voting/std",
"pallet-evm-precompile-datahaven-native-transfer/std",
"pallet-evm-precompile-identity/std",
"pallet-evm-precompile-proxy/std",
"pallet-evm-precompile-referenda/std",
"pallet-evm-precompile-registry/std",
"pallet-external-validators/std",
"pallet-external-validators-rewards/std",
"pallet-external-validator-slashes/std",
"pallet-grandpa/std",
"pallet-identity/std",
"pallet-im-online/std",
"pallet-message-queue/std",
"pallet-migrations/std",
"pallet-mmr/std",
"pallet-multisig/std",
"pallet-offences/std",
"pallet-parameters/std",
"pallet-preimage/std",
"pallet-safe-mode/std",
"pallet-tx-pause/std",
"pallet-referenda/std",
"pallet-proxy/std",
"pallet-scheduler/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-treasury/std",
"pallet-utility/std",
"pallet-whitelist/std",
"polkadot-primitives/std",
"polkadot-runtime-common/std",
"precompile-utils/std",
"scale-info/std",
"serde_json/std",
"snowbridge-beacon-primitives/std",
"snowbridge-inbound-queue-primitives/std",
"snowbridge-outbound-queue-primitives/std",
"snowbridge-pallet-ethereum-client/std",
"snowbridge-pallet-inbound-queue-v2/std",
"snowbridge-pallet-outbound-queue-v2/std",
"snowbridge-merkle-tree/std",
"snowbridge-outbound-queue-v2-runtime-api/std",
"snowbridge-pallet-system/std",
"snowbridge-pallet-system-v2/std",
"snowbridge-system-v2-runtime-api/std",
"dhp-bridge/std",
"snowbridge-verification-primitives/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-babe/std",
"sp-consensus-beefy/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-keyring/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-staking/std",
"sp-std/std",
"sp-storage/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
"pallet-outbound-commitment-store/std",
"pallet-datahaven-native-transfer/std",
# StorageHub
"pallet-bucket-nfts/std",
"pallet-nfts/std",
"pallet-cr-randomness/std",
"pallet-file-system/std",
"pallet-file-system-runtime-api/std",
"pallet-payment-streams/std",
"pallet-payment-streams-runtime-api/std",
"pallet-proofs-dealer/std",
"pallet-proofs-dealer-runtime-api/std",
"pallet-randomness/std",
"pallet-storage-providers/std",
"pallet-storage-providers-runtime-api/std",
"dep:shc-common",
"shc-common/std",
"shp-constants/std",
"shp-file-metadata/std",
"shp-forest-verifier/std",
"shp-traits/std",
"shp-treasury-funding/std",
"shp-file-key-verifier/std",
"pallet-evm-precompile-file-system/std",
]
runtime-benchmarks = [
"bridge-hub-common",
"datahaven-runtime-common/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-beefy-mmr/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-ethereum/runtime-benchmarks",
"pallet-evm/runtime-benchmarks",
"pallet-external-validators/runtime-benchmarks",
"pallet-external-validators-rewards/runtime-benchmarks",
"pallet-external-validator-slashes/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-migrations/runtime-benchmarks",
"pallet-mmr/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-offences/runtime-benchmarks",
"pallet-parameters/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-safe-mode/runtime-benchmarks",
"pallet-tx-pause/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-session-benchmarking/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-whitelist/runtime-benchmarks",
"pallet-randomness/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"snowbridge-inbound-queue-primitives/runtime-benchmarks",
"snowbridge-pallet-ethereum-client/runtime-benchmarks",
"snowbridge-pallet-ethereum-client-fixtures/runtime-benchmarks",
"snowbridge-pallet-inbound-queue-v2/runtime-benchmarks",
"snowbridge-pallet-system-v2/runtime-benchmarks",
"snowbridge-pallet-outbound-queue-v2/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"snowbridge-pallet-system/runtime-benchmarks",
"pallet-outbound-commitment-store/runtime-benchmarks",
"pallet-datahaven-native-transfer/runtime-benchmarks",
]
try-runtime = [
"fp-self-contained/try-runtime",
"frame-executive/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-authorship/try-runtime",
"pallet-babe/try-runtime",
"pallet-balances/try-runtime",
"pallet-beefy-mmr/try-runtime",
"pallet-beefy/try-runtime",
"pallet-collective/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-ethereum/try-runtime",
"pallet-evm/try-runtime",
"pallet-external-validators/try-runtime",
"pallet-external-validators-rewards/try-runtime",
"pallet-external-validator-slashes/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-identity/try-runtime",
"pallet-im-online/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-migrations/try-runtime",
"pallet-mmr/try-runtime",
"pallet-multisig/try-runtime",
"pallet-offences/try-runtime",
"pallet-parameters/try-runtime",
"pallet-preimage/try-runtime",
"pallet-safe-mode/try-runtime",
"pallet-tx-pause/try-runtime",
"pallet-referenda/try-runtime",
"pallet-proxy/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-treasury/try-runtime",
"pallet-utility/try-runtime",
"pallet-whitelist/try-runtime",
"polkadot-runtime-common/try-runtime",
"snowbridge-pallet-ethereum-client/try-runtime",
"snowbridge-pallet-inbound-queue-v2/try-runtime",
"snowbridge-pallet-system-v2/try-runtime",
"snowbridge-pallet-outbound-queue-v2/try-runtime",
"sp-runtime/try-runtime",
"snowbridge-pallet-system/try-runtime",
"pallet-outbound-commitment-store/try-runtime",
"pallet-datahaven-native-transfer/try-runtime",
]
fast-runtime = ["datahaven-runtime-common/fast-runtime"]
# Enable the metadata hash generation.
#
# This is hidden behind a feature because it increases the compile time.
# The wasm binary needs to be compiled twice, once to fetch the metadata,
# generate the metadata hash and then a second time with the
# `RUNTIME_METADATA_HASH` environment variable set for the `CheckMetadataHash`
# extension.
metadata-hash = ["substrate-wasm-builder/metadata-hash"]
# A convenience feature for enabling things when doing a build
# for an on-chain release.
on-chain-release-build = ["metadata-hash", "sp-api/disable-logging"]