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

Events that take structs have malformed ABI JSON #2483

Closed
haltman-at opened this issue Oct 9, 2021 · 2 comments · Fixed by #2508
Closed

Events that take structs have malformed ABI JSON #2483

haltman-at opened this issue Oct 9, 2021 · 2 comments · Fixed by #2508
Assignees
Labels
bug Bug that shouldn't change language semantics when fixed. Easy Pickings Used to denote issues that should be easy to implement help wanted

Comments

@haltman-at
Copy link

Version Information

  • vyper Version (output of vyper --version): 0.3.0+commit.8a23feb
  • OS: Release Linux Mint 20.2 Uma 64-bit
  • Python Version (output of python --version): Python 3.8.10

What's your issue about?

If you declare an event that takes a struct, the ABI JSON for it will be malformed. Note that unlike the previous encoding bug, this bug is not specific to the case where the input is just a single struct alone; all structs used as event arguments appear to exhibit this bug. Because of this, decoding libraries will fail to decode such events.

As an example, suppose I write a contract with the following declarations:

struct Pair:
    x: uint256
    y: uint256

event Stuff:
    pair: Pair
    z: uint256

The ABI JSON I get for this event is:

    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": false,
          "name": "pair",
          "type": "(uint256,uint256)"
        },
        {
          "indexed": false,
          "name": "z",
          "type": "uint256"
        }
      ],
      "name": "Stuff",
      "type": "event"
    },

As you can see, this ABI item is malformed. The first input, rather than having type "tuple" and an appropriate components field, instead has the malformed type "(uint256,uint256)". Decoding libraries are unable to handle this.

This bug does not apply to function inputs, function outputs, or constructor inputs; those have proper ABI JSON.

How can it be fixed?

Given that structs are handled properly in the ABI JSON for functions and constructors, both on input and on output, whatever code you use for handling those can presumably be applied to event inputs as well.

@charles-cooper
Copy link
Member

Thanks for the bug report!

@charles-cooper charles-cooper self-assigned this Oct 10, 2021
@charles-cooper charles-cooper added bug Bug that shouldn't change language semantics when fixed. Easy Pickings Used to denote issues that should be easy to implement labels Oct 10, 2021
@charles-cooper
Copy link
Member

update: PR to fix this is open but blocked on ethereum/web3.py#1629 for testing the functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed. Easy Pickings Used to denote issues that should be easy to implement help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants