Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Always validate callback signatures & add support for EIP-1271 signatures #1885

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
05c6024
Update generated wrappers for coordinator and exchange.
dorothy-zbornak Mar 26, 2019
d835071
`@0x/base-contract`: Make `PromiseWithTransactionHash` fully compatib…
dorothy-zbornak Jun 19, 2019
4e86c53
`@0x/contracts-exchange`: Always check `OrderValidator` and `WalletOr…
dorothy-zbornak Jun 21, 2019
b1439cd
`@0x/utils`: Add `toStringTag` symbol to `RevertError`
dorothy-zbornak Jun 21, 2019
a9e1a26
`@0x/contracts-exchange`: Update changelog
dorothy-zbornak Jun 21, 2019
ce6f447
`@0x/order-utils`: Add `validator` field to `SignatureOrderValidatorE…
dorothy-zbornak Jun 21, 2019
18cc4b7
`@0x/contracts-exchange`: Have `TestValidatorWallet` always accept `W…
dorothy-zbornak Jun 21, 2019
cad5dd8
`@0x/types`: Rename `WalletOrderValidator` to `OrderWallet` in `Signa…
dorothy-zbornak Jun 22, 2019
89ca1e0
`@0x/order-utils`: Rename `SignatureWalletOrderValidatorError` to `Si…
dorothy-zbornak Jun 22, 2019
577a721
`@0x/contracts-exchange`: Rename `WalletOrderValidator` to `OrderWall…
dorothy-zbornak Jun 22, 2019
81f6265
Run prettier/linter
dorothy-zbornak Jun 22, 2019
56dbaa5
Update changelogs
dorothy-zbornak Jun 22, 2019
0e9d1cf
Rebase against 3.0
dorothy-zbornak Jun 24, 2019
d5623cf
`@0x/contracts-utils`: Add LibEIP1271.sol
dorothy-zbornak Jun 25, 2019
e3c4442
`@0x/contracts-exchange`: Fix comments in `test/signature_validator.ts`
dorothy-zbornak Jun 25, 2019
c6761b2
`@0x/contracts-exchange`: Refactor out `EIP1271_MAGIC_VALUE` into a `…
dorothy-zbornak Jun 25, 2019
6093a73
`@0x/contracts-exchange`: Add comments about preserving signatures in…
dorothy-zbornak Jun 25, 2019
1186820
Fix linter errors
dorothy-zbornak Jun 25, 2019
24b21ed
`@0x/contracts-exchange`: Consolidate signature types.
dorothy-zbornak Jun 25, 2019
acdcb1b
`@0x/contracts-exchange`: Fix linearization issues.
dorothy-zbornak Jun 25, 2019
c0aa42b
`@0x/types`: Consolidate signature types.
dorothy-zbornak Jun 25, 2019
c08a618
`@0x/order-utils`: Remove unused exchange revert errors
dorothy-zbornak Jun 25, 2019
721de3c
`@0x/contracts-exchange`: Add `isValidHashSignature()` back.
dorothy-zbornak Jun 26, 2019
51638fc
`@0x/contracts-exchange`: Remove `isValidOrderSignature()` from `IWal…
dorothy-zbornak Jun 26, 2019
1f28d67
`@0x/contracts-test-utils`: Add `hexConcat()` in `hex_utils.ts`.
dorothy-zbornak Jun 26, 2019
13e0433
`@0x/contracts-exchange`: Update tests for new/consolidated signature…
dorothy-zbornak Jun 26, 2019
3ab8eab
`@0x/contracts-exchange`: Update CHANGELOG
dorothy-zbornak Jun 26, 2019
8e9c185
`@0x/order-utils`: Update CHANGELOG
dorothy-zbornak Jun 26, 2019
a099f05
`@0x/contracts-exchange`: Run `contracts:gen`
dorothy-zbornak Jun 26, 2019
e7bde04
`@0x/contracts-exchange`: Make `assertValidFill` and `calculateMatche…
dorothy-zbornak Jun 26, 2019
a966abd
`@0x/contracts-exchange`: Cosmetic changes to contracts.
dorothy-zbornak Jun 26, 2019
c2f4d45
`@0x/contracts-exchange`: Make `assertValidFill()` internal again.
dorothy-zbornak Jul 1, 2019
896cd51
`@0x/contracts-exchange`: REALLY make `assertValidFill()` internal ag…
dorothy-zbornak Jul 1, 2019
d85e9c7
`@0x/contracts-exchange`: Use named return values in `MixinSignatureV…
dorothy-zbornak Jul 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
@0x/contracts-exchange: Always check OrderValidator and `WalletOr…
…derValidator` signature types on every fill

`@0x/contracts-exchange`: Add `validatorAddress` field to `SignatureValidatorError` and `SignatureOrderValidatorError` rich reverts
`@0x/contracts-exchange`: Add separate `SignatureOrderValidatorNotApprovedError` for `OrderValidator` signatures
`@0x/contracts-exchange`: Consolidate Wallet and Validator test contracts into a single configurable `TestValidatorWallet` contract.
`@0x/contracts-exchange`: Rewrite many tests in `signature_validator.ts` for brevity.
  • Loading branch information
