Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Uncaught TypeError: this.removeListener is not a function #4

Closed
BlinkyStitt opened this issue Jan 19, 2019 · 34 comments
Closed

Uncaught TypeError: this.removeListener is not a function #4

BlinkyStitt opened this issue Jan 19, 2019 · 34 comments
Assignees

Comments

@BlinkyStitt
Copy link

Because of #3, I had a test fail. I noticed the test after it failed with this short error:

     Uncaught TypeError: this.removeListener is not a function
      at Object.receipt (node_modules/truffle/build/webpack:/packages/truffle-contract/lib/handlers.js:134:1)
      at Function.start (node_modules/truffle/build/webpack:/packages/truffle-contract/lib/override.js:56:1)

The test succeeded on the first run, so I think this is something about test cleanup.

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Jan 27, 2019

Even with restarting geth, I'm still seeing occasional errors. This time there is more to them.

# time yarn test
yarn run v1.12.3
$ truffle test
Using network 'development'.



  Contract: Bank
    ✓ ...should start empty (126ms)
    ✓ ...only admins should be able to change max borrow amount
    ✓ ...should let admins configure the max borrow amount (141ms)
TypeError: this.removeListener is not a function
    at Object.receipt (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-contract/lib/handlers.js:134:1)
    at Function.start (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-contract/lib/override.js:56:1)
TypeError: this.removeListener is not a function
    at Object.receipt (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-contract/lib/handlers.js:134:1)
    at Function.start (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-contract/lib/override.js:56:1)
/usr/src/app/node_modules/mocha/lib/runner.js:707
  err.uncaught = true;
               ^

TypeError: Cannot create property 'uncaught' on string 'abort({}). Build with -s ASSERTIONS=1 for more info.'
    at Runner.uncaught (/usr/src/app/node_modules/mocha/lib/runner.js:707:16)
    at process.uncaught (/usr/src/app/node_modules/mocha/lib/runner.js:821:10)
    at process.emit (events.js:182:13)
    at process.emit (/usr/src/app/node_modules/truffle/build/webpack:/~/source-map-support/source-map-support.js:461:1)
    at process.emit (/usr/src/app/node_modules/source-map-support/source-map-support.js:461:21)
    at process._fatalException (internal/bootstrap/node.js:493:27)
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

real	0m39.983s
user	0m11.820s
sys	0m4.540s

Where do I add -s ASSERTIONS=1?

@nitper
Copy link
Contributor

nitper commented Feb 5, 2019

I'm also getting the same problem when I run truffle test. Running MODE=trace truffle test seems to work most of the time, but I'd still like to understand why this is happening.

@LogvinovLeon
Copy link
Contributor

This seems like a mocha error. I would suggest looking here:
mochajs/mocha#3320 and here: mochajs/mocha#3471

Truffle might be just using an old version of mocha

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 7, 2019

If I change my truffle-config.js to be just a simple module.exports that points to a local ganache, the tests all run fine without any errors. So even if the error is in mocha, I feel like the example truffle-config.js could do something to work around it.

I did a yarn upgrade and a yarn outdated and I have the latest versions that I can. Truffle is using mocha v4.1.0, while the latest is v5. I'm looking at why it is staying on v4 now.

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 7, 2019

Opened trufflesuite/truffle#1705 to figure out why truffle is on mocha v4.

I also changed my truffle-config.js to connect to the devnet geth and the tests ran to completion without any errors. I'm thinking it's more likely that the error is in web3-provider-engine or how truffle is trying to use it. Considering there is already one comment saying "HACK," I'm guessing we will need another.

I wish async code had more useful tracebacks. Does anyone know how to get better logs out of mocha?

@BlinkyStitt
Copy link
Author

I switched to using the websocket provider at https://github.com/MetaMask/provider-engine/blob/master/subproviders/websocket.js instead of the rpc provider and I think it's working.

Truffle need this for subscribing to events.

https://hanezu.github.io/posts/Enable-WebSocket-support-of-Ganache-CLI-and-Subscribe-to-Events.html

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 8, 2019

Well the tests got further, but they got stuck somewhere in the middle of one that was minting gastoken. If I turn on debug logging, this is what I see:

    ✓ ... should have some ETH to lend (133ms)
[WSProvider] Sent: eth_blockNumber #87
[WSProvider] Received: eth_blockNumber #87
[WSProvider] Sent: eth_getBlockByNumber #88
[WSProvider] Received: eth_getBlockByNumber #88
[WSProvider] Sent: eth_getBlockByNumber #89
[WSProvider] Received: eth_getBlockByNumber #89
[WSProvider] Sent: eth_getBlockByNumber #90
[WSProvider] Received: eth_getBlockByNumber #90
[WSProvider] Sent: eth_sendTransaction #91
[WSProvider] Received: eth_sendTransaction #91
[WSProvider] Sent: eth_getTransactionReceipt #92
[WSProvider] Received: eth_getTransactionReceipt #92
[WSProvider] Sent: eth_subscribe #93
[WSProvider] Sent: eth_getBlockByNumber #94
[WSProvider] Received: eth_subscribe #93
[WSProvider] Received: eth_getBlockByNumber #94
[WSProvider] Sent: eth_call #14
[WSProvider] Received: eth_call #14
    ✓ ... should have some TutorialToken to lend (77ms)
