Skip to content

feat: added slash amount#590

Merged
Mikelle merged 9 commits intomainfrom
feat/add-slash-amt
Feb 10, 2025
Merged

feat: added slash amount#590
Mikelle merged 9 commits intomainfrom
feat/add-slash-amt

Conversation

@Mikelle
Copy link
Copy Markdown
Contributor

@Mikelle Mikelle commented Feb 6, 2025

Describe your changes

This PR introduces a comprehensive update to how bid slashing is handled throughout the system. In particular, it adds an explicit slashAmt parameter to bids and related commitment processing, ensuring that the amount to be slashed from a provider’s stake is clearly defined and propagated through the entire preconfirmation flow.


Major Changes

1. PreconfManager Updates

  • EIP-712 Type Hash Revision:
    The bid type hash now includes the slashAmt field. For example, the type string was extended from:
    PreConfBid(string txnHash,string revertingTxHashes,uint256 bidAmt,uint64 blockNumber,uint64 decayStartTimeStamp,uint64 decayEndTimeStamp,uint256 bidderPKx,uint256 bidderPKy)
    to
    PreConfBid(string txnHash,string revertingTxHashes,uint256 bidAmt,uint64 blockNumber,uint64 decayStartTimeStamp,uint64 decayEndTimeStamp,uint256 slashAmt,uint256 bidderPKx,uint256 bidderPKy)

This ensures that the bid’s slashing amount is an integral part of the signed data.

Bid Hash and Commitment Digest

  • All functions that compute bid hashes (e.g. getBidHash) and commitment digests have been updated to accept and incorporate slashAmt as a parameter. This change propagates the new field through bid verification and commitment creation.

Internal Logic Adjustments

  • Functions such as _getBidderAddressAndCommitmentDigest was introduced to avoid stack too deep issue and now forward slashAmt to the bid verification logic.

2. ProviderRegistry Enhancements

Slash Function Overhaul

The slash function now accounts for the explicit slashAmt when calculating the amounts to deduct from a provider’s stake. The new logic:

  • Computes the residual amount based on the decayed bid amount and fee percentage.
  • Incorporates slashAmt when determining the bidder’s payout and the total amount to slash.
  • Emits events and performs additional checks if the provider’s stake is insufficient.

3. P2P/API Changes

P2P and API Modifications

  • Protobuf definitions (in bidder and provider API specs) and the corresponding OpenAPI (Swagger) files have been updated to include the new slash_amount field.

Checklist before requesting a review

  • I have added tests that prove my fix is effective or that my feature works
  • I have made corresponding changes to the documentation

@Mikelle Mikelle self-assigned this Feb 6, 2025
@Mikelle Mikelle requested a review from mrekucci February 6, 2025 14:05
Copy link
Copy Markdown
Collaborator

@aloknerurkar aloknerurkar left a comment

Choose a reason for hiding this comment

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

We should add integration test for this. You can either modify the existing one or create a separate one for this.

uint64 decayStartTimeStamp,
uint64 decayEndTimeStamp,
bytes calldata bidSignature,
uint256 slashAmt,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At some point we should create a struct called CommitmentParams which can hold all these params. Maybe not the index but the bid params.

@Mikelle Mikelle force-pushed the feat/add-slash-amt branch from 8cabe16 to 8a45adc Compare February 6, 2025 16:12
@Mikelle Mikelle requested a review from aloknerurkar February 6, 2025 17:57
@Mikelle Mikelle merged commit 9c22b77 into main Feb 10, 2025
@Mikelle Mikelle deleted the feat/add-slash-amt branch February 10, 2025 19:06
@shaspitz shaspitz mentioned this pull request Jun 26, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants