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 on getPastEvents for solidity@0.4.x #3680

Closed
hbarcelos opened this issue Aug 10, 2020 · 7 comments
Closed

Error on getPastEvents for solidity@0.4.x #3680

hbarcelos opened this issue Aug 10, 2020 · 7 comments
Labels
1.x 1.0 related issues Bug Addressing a bug In Progress Currently being worked on Stale Has not received enough activity

Comments

@hbarcelos
Copy link

This relates to #3544.

Expected behavior

If I use web3<=1.2.6, everything works just fine.

Actual behavior

I get the following error:

Error: data out-of-bounds (length=110, offset=128, code=BUFFER_OVERRUN, version=abi/5.0.0-beta.153)
    at Logger.makeError (/home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/logger/lib/index.js:179:21)
    at Logger.throwError (/home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/logger/lib/index.js:188:20)
    at Reader._peekBytes (/home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/abi/lib/coders/abstract-coder.js:135:20)
    at Reader.readBytes (/home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/abi/lib/coders/abstract-coder.js:146:26)
    at StringCoder.DynamicBytesCoder.decode (/home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/abi/lib/coders/bytes.js:30:23)
    at StringCoder.decode (/home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/abi/lib/coders/string.js:27:63)
    at /home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/abi/lib/coders/array.js:77:31
    at Array.forEach (<anonymous>)
    at Object.unpack (/home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/abi/lib/coders/array.js:71:12)
    at TupleCoder.decode (/home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/abi/lib/coders/tuple.js:39:49)
    at AbiCoder.decode (/home/henrique/labs/web3-getPastEvents-issue/node_modules/@ethersproject/abi/lib/abi-coder.js:93:22)
    at ABICoder.decodeParameters (/home/henrique/labs/web3-getPastEvents-issue/node_modules/web3-eth-abi/src/index.js:347:30)
    at ABICoder.decodeLog (/home/henrique/labs/web3-getPastEvents-issue/node_modules/web3-eth-abi/src/index.js:401:52)
    at Object.Contract._decodeEventABI (/home/henrique/labs/web3-getPastEvents-issue/node_modules/web3-eth-contract/src/index.js:482:31)
    at /home/henrique/labs/web3-getPastEvents-issue/node_modules/web3-core-method/src/index.js:166:57
    at Array.map (<anonymous>)

Steps to reproduce the behavior

  1. Here's the relevant part of the ABI for the contract:

    [{
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "name": "_metaEvidenceID",
          "type": "uint256"
        },
        {
          "indexed": false,
          "name": "_evidence",
          "type": "string"
        }
      ],
      "name": "MetaEvidence",
      "type": "event"
    }]

    Here's the link to the smart contract implementation: https://github.com/kleros/kleros-interaction/blob/master/contracts/standard/arbitration/IArbitrable.sol#L27

    Here's the address of the deployed contract on Kovan network: 0x0825f16598AcB518851f8959b8267EF296c57f81.

  2. Using the following snippet:

    const Web3 = require("web3");
    const abi = require("./abi.json");
    
    const web3 = new Web3(
      new Web3.providers.HttpProvider(
        `https://kovan.infura.io/v3/${process.env.INFURA_API_KEY}`
      )
    );
    const address = "0x0825f16598AcB518851f8959b8267EF296c57f81";
    
    const contract = new web3.eth.Contract(abi, address);
    
    (async () => {
      const data = await contract.getPastEvents("MetaEvidence", {
        filter: { _metaEvidenceID: "28" },
        fromBlock: 0,
      });
    })();

Logs

N/A

Environment

  • node @ 10.22.0
  • web3 @ 1.2.11
  • yarn @ 1.22.4
@GregTheGreek
Copy link
Contributor

Please see related issue: #3544

from ethers-io/ethers.js#992 (comment):

There is a known Solidity v4.x bug that events emitted from an external (public is fine) function in Solidity that dynamic objects are encoded incorrectly.
This is a compiler bug which makes it very hard to work around. :(
The work around for it can break correctly functioning contracts, which is the problem.

@GregTheGreek GregTheGreek added 1.x 1.0 related issues Bug Addressing a bug Discussion labels Aug 16, 2020
@ricmoo
Copy link
Contributor

ricmoo commented Sep 8, 2020

I've added support in ethers 5.0.12 for supporting legacy Solidity 0.4 external event data. I believe web3 depends on the abi package directly, in which case web3 should upgrade to @ethersproject/abi version 5.0.4.

For more details, please see ethers-io/ethers.js#891.

@github-actions
Copy link

github-actions bot commented Nov 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

@github-actions github-actions bot added the Stale Has not received enough activity label Nov 8, 2020
@spacesailor24
Copy link
Contributor

I think #3738 is related, and the release candidate should fix this

@spacesailor24 spacesailor24 added In Progress Currently being worked on and removed Stale Has not received enough activity Discussion labels Nov 11, 2020
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

@github-actions github-actions bot added the Stale Has not received enough activity label Jan 11, 2021
@GregTheGreek
Copy link
Contributor

@spacesailor24 can you confirm if the RC fixed this?

@spacesailor24
Copy link
Contributor

I copied over the provided code into a test repo

I'm getting the presumably expected output of:

[
  {
    address: '0x0825f16598AcB518851f8959b8267EF296c57f81',
    blockHash: '0xc6ccd170d9dd5d86906b0f7dd9c5d34cadc19bc8d9c54eba5c4b9a5f5cfe72bf',
    blockNumber: 19567645,
    logIndex: 7,
    removed: false,
    transactionHash: '0xae646874553121365f59bb08864a61b1a883f0a0d25d7ee100a3786e2a3a37b5',
    transactionIndex: 2,
    transactionLogIndex: '0x0',
    type: 'mined',
    id: 'log_dc96d986',
    returnValues: Result {
      '0': '28',
      '1': '/ipfs/QmTJXDEWMPwNq1qhXB9EKCT6L7oqcnZm5dbyqFZiPCQF2V/linguo-meta-evidence.json',
      _metaEvidenceID: '28',
      _evidence: '/ipfs/QmTJXDEWMPwNq1qhXB9EKCT6L7oqcnZm5dbyqFZiPCQF2V/linguo-meta-evidence.json'
    },
    event: 'MetaEvidence',
    signature: '0x61606860eb6c87306811e2695215385101daab53bd6ab4e9f9049aead9363c7d',
    raw: {
      data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004e2f697066732f516d544a584445574d50774e71317168584239454b4354364c376f71636e5a6d3564627971465a695043514632562f6c696e67756f2d6d6574612d65766964656e63652e6a736f6e',
      topics: [Array]
    }
  }
]

So @GregTheGreek I do believe this to be resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Bug Addressing a bug In Progress Currently being worked on Stale Has not received enough activity
Projects
None yet
Development

No branches or pull requests

4 participants