[WSProvider] Sent: eth_blockNumber #95
[WSProvider] Received: eth_blockNumber #95
[WSProvider] Sent: eth_getBlockByNumber #96
[WSProvider] Received: eth_getBlockByNumber #96
[WSProvider] Sent: eth_getBlockByNumber #97
[WSProvider] Received: eth_getBlockByNumber #97
[WSProvider] Sent: eth_getBlockByNumber #98
[WSProvider] Received: eth_getBlockByNumber #98
[WSProvider] Sent: eth_sendTransaction #99
[WSProvider] Received: eth_sendTransaction #99
[WSProvider] Sent: eth_getTransactionReceipt #100
[WSProvider] Received: eth_getTransactionReceipt #100
[WSProvider] Sent: eth_subscribe #101
[WSProvider] Received: eth_subscribe #101
[WSProvider] Sent: eth_getTransactionReceipt #102
[WSProvider] Received: eth_getTransactionReceipt #102
[WSProvider] Sent: eth_getTransactionReceipt #103
[WSProvider] Received: eth_getTransactionReceipt #103
[WSProvider] Sent: eth_getTransactionReceipt #104
[WSProvider] Received: eth_getTransactionReceipt #104
[WSProvider] Sent: eth_getTransactionReceipt #105
[WSProvider] Received: eth_getTransactionReceipt #105
[WSProvider] Sent: eth_getBlockByNumber #1235379310713340
[WSProvider] Received: eth_getBlockByNumber #1235379310713340
[WSProvider] Sent: eth_getBlockByNumber #1235379310713341
[WSProvider] Received: eth_getBlockByNumber #1235379310713341
[WSProvider] Sent: eth_getBlockByNumber #1235379310713342
[WSProvider] Received: eth_getBlockByNumber #1235379310713342
[WSProvider] Sent: eth_getBlockByNumber #1235379310713343
[WSProvider] Received: eth_getBlockByNumber #1235379310713343
[WSProvider] Sent: eth_getTransactionReceipt #106
[WSProvider] Received: eth_getTransactionReceipt #106
[WSProvider] Sent: eth_getTransactionReceipt #107
[WSProvider] Received: eth_getTransactionReceipt #107
[WSProvider] Sent: eth_getTransactionReceipt #108
[WSProvider] Received: eth_getTransactionReceipt #108
[WSProvider] Sent: eth_getTransactionReceipt #109
[WSProvider] Received: eth_getTransactionReceipt #109
[WSProvider] Sent: eth_getBlockByNumber #1235379310713344
[WSProvider] Received: eth_getBlockByNumber #1235379310713344
[WSProvider] Sent: eth_getTransactionReceipt #110
[WSProvider] Received: eth_getTransactionReceipt #110
[WSProvider] Sent: eth_getTransactionReceipt #111
[WSProvider] Received: eth_getTransactionReceipt #111
[WSProvider] Sent: eth_getTransactionReceipt #112
[WSProvider] Received: eth_getTransactionReceipt #112
[WSProvider] Sent: eth_getTransactionReceipt #113
[WSProvider] Received: eth_getTransactionReceipt #113
[WSProvider] Sent: eth_getBlockByNumber #1235379310713345
[WSProvider] Received: eth_getBlockByNumber #1235379310713345
[WSProvider] Sent: eth_getTransactionReceipt #114
[WSProvider] Received: eth_getTransactionReceipt #114
[WSProvider] Sent: eth_getTransactionReceipt #115
[WSProvider] Received: eth_getTransactionReceipt #115
[WSProvider] Sent: eth_getTransactionReceipt #116
[WSProvider] Received: eth_getTransactionReceipt #116
[WSProvider] Sent: eth_getTransactionReceipt #117
[WSProvider] Received: eth_getTransactionReceipt #117
[WSProvider] Sent: eth_getBlockByNumber #1235379310713346
[WSProvider] Received: eth_getBlockByNumber #1235379310713346
[WSProvider] Sent: eth_getTransactionReceipt #118
[WSProvider] Received: eth_getTransactionReceipt #118
[WSProvider] Sent: eth_getTransactionReceipt #119
[WSProvider] Received: eth_getTransactionReceipt #119
[WSProvider] Sent: eth_getTransactionReceipt #120
[WSProvider] Received: eth_getTransactionReceipt #120
[WSProvider] Sent: eth_getTransactionReceipt #121
[WSProvider] Received: eth_getTransactionReceipt #121
[WSProvider] Sent: eth_getBlockByNumber #1235379310713347
[WSProvider] Received: eth_getBlockByNumber #1235379310713347
[WSProvider] Sent: eth_getTransactionReceipt #122
[WSProvider] Received: eth_getTransactionReceipt #122
[WSProvider] Sent: eth_getTransactionReceipt #123
[WSProvider] Received: eth_getTransactionReceipt #123
[WSProvider] Sent: eth_getTransactionReceipt #124
[WSProvider] Received: eth_getTransactionReceipt #124
[WSProvider] Sent: eth_getBlockByNumber #1235379310713348
[WSProvider] Received: eth_getBlockByNumber #1235379310713348
[WSProvider] Sent: eth_getBlockByNumber #1235379310713349
[WSProvider] Received: eth_getBlockByNumber #1235379310713349
[WSProvider] Sent: eth_getBlockByNumber #1235379310713350
[WSProvider] Received: eth_getBlockByNumber #1235379310713350
[WSProvider] Sent: eth_getBlockByNumber #1235379310713351
[WSProvider] Received: eth_getBlockByNumber #1235379310713351
[WSProvider] Sent: eth_getBlockByNumber #1235379310713352
[WSProvider] Received: eth_getBlockByNumber #1235379310713352
[WSProvider] Sent: eth_getBlockByNumber #1235379310713353
[WSProvider] Received: eth_getBlockByNumber #1235379310713353
[WSProvider] Sent: eth_getBlockByNumber #1235379310713354
[WSProvider] Received: eth_getBlockByNumber #1235379310713354
[WSProvider] Sent: eth_getBlockByNumber #1235379310713355
[WSProvider] Received: eth_getBlockByNumber #1235379310713355
[WSProvider] Sent: eth_getBlockByNumber #1235379310713356
[WSProvider] Received: eth_getBlockByNumber #1235379310713356
[WSProvider] Sent: eth_getBlockByNumber #1235379310713357
[WSProvider] Received: eth_getBlockByNumber #1235379310713357
[WSProvider] Sent: eth_getBlockByNumber #1235379310713358
[WSProvider] Received: eth_getBlockByNumber #1235379310713358
[WSProvider] Sent: eth_getBlockByNumber #1235379310713359
[WSProvider] Received: eth_getBlockByNumber #1235379310713359
[WSProvider] Sent: eth_getBlockByNumber #1235379310713360
[WSProvider] Received: eth_getBlockByNumber #1235379310713360
[WSProvider] Sent: eth_getBlockByNumber #1235379310713361
[WSProvider] Received: eth_getBlockByNumber #1235379310713361
[WSProvider] Sent: eth_getBlockByNumber #1235379310713362
[WSProvider] Received: eth_getBlockByNumber #1235379310713362
[WSProvider] Sent: eth_getBlockByNumber #1235379310713363
[WSProvider] Received: eth_getBlockByNumber #1235379310713363
[WSProvider] Sent: eth_getBlockByNumber #1235379310713364
[WSProvider] Received: eth_getBlockByNumber #1235379310713364
[WSProvider] Sent: eth_getBlockByNumber #1235379310713365
[WSProvider] Received: eth_getBlockByNumber #1235379310713365
[WSProvider] Sent: eth_getBlockByNumber #1235379310713366
[WSProvider] Received: eth_getBlockByNumber #1235379310713366
[WSProvider] Sent: eth_getBlockByNumber #1235379310713367
[WSProvider] Received: eth_getBlockByNumber #1235379310713367
[WSProvider] Sent: eth_getBlockByNumber #1235379310713368
[WSProvider] Received: eth_getBlockByNumber #1235379310713368
[WSProvider] Sent: eth_getBlockByNumber #1235379310713369
[WSProvider] Received: eth_getBlockByNumber #1235379310713369
[WSProvider] Sent: eth_getBlockByNumber #1235379310713370
[WSProvider] Received: eth_getBlockByNumber #1235379310713370
[WSProvider] Sent: eth_getBlockByNumber #1235379310713371
[WSProvider] Received: eth_getBlockByNumber #1235379310713371
[WSProvider] Sent: eth_getBlockByNumber #1235379310713372
[WSProvider] Received: eth_getBlockByNumber #1235379310713372
[WSProvider] Sent: eth_getBlockByNumber #1235379310713373
[WSProvider] Received: eth_getBlockByNumber #1235379310713373
[WSProvider] Sent: eth_getBlockByNumber #1235379310713374
[WSProvider] Received: eth_getBlockByNumber #1235379310713374
[WSProvider] Sent: eth_getBlockByNumber #1235379310713375
[WSProvider] Received: eth_getBlockByNumber #1235379310713375
[WSProvider] Sent: eth_getBlockByNumber #1235379310713376
[WSProvider] Received: eth_getBlockByNumber #1235379310713376
[WSProvider] Sent: eth_getBlockByNumber #1235379310713377
[WSProvider] Received: eth_getBlockByNumber #1235379310713377
[WSProvider] Sent: eth_getBlockByNumber #1235379310713378
[WSProvider] Received: eth_getBlockByNumber #1235379310713378
[WSProvider] Sent: eth_getBlockByNumber #1235379310713379
[WSProvider] Received: eth_getBlockByNumber #1235379310713379
[WSProvider] Sent: eth_getBlockByNumber #1235379310713380
[WSProvider] Received: eth_getBlockByNumber #1235379310713380
[WSProvider] Sent: eth_getBlockByNumber #1235379310713381
[WSProvider] Received: eth_getBlockByNumber #1235379310713381
[WSProvider] Sent: eth_getBlockByNumber #1235379310713382
[WSProvider] Received: eth_getBlockByNumber #1235379310713382
[WSProvider] Sent: eth_getBlockByNumber #1235379310713383
[WSProvider] Received: eth_getBlockByNumber #1235379310713383
[WSProvider] Sent: eth_getBlockByNumber #1235379310713384
[WSProvider] Received: eth_getBlockByNumber #1235379310713384
[WSProvider] Sent: eth_getBlockByNumber #1235379310713385
[WSProvider] Received: eth_getBlockByNumber #1235379310713385
[WSProvider] Sent: eth_getBlockByNumber #1235379310713386
[WSProvider] Received: eth_getBlockByNumber #1235379310713386
[WSProvider] Sent: eth_getBlockByNumber #1235379310713387
[WSProvider] Received: eth_getBlockByNumber #1235379310713387
[WSProvider] Sent: eth_getBlockByNumber #1235379310713388
[WSProvider] Received: eth_getBlockByNumber #1235379310713388
[WSProvider] Sent: eth_getBlockByNumber #1235379310713389
[WSProvider] Received: eth_getBlockByNumber #1235379310713389
[WSProvider] Sent: eth_getBlockByNumber #1235379310713390
[WSProvider] Received: eth_getBlockByNumber #1235379310713390
[WSProvider] Sent: eth_getBlockByNumber #1235379310713391
[WSProvider] Received: eth_getBlockByNumber #1235379310713391
[WSProvider] Sent: eth_getBlockByNumber #1235379310713392
[WSProvider] Received: eth_getBlockByNumber #1235379310713392
[WSProvider] Sent: eth_getBlockByNumber #1235379310713393
[WSProvider] Received: eth_getBlockByNumber #1235379310713393
[WSProvider] Sent: eth_getBlockByNumber #1235379310713394
[WSProvider] Received: eth_getBlockByNumber #1235379310713394
[WSProvider] Sent: eth_getBlockByNumber #1235379310713395
[WSProvider] Received: eth_getBlockByNumber #1235379310713395
[WSProvider] Sent: eth_getBlockByNumber #1235379310713396
[WSProvider] Received: eth_getBlockByNumber #1235379310713396
[WSProvider] Sent: eth_getBlockByNumber #1235379310713397
[WSProvider] Received: eth_getBlockByNumber #1235379310713397
[WSProvider] Sent: eth_getBlockByNumber #1235379310713398
[WSProvider] Received: eth_getBlockByNumber #1235379310713398
[WSProvider] Sent: eth_getBlockByNumber #1235379310713399
[WSProvider] Received: eth_getBlockByNumber #1235379310713399
[WSProvider] Sent: eth_getBlockByNumber #1235379310713400
[WSProvider] Received: eth_getBlockByNumber #1235379310713400
[WSProvider] Sent: eth_getBlockByNumber #1235379310713401
[WSProvider] Received: eth_getBlockByNumber #1235379310713401
[WSProvider] Sent: eth_getBlockByNumber #1235379310713402
[WSProvider] Received: eth_getBlockByNumber #1235379310713402
[WSProvider] Sent: eth_getBlockByNumber #1235379310713403
[WSProvider] Received: eth_getBlockByNumber #1235379310713403
[WSProvider] Sent: eth_getBlockByNumber #1235379310713404
[WSProvider] Received: eth_getBlockByNumber #1235379310713404
[WSProvider] Sent: eth_getBlockByNumber #1235379310713405
[WSProvider] Received: eth_getBlockByNumber #1235379310713405
[WSProvider] Sent: eth_getBlockByNumber #1235379310713406
[WSProvider] Received: eth_getBlockByNumber #1235379310713406
[WSProvider] Sent: eth_getBlockByNumber #1235379310713407
[WSProvider] Received: eth_getBlockByNumber #1235379310713407
[WSProvider] Sent: eth_getBlockByNumber #1235379310713408
[WSProvider] Received: eth_getBlockByNumber #1235379310713408
[WSProvider] Sent: eth_getBlockByNumber #1235379310713409
[WSProvider] Received: eth_getBlockByNumber #1235379310713409
[WSProvider] Sent: eth_getBlockByNumber #1235379310713410
[WSProvider] Received: eth_getBlockByNumber #1235379310713410
[WSProvider] Sent: eth_getBlockByNumber #1235379310713411
[WSProvider] Received: eth_getBlockByNumber #1235379310713411

I could let it run longer, but it doesn't look like it is doing anything.

This is the test that passes fine against ganache:

  it("... should have some gas token to burn", async () => {
    const bankTellerInstance = await BankTeller.deployed();

    const gasTokenInstance = await GasToken2.deployed();

    await gasTokenInstance.mint(100, { from: accounts[3] });

    await gasTokenInstance.approve(BankTeller.address, 100, { from: accounts[3] });

    await bankTellerInstance.setGasToken(accounts[3]);
  });

@LogvinovLeon
Copy link
Contributor

@wysenynja After trufflesuite/ganache#280 got fixed - you can use dev-tools with Ganache (except for sol-profiler). Could you try that? I've updated an example repo.

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 26, 2019

That certainly seems to be working better. It runs several passing tests, but then gives this error:

Error: GasToken2 was compiled with solidity soljson-v0.4.16+commit.d7661dd9.js but specified version is 0.5.4 making it impossible to process traces
    at TruffleArtifactAdapter._assertSolidityVersionIsCorrect (/usr/src/app/node_modules/@0x/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:80:23)
    at TruffleArtifactAdapter.<anonymous> (/usr/src/app/node_modules/@0x/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts:37:14)
    at step (/usr/src/app/node_modules/@0x/sol-tracing-utils/lib/src/artifact_adapters/truffle_artifact_adapter.js:56:23)
    at Object.next (/usr/src/app/node_modules/@0x/sol-tracing-utils/lib/src/artifact_adapters/truffle_artifact_adapter.js:37:53)
    at /usr/src/app/node_modules/@0x/sol-tracing-utils/lib/src/artifact_adapters/truffle_artifact_adapter.js:31:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/src/app/node_modules/@0x/sol-tracing-utils/lib/src/artifact_adapters/truffle_artifact_adapter.js:27:12)
    at TruffleArtifactAdapter.collectContractsDataAsync (/usr/src/app/node_modules/@0x/sol-tracing-utils/lib/src/artifact_adapters/truffle_artifact_adapter.js:93:16)
    at RevertTraceSubprovider.<anonymous> (/usr/src/app/node_modules/@0x/sol-trace/src/revert_trace_subprovider.ts:64:63)
    at step (/usr/src/app/node_modules/@0x/sol-trace/lib/src/revert_trace_subprovider.js:45:23)
    at Object.next (/usr/src/app/node_modules/@0x/sol-trace/lib/src/revert_trace_subprovider.js:26:53)
    at /usr/src/app/node_modules/@0x/sol-trace/lib/src/revert_trace_subprovider.js:20:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/src/app/node_modules/@0x/sol-trace/lib/src/revert_trace_subprovider.js:16:12)
    at RevertTraceSubprovider._printStackTraceAsync (/usr/src/app/node_modules/@0x/sol-trace/lib/src/revert_trace_subprovider.js:124:16)
    at RevertTraceSubprovider.<anonymous> (/usr/src/app/node_modules/@0x/sol-trace/src/revert_trace_subprovider.ts:58:24)
    at step (/usr/src/app/node_modules/@0x/sol-trace/lib/src/revert_trace_subprovider.js:45:23)
    at Object.next (/usr/src/app/node_modules/@0x/sol-trace/lib/src/revert_trace_subprovider.js:26:53)
    at fulfilled (/usr/src/app/node_modules/@0x/sol-trace/lib/src/revert_trace_subprovider.js:17:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)

My problem is that I have artifacts from sol-compiler and also from truffle.

Is there some way to have 2 artifact adapters?

I also see Detected a contract created from within another contract. We currently do not support that scenario. We'll just skip that trace higher up in the logs. If multiple artifact adapters aren't supported, I think a warning like that should probably be emitted instead of throwing.

@BlinkyStitt
Copy link
Author

At first I was thinking I could write a custom artifact adapter that tried truffle and then sol-compiler artifacts, but that won't be enough. I need to change https://github.com/0xProject/0x-monorepo/blob/development/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts#L80 otherwise it won't let me get that far.

@LogvinovLeon
Copy link
Contributor

Do I understand correctly that you have two types of artifacts in the same folder and truffleArtifactAdapter consumes artifacts from sol-compiler that have different version?

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 26, 2019

  1. I have sol-compiler building GasToken (and soon other contracts with varying versions of solc).
  2. I have truffle compile building my main project's artifacts. (I was using sol-compiler for everything, but the eth-gas-reporter package wasn't able to parse the artifacts when I did that.)
  3. I have an external compile step run by truffle compile that converts the sol-compiler json files into something that truffle's artifacts.require(...) can load. All the artifacts end up in truffle's artifacts folder in a format that truffle can read.

More details at trufflesuite/truffle#1607 (comment)

@LogvinovLeon
Copy link
Contributor

What if you just use sol-compiler to compile every contract you have and use SolCompilerArtifactAdapter? Either way, truffle artifacts don't have enough data for the tools and we will recompile your stuff under the hood into a hidden folder.

@BlinkyStitt
Copy link
Author

I'll try going back to that. I liked having eth-gas-reporter's output though.

@LogvinovLeon
Copy link
Contributor

Can we jump on a call to discuss that?

@LogvinovLeon
Copy link
Contributor

I think there is a way to achieve all you need. I just need to understand it better

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 26, 2019

I moved my contracts into the directory that sol-compiler is configured to build, but ran into another issue (one I had forgotten about: trufflesuite/truffle#1607 (comment)). For some reason truffle is able to compile contracts with pragma experimental ABIEncoderV2, but my sol-compiler-json-to-truffle.js script is doing something different than truffle is.

Converting /usr/src/app/build/external/sol-compiler/BankTeller.json to a truffle artifact...
Error: Schema validation failed. Errors:

should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[22]',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'constant' },
  data:
   { constant: true,
     inputs:
      [ { name: '_addresses', type: 'address[]' },
        { name: '_values', type: 'uint256[]' },
        { name: '_calldatas', type: 'bytes[]' } ],
     name: 'encodeContractCalls',
     outputs: [ { name: 'script', type: 'bytes' } ],
     payable: false,
     stateMutability: 'pure',
     type: 'function' },
  parentSchema:
   { type: 'object',
     properties:
      { type: { type: 'string', enum: [ 'event' ] },
        name: { '$ref': '#/definitions/Name' },
        inputs:
         { type: 'array',
           items: { '$ref': '#/definitions/EventParameter' } },
        anonymous: { type: 'boolean' } },
     required: [ 'type', 'name', 'inputs', 'anonymous' ],
     additionalProperties: false } }

I'm too busy for a call today, but tomorrow afternoon (PST) works for me.

I can go back to removing the experimental encoder from this contract, but I think I am going to need it for another contract later on.

@LogvinovLeon
Copy link
Contributor

This definitely doesn't seem like the dev tools error. More like the one in truffle or converting script

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 26, 2019

That error is something to do with the abi that sol-compiler outputs being different in some way than what the same contract under truffle outputs. I just mentioned it here since it's blocking. It should be easy to get a diff.

The conversion script (trufflesuite/truffle#1607 (comment)) is very short and essentially just copies whats in one json file into another slightly different file. I'm not modifying any of the fields, so I would be really surprised if the bug is there.

I got rid of the function that uses pragma experimental ABIEncoderV2 and removed my interfaces to ZrxExchange and sol-compiler works. Will try sol-trace again later.

@LogvinovLeon
Copy link
Contributor

Sol-compiler outputs exactly the ABI it's getting from solidity compiler. It's dependent on the version of the solidity compiler you use. Solc-js has functions to migrate old ABI formats to new ones

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 26, 2019

That's why I assumed that simply copy/paste of the abi from sol-compiler's output would be identical to truffle's. Both sol-compiler and my truffle-config.js are set to use 0.5.4. How would I be getting an older ABI format? And how I can tell what format I even have?

sol-compiler says:

Compiling 15 contracts (...) with Solidity v0.5.4...

truffle-config.js:

  compilers: {
    solc: {
      version: "0.5.4",
      optimizer: {
        enabled: true,
      },
    },

Truffle's Migration.sol leads to a json artifact with:

    "version": "0.5.4+commit.9549d8ff.Emscripten.clang"

While sol-compiler's output has an artifact with:

    "version": "soljson-v0.5.4+commit.9549d8ff.js"

@LogvinovLeon
Copy link
Contributor

I would not be able to answer that without further research into the topic

@LogvinovLeon
Copy link
Contributor

It could be that truffle is using native solc. Sol-compiler uses solcjs by default. You can tell it to useDockerisedSolc. It will speed up compilation of huge projects, but will require your env to have docker.

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 26, 2019 via email

@LogvinovLeon
Copy link
Contributor

You most probably will also be affected by that issue: 0xProject/0x-monorepo#1650

@BlinkyStitt
Copy link
Author

Interesting. Thanks. I'll try dropping everything to 0.5.0 and see what changes, too.

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 27, 2019

Downgrading to 0.5.0 made no change. Neither did disabling solc optimizer.

I started looking at solc-js' helper functions, but I'm not actually updating the abi (Both sides are 0.5.4) and so calling that doesn't look like it would do anything. Interestingly, I do have a contract written in 0.4.16, and the abi generated for it passes truffle's validation without any issue.

truffle's IZrxExchange.json: https://gist.github.com/WyseNynja/bc809498444cb93fd52f93105ec40c58

sol-compiler's IZrxExchange.json: https://gist.github.com/WyseNynja/6dedecd5bf15904689951523bb182ee7

sol-compiler's IZrxExchange.json converted to a truffle artifact (fails to parse): https://gist.github.com/WyseNynja/693133309719362ec25792b05212913a

As expected, the JSON is sorted differently. I'm not having much luck seeing why it thinks there are invalid "additionalProperties" though. AFAICT, the properties are the same for both json files. Who should I open a ticket about this with?

Parse error:

Error: Schema validation failed. Errors:

should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[0]',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'constant' },
  data:
   { constant: false,
     inputs:
      [ { name: 'orders', type: 'bytes[]' },
        { name: 'takerAssetFillAmounts', type: 'uint256[]' },
        { name: 'signatures', type: 'bytes[]' } ],
     name: 'batchFillOrKillOrders',
     outputs: [ { name: 'totalFillResults', type: 'bytes' } ],
     payable: false,
     stateMutability: 'nonpayable',
     type: 'function' },
  parentSchema:
   { type: 'object',
     properties:
      { type: { type: 'string', enum: [ 'event' ] },
        name: { '$ref': '#/definitions/Name' },
        inputs:
         { type: 'array',
           items: { '$ref': '#/definitions/EventParameter' } },
        anonymous: { type: 'boolean' } },
     required: [ 'type', 'name', 'inputs', 'anonymous' ],
     additionalProperties: false } }

should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[0]',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'name' },
  data:
   { constant: false,
     inputs:
      [ { name: 'orders', type: 'bytes[]' },
        { name: 'takerAssetFillAmounts', type: 'uint256[]' },
        { name: 'signatures', type: 'bytes[]' } ],
     name: 'batchFillOrKillOrders',
     outputs: [ { name: 'totalFillResults', type: 'bytes' } ],
     payable: false,
     stateMutability: 'nonpayable',
     type: 'function' },
  parentSchema:
   { type: 'object',
     properties:
      { type: { type: 'string', enum: [ 'constructor' ] },
        inputs:
         { type: 'array', items: { '$ref': '#/definitions/Parameter' } },
        stateMutability: { '$ref': '#/definitions/StateMutability' },
        constant: { type: 'boolean' },
        payable: { type: 'boolean', default: false } },
     required: [ 'type', 'inputs', 'stateMutability' ],
     additionalProperties: false } }

