-
Notifications
You must be signed in to change notification settings - Fork 75
fix: [L02] prevent locking in the case of misparameterization #142
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
Conversation
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
|
Can you explain the failure case this addresses? |
@nicholaspai great point. Added a description that describes this. PTAL. |
contracts/PolygonTokenBridger.sol
Outdated
| if (isWrappedMatic) { | ||
| uint256 balance = address(this).balance; | ||
| maticToken.withdraw{ value: balance }(balance); | ||
| } |
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.
nit: does this need to be a separate state variable? could it not be:
| if (isWrappedMatic) { | |
| uint256 balance = address(this).balance; | |
| maticToken.withdraw{ value: balance }(balance); | |
| } | |
| if (isWrappedMatic) maticToken.withdraw{ value: address(this).balance }(balance); |
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.
seems reasonable and saves an MSTORE right?
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.
I don't think the above works, since balance doesn't exist. Maybe you meant:
if (isWrappedMatic) maticToken.withdraw{ value: address(this).balance }(address(this).balance);
?
We could do that. I'm not sure it would be cheaper, but that might not matter since this is on polygon and the call is already pretty cheap.
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.
Done.
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.
ye, sorry. it's hard to structure feedback in these comments with the proposed blocks. what you did is what I had intended.
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
nicholaspai
left a comment
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.
Nice and clean, LGTM
This addresses two potential cases where tokens get locked:
In both cases, this ensures that the tokens make it to the HubPool contract.