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

Maroutis - Wrong bribeCountPerPrincipleOnEpoch index update in incentivizePair function #1014

Open
sherlock-admin2 opened this issue Nov 25, 2024 · 0 comments

Comments

@sherlock-admin2
Copy link

sherlock-admin2 commented Nov 25, 2024

Maroutis

Medium

Wrong bribeCountPerPrincipleOnEpoch index update in incentivizePair function

Summary

In the incentivizePair function, the index bribeCountPerPrincipleOnEpoch is incorrectly incremented using incentivizeToken instead of principle. This causes the index to remain unchanged for a given principle and epoch, leading to overwriting of incentives and preventing multiple tokens from being incentivized for the same principle and epoch.

Details

In the provided code snippet:

uint lastAmount = bribeCountPerPrincipleOnEpoch[epoch][principle];
SpecificBribePerPrincipleOnEpoch[epoch][hashVariables(principle, lastAmount)] = incentivizeToken; // Overwrites existing entry
bribeCountPerPrincipleOnEpoch[epoch][incentivizeToken]++; // Incorrect increment
  • The lastAmount variable retrieves the current index for the given principle and epoch.
  • SpecificBribePerPrincipleOnEpoch uses this index to store the incentivizeToken.
  • However, bribeCountPerPrincipleOnEpoch[epoch][incentivizeToken]++ increments the count for incentivizeToken instead of principle.
  • This means lastAmount does not change for the same principle and epoch, causing subsequent incentives to overwrite the previous one.
  • As a result, only one incentive token can be stored per principle and epoch, and any additional incentives overwrite existing ones.

Impact

Users querying this information will only see the last incentivized token, unaware of any previously added tokens. This can lead to users making decisions based on inaccurate data,

Mitigation

Correct the increment operation to update the index for the principle:
bribeCountPerPrincipleOnEpoch[epoch][principle]++;

@sherlock-admin3 sherlock-admin3 changed the title Future Obsidian Puma - Wrong bribeCountPerPrincipleOnEpoch index update in incentivizePair function Maroutis - Wrong bribeCountPerPrincipleOnEpoch index update in incentivizePair function Dec 12, 2024
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

No branches or pull requests

1 participant