should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[0]',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'inputs' },
  data:
   { constant: false,
     inputs:
      [ { name: 'orders', type: 'bytes[]' },
        { name: 'takerAssetFillAmounts', type: 'uint256[]' },
        { name: 'signatures', type: 'bytes[]' } ],
     name: 'batchFillOrKillOrders',
     outputs: [ { name: 'totalFillResults', type: 'bytes' } ],
     payable: false,
     stateMutability: 'nonpayable',
     type: 'function' },
  parentSchema:
   { type: 'object',
     properties:
      { type: { type: 'string', enum: [ 'fallback' ] },
        stateMutability: { '$ref': '#/definitions/StateMutability' },
        constant: { type: 'boolean' },
        payable: { type: 'boolean', default: false } },
     required: [ 'type', 'stateMutability' ],
     additionalProperties: false } }

should match pattern "^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?(\[[0-9]*\])?$" (pattern):
{ dataPath: '.abi[0].inputs[0].type',
  schemaPath: '#/definitions/Type/oneOf/0/pattern',
  params:
   { pattern:
      '^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?(\\[[0-9]*\\])?$' },
  data: 'bytes[]',
  parentSchema:
   { type: 'string',
     pattern:
      '^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?(\\[[0-9]*\\])?$' } }

should match pattern "^address(\[[0-9]*\])?$" (pattern):
{ dataPath: '.abi[0].inputs[0].type',
  schemaPath: '#/definitions/Type/oneOf/1/pattern',
  params: { pattern: '^address(\\[[0-9]*\\])?$' },
  data: 'bytes[]',
  parentSchema: { type: 'string', pattern: '^address(\\[[0-9]*\\])?$' } }

should match pattern "^bool(\[[0-9]*\])?$" (pattern):
{ dataPath: '.abi[0].inputs[0].type',
  schemaPath: '#/definitions/Type/oneOf/2/pattern',
  params: { pattern: '^bool(\\[[0-9]*\\])?$' },
  data: 'bytes[]',
  parentSchema: { type: 'string', pattern: '^bool(\\[[0-9]*\\])?$' } }

