Package Logo
substreams_evm_precompiles_popularity
substreams-evm-precompiles-popularity@v0.3.1
Total Downloads
20
Published
yesterday
Network
mainnet mainnet
Publisher
User Avatar maoueh

Readme

Substreams EVM Precompiles Popularity

This project leverages Substreams to calculate the popularity of Ethereum precompiled contracts from call data.

Overview

  • Processes Ethereum call events using Substreams.
  • Counts and maps occurrences of precompiles.
  • Outputs results using Protocol Buffers.

Getting Started

substreams gui substreams-evm-precompiles-popularity@v0.2.0

Results

Ethereum Mainnet

At block #21 996 000:

  1. 0x0000000000000000000000000000000000000001 => 247543455 (ecrecover)
  2. 0x0000000000000000000000000000000000000002 => 128524392 (sha256Hash)
  3. 0x0000000000000000000000000000000000000004 => 46295370 (dataCopy)
  4. 0x0000000000000000000000000000000000000006 => 44480667 (bn256Add)
  5. 0x0000000000000000000000000000000000000007 => 44330095 (bn256ScalarMul)
  6. 0x0000000000000000000000000000000000000005 => 16939742 (bigModExp)
  7. 0x0000000000000000000000000000000000000008 => 2504972 (bn256Pairing)
  8. 0x0000000000000000000000000000000000000003 => 618211 (ripemd160Hash)
  9. 0x000000000000000000000000000000000000000a => 570252 (kzgPointEvaluation)
  10. 0x0000000000000000000000000000000000000009 => 161695 (blake2F)

Compute Results

substreams run substreams-evm-precompiles-popularity@v0.2.0 map_counts -s 21996000 -t +1 -o jsonl | skip 1 | head -n1 | jq -rc '."@data".entries | sort_by(-(.count|tonumber)) | .[] | "0x\(.address) => \(.count) (\(.name))"'

License

Apache 2.0

Documentation

Modules

Maps icon
Maps

map
map_counts

09e01559016b3a57b4ac5c95ba0abe1cd2b4dee4
map map_counts (
store_countsGET<add,int64>
store_countsDELTAS<add,int64>
)  -> contract.v1.PrecompilesPopularity
substreams gui substreams-evm-precompiles-popularity@v0.3.1 map_counts

map
ethcommon:all_calls

1aeb5fdc0e2ae46083b4543c9f5b759bba4748e7
map ethcommon:all_calls (
)  -> sf.substreams.ethereum.v1.Calls

all_calls gives you all the calls in a block (including internal calls), with basic block hash/number/timestamp and transaction hash

substreams gui substreams-evm-precompiles-popularity@v0.3.1 ethcommon:all_calls

map
ethcommon:filtered_calls

d11563886667ab0683eea8f3550d41cb8ba28513
Default param : call_to:0x0000000000000000000000000000000000000001 || call_to:0x0000000000000000000000000000000000000002 || call_to:0x0000000000000000000000000000000000000003 || call_to:0x0000000000000000000000000000000000000004 || call_to:0x0000000000000000000000000000000000000005 || call_to:0x0000000000000000000000000000000000000006 || call_to:0x0000000000000000000000000000000000000007 || call_to:0x0000000000000000000000000000000000000008 || call_to:0x0000000000000000000000000000000000000009 || call_to:0x000000000000000000000000000000000000000a || call_to:0x000000000000000000000000000000000000000b || call_to:0x000000000000000000000000000000000000000c || call_to:0x000000000000000000000000000000000000000d || call_to:0x000000000000000000000000000000000000000e || call_to:0x000000000000000000000000000000000000000f || call_to:0x0000000000000000000000000000000000000010 || call_to:0x0000000000000000000000000000000000000011

filtered_calls reads from all_calls and applies a filter on the called contract, the caller and the method 4-bytes signature Supported operators are: logical or ||, logical and && and parenthesis: () Addresses to match must be written as 0x-prefixed hexadecimal, lowercase, prefixed by call_to: or call_from:, methods by call_method:. Example: (call_to:0x1234... || call_from:0x1234...) && call_method:0xdeadbeef...

substreams gui substreams-evm-precompiles-popularity@v0.3.1 ethcommon:filtered_calls
Stores icon
Stores

store
store_counts

dd3c342a365141ee49e4d64d1b098a0038071061
substreams gui substreams-evm-precompiles-popularity@v0.3.1 store_counts
Block Indexes icon
Block Indexes

blockIndex
ethcommon:index_calls

eee3f6b287e7baca3f7a530810b3a359e2fb19aa

index_calls sets the following keys on the block:

  • Call contract call_to:0x0123456789abcdef0123456789abcdef01234567 (contract address in hex, prefixed by 0x)
  • Caller call_from:0x0123456789abcdef0123456789abcdef01234567 (caller address in hex, prefixed by 0x)
  • Call method call_method:0x01234567 (4 bytes of method signature in hex, prefixed by 0x)
substreams gui substreams-evm-precompiles-popularity@v0.3.1 ethcommon:index_calls
Protobuf

Protobuf Docs Explorer

sf.ethereum.type.v2
sf.ethereum.substreams.v1
contract.v1