Posts tagged "Smart-Contracts"
Decoding Ethereum Events
Smart contracts have many differences from regular programs, logging is one of them. Logs in the Ethereum ecosystem aren’t just strings written to standard out, but rather a fundamental part of the Ethereum Virtual Machine (EVM) embedded in the protocol. They enable developers to not only understand what’s happening with a contract, but prove properties across networks thanks to receipt root proofs.
Contracts can emit events through 5 different opcodes, LOG0
through to LOG4
. All these opcodes let you record some region of memory1, and with the exception of LOG0
all the opcodes store topics which are indexed 256-bit parameters2. Generally the first indexed topic is used to denote the event type, which is obtained by hashing the signature of the event method (known as the event selector), however languages also provide the means to do “anonymous” events which do not set the first topic as the selector.
Bulk Storage Extraction
Most Dapp developers have heard of and probably use the excellent Multicall contract to bundle their eth_call
s and reduce latency for bulk ETL in their applications (we do too, we even have a python library for it: Manifold).
Unfortunately, we cannot use this same trick when getting storage slots, as we discovered when developing our storage explorer, forcing developers to issue an eth_getStorageAt
for each slot they want to query. Luckily, Geth has a trick up its sleeve, the “State Override Set”, which, with a little ingenuity, we can leverage to get bulk storage extraction.