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

Use local EVM for pure functions #2108

Merged
merged 7 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ jobs:
./install
./lint
static-tests:
resource_class: large
working_directory: ~/repo
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
Expand Down
12 changes: 4 additions & 8 deletions contracts/coordinator/test/mixins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ describe('Mixins tests', () => {
transaction.signature.length - 2,
)}${illegalSignatureByte}`;
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
expectContractCallFailedAsync(
mixins.getSignerAddress.callAsync(transactionHash, transaction.signature),
expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.be.rejectedWith(
RevertReason.SignatureIllegal,
);
});
Expand All @@ -115,8 +114,7 @@ describe('Mixins tests', () => {
const invalidSignatureByte = ethUtil.toBuffer(SignatureType.Invalid).toString('hex');
transaction.signature = `0x${invalidSignatureByte}`;
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
expectContractCallFailedAsync(
mixins.getSignerAddress.callAsync(transactionHash, transaction.signature),
expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.be.rejectedWith(
RevertReason.SignatureInvalid,
);
});
Expand All @@ -129,8 +127,7 @@ describe('Mixins tests', () => {
transaction.signature.length - 2,
)}${invalidSignatureByte}`;
const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
expectContractCallFailedAsync(
mixins.getSignerAddress.callAsync(transactionHash, transaction.signature),
expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.be.rejectedWith(
RevertReason.SignatureUnsupported,
);
});
Expand Down Expand Up @@ -193,8 +190,7 @@ describe('Mixins tests', () => {
});
it('should revert if data is less than 4 bytes long', async () => {
const data = '0x010203';
await expectContractCallFailedAsync(
mixins.decodeOrdersFromFillData.callAsync(data),
expect(mixins.decodeOrdersFromFillData.callAsync(data)).to.be.rejectedWith(
RevertReason.LibBytesGreaterOrEqualTo4LengthRequired,
);
});
Expand Down
12 changes: 2 additions & 10 deletions contracts/utils/test/lib_address_array.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
addressUtils,
chaiSetup,
expectContractCallFailedAsync,
provider,
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
import { addressUtils, chaiSetup, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
xianny marked this conversation as resolved.
Show resolved Hide resolved
import { BlockchainLifecycle } from '@0x/dev-utils';
import { RevertReason } from '@0x/types';
import { BigNumber } from '@0x/utils';
Expand Down Expand Up @@ -55,8 +48,7 @@ describe('LibAddressArray', () => {
const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
const addr = addressUtils.generatePseudoRandomAddress();
const freeMemOffset = new BigNumber(-1);
return expectContractCallFailedAsync(
lib.testAppendRealloc.callAsync(arr, freeMemOffset, addr),
return expect(lib.testAppendRealloc.callAsync(arr, freeMemOffset, addr)).to.be.rejectedWith(
RevertReason.InvalidFreeMemoryPtr,
);
});
Expand Down
107 changes: 36 additions & 71 deletions contracts/utils/test/lib_bytes.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
"files": [
{
"path": "packages/0x.js/_bundles/index.min.js",
"maxSize": "800kB"
"maxSize": "1150kB"
},
{
"path": "packages/instant/umd/instant.js",
"maxSize": "1000kB"
"maxSize": "1350kB"
}
],
"ci": {
Expand Down
3 changes: 3 additions & 0 deletions packages/0x.js/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ module.exports = {
}),
],
},
node: {
fs: 'empty',
},
xianny marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still worried about this hack. Does this mean anyone using 0x.js in a webpack project will need to do this too to get it to work? If so, please add browser-specific instructions to the README explaining the need for this step.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a test project importing 0x.js and tried bundling with webpack. Sadly yes and there doesn't seem to be any workaround as long as we are using ethereumjs-vm as a dependency. I'll add instructions to the README.

module: {
rules: [
{
Expand Down
9 changes: 9 additions & 0 deletions packages/abi-gen-wrappers/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "5.3.2",
"changes": [
{
"note": "Redirect `callAsync` to use local EVM instead of eth_call for pure functions",
"pr": 2108
}
]
},
{
"timestamp": 1567521715,
"version": "5.3.1",
Expand Down
Loading