should match pattern "^u?fixed(0x8|8x0|0x16|8x8|16x0|0x24|8x16|16x8|24x0|0x32|8x24|16x16|24x8|32x0|0x40|8x32|16x24|24x16|32x8|40x0|0x48|8x40|16x32|24x24|32x16|40x8|48x0|0x56|8x48|16x40|24x32|32x24|40x16|48x8|56x0|0x64|8x56|16x48|24x40|32x32|40x24|48x16|56x8|64x0|0x72|8x64|16x56|24x48|32x40|40x32|48x24|56x16|64x8|72x0|0x80|8x72|16x64|24x56|32x48|40x40|48x32|56x24|64x16|72x8|80x0|0x88|8x80|16x72|24x64|32x56|40x48|48x40|56x32|64x24|72x16|80x8|88x0|0x96|8x88|16x80|24x72|32x64|40x56|48x48|56x40|64x32|72x24|80x16|88x8|96x0|0x104|8x96|16x88|24x80|32x72|40x64|48x56|56x48|64x40|72x32|80x24|88x16|96x8|104x0|0x112|8x104|16x96|24x88|32x80|40x72|48x64|56x56|64x48|72x40|80x32|88x24|96x16|104x8|112x0|0x120|8x112|16x104|24x96|32x88|40x80|48x72|56x64|64x56|72x48|80x40|88x32|96x24|104x16|112x8|120x0|0x128|8x120|16x112|24x104|32x96|40x88|48x80|56x72|64x64|72x56|80x48|88x40|96x32|104x24|112x16|120x8|128x0|0x136|8x128|16x120|24x112|32x104|40x96|48x88|56x80|64x72|72x64|80x56|88x48|96x40|104x32|112x24|120x16|128x8|136x0|0x144|8x136|16x128|24x120|32x112|40x104|48x96|56x88|64x80|72x72|80x64|88x56|96x48|104x40|112x32|120x24|128x16|136x8|144x0|0x152|8x144|16x136|24x128|32x120|40x112|48x104|56x96|64x88|72x80|80x72|88x64|96x56|104x48|112x40|120x32|128x24|136x16|144x8|152x0|0x160|8x152|16x144|24x136|32x128|40x120|48x112|56x104|64x96|72x88|80x80|88x72|96x64|104x56|112x48|120x40|128x32|136x24|144x16|152x8|160x0|0x168|8x160|16x152|24x144|32x136|40x128|48x120|56x112|64x104|72x96|80x88|88x80|96x72|104x64|112x56|120x48|128x40|136x32|144x24|152x16|160x8|168x0|0x176|8x168|16x160|24x152|32x144|40x136|48x128|56x120|64x112|72x104|80x96|88x88|96x80|104x72|112x64|120x56|128x48|136x40|144x32|152x24|160x16|168x8|176x0|0x184|8x176|16x168|24x160|32x152|40x144|48x136|56x128|64x120|72x112|80x104|88x96|96x88|104x80|112x72|120x64|128x56|136x48|144x40|152x32|160x24|168x16|176x8|184x0|0x192|8x184|16x176|24x168|32x160|40x152|48x144|56x136|64x128|72x120|80x112|88x104|96x96|104x88|112x80|120x72|128x64|136x56|144x48|152x40|160x32|168x24|176x16|184x8|192x0|0x200|8x192|16x184|24x176|32x168|40x160|48x152|56x144|64x136|72x128|80x120|88x112|96x104|104x96|112x88|120x80|128x72|136x64|144x56|152x48|160x40|168x32|176x24|184x16|192x8|200x0|0x208|8x200|16x192|24x184|32x176|40x168|48x160|56x152|64x144|72x136|80x128|88x120|96x112|104x104|112x96|120x88|128x80|136x72|144x64|152x56|160x48|168x40|176x32|184x24|192x16|200x8|208x0|0x216|8x208|16x200|24x192|32x184|40x176|48x168|56x160|64x152|72x144|80x136|88x128|96x120|104x112|112x104|120x96|128x88|136x80|144x72|152x64|160x56|168x48|176x40|184x32|192x24|200x16|208x8|216x0|0x224|8x216|16x208|24x200|32x192|40x184|48x176|56x168|64x160|72x152|80x144|88x136|96x128|104x120|112x112|120x104|128x96|136x88|144x80|152x72|160x64|168x56|176x48|184x40|192x32|200x24|208x16|216x8|224x0|0x232|8x224|16x216|24x208|32x200|40x192|48x184|56x176|64x168|72x160|80x152|88x144|96x136|104x128|112x120|120x112|128x104|136x96|144x88|152x80|160x72|168x64|176x56|184x48|192x40|200x32|208x24|216x16|224x8|232x0|0x240|8x232|16x224|24x216|32x208|40x200|48x192|56x184|64x176|72x168|80x160|88x152|96x144|104x136|112x128|120x120|128x112|136x104|144x96|152x88|160x80|168x72|176x64|184x56|192x48|200x40|208x32|216x24|224x16|232x8|240x0|0x248|8x240|16x232|24x224|32x216|40x208|48x200|56x192|64x184|72x176|80x168|88x160|96x152|104x144|112x136|120x128|128x120|136x112|144x104|152x96|160x88|168x80|176x72|184x64|192x56|200x48|208x40|216x32|224x24|232x16|240x8|248x0|0x256|8x248|16x240|24x232|32x224|40x216|48x208|56x200|64x192|72x184|80x176|88x168|96x160|104x152|112x144|120x136|128x128|136x120|144x112|152x104|160x96|168x88|176x80|184x72|192x64|200x56|208x48|216x40|224x32|232x24|240x16|248x8|256x0)?(\[[0-9]*\])?$" (pattern):
{ dataPath: '.abi[0].inputs[0].type',
  schemaPath: '#/definitions/Type/oneOf/3/pattern',
  params:
   { pattern:
      '^u?fixed(0x8|8x0|0x16|8x8|16x0|0x24|8x16|16x8|24x0|0x32|8x24|16x16|24x8|32x0|0x40|8x32|16x24|24x16|32x8|40x0|0x48|8x40|16x32|24x24|32x16|40x8|48x0|0x56|8x48|16x40|24x32|32x24|40x16|48x8|56x0|0x64|8x56|16x48|24x40|32x32|40x24|48x16|56x8|64x0|0x72|8x64|16x56|24x48|32x40|40x32|48x24|56x16|64x8|72x0|0x80|8x72|16x64|24x56|32x48|40x40|48x32|56x24|64x16|72x8|80x0|0x88|8x80|16x72|24x64|32x56|40x48|48x40|56x32|64x24|72x16|80x8|88x0|0x96|8x88|16x80|24x72|32x64|40x56|48x48|56x40|64x32|72x24|80x16|88x8|96x0|0x104|8x96|16x88|24x80|32x72|40x64|48x56|56x48|64x40|72x32|80x24|88x16|96x8|104x0|0x112|8x104|16x96|24x88|32x80|40x72|48x64|56x56|64x48|72x40|80x32|88x24|96x16|104x8|112x0|0x120|8x112|16x104|24x96|32x88|40x80|48x72|56x64|64x56|72x48|80x40|88x32|96x24|104x16|112x8|120x0|0x128|8x120|16x112|24x104|32x96|40x88|48x80|56x72|64x64|72x56|80x48|88x40|96x32|104x24|112x16|120x8|128x0|0x136|8x128|16x120|24x112|32x104|40x96|48x88|56x80|64x72|72x64|80x56|88x48|96x40|104x32|112x24|120x16|128x8|136x0|0x144|8x136|16x128|24x120|32x112|40x104|48x96|56x88|64x80|72x72|80x64|88x56|96x48|104x40|112x32|120x24|128x16|136x8|144x0|0x152|8x144|16x136|24x128|32x120|40x112|48x104|56x96|64x88|72x80|80x72|88x64|96x56|104x48|112x40|120x32|128x24|136x16|144x8|152x0|0x160|8x152|16x144|24x136|32x128|40x120|48x112|56x104|64x96|72x88|80x80|88x72|96x64|104x56|112x48|120x40|128x32|136x24|144x16|152x8|160x0|0x168|8x160|16x152|24x144|32x136|40x128|48x120|56x112|64x104|72x96|80x88|88x80|96x72|104x64|112x56|120x48|128x40|136x32|144x24|152x16|160x8|168x0|0x176|8x168|16x160|24x152|32x144|40x136|48x128|56x120|64x112|72x104|80x96|88x88|96x80|104x72|112x64|120x56|128x48|136x40|144x32|152x24|160x16|168x8|176x0|0x184|8x176|16x168|24x160|32x152|40x144|48x136|56x128|64x120|72x112|80x104|88x96|96x88|104x80|112x72|120x64|128x56|136x48|144x40|152x32|160x24|168x16|176x8|184x0|0x192|8x184|16x176|24x168|32x160|40x152|48x144|56x136|64x128|72x120|80x112|88x104|96x96|104x88|112x80|120x72|128x64|136x56|144x48|152x40|160x32|168x24|176x16|184x8|192x0|0x200|8x192|16x184|24x176|32x168|40x160|48x152|56x144|64x136|72x128|80x120|88x112|96x104|104x96|112x88|120x80|128x72|136x64|144x56|152x48|160x40|168x32|176x24|184x16|192x8|200x0|0x208|8x200|16x192|24x184|32x176|40x168|48x160|56x152|64x144|72x136|80x128|88x120|96x112|104x104|112x96|120x88|128x80|136x72|144x64|152x56|160x48|168x40|176x32|184x24|192x16|200x8|208x0|0x216|8x208|16x200|24x192|32x184|40x176|48x168|56x160|64x152|72x144|80x136|88x128|96x120|104x112|112x104|120x96|128x88|136x80|144x72|152x64|160x56|168x48|176x40|184x32|192x24|200x16|208x8|216x0|0x224|8x216|16x208|24x200|32x192|40x184|48x176|56x168|64x160|72x152|80x144|88x136|96x128|104x120|112x112|120x104|128x96|136x88|144x80|152x72|160x64|168x56|176x48|184x40|192x32|200x24|208x16|216x8|224x0|0x232|8x224|16x216|24x208|32x200|40x192|48x184|56x176|64x168|72x160|80x152|88x144|96x136|104x128|112x120|120x112|128x104|136x96|144x88|152x80|160x72|168x64|176x56|184x48|192x40|200x32|208x24|216x16|224x8|232x0|0x240|8x232|16x224|24x216|32x208|40x200|48x192|56x184|64x176|72x168|80x160|88x152|96x144|104x136|112x128|120x120|128x112|136x104|144x96|152x88|160x80|168x72|176x64|184x56|192x48|200x40|208x32|216x24|224x16|232x8|240x0|0x248|8x240|16x232|24x224|32x216|40x208|48x200|56x192|64x184|72x176|80x168|88x160|96x152|104x144|112x136|120x128|128x120|136x112|144x104|152x96|160x88|168x80|176x72|184x64|192x56|200x48|208x40|216x32|224x24|232x16|240x8|248x0|0x256|8x248|16x240|24x232|32x224|40x216|48x208|56x200|64x192|72x184|80x176|88x168|96x160|104x152|112x144|120x136|128x128|136x120|144x112|152x104|160x96|168x88|176x80|184x72|192x64|200x56|208x48|216x40|224x32|232x24|240x16|248x8|256x0)?(\\[[0-9]*\\])?$' },
  data: 'bytes[]',
  parentSchema:
   { type: 'string',
     pattern:
      '^u?fixed(0x8|8x0|0x16|8x8|16x0|0x24|8x16|16x8|24x0|0x32|8x24|16x16|24x8|32x0|0x40|8x32|16x24|24x16|32x8|40x0|0x48|8x40|16x32|24x24|32x16|40x8|48x0|0x56|8x48|16x40|24x32|32x24|40x16|48x8|56x0|0x64|8x56|16x48|24x40|32x32|40x24|48x16|56x8|64x0|0x72|8x64|16x56|24x48|32x40|40x32|48x24|56x16|64x8|72x0|0x80|8x72|16x64|24x56|32x48|40x40|48x32|56x24|64x16|72x8|80x0|0x88|8x80|16x72|24x64|32x56|40x48|48x40|56x32|64x24|72x16|80x8|88x0|0x96|8x88|16x80|24x72|32x64|40x56|48x48|56x40|64x32|72x24|80x16|88x8|96x0|0x104|8x96|16x88|24x80|32x72|40x64|48x56|56x48|64x40|72x32|80x24|88x16|96x8|104x0|0x112|8x104|16x96|24x88|32x80|40x72|48x64|56x56|64x48|72x40|80x32|88x24|96x16|104x8|112x0|0x120|8x112|16x104|24x96|32x88|40x80|48x72|56x64|64x56|72x48|80x40|88x32|96x24|104x16|112x8|120x0|0x128|8x120|16x112|24x104|32x96|40x88|48x80|56x72|64x64|72x56|80x48|88x40|96x32|104x24|112x16|120x8|128x0|0x136|8x128|16x120|24x112|32x104|40x96|48x88|56x80|64x72|72x64|80x56|88x48|96x40|104x32|112x24|120x16|128x8|136x0|0x144|8x136|16x128|24x120|32x112|40x104|48x96|56x88|64x80|72x72|80x64|88x56|96x48|104x40|112x32|120x24|128x16|136x8|144x0|0x152|8x144|16x136|24x128|32x120|40x112|48x104|56x96|64x88|72x80|80x72|88x64|96x56|104x48|112x40|120x32|128x24|136x16|144x8|152x0|0x160|8x152|16x144|24x136|32x128|40x120|48x112|56x104|64x96|72x88|80x80|88x72|96x64|104x56|112x48|120x40|128x32|136x24|144x16|152x8|160x0|0x168|8x160|16x152|24x144|32x136|40x128|48x120|56x112|64x104|72x96|80x88|88x80|96x72|104x64|112x56|120x48|128x40|136x32|144x24|152x16|160x8|168x0|0x176|8x168|16x160|24x152|32x144|40x136|48x128|56x120|64x112|72x104|80x96|88x88|96x80|104x72|112x64|120x56|128x48|136x40|144x32|152x24|160x16|168x8|176x0|0x184|8x176|16x168|24x160|32x152|40x144|48x136|56x128|64x120|72x112|80x104|88x96|96x88|104x80|112x72|120x64|128x56|136x48|144x40|152x32|160x24|168x16|176x8|184x0|0x192|8x184|16x176|24x168|32x160|40x152|48x144|56x136|64x128|72x120|80x112|88x104|96x96|104x88|112x80|120x72|128x64|136x56|144x48|152x40|160x32|168x24|176x16|184x8|192x0|0x200|8x192|16x184|24x176|32x168|40x160|48x152|56x144|64x136|72x128|80x120|88x112|96x104|104x96|112x88|120x80|128x72|136x64|144x56|152x48|160x40|168x32|176x24|184x16|192x8|200x0|0x208|8x200|16x192|24x184|32x176|40x168|48x160|56x152|64x144|72x136|80x128|88x120|96x112|104x104|112x96|120x88|128x80|136x72|144x64|152x56|160x48|168x40|176x32|184x24|192x16|200x8|208x0|0x216|8x208|16x200|24x192|32x184|40x176|48x168|56x160|64x152|72x144|80x136|88x128|96x120|104x112|112x104|120x96|128x88|136x80|144x72|152x64|160x56|168x48|176x40|184x32|192x24|200x16|208x8|216x0|0x224|8x216|16x208|24x200|32x192|40x184|48x176|56x168|64x160|72x152|80x144|88x136|96x128|104x120|112x112|120x104|128x96|136x88|144x80|152x72|160x64|168x56|176x48|184x40|192x32|200x24|208x16|216x8|224x0|0x232|8x224|16x216|24x208|32x200|40x192|48x184|56x176|64x168|72x160|80x152|88x144|96x136|104x128|112x120|120x112|128x104|136x96|144x88|152x80|160x72|168x64|176x56|184x48|192x40|200x32|208x24|216x16|224x8|232x0|0x240|8x232|16x224|24x216|32x208|40x200|48x192|56x184|64x176|72x168|80x160|88x152|96x144|104x136|112x128|120x120|128x112|136x104|144x96|152x88|160x80|168x72|176x64|184x56|192x48|200x40|208x32|216x24|224x16|232x8|240x0|0x248|8x240|16x232|24x224|32x216|40x208|48x200|56x192|64x184|72x176|80x168|88x160|96x152|104x144|112x136|120x128|128x120|136x112|144x104|152x96|160x88|168x80|176x72|184x64|192x56|200x48|208x40|216x32|224x24|232x16|240x8|248x0|0x256|8x248|16x240|24x232|32x224|40x216|48x208|56x200|64x192|72x184|80x176|88x168|96x160|104x152|112x144|120x136|128x128|136x120|144x112|152x104|160x96|168x88|176x80|184x72|192x64|200x56|208x48|216x40|224x32|232x24|240x16|248x8|256x0)?(\\[[0-9]*\\])?$' } }

