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
Calling resolveClaim() can unexpectedly fail due to non-constant gas cost of delete #9249
Comments
The for-loop in the resolveClaim() may have a similar issue
|
Thanks for the issue! Great spot, and glad that people are already taking a look at these contracts. This is a known issue, but was pushed aside for a bit due to the cost-to-grief. We'll likely make some improvements here based on your suggestions to improve readability and make this path more FV friendly 😄 This issue would prevent the game from resolving, locking all bonds up within the game above the subgame that's bricked. However, it would not cause the game to resolve incorrectly - it would effectively be bricked due to all sub-games not being resolved. The impact of this is low-medium in severity, and the attack is costly for the malicious party:
Bonds are not currently defined in the |
@clabby We should ensure there is a section in the specs that includes your reasoning as to why this is safe. It will help to centralize the source of truth for the design in a single place |
Describe the bug
optimism/packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
Line 414 in 546fb2c
The line
delete subgames[_claimIndex];
will delete all subgames given _claimIndex. However, the cost of the delete operation in solidity is non-constant, where each of the items in the array will take about 5000 gas to delete. The following lists the gas cost with the number of items in the array (tested in remix Shanghai):Given block limit 30e6, creating 6000 subgames of a claim will block the claim from resolving forever.
To Reproduce
The following code can be used to check the non-constant gas cost of delete:
Expected behavior
The gas cot of resolveClaim() should be O(1).
Use another variable to check if the subgame is solved consistently (e.g., ClaimData.bond == uint128.max) without deleting the array.
Screenshots
If applicable, add screenshots to help explain your problem.
System Specs:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: