Skip to content
This repository was archived by the owner on Apr 25, 2026. It is now read-only.

feat: Slashing Queue#793

Merged
drewstone merged 3 commits into
service-updatefrom
shady/services-slash-queue
Oct 16, 2024
Merged

feat: Slashing Queue#793
drewstone merged 3 commits into
service-updatefrom
shady/services-slash-queue

Conversation

@shekohex

@shekohex shekohex commented Oct 14, 2024

Copy link
Copy Markdown
Contributor

Summary of changes
Changes introduced in this pull request:

This pull request includes several significant changes to the pallets/multi-asset-delegation and pallets/services modules, focusing on adding new functionalities, refining existing ones, and removing deprecated features.

New Functionalities:

  • Added get_delegators_for_operator method in MultiAssetDelegationInfo trait to retrieve delegators for a given operator. (pallets/multi-asset-delegation/src/traits.rs)
  • Introduced SlashDeferDuration and SlashOrigin types for managing slashing actions and deferring slashes. (pallets/services/src/lib.rs)
  • Added UnappliedSlash event and storage for managing unapplied slashes. (pallets/services/src/lib.rs) [1] [2]

Refinements:

  • Modified the approve method to include a restaking_percent parameter, allowing operators to specify the percentage of restaked tokens exposed to the service. (pallets/services/src/lib.rs)
  • Updated the request method to simplify the process and removed the approval preference logic. (pallets/services/src/lib.rs) [1] [2] [3]

Removals:

  • Removed the update_approval_preference method and related event, as well as deprecated the ServiceRequestUpdated event. (pallets/services/src/lib.rs) [1] [2] [3]

Minor Changes:

  • Removed the approval field from OperatorPreferences struct. (pallets/services/src/benchmarking.rs)
  • Added sp_runtime::Percent import for percentage calculations. (pallets/services/src/lib.rs)

These changes collectively enhance the flexibility and functionality of the modules, while also cleaning up outdated code.

Reference issue to close (if applicable)

Closes #775

@shekohex shekohex added feature ➕ Tasks that are functional additions or enhancements and removed wip 🚧 DO NOT MERGE 🛑 labels Oct 15, 2024
@shekohex shekohex marked this pull request as ready for review October 15, 2024 18:27
@drewstone drewstone changed the base branch from main to service-update October 15, 2024 18:44

@drewstone drewstone left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good besides comments provided. Please address and please consider pulling out the logic into separate files once we get the service-update branch in a good state.

Comment thread pallets/services/src/lib.rs
Comment thread pallets/services/src/lib.rs Outdated
Comment thread pallets/services/src/lib.rs Outdated
Comment thread pallets/services/src/lib.rs Outdated
Comment thread pallets/services/src/lib.rs
let own_slash = percent.mul_floor(own_stake);
let others_slash = delegators
.into_iter()
.map(|(delegator, stake, _asset_id)| (delegator, percent.mul_floor(stake)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why remove knowledge of the asset when you return it? Isn't this necessary across all assets being used by the service?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we currently treat them equally, i.e if the slash is 10%, then we slash every delegator's stake by the 10% regardless of the asset kind. this not ideal of course, since not all assets are equal. Until we have an interface to map everything to Native token (TNT) we can take asset kind into account.

@shekohex shekohex requested a review from drewstone October 16, 2024 15:31
@drewstone drewstone merged commit 6477d74 into service-update Oct 16, 2024
@drewstone drewstone deleted the shady/services-slash-queue branch October 16, 2024 17:56
drewstone added a commit that referenced this pull request Oct 22, 2024
* feat: Slashing Queue (#793)

* feat: Slashing Queue

* feat: Per Service restaking percentage exposure

* test: add more tests for the unapplied slash

* feat: slashing precompile (#795)

* feat: slashing precompile

* feat: Slashing and Dispute precompiles

* Update subxt

* test: add more tests to cover more cases

* doc: Update internal functions docs

* chore: Update toml formatting

* lint: fix clippy

* chore: update tangle-subxt version

---------

Co-authored-by: shekohex <dev+github@shadykhalifa.me>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature ➕ Tasks that are functional additions or enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Implement a queue for slashing events

2 participants