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

Getting a typeError when running truffle test after update #2723

Closed
Amxx opened this issue Jan 6, 2020 · 16 comments
Closed

Getting a typeError when running truffle test after update #2723

Amxx opened this issue Jan 6, 2020 · 16 comments

Comments

@Amxx
Copy link

Amxx commented Jan 6, 2020

Coming back from vacations, I just updated my truffle install from v5.1.4 to v5.1.7.

When running truffle tests (that used to work) I'm now getting:

  "before all" hook: prepare suite:
     TypeError: Cannot read property 'typeClass' of undefined
      at abiSizeAndAllocate (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:91:1)
      at abiSizeAndAllocate (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:199:65)
      at allocateMembers (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:60:63)
      at allocateDataArguments (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:370:1)
      at allocateCalldataAndReturndata (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:301:60)
      at getCalldataAllocationsForContract (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:525:1)
      at Object.getCalldataAllocations (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:563:1)
      at new WireDecoder (node_modules/truffle/build/webpack:/packages/decoder/dist/decoders.js:189:1)
      at Object.<anonymous> (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:213:1)
      at step (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:164:1)
      at Object.next (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:145:45)
      at /home/amxx/Work/iExec/code/PoCo-dev/node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:139:1
      at new Promise (<anonymous>)
      at __awaiter (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:135:1)
      at Object.forProject (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:211:1)
      at TestRunner.initialize (node_modules/truffle/build/webpack:/packages/core/lib/testing/testrunner.js:80:1)
      at process._tickCallback (internal/process/next_tick.js:68:7)

@gnidan
Copy link
Contributor

gnidan commented Jan 6, 2020

Looks like something's gone awry with our decoder. @haltman-at might be able to help if you provide some reproduction steps. Sorry about that!

@gnidan
Copy link
Contributor

gnidan commented Jan 11, 2020

@Amxx writes on twitter that this is still broken in v5.1.8

@gnidan
Copy link
Contributor

gnidan commented Jan 15, 2020

Hey @Amxx can we get reproduction steps? Pretty please?

@Amxx
Copy link
Author

Amxx commented Feb 17, 2020

Using 5.1.4 was ok for now, but it's looking like it's not going to support my transition to ^0.6.0.

@gnidan The code that triggers that is not public, but I could send you an archive with it

@Amxx
Copy link
Author

Amxx commented Feb 19, 2020

I deleted all the tests except for one empty it. I also removed all the migrations scripts. Error still happens.

  • truffle compile → ok
  • truffle deploy → ok
  • truffle test → error

Obviously, if I removed all my contracts the error disappears. So something is wrong ith my contracts being there, even if I don't deploy them / import them in test scripts.

What email can I send the archive to?

@gnidan
Copy link
Contributor

gnidan commented Feb 19, 2020

@Amxx thank you! Please send to [email protected] :)

@haltman-at
Copy link
Contributor

haltman-at commented Mar 4, 2020

OK, I've put up #2871 to address this; sorry about the delay, was working on some other things.

A bit of explanation for everyone else -- on inspecting the reproduction example, it turned out that this is actually a Solidity problem; the Solidity compiler was emitting ill-formed ABIs. We can't really fix that -- and it will have to be fixed, for obvious reasons! -- but I can at least add this workaround that should at least get the tests working again. (And, to be clear, it does get the test in the reproduction example working!)

@gnidan
Copy link
Contributor

gnidan commented Mar 4, 2020

That fix will go out in the release tomorrow!

@eggplantzzz
Copy link
Contributor

A fix should be in the latest Truffle (https://github.com/trufflesuite/truffle/releases/tag/v5.1.16).

Let us know if this doesn't solve this issue and we'll be happy to re-open!

@haltman-at
Copy link
Contributor

Reopening issue per @Amxx's comments in email. @Amxx, could you tell us what error messages you're getting now? Thank you!

@haltman-at
Copy link
Contributor

OK, just put up a PR #2873 with a (partial?) fix for this; see that PR for more information. Note that while this problem is basically our fault due to failure to gracefully handle an AST node ID collision, you might want to report to Solidity that there was an AST node ID collision at all, because my understanding is that that AST node IDs are supposed to be unique within a single compilation. (And I assume that you compiled the whole project at once, like I did, seeing as we got the same error.)

(Specifically: Both the contract ERC1538Proxy, and the struct IexecLibCore_v5.Resource, somehow ended up with an ID of 290.)

I'm actually still getting errors on some tests (not all, thankfully!) when I try to test your project, but these errors don't look like they're our fault, so I'm not sure if there's anything for us to do about them. Specifically I'm getting:

     TypeError: Cannot read property 'slice' of undefined
      at Object.fromPrivate (/home/sniffnoy/truffle/truffle/node_modules/eth-lib/lib/account.js:29:38)
      at Accounts.privateKeyToAccount (/home/sniffnoy/truffle/truffle/node_modules/web3-eth-accounts/src/index.js:129:46)
      at new iExecAgent (utils/odb-tools.js:214:23)
      at Context.before (test/ERC1154/resultFor.js:71:21)
      at process._tickCallback (internal/process/next_tick.js:68:7)

on a number of tests. But like I said I don't think that's a Truffle issue...

@haltman-at
Copy link
Contributor

OK, the fix is released, so I'm closing this again. Let us know if there are still problems.

@andy-mcewan-artos-io
Copy link

I'm seeing this error now too but want to actually use the contracts that are causing the ID clash, so I don't think that upgrading truffle will help.

Has anyone actually reported this as a bug on Solidity? I can't find it being mentioned anywhere but here.

@haltman-at
Copy link
Contributor

I'm seeing this error now too but want to actually use the contracts that are causing the ID clash, so I don't think that upgrading truffle will help.

Upgrading Truffle is still what you want to do here, I think. Again, the upgraded version will better handle the ID clash rather than erroring out. You should be able to use the contracts just fine. The ID clash just means that the decoder (used for decoding test events, for instance) will return slightly less information. You don't need a contract's AST ID for most uses.

Now, if you're getting the original error, then, well, first of all you should still upgrade Truffle so you can avoid errors. But yes, if it's the original error, with malformed ABIs rather than an ID clash, then you have more of a problem; as mentioned, you could manually edit the ABIs as a workaround? Upgrading Truffle won't somehow prevent you from using this stuff though.

Has anyone actually reported this as a bug on Solidity? I can't find it being mentioned anywhere but here.

Unfortunately no as far as I'm aware (both of these, both the malformed ABI and the ID clash). I encouraged @Amxx to report them but I don't believe he did.

@andy-mcewan-artos-io
Copy link

I've upgraded truffle and the error has gone. I'm adding new files which are not yet being run in tests so I'm not sure if the problem is the ID clash or bad ABI just yet - I had a quick look and couldn't see anything obvious. I guess I'll see what happens when I use them. Thanks for the help so far, anyway.

As for the Solidity bug report, as you seem to understand the problem in depth better than anyone else on this thread, I think you are the best person to raise the bug yourself. Please link to here if you do so the rest of us who don't understand it as well can keep track :)

@haltman-at
Copy link
Contributor

haltman-at commented Apr 1, 2020

Well, I mentioned it to them on their Gitter, but I didn't open an issue because I'd be missing one key thing: A reproduction example! (I couldn't use Amxx's because his was sent to us privately.) So, it would be better if you could open the issue. But if you have a reproduction example, I suppose I could do it.

As for telling the two errors apart... yeah, they don't really belong in the same thread; sometimes unrelated errors just end up grouped like that. :-/ They don't actually resemble each other, just the new error message (from the ID clash) never got posted here because some of this discussion was conducted with Amxx in email.

The error that resulted from the ID clash -- copying it in from Amxx's email -- looked like this:

     TypeError: Cannot read property 'find' of undefined
      at linearizedBaseContracts.reduce (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:263:1)
      at Array.reduce (<anonymous>)
      at allocateCalldataAndReturndata (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:253:1)
      at getCalldataAllocationsForContract (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:530:1)
      at Object.getCalldataAllocations (node_modules/truffle/build/webpack:/packages/codec/dist/lib/abi-data/allocate/index.js:568:1)
      at new WireDecoder (node_modules/truffle/build/webpack:/packages/decoder/dist/decoders.js:203:1)
      at Object.<anonymous> (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:223:1)
      at step (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:164:1)
      at Object.next (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:145:45)
      at /home/amxx/Work/iExec/code/_archive/node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:139:1
      at new Promise (<anonymous>)
      at __awaiter (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:135:1)
      at Object.forProject (node_modules/truffle/build/webpack:/packages/decoder/dist/index.js:219:1)
      at TestRunner.initialize (node_modules/truffle/build/webpack:/packages/core/lib/testing/testrunner.js:84:1)
      at process._tickCallback (internal/process/next_tick.js:68:7)

So, if you were getting the first of these errors, rather than the second, it's more likely a bad ABI.

Anyway, I would encourage you to submit the issue yourself (or @Amxx, I would still encourage you to do so, with both issues!) but if you can send us a reproduction example I might have time to inspect it and submit the issue.

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

No branches or pull requests

5 participants