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

sha3 Event hash consistency issue #209

Closed
brianlenz opened this issue Oct 28, 2017 · 4 comments · Fixed by #440
Closed

sha3 Event hash consistency issue #209

brianlenz opened this issue Oct 28, 2017 · 4 comments · Fixed by #440
Labels
bug A bug in behaviour or functionality help wanted

Comments

@brianlenz
Copy link

Say you have an event:

event ReceivedETH(address indexed backer, uint amount, uint8 indexed step);

EventEncoder.encode won't create the proper sha3 hash for this Event due to the fact that there is an indexed property after an unindexed property. EventEncoder.encodeorders the parameters by indexed first, which results in the hash being:

ReceivedETH(address,uint8,uint)

but the proper hash used in the Event's tokens will be based on:

ReceivedETH(address,uint,uint8)

I am admittedly new to Ethereum, but based on how I've seen everything working on the blockchain, it seems like this is a bug in Web3j?

To workaround the issue, we just rearranged the parameters on the event definition so that it is compatible with the forced ordering of Web3j:

event ReceivedETH(address indexed backer, uint8 indexed step, uint amount);
@conor10
Copy link
Contributor

conor10 commented Nov 8, 2017

Hi @brianlenz, that sounds correct.

@conor10 conor10 added the bug A bug in behaviour or functionality label Nov 8, 2017
@4ntoine
Copy link

4ntoine commented Feb 6, 2018

Any fixes?

@mushketyk
Copy link
Contributor

@conor10 I've implemented a fix by changing the Event class constructor to:

    public Event(String name, List<TypeReference<?>> parameters) {
        this.name = name;
        this.parameters = convert(parameters);
    }

But now I need to re-generate ENS and PublicResolver contracts, but I can't find how to do this. What commands do you use for this?

@4ntoine
Copy link

4ntoine commented Jun 14, 2018

Still open bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug in behaviour or functionality help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants