Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starlight <> Ethereum: Slashes mapping #793

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

Agusrodri
Copy link
Contributor

@Agusrodri Agusrodri commented Dec 31, 2024

Introduces slashes to be sent to Ethereum from pallet-external-validator-slashes.

Up to now slashes were just recorded but nothing was done with them. This PR changes this by:

  • scheduling those slashes to be sent externally at a certain era change.
  • Send this slashes in batches of QueuedSlashesProcessedPerBlock. This batches are sent on-initialize of each block, with one batch at most per block
  • Introduce the Slashes command which contains: The era in which the slashes are sent, the slashes, and a timestamp. Currently the timestamp is likely wrong, in the future it will contain a timestamp to identify the validators in the external chain.
  • Tests validating the approach, both rust and typescript

Copy link
Contributor

github-actions bot commented Dec 31, 2024

WASM runtime size check:

Compared to target branch

dancebox runtime: 1416 KB (no changes) ✅

flashbox runtime: 824 KB (no changes) ✅

dancelight runtime: 2148 KB (+2148 KB) ⚠️

container chain template simple runtime: 1124 KB (-4296 KB) ✅

container chain template frontier runtime: 1400 KB (-5152 KB) ✅

let mut slashes_to_send: Vec<_> = vec![];

for unreported_slash in unreported_slashes.iter() {
// TODO: check if validator.clone().encode() matches with the actual account bytes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not, use validator.as_ref().to_vec()

pallets/external-validator-slashes/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Jan 8, 2025

Coverage Report

(master)

@@                   Coverage Diff                   @@
##           master   agustin-map-slashes      +/-   ##
=======================================================
+ Coverage   65.15%                65.70%   +0.55%     
- Files         330                   329       -1     
+ Lines       57796                 58046     +250     
=======================================================
+ Hits        37655                 38139     +484     
- Misses      20141                 19907     -234     
Files Changed Coverage
/chains/orchestrator-relays/runtime/dancelight/src/lib.rs 68.25% (+0.65%)
/chains/orchestrator-relays/runtime/dancelight/src/tests/common/mod.rs 97.28% (+0.01%)
/chains/orchestrator-relays/runtime/dancelight/src/tests/slashes.rs 98.70% (-1.30%)
/chains/orchestrator-relays/runtime/dancelight/src/weights/pallet_external_validator_slashes.rs 30.77% (+30.77%)
/chains/orchestrator-relays/runtime/dancelight/src/weights/pallet_message_queue.rs 59.55% (+59.55%)
/chains/orchestrator-relays/runtime/dancelight/src/weights/runtime_common_paras_registrar.rs 0.00% (-13.64%)
/chains/orchestrator-relays/runtime/dancelight/src/weights/snowbridge_pallet_outbound_queue.rs 33.33% (+33.33%)
/pallets/external-validator-slashes/src/lib.rs 78.57% (+3.86%)
/pallets/external-validator-slashes/src/weights.rs 14.63% (+14.63%)
/primitives/bridge/src/custom_do_process_message.rs 96.20% (+96.20%)
/primitives/bridge/src/lib.rs 80.45% (+22.65%)

Coverage generated Fri Jan 10 15:15:09 UTC 2025

@girazoki girazoki changed the title [WIP] Starlight <> Ethereum: Slashes mapping Starlight <> Ethereum: Slashes mapping Jan 10, 2025
@girazoki girazoki added a0-pleasereview Pull request needs code review. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes labels Jan 10, 2025
@girazoki girazoki added D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited breaking Needs to be mentioned in breaking changes labels Jan 10, 2025
* optimize storage writes and prepare bench

* run bench locally
@girazoki girazoki marked this pull request as ready for review January 10, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a0-pleasereview Pull request needs code review. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes D9-needsaudit👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants