-
Notifications
You must be signed in to change notification settings - Fork 56
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
improve: Make changes after running Slither on SpokePool contracts #229
Changes from all commits
b9a38f8
d409fca
034e801
f4185df
6db44cd
38b3adf
cfdf07e
54e97c0
681a192
0ee774e
98b272b
dd41c7b
77b449a
c4c4771
7e2b7ed
ba9e88f
8adde77
6a9f509
2932946
c689fa2
ccec16e
c0bb1b1
b8fb099
22f5fbe
cb54ea7
5d13900
2ab13f6
c36e9d8
57855d1
bc58c17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,6 +290,11 @@ abstract contract SpokePool is | |
* to ensure that a small input range doesn't limit which indices this method is able to reach. | ||
*/ | ||
function emergencyDeleteRootBundle(uint256 rootBundleId) public override onlyAdmin nonReentrant { | ||
// Deleting a struct containing a mapping does not delete the mapping in Solidity, therefore the bitmap's | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This warning was the most interesting in this PR IMO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree - interesting find. It seems OK to suppress the warning:
Additionally:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @pxrl. Just to add one point: we will never reuse this array slot (because deleting an element of an array does not actually reduce the array.length I believe, meaning the slot is still reserved), so the mapping will never be read or written to again, by definition, no? So we shouldn't need to worry about this at all right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You're right - I'd understood that the array element was actually removed, but I can see that it's only zeroed. So my 4th point was garbage! |
||
// data will still remain potentially leading to vulnerabilities down the line. The way around this would | ||
// be to iterate through every key in the mapping and resetting the value to 0, but this seems expensive and | ||
// would require a new list in storage to keep track of keys. | ||
//slither-disable-next-line mapping-deletion | ||
delete rootBundles[rootBundleId]; | ||
emit EmergencyDeleteRootBundle(rootBundleId); | ||
} | ||
|
@@ -332,11 +337,17 @@ abstract contract SpokePool is | |
// buffer of this contract's block time to allow for this variance. | ||
// Note also that quoteTimestamp cannot be less than the buffer otherwise the following arithmetic can result | ||
// in underflow. This isn't a problem as the deposit will revert, but the error might be unexpected for clients. | ||
|
||
//slither-disable-next-line timestamp | ||
require( | ||
getCurrentTime() >= quoteTimestamp - depositQuoteTimeBuffer && | ||
getCurrentTime() <= quoteTimestamp + depositQuoteTimeBuffer, | ||
"invalid quote time" | ||
); | ||
|
||
// Increment count of deposits so that deposit ID for this spoke pool is unique. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move the storage variable modification to |
||
uint32 newDepositId = numberOfDeposits++; | ||
|
||
// If the address of the origin token is a wrappedNativeToken contract and there is a msg.value with the | ||
// transaction then the user is sending ETH. In this case, the ETH should be deposited to wrappedNativeToken. | ||
if (originToken == address(wrappedNativeToken) && msg.value > 0) { | ||
|
@@ -352,18 +363,12 @@ abstract contract SpokePool is | |
chainId(), | ||
destinationChainId, | ||
relayerFeePct, | ||
numberOfDeposits, | ||
newDepositId, | ||
quoteTimestamp, | ||
originToken, | ||
recipient, | ||
msg.sender | ||
); | ||
|
||
// Increment count of deposits so that deposit ID for this spoke pool is unique. | ||
// @dev: Use pre-increment to save gas: | ||
// i++ --> Load, Store, Add, Store | ||
// ++i --> Load, Add, Store | ||
++numberOfDeposits; | ||
} | ||
|
||
/** | ||
|
@@ -798,6 +803,7 @@ abstract contract SpokePool is | |
IERC20Upgradeable(address(wrappedNativeToken)).safeTransfer(to, amount); | ||
} else { | ||
wrappedNativeToken.withdraw(amount); | ||
//slither-disable-next-line arbitrary-send-eth | ||
to.transfer(amount); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ interface WETH9Interface { | |
|
||
function balanceOf(address guy) external view returns (uint256 wad); | ||
|
||
function transfer(address guy, uint256 wad) external; | ||
function transfer(address guy, uint256 wad) external returns (bool); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This interface was incorrect and inconsistent with how we implement WETH9 |
||
} |
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.
Should we make a shortcut for this via package.json?
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.
hmm i'm having trouble getting this to work from an npm run will look into it further