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

getPastLogs generates wrong topics array after beta.37 for JSON RPC #2457

Closed
vshab opened this issue Mar 5, 2019 · 3 comments · Fixed by #2458
Closed

getPastLogs generates wrong topics array after beta.37 for JSON RPC #2457

vshab opened this issue Mar 5, 2019 · 3 comments · Fixed by #2458
Labels
Bug Addressing a bug

Comments

@vshab
Copy link

vshab commented Mar 5, 2019

Description

Hello!

After upgrading from beta.37 getPastLogs generates wrong topics array for eth_getLogs WebSocket RPC which causes inadequate data in return.

We have event with 3 indexed parameters:

  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "name": "p1",
        "type": "uint256"
      },
      {
        "indexed": false,
        "name": "p2",
        "type": "uint256"
      },
      {
        "indexed": true,
        "name": "p3",
        "type": "address"
      },
      {
        "indexed": true,
        "name": "p4",
        "type": "uint256"
      },
      {
        "indexed": false,
        "name": "p5",
        "type": "uint256"
      }
    ],
    "name": "Event",
    "type": "event"
  }

Expected behavior

beta.37 sends this

{
  "jsonrpc": "2.0",
  "id": 13,
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x0",
      "toBlock": "latest",
      "topics": [
        "0xaf2d03aa2fdc9b785775529881274caad1884e0279e02729f03eca55d57eea72",
        null,
        null,
        "0x000000000000000000000000000000000000000000000000000000000000001d"
      ],
      "address": "0x16***f0"
    }
  ]
}

Having topic for the third(p4) indexed parameter.

Actual behavior

beta.48 sends this

{
  "jsonrpc": "2.0",
  "id": 12,
  "method": "eth_getLogs",
  "params": [
    {
      "fromBlock": "0x0",
      "toBlock": "latest",
      "filter": { "p4": 29 },
      "topics": [
        "0xaf2d03aa2fdc9b785775529881274caad1884e0279e02729f03eca55d57eea72",
        "0x000000000000000000000000000000000000000000000000000000000000001d"
      ],
      "address": "0x16***f0"
    }
  ]
}

Having topic for the first(p1) indexed parameter instead of the third(p4). The value of topic is correct thought.

I believe the order is important here and 0x000000000000000000000000000000000000000000000000000000000000001d should be on fourth place.

I don't know about having "filter": { "p4": 29 }, field in new version though.

Steps to reproduce the behavior

web3.eth.contract.getPastEvents('Event', {
    fromBlock: 0,
    toBlock: 'latest',
    filter: {
      p4: 29,
    },
  });

Versions

  • web3.js: 1.0.0-beta.48
  • nodejs: N/A
  • browser: Chrome Version 72.0.3626.119
  • ethereum node: infura.io
@nivida
Copy link
Contributor

nivida commented Mar 5, 2019

Thanks for creating this issue! You're talking about version beta.46 in the example and about version beta.48 in the versions list. Could you tell me which version are you using?

@nivida
Copy link
Contributor

nivida commented Mar 5, 2019

Tested it in the latest version and this behavior also happens. Will fix and release it asap.

@vshab
Copy link
Author

vshab commented Mar 6, 2019

@nivida yeah, beta.48 in both cases. :) I updated the text. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants