Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

getPastLogs: must pass "filter" validation #6181

Closed
pustovalov opened this issue Jun 9, 2023 · 9 comments
Closed

getPastLogs: must pass "filter" validation #6181

pustovalov opened this issue Jun 9, 2023 · 9 comments
Assignees
Labels
4.x 4.0 related Bug Addressing a bug

Comments

@pustovalov
Copy link

Expected behavior

      const response = await web3.eth.getPastLogs({
        blockHash: '0x19e54b41ac6ed5eb5045aab59967489bbab1852e742857b1987f62290a4b89af',
      })

      expect(response).toMatchInlineSnapshot(`
        [
          {
            "address": "0xC6e5185438e1730959c1eF3551059A3feC744E90",
            "blockHash": "0x19e54b41ac6ed5eb5045aab59967489bbab1852e742857b1987f62290a4b89af",
            "blockNumber": 70762849,
            "data": "0x",
            "id": "log_7e911bc2",
            "logIndex": 0,
            "removed": false,
            "topics": [
              "0x2d452398cb8bb9e5cdadeaabfe0a5d66bf83abdf317ed5633a64528f5bee7458",
              "0x0000000000000000000000003195949f267702723bc614cae037cdc8d1e94786",
              "0x0000000000000000000000000000000000000000000000000000000018994c8a",
              "0x000000000000000000000000f2b7e347ca4ec2a0f139b1d3073d679911295a2a",
            ],
            "transactionHash": "0xe716505f8269e5d13078dcb52efbcd6476a3603e57145d4e8306d3f92b8d7d5f",
            "transactionIndex": 0,
          },
        ]
      `)
    })

Actual behavior

    Web3ValidatorError: Web3 validator found 1 error[s]:
    value "[object Object]" at "/0" must pass "filter" validation

Steps to reproduce the behavior

import { Web3 } from 'Web3'

(async () => {
    const env = "https://mainnet.aurora.dev"
    const web3 = new Web3(env)

    const response = await web3.eth.getPastLogs({
      blockHash: '0x19e54b41ac6ed5eb5045aab59967489bbab1852e742857b1987f62290a4b89af',
    })

    console.log('response', response)
})()

Logs

file://raw/node_modules/.pnpm/web3-validator@1.0.0/node_modules/web3-validator/lib/esm/validator.js:42
                throw new Web3ValidatorError(errors);
                      ^

