evm_contracts / README.md
apehex's picture
Fix config name bug + tidy
0f04ad8
|
raw
history blame
5.95 kB
metadata
license: agpl-3.0
configs:
  - config_name: hex-ethereum
    data_files:
      - split: train
        path: hex/ethereum/train/*.parquet
  - config_name: bin-ethereum
    data_files:
      - split: train
        path: bin/ethereum/train/*.parquet

EVM Contracts

Description

EVMC (Ethereum Virtual Machine Contracts) is a collection of smart contracts from the ETH blockchain.

In particular, each sample holds the creation and runtime bytecodes. When available, the sources are also included.

Metadata

The transaction data is available for all records, in particular creation and runtime bytecodes are filled.

But the source code cannot be collected via standard RPC nodes, they have to be obtained through the APIs of block explorers. These have a small rate limit and it takes a long time.

So the source code data has only been scraped for a portion of the records, as listed in the tables below.

This data was collected by the scripts of a dedicated package, feedblocks.

HEX Dataset

Config Split Size Samples Blocks Scraped sources
'hex-ethereum' 'train' 2.1 GB 1,294,247 19,493,000 - 20,292,000 19,493,000 - 19,959,999 (58%)

BIN Dataset

Config Split Size Samples Blocks Scraped sources
'bin-ethereum' 'train' 1.7 GB 1,294,247 19,493,000 - 20,292,000 19,493,000 - 19,959,999 (58%)

Features

The data comes in two flavors: binary and hexadecimal encodings. The fields have the same names in both and the underlying data is also identical.

In binary form, the raw bytes are stored in most fields:

datasets.Features({
    "chain_id": datasets.features.Value(dtype='uint64'),
    "block_number": datasets.features.Value(dtype='uint32'),
    'block_hash': datasets.features.Value(dtype='large_binary'),
    'transaction_hash': datasets.features.Value(dtype='large_binary'),
    'deployer_address': datasets.features.Value(dtype='large_binary'),
    'factory_address': datasets.features.Value(dtype='large_binary'),
    'contract_address': datasets.features.Value(dtype='large_binary'),
    'creation_bytecode': datasets.features.Value(dtype='large_binary'),
    'runtime_bytecode': datasets.features.Value(dtype='large_binary'),
    'creation_sourcecode': datasets.features.Value(dtype='large_binary'),})

While in hexadecimal format, the data is encoded into HEX strings:

datasets.Features({
    "chain_id": datasets.features.Value(dtype='uint64'),
    "block_number": datasets.features.Value(dtype='uint64'),
    'block_hash': datasets.features.Value(dtype='string'),
    'transaction_hash': datasets.features.Value(dtype='string'),
    'deployer_address': datasets.features.Value(dtype='string'),
    'factory_address': datasets.features.Value(dtype='string'),
    'contract_address': datasets.features.Value(dtype='string'),
    'creation_bytecode': datasets.features.Value(dtype='string'),
    'runtime_bytecode': datasets.features.Value(dtype='string'),
    'creation_sourcecode': datasets.features.Value(dtype='string'),})

Chain And Block Numbers

Both ids are stored as unsigned integers.

Solidity Sources

The sources all have open source licenses. They were collected from block explorer APIs like Etherscan.

The sources are formatted as standard JSON input for the solidity compiler.

The resulting JSON is then encoded using UTF-8 into a single string.

HEX Dataset

All the other features are HEX encoded into strings, without the 0x prefix.

For example:

{
    'chain_id': 1,
    'block_number': 20155815,
    'block_hash': 'fcddf33b1b5a728a40588eda60262639201ac0d3f611f08286a9e2ef65576111',
    'transaction_hash': 'ec3723ffb8a3bbb8b83b25481f61cbfc46383fc88ff8eb364186b53aa226e4bf'
    'deployer_address': 'ba57abe375903838b5c19709e96dae12191fa37e',
    'factory_address': '0000000000b3f879cb30fe243b4dfee438691c04',
    'contract_address': 'eff10e7d4feef60ed9b9e9bb9fee12c2504bd0ba',
    'creation_bytecode': '756eb3f879cb30fe243b4dfee438691c043318585733ff6000526016600af3',
    'runtime_bytecode': '6eb3f879cb30fe243b4dfee438691c043318585733ff',
    'solidity_sourcecode': '',}

BIN Dataset

All the other features are stored in binary format:

{
    'chain_id': 1,
    'block_number': 20155815,
    'block_hash': b'\xfc\xdd\xf3;\x1bZr\x8a@X\x8e\xda`&&9 \x1a\xc0\xd3\xf6\x11\xf0\x82\x86\xa9\xe2\xefeWa\x11',
    'transaction_hash': b'\xec7#\xff\xb8\xa3\xbb\xb8\xb8;%H\x1fa\xcb\xfcF8?\xc8\x8f\xf8\xeb6A\x86\xb5:\xa2&\xe4\xbf',
    'deployer_address': b'\xbaW\xab\xe3u\x9088\xb5\xc1\x97\t\xe9m\xae\x12\x19\x1f\xa3~',
    'factory_address': b'\x00\x00\x00\x00\x00\xb3\xf8y\xcb0\xfe$;M\xfe\xe48i\x1c\x04',
    'contract_address': b'\xc7%\xbc1\xcb\xa2LS\xe5\xc0\xc2\xe2\x06]K@\xf5#Fx',
    'creation_bytecode': b'un\xb3\xf8y\xcb0\xfe$;M\xfe\xe48i\x1c\x043\x18XW3\xff`\x00R`\x16`\n\xf3',
    'runtime_bytecode': b'n\xb3\xf8y\xcb0\xfe$;M\xfe\xe48i\x1c\x043\x18XW3\xff',
    'creation_sourcecode': b''}

This saves disk space and may actually be more practical for further processing.