Ethereum Classic (ETC) blocks contain Bloom filters to speed up searches of their transaction logs. I will describe how these Bloom filters are created.

Basics

ETC Bloom filters are 2048 bit strings that encode transaction log information. Transaction logs have associated smart contract addresses and topics. Transaction log topics denote the identifiers and types of stored values. For example, token transfer transactions might lead to the logging of sending addresses, receiving addresses and transfer amounts. This information is typically associated with the transaction log topic consisting of the Keccak 256 hash of the following string:

Transfer(address,address,uint256)

Recipe

To create ETC block Bloom filters use the following recipe:

Calculate the Keccak 256 hashes of all the transaction log smart contract addresses and topics for the block. Find the values modulo 2048 of the first three byte pairs of all those hashes. Set the Bloom filter bits with indices corresponding to all those values.

Example

Block 5,000,000 contains the following topic with respect to smart contract address 0xb09cbe4f7e845184d8c6e4607cd816bfc9bc08d3:

0x23919512b2162ddc59b67a65e3b03c419d4105366f7d4a632f5d3c3bee9b1cff

Here are the corresponding Keccak 256 hashes:

0xe03fd25d22a7284b1afa5c2afaf78b318421dd35094243e5b9e470e530c5132c

0x14a60b08f93d1972e19ec54d536b3ba32f1a9bcf6182882e45d908113b585ff6

Here are the corresponding byte pairs:

0xe03f

0xd25d

0x22a7

0x14a6

0x0b08

0xf93d

Here are the corresponding values modulo 2048:

63

605

679

1190

776

317

Finally, here is the Bloom filter with all the corresponding bits set:

0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000080000000000000000020000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000

Conclusion

Bloom filters greatly assist with ETC transaction log searches. Their details do not have to remain mysterious.

Feedback

Feel free to leave any comments or questions below. You can also contact me by email at cs@etcplanet.org or by clicking any of these icons:

Acknowledgements

I would like to thank IOHK (Input Output Hong Kong) for funding this effort.

License

This work is licensed under the Creative Commons Attribution ShareAlike 4.0

International License.