should match pattern "^bytes(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)(\[[0-9]*\])?" (pattern):
{ dataPath: '.abi[0].inputs[0].type',
  schemaPath: '#/definitions/Type/oneOf/4/pattern',
  params:
   { pattern:
      '^bytes(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)(\\[[0-9]*\\])?' },
  data: 'bytes[]',
  parentSchema:
   { type: 'string',
     pattern:
      '^bytes(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)(\\[[0-9]*\\])?' } }

should match pattern "^bytes$" (pattern):
{ dataPath: '.abi[0].inputs[0].type',
  schemaPath: '#/definitions/Type/oneOf/5/pattern',
  params: { pattern: '^bytes$' },
  data: 'bytes[]',
  parentSchema: { type: 'string', pattern: '^bytes$' } }

should match pattern "^function(\[[0-9]*\])?$" (pattern):
{ dataPath: '.abi[0].inputs[0].type',
  schemaPath: '#/definitions/Type/oneOf/6/pattern',
  params: { pattern: '^function(\\[[0-9]*\\])?$' },
  data: 'bytes[]',
  parentSchema: { type: 'string', pattern: '^function(\\[[0-9]*\\])?$' } }

should match pattern "^string$" (pattern):
{ dataPath: '.abi[0].inputs[0].type',
  schemaPath: '#/definitions/Type/oneOf/7/pattern',
  params: { pattern: '^string$' },
  data: 'bytes[]',
  parentSchema: { type: 'string', pattern: '^string$' } }

