-
Notifications
You must be signed in to change notification settings - Fork 465
Conversation
6538e34
to
416045a
Compare
4164577
to
6342faa
Compare
// + 32 (assetData len) | ||
// + 4 (proxyId) | ||
// + 32 (callTarget) | ||
// + 32 (assetDataOffset) |
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.
This should be + 32 (staticCallDataOffset)
instead of + 32 (assetDataOffset)
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.
Looking good ~ I'm excited for this functionality 💪 ! Just left a few small notes.
pure | ||
{} | ||
|
||
function dynamicInputFunction(bytes calldata a) |
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.
It could be good to do some sanity check on the input data, to ensure it was forwarded correctly.
return isOdd; | ||
} | ||
|
||
function noInputFunction() |
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.
It could be good to do a sanity check to ensure that calldata() == <selector>
without any extra data.
(bool success,) = _STATIC_CALL_PROXY_ADDRESS.staticcall(transferFromData); | ||
|
||
// Success means that the staticcall can be made an unlimited amount of times | ||
balance = success ? _MAX_UINT256 : 0; |
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.
Could be worthwhile to special-case Multi-Asset Data
, especially in this case where the only valid values are MAX_UINT256
and 0
. The alternative would be to highlight in our documentation that any non-zero value implies an unlimited amount of times, in which case we should add a note to the function comment + add a test case for this.
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'm also not sure exactly how to interpret "the staticcall can be made an unlimited amount of times". What if the following function is called:
function a() public view {
require(block.number < 7977075);
}
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.
That call can be made an unlimited amount of times at the particular block in which this gets called (not accounting for gas). This should always be true since the staticcall can't update state and will therefore never have side effects that would prevent the staticcall from failing if called again.
// | | 4 | | 1. offset to assetData (*) | | ||
// | | 36 | | 2. from | | ||
// | | 68 | | 3. to | | ||
// | | 100 | | 4. amount | |
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.
Since we're moving towards localizing validation within the proxies, we may want to assert that amount
is some fixed, standardized value -- like 0
. Ex, in the MultiAssetProxy
scaling this value should have no effect.
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.
The problem is that the Exchange
contract doesn't allow 0
transfers. Any non-zero number would be scaled with the MAP.
6342faa
to
5da88f7
Compare
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.
Really nice!
|
||
// Validate length of `assetData` | ||
let assetDataLen := calldataload(assetDataOffset) | ||
if or(lt(assetDataLen, 100), mod(sub(assetDataLen, 4), 32)) { |
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.
if or(lt(assetDataLen, 100), mod(sub(assetDataLen, 4), 32)) { | |
if lt(assetDataLen, 132) { |
staticCallData Length
should always be part of the asset data regardless, no?- Do we need to enforce that the entire asset data be word-aligned? It's conceivable to me that an abi-encoder (though probably not ours) would not word-align parameters such as
bytes
types.
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.
- True, but the offset to
staticCallData
can point to inside the first 100 bytes, which could technically be valid. - From the ABI spec (https://solidity.readthedocs.io/en/v0.5.9/abi-spec.html):
bytes, of length k (which is assumed to be of type uint256):
enc(X) = enc(k) pad_right(X), i.e. the number of bytes is encoded as a uint256 followed by the actual value of X as a byte sequence, followed by the minimum number of zero-bytes such that len(enc(X)) is a multiple of 32.
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.
Interesting. I guess this also explains why we word align revert strings.
}), | ||
constants.AWAIT_TRANSACTION_MINED_MS, | ||
); | ||
await erc20Proxy.addAuthorizedAddress.awaitTransactionSuccessAsync(exchange.address, { from: owner }); |
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.
🙏
47c84dd
to
8897dc1
Compare
8897dc1
to
323fb0a
Compare
Description
types
andorder-utils
abi-gen-templates
to includegetABIEncodedTransactionData
in thecallAsync
template (rather than thetx
template). This was useful for implementing tests for theStaticCallProxy
.ERC1155Proxy
(also used in theStaticCallProxy
)StaticCallProxy
support toLibAssetData
Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.