Web3ValidatorError: Web3 validator found 1 error[s]:
value "[object Object]" at "/0" must pass "filter" validation
    at Validator.validate (file://raw/node_modules/.pnpm/web3-validator@1.0.0/node_modules/web3-validator/lib/esm/validator.js:42:23)
    at Web3Validator.validate (file://raw/node_modules/.pnpm/web3-validator@1.0.0/node_modules/web3-validator/lib/esm/web3_validator.js:32:32)
    at Module.<anonymous> (file://raw/node_modules/.pnpm/web3-rpc-methods@1.0.0/node_modules/web3-rpc-methods/lib/esm/eth_rpc_methods.js:371:19)
    at Generator.next (<anonymous>)
    at file://raw/node_modules/.pnpm/web3-rpc-methods@1.0.0/node_modules/web3-rpc-methods/lib/esm/eth_rpc_methods.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (file://raw/node_modules/.pnpm/web3-rpc-methods@1.0.0/node_modules/web3-rpc-methods/lib/esm/eth_rpc_methods.js:3:12)
    at Module.getLogs (file://raw/node_modules/.pnpm/web3-rpc-methods@1.0.0/node_modules/web3-rpc-methods/lib/esm/eth_rpc_methods.js:370:12)
    at Module.<anonymous> (file://raw/node_modules/.pnpm/web3-eth@4.0.1/node_modules/web3-eth/lib/esm/rpc_method_wrappers.js:553:46)
    at Generator.next (<anonymous>) {
  innerError: undefined,
  code: 1100,
  errors: [
    {
      keyword: 'data["0"]',
      instancePath: '/0',
      schemaPath: '#',
      params: {
        value: {
          blockHash: '0x19e54b41ac6ed5eb5045aab59967489bbab1852e742857b1987f62290a4b89af'
        }
      },
      message: 'must pass "filter" validation'
    }
  ]
}

eth_getLogs on ethereum mainnet

{
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [
        {
            "blockHash": "0x947d7c7450fb1c9075c72348a46cda799c644e8f5e913705cba4c51bf650a029"
        }
    ],
    "id": 2
}
{
    "jsonrpc": "2.0",
    "id": 2,
    "result": [
        {
            "address": "0xa2e123dc38f1899a9d9515c65036690854cb184b",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x000000000000000000000000ab9c689fc67ca5de46e81aadff8addd8304853c8",
                "0x0000000000000000000000003ba47c54b4e2bc7e95df7c8d2002789e9fd71f09"
            ],
            "data": "0x000000000000000000000000000000000000000003ff34a5144f05ffc3ce8977",
            "blockNumber": "0x10a2ac7",
            "transactionHash": "0x03584579dd8ee1eefe0085f696782bba7da7671fa923f7abbec04df76fb3e002",
            "transactionIndex": "0x0",
            "blockHash": "0x947d7c7450fb1c9075c72348a46cda799c644e8f5e913705cba4c51bf650a029",
            "logIndex": "0x0",
            "removed": false
        },

Environment

node: v18.16.0
web3.js: 4.0.1

@erik-451
Copy link

Hi @pustovalov

I had the same error,
It started to give me problems when they updated the library to the current version, a few days ago.
If it helps you, I have used a version of web3js previous to the current one and it has solved it.

Good luck!

@jdevcs jdevcs added the 4.x 4.0 related label Jun 10, 2023
@jdevcs jdevcs self-assigned this Jun 19, 2023
@mconnelly8 mconnelly8 added the Bug Addressing a bug label Jun 20, 2023
@luu-alex
Copy link
Contributor

Hi there! Thank you for submitting this error, i'll be taking a look into this.
@erik-451 what did ur code look like when u recieved this error. -alex

@luu-alex luu-alex assigned luu-alex and unassigned jdevcs Jun 22, 2023
@luu-alex
Copy link
Contributor

Created a PR for this :) thank you #6219 will get this merged in, should be available for next version and be fixed

@luu-alex
Copy link
Contributor

PR has been merged to fix this, it'll be available next release.

@louloub
Copy link

louloub commented Aug 29, 2023

i have a similar error with web3 4.1.1 when using web3.eth.sendSignedTransaction function.
I'm working on Hyperledger Besu blockchain (i opened issue on Hyperledger) and i can't send my signed transaction. Does i open new issue or i put my message here ?

Thanks

@luu-alex
Copy link
Contributor

hey there @louloub whats the error?

@louloub
Copy link

louloub commented Aug 29, 2023

Hey @luu-alex thanks for your answer, this is the error :

/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-validator/lib/commonjs/validator.js:73
                throw new errors_js_1.Web3ValidatorError(errors);
                      ^

Web3ValidatorError: Web3 validator found 1 error[s]:
value at "/0" is required
    at Validator.validate (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-validator/lib/commonjs/validator.js:73:23)
    at Web3Validator.validate (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-validator/lib/commonjs/web3_validator.js:35:32)
    at bytesToUint8Array (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/node_modules/web3-utils/lib/commonjs/converters.js:69:32)
    at hexToBytes (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/node_modules/web3-utils/lib/commonjs/converters.js:114:42)
    at Object.<anonymous> (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/lib/commonjs/rpc_method_wrappers.js:429:171)
    at Generator.next (<anonymous>)
    at /home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/lib/commonjs/rpc_method_wrappers.js:24:71
    at new Promise (<anonymous>)
    at __awaiter (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/lib/commonjs/rpc_method_wrappers.js:20:12)
    at /home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/lib/commonjs/rpc_method_wrappers.js:426:20 {
  innerError: undefined,
  code: 1100,
  errors: [
    {
      keyword: '0',
      instancePath: '/0',
      schemaPath: '#0',
      params: { value: undefined },
      message: 'value at "/0" is required'
    }
  ]
}

I can provide to you all the js code if necessary !

@luu-alex
Copy link
Contributor

@louloub that would be great! if u can open a new issue and include the js code + this error, the team can investigate :) thank you

@louloub
Copy link

louloub commented Aug 29, 2023

Thanks @luu-alex i will do that :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4.x 4.0 related Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

6 participants