dorothy-zbornak committed Jun 24, 2019
commit 4e86c53a5b17f9783e24f7a746876832a0b078ce
5 changes: 1 addition & 4 deletions contracts/exchange/compiler.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
},
"contracts": [
"examples/ExchangeWrapper.sol",
"examples/Validator.sol",
"examples/Wallet.sol",
"examples/Whitelist.sol",
"src/Exchange.sol",
"src/interfaces/IAssetProxyDispatcher.sol",
Expand All @@ -42,8 +40,7 @@
"test/TestAssetProxyDispatcher.sol",
"test/TestExchangeInternals.sol",
"test/TestLibExchangeRichErrorDecoder.sol",
"test/TestRevertReceiver.sol",
"test/TestSignatureValidator.sol",
"test/TestStaticCallReceiver.sol"
"test/TestValidatorWallet.sol"
]
}
79 changes: 0 additions & 79 deletions contracts/exchange/contracts/examples/Validator.sol

This file was deleted.

100 changes: 0 additions & 100 deletions contracts/exchange/contracts/examples/Wallet.sol

This file was deleted.

34 changes: 34 additions & 0 deletions contracts/exchange/contracts/src/MixinExchangeRichErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,40 @@ contract MixinExchangeRichErrors is
);
}

function SignatureValidatorNotApprovedError(
address signerAddress,
address validatorAddress
)
internal
pure
returns (bytes memory)
{
return abi.encodeWithSelector(
SIGNATURE_VALIDATOR_NOT_APPROVED_ERROR_SELECTOR,
signerAddress,
validatorAddress
);
}

function SignatureOrderValidatorNotApprovedError(
address signerAddress,
address validatorAddress
)
internal
pure
returns (bytes memory)
{
return abi.encodeWithSelector(
SIGNATURE_ORDER_VALIDATOR_NOT_APPROVED_ERROR_SELECTOR,
signerAddress,
validatorAddress
);
}

function SignatureValidatorError(
bytes32 hash,
address signerAddress,
address validatorAddress,
bytes memory signature,
bytes memory errorData
)
Expand All @@ -61,6 +92,7 @@ contract MixinExchangeRichErrors is
SIGNATURE_VALIDATOR_ERROR_SELECTOR,
hash,
signerAddress,
validatorAddress,
signature,
errorData
);
Expand Down Expand Up @@ -88,6 +120,7 @@ contract MixinExchangeRichErrors is
function SignatureOrderValidatorError(
bytes32 orderHash,
address signerAddress,
address validatorAddress,
bytes memory signature,
bytes memory errorData
)
Expand All @@ -99,6 +132,7 @@ contract MixinExchangeRichErrors is
SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR,
orderHash,
signerAddress,
validatorAddress,
signature,
errorData
);
Expand Down
12 changes: 10 additions & 2 deletions contracts/exchange/contracts/src/MixinSignatureValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ contract MixinSignatureValidator is
address validatorAddress = signature.readAddress(signatureLength - 21);
// Ensure signer has approved validator.
if (!allowedValidators[signerAddress][validatorAddress]) {
return false;
_rrevert(SignatureValidatorNotApprovedError(
signerAddress,
validatorAddress
));
}
// Shave the validator address and signature type from the signature.
assembly {
Expand All @@ -387,6 +390,7 @@ contract MixinSignatureValidator is
_rrevert(SignatureValidatorError(
hash,
signerAddress,
validatorAddress,
signature,
returnData
));
Expand Down Expand Up @@ -468,7 +472,10 @@ contract MixinSignatureValidator is
address validatorAddress = signature.readAddress(signatureLength - 21);
// Ensure signer has approved validator.
if (!allowedOrderValidators[signerAddress][validatorAddress]) {
return false;
_rrevert(SignatureOrderValidatorNotApprovedError(
signerAddress,
validatorAddress
));
}
// Shave the validator address and signature type from the signature.
assembly {
Expand All @@ -495,6 +502,7 @@ contract MixinSignatureValidator is
_rrevert(SignatureOrderValidatorError(
orderHash,
signerAddress,
validatorAddress,
signature,
returnData
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,25 @@ contract IExchangeRichErrors {
bytes4 internal constant SIGNATURE_ERROR_SELECTOR =
0x7e5a2318;

// bytes4(keccak256("SignatureValidatorError(bytes32,address,bytes,bytes)"))
// bytes4(keccak256("SignatureValidatorNotApprovedError(address,address)"))
bytes4 internal constant SIGNATURE_VALIDATOR_NOT_APPROVED_ERROR_SELECTOR =
0xa15c0d06;

// bytes4(keccak256("SignatureOrderValidatorNotApprovedError(address,address)"))
bytes4 internal constant SIGNATURE_ORDER_VALIDATOR_NOT_APPROVED_ERROR_SELECTOR =
0x6d273c5a;

// bytes4(keccak256("SignatureValidatorError(bytes32,address,address,bytes,bytes)"))
bytes4 internal constant SIGNATURE_VALIDATOR_ERROR_SELECTOR =
0x169fad8c;
0xa23838b8;

// bytes4(keccak256("SignatureWalletError(bytes32,address,bytes,bytes)"))
bytes4 internal constant SIGNATURE_WALLET_ERROR_SELECTOR =
0x1b8388f7;

// bytes4(keccak256("SignatureOrderValidatorError(bytes32,address,bytes,bytes)"))
// bytes4(keccak256("SignatureOrderValidatorError(bytes32,address,address,bytes,bytes)"))
bytes4 internal constant SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR =
0xfabf4577;
0xf45375b7;

// bytes4(keccak256("SignatureWalletOrderValidatorError(bytes32,address,bytes,bytes)"))
bytes4 internal constant SIGNATURE_WALLET_ORDER_VALIDATOR_ERROR_SELECTOR =
Expand Down
Loading