Skip to content

Clarification about event topic reconstruction in EventStorage.sol #4

Description

@bonedaddy

I'm trying to better understand event logs in ethereum and their usage with bloom filters. Everything I read about event logs indicates that the very first topic should be the hash of the event signature keccak256(keccak256(DataStored(bytes,bytes)))

However in EventStorage.sol the first topic is the hash of the address of the contract that the event originated from, in this case EventStorage (

bytes32 _topic1 = keccak256(address(this));
)

Exerpt from solidity docs:

Up to three parameters can receive the attribute indexed which will cause the respective arguments to be searched for: It is possible to filter for specific values of indexed arguments in the user interface.

If arrays (including string and bytes) are used as indexed arguments, the Keccak-256 hash of it is stored as topic instead.

The hash of the signature of the event is one of the topics except if you declared the event with anonymous specifier. This means that it is not possible to filter for specific anonymous events by name.

As I mentioned in the beginning of the issue, everything I read indicates that the first topic should be the hash of the event signature:
https://ethereum.stackexchange.com/questions/12950/what-are-event-topics
https://media.consensys.net/technical-introduction-to-events-and-logs-in-ethereum-a074d65dd61e
https://ethereum.stackexchange.com/questions/25006/does-the-address-of-an-event-get-automatically-indexed?rq=1

But as is evident by EventStorage.sol this is not the case (I believe event log records in etherscan indicate this as well)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions