Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while making the address's indexed in events #1171

Closed
shivam0x opened this issue Nov 25, 2020 · 10 comments
Closed

Error while making the address's indexed in events #1171

shivam0x opened this issue Nov 25, 2020 · 10 comments
Labels
discussion Questions, feedback and general information.

Comments

@shivam0x
Copy link

Hi,

I've a contract in which I've events with addresses. Everything(tests) is working fine. But as soon as I make the addresses in event as indexed I get the following error:

Error: data out-of-bounds (length=32, offset=64, code=BUFFER_OVERRUN, version=abi/5.0.9) at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:205:28) at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:217:20) at Reader._peekBytes (node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/coders/abstract-coder.ts:184:24) at Reader.readBytes (node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/coders/abstract-coder.ts:198:26) at Reader.readValue (node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/coders/abstract-coder.ts:205:36) at AddressCoder.decode (node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/coders/address.ts:28:45) at /Users/Project/node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/coders/array.ts:108:31 at Array.forEach (<anonymous>) at Object.unpack (node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/coders/array.ts:89:12) at TupleCoder.decode (node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/coders/tuple.ts:58:41) at AbiCoder.decode (node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/abi-coder.ts:119:22) at Interface.decodeEventLog (node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/interface.ts:478:47) at Interface.parseLog (node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/src.ts/interface.ts:567:24) at assertArgsArraysEqual (node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:38:55) at tryAssertArgsArraysEqual (node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:54:20) at /Users/Project/node_modules/@ethereum-waffle/chai/dist/cjs/matchers/emit.js:66:13

Solidity code:
event ContributorContributed(address indexed contributor, uint256 amount);
emit ContributorContributed(_sender, _value);

If in the above event I remove the indexed keyword then tests are working fine.

This is not happening with all the events but most of them.

My Test code:
await expect(owner.withdrawRandomAssets(randomToken.address, false)) .emit(contract, "RandomAssetsWithdrawn") .withArgs(owner, randomToken.address, 5000)

@yuetloo
Copy link
Collaborator

yuetloo commented Nov 25, 2020

Not sure if this is related to #992 (unable to parse events with indexed parameters if contract compiled with solc 0.4.x), but try with latest version of ethers and see if this is still a problem.

@yuetloo
Copy link
Collaborator

yuetloo commented Nov 25, 2020

Hmmm...You are using the latest version of abi. 5.0.9.

@shivam0x
Copy link
Author

Yes and even solidity 0.7.0.

@ricmoo
Copy link
Member

ricmoo commented Nov 26, 2020

Can you provide a transaction hash of a transaction that is causing this issue?

I don't quite know what that .emit is doing? Is that part of a test framework? Perhaps it isn't encoding things properly for the indexed fields (which get placed in topics, not the data).

@ricmoo ricmoo added the discussion Questions, feedback and general information. label Nov 26, 2020
@shivam0x
Copy link
Author

@ricmoo I'm getting this error while running tests itself so no transaction hash available for this.
I'm using buidler and waffle for testing to .emit is used for testing purposes to check if the event is getting emitted or not.

@zemse
Copy link
Collaborator

zemse commented Nov 26, 2020

If it is possible for you to deploy the contract on some testnet using remix and do this particular transaction that emits this log, pls share the tx hash as it will be easier to debug quickly.

@ricmoo
Copy link
Member

ricmoo commented Nov 26, 2020

I think this might be a bug with how the .emit works in buidler or waffle, or there is some other way in those projects to specify which methods are indexed...

Pinging @alcuadrado, @marekkirejczyk and @sz-piotr.

@alcuadrado
Copy link

Can this be related? NomicFoundation/hardhat#1048

@ricmoo
Copy link
Member

ricmoo commented Nov 26, 2020

That seems like the issue here. :)

@shivam0x
Copy link
Author

Sure, I'll resume this issue in hardhat repository then.
Thanks everyone :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Questions, feedback and general information.
Projects
None yet
Development

No branches or pull requests

5 participants