-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix(protocol): fix liveness bond related tokenomics issue #16684
Conversation
fix(protocol): fix liveness bond related tokenomics issue
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
@Brechtpd please take another look at the last commit - suggested by David C. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM, looks it has changed a lot but local
variable is causing most of the diffs.
A friendly reminder that this code (especially contestation and it's bond) part is still complex, so best would be
- to pay high attention when modify and review
- in case we will have reliable ZK - just switch to a one, combined tier (ZK /sg/Guardian) for the sake of quick finalization
BEGIN_COMMIT_OVERRIDE
fix(protocol): return liveness bond only to assigned prover
feat(protocol): allow assigned prover to prove blocks outside proving window (liveness bond not returned)
feat(protocol): remove
contestations
fromTransitionState
and events (it's buggy)feat(protocol): add
TaikoL1.getTransition(blockId, transitionID)
functionrefactor(protocol): use a
Local
struct in LibProving to cache state variables and get around of stack-too-deep errortest(protocol): add more tests to verify bonds are handled correctly
END_COMMIT_OVERRIDE
The liveness bug
The bug was identified by(OpenZeppelin) and Code4rena.
Scenario (quoted from the bug report)
As a result of the above, Henry has lost his initial liveness bond but got 1/4th of the contest bond, a net loss of 125 TKO. Mallory has lost 3/4th of her contest bond but got back half of the liveness bond, a net loss of 250 TKO.
Result
Fix
The bug was in the handling of the liveness bond, which was returned to
ts.prover
instead ofblk.assignedProver
. The liveness bond was returned upon block verification, and only if the assigned prover created and used the first transition to finalize the block.Now, the liveness bond is returned to the assigned prover immediately upon the creation of the first transition, provided it's done before the proving window expires. Otherwise,
ts.livenessBond
is set to0
.test_taikoL1_group_2_case_1
covers the scenario above.