should match exactly one schema in oneOf (oneOf):
{ dataPath: '.abi[0].inputs[0].type',
  schemaPath: '#/definitions/Type/oneOf',
  params: {},
  data: 'bytes[]',
  parentSchema:
   { oneOf:
      [ { type: 'string',
          pattern:
           '^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?(\\[[0-9]*\\])?$' },
        { type: 'string', pattern: '^address(\\[[0-9]*\\])?$' },
        { type: 'string', pattern: '^bool(\\[[0-9]*\\])?$' },
        { type: 'string',
          pattern:
           '^u?fixed(0x8|8x0|0x16|8x8|16x0|0x24|8x16|16x8|24x0|0x32|8x24|16x16|24x8|32x0|0x40|8x32|16x24|24x16|32x8|40x0|0x48|8x40|16x32|24x24|32x16|40x8|48x0|0x56|8x48|16x40|24x32|32x24|40x16|48x8|56x0|0x64|8x56|16x48|24x40|32x32|40x24|48x16|56x8|64x0|0x72|8x64|16x56|24x48|32x40|40x32|48x24|56x16|64x8|72x0|0x80|8x72|16x64|24x56|32x48|40x40|48x32|56x24|64x16|72x8|80x0|0x88|8x80|16x72|24x64|32x56|40x48|48x40|56x32|64x24|72x16|80x8|88x0|0x96|8x88|16x80|24x72|32x64|40x56|48x48|56x40|64x32|72x24|80x16|88x8|96x0|0x104|8x96|16x88|24x80|32x72|40x64|48x56|56x48|64x40|72x32|80x24|88x16|96x8|104x0|0x112|8x104|16x96|24x88|32x80|40x72|48x64|56x56|64x48|72x40|80x32|88x24|96x16|104x8|112x0|0x120|8x112|16x104|24x96|32x88|40x80|48x72|56x64|64x56|72x48|80x40|88x32|96x24|104x16|112x8|120x0|0x128|8x120|16x112|24x104|32x96|40x88|48x80|56x72|64x64|72x56|80x48|88x40|96x32|104x24|112x16|120x8|128x0|0x136|8x128|16x120|24x112|32x104|40x96|48x88|56x80|64x72|72x64|80x56|88x48|96x40|104x32|112x24|120x16|128x8|136x0|0x144|8x136|16x128|24x120|32x112|40x104|48x96|56x88|64x80|72x72|80x64|88x56|96x48|104x40|112x32|120x24|128x16|136x8|144x0|0x152|8x144|16x136|24x128|32x120|40x112|48x104|56x96|64x88|72x80|80x72|88x64|96x56|104x48|112x40|120x32|128x24|136x16|144x8|152x0|0x160|8x152|16x144|24x136|32x128|40x120|48x112|56x104|64x96|72x88|80x80|88x72|96x64|104x56|112x48|120x40|128x32|136x24|144x16|152x8|160x0|0x168|8x160|16x152|24x144|32x136|40x128|48x120|56x112|64x104|72x96|80x88|88x80|96x72|104x64|112x56|120x48|128x40|136x32|144x24|152x16|160x8|168x0|0x176|8x168|16x160|24x152|32x144|40x136|48x128|56x120|64x112|72x104|80x96|88x88|96x80|104x72|112x64|120x56|128x48|136x40|144x32|152x24|160x16|168x8|176x0|0x184|8x176|16x168|24x160|32x152|40x144|48x136|56x128|64x120|72x112|80x104|88x96|96x88|104x80|112x72|120x64|128x56|136x48|144x40|152x32|160x24|168x16|176x8|184x0|0x192|8x184|16x176|24x168|32x160|40x152|48x144|56x136|64x128|72x120|80x112|88x104|96x96|104x88|112x80|120x72|128x64|136x56|144x48|152x40|160x32|168x24|176x16|184x8|192x0|0x200|8x192|16x184|24x176|32x168|40x160|48x152|56x144|64x136|72x128|80x120|88x112|96x104|104x96|112x88|120x80|128x72|136x64|144x56|152x48|160x40|168x32|176x24|184x16|192x8|200x0|0x208|8x200|16x192|24x184|32x176|40x168|48x160|56x152|64x144|72x136|80x128|88x120|96x112|104x104|112x96|120x88|128x80|136x72|144x64|152x56|160x48|168x40|176x32|184x24|192x16|200x8|208x0|0x216|8x208|16x200|24x192|32x184|40x176|48x168|56x160|64x152|72x144|80x136|88x128|96x120|104x112|112x104|120x96|128x88|136x80|144x72|152x64|160x56|168x48|176x40|184x32|192x24|200x16|208x8|216x0|0x224|8x216|16x208|24x200|32x192|40x184|48x176|56x168|64x160|72x152|80x144|88x136|96x128|104x120|112x112|120x104|128x96|136x88|144x80|152x72|160x64|168x56|176x48|184x40|192x32|200x24|208x16|216x8|224x0|0x232|8x224|16x216|24x208|32x200|40x192|48x184|56x176|64x168|72x160|80x152|88x144|96x136|104x128|112x120|120x112|128x104|136x96|144x88|152x80|160x72|168x64|176x56|184x48|192x40|200x32|208x24|216x16|224x8|232x0|0x240|8x232|16x224|24x216|32x208|40x200|48x192|56x184|64x176|72x168|80x160|88x152|96x144|104x136|112x128|120x120|128x112|136x104|144x96|152x88|160x80|168x72|176x64|184x56|192x48|200x40|208x32|216x24|224x16|232x8|240x0|0x248|8x240|16x232|24x224|32x216|40x208|48x200|56x192|64x184|72x176|80x168|88x160|96x152|104x144|112x136|120x128|128x120|136x112|144x104|152x96|160x88|168x80|176x72|184x64|192x56|200x48|208x40|216x32|224x24|232x16|240x8|248x0|0x256|8x248|16x240|24x232|32x224|40x216|48x208|56x200|64x192|72x184|80x176|88x168|96x160|104x152|112x144|120x136|128x128|136x120|144x112|152x104|160x96|168x88|176x80|184x72|192x64|200x56|208x48|216x40|224x32|232x24|240x16|248x8|256x0)?(\\[[0-9]*\\])?$' },
        { type: 'string',
          pattern:
           '^bytes(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)(\\[[0-9]*\\])?' },
        { type: 'string', pattern: '^bytes$' },
        { type: 'string', pattern: '^function(\\[[0-9]*\\])?$' },
        { type: 'string', pattern: '^string$' } ] } }

should match exactly one schema in oneOf (oneOf):
{ dataPath: '.abi[0]',
  schemaPath: '#/items/oneOf',
  params: {},
  data:
   { constant: false,
     inputs:
      [ { name: 'orders', type: 'bytes[]' },
        { name: 'takerAssetFillAmounts', type: 'uint256[]' },
        { name: 'signatures', type: 'bytes[]' } ],
     name: 'batchFillOrKillOrders',
     outputs: [ { name: 'totalFillResults', type: 'bytes' } ],
     payable: false,
     stateMutability: 'nonpayable',
     type: 'function' },
  parentSchema:
   { oneOf:
      [ { '$ref': '#/definitions/Event' },
        { '$ref': '#/definitions/ConstructorFunction' },
        { '$ref': '#/definitions/FallbackFunction' },
        { '$ref': '#/definitions/NormalFunction' } ] } }

    at Object.validate (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-contract-schema/index.js:197:1)
    at processTargets (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-external-compile/index.js:154:1)

@BlinkyStitt
Copy link
Author

Well this is really weird. I copy/pasted the abi out of the gists, sorted them with http://novicelab.org/jsonabc/, and compared them at https://jsoncompare.com/#!/diff/. AFAICT, they are identical after being sorted. This makes me think the bug must be in truffle's validation. It must do the validation slightly differently for artifacts generated the "normal" way.

@BlinkyStitt
Copy link
Author

And here is the interface I'm trying to compile: https://gist.github.com/WyseNynja/e3a5eeee8e11983b603dc7e28243c0f2

It isn't finished and won't actually work fully against an actual exchange project, but it compiles under truffle without issue.

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 27, 2019

Ok. This is weird. If I let truffle compile the artifact, copy the bin out of it and into a seperate file, remove the contract, and then add an external target like this:

        {
          properties: {
            contractName: "IZrxExchange",
          },
          fileProperties: {
            abi: "external/IZrxExchange-truffle.abi.json",
          },
        },

Truffle fails to validate. I'm 99% sure this is a bug with truffle. It doesn't seem to want to validate contracts with ABIEncoderV2 even though it compiles them just fine. I'll make a simple test case and open the issue with them

@BlinkyStitt
Copy link
Author

I've made a simple repo that fails with this same error and created an issue at trufflesuite/truffle#1774

@BlinkyStitt
Copy link
Author

So after upgrading to the latest versions of everything, using GancheProvider, and removing the contracts with ABIEncoderV2, my tests are able to run to completion without giving "this.removeListener is not a function"

Also, I switched from using GanacheProvider to WebsocketProvider and it also works:

    provider.addProvider(new WebsocketSubprovider({ rpcUrl: "http://host.docker.internal:7545" }));

One of my tests is failing though. I am checking error.reason inside a catch block and it is undefined when running with MODE=trace. I'll open a separate ticket for that.

hiddentao added a commit to hiddentao/dev-tools-truffle-example that referenced this issue Jul 25, 2019
As per 0xProject#4, Truffle needs to be able to use subscriptions, and thus a websocket connection is needed.
@hiddentao
Copy link
Contributor

Just seeing this now myself. Thanks to all previous commenters who figured out the issues! Raised PR #12

@wjmelements
Copy link

I also see this error in truffle 5.0.44

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants