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

feat: Slashing Queue #793

Merged
merged 3 commits into from
Oct 16, 2024
Merged

feat: Slashing Queue #793

merged 3 commits into from
Oct 16, 2024

Conversation

shekohex
Copy link
Contributor

@shekohex shekohex commented Oct 14, 2024

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
Copy link
Contributor

@drewstone drewstone left a comment

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.

pallets/services/src/lib.rs Show resolved Hide resolved
pallets/services/src/lib.rs Outdated Show resolved Hide resolved
pallets/services/src/lib.rs Outdated Show resolved Hide resolved
pallets/services/src/lib.rs Outdated Show resolved Hide resolved
pallets/services/src/lib.rs Show resolved Hide resolved
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
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
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.

@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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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