cryo

repository·main·Indexed 23 days ago

https://github.com/paradigmxyz/cryo

A tool for extracting blockchain data to parquet, csv, or json formats. It includes a CLI for data acquisition, a Python implementation, and a specialized utility called `cryo_test` for comparing outputs across different RPCs, executables, or implementations to ensure consistency.

Tokens
16.7K
Snippets
17
Records
118
Agent score
81%

What's inside cryo

  1. Install cryo from source

    main

    To use the latest unreleased version of cryo, you can install it from source. This requires maturin and a Rust environment. Follow these steps:

    1. Install maturin.
    2. Clone the repository.
    3. Navigate to the python crate directory.
    4. Build the release version using maturin.
    5. Reinstall the resulting .whl file using pip.
    pip install maturin
    git clone https://github.com/paradigmxyz/cryo
    cd cryo/crates/python
    maturin build --release
    pip install --force-reinstall <OUTPUT_OF_MATURIN_BUILD>.whl
  2. Use cryo_test to compare cryo environments

    main

    The cryo_test CLI tool is used to perform comparisons between different cryo outputs across various conditions. The tool follows a three-step lifecycle:

    1. Setup: Creates a comparison directory.
    2. Collect: Gathers data from the specified sources.
    3. Compare: Analyzes the collected outputs.

    You can compare different RPC endpoints, different versions of the cryo executable, or compare the CLI output against the Python implementation.

  3. Extract EVM data with cryo_freeze

    main
    The cryo_freeze crate provides functionality to extract EVM (Ethereum Virtual Machine) data into structured formats such as Parquet, CSV, or JSON. The primary entry points for data extraction are the collect and freeze functions, along with support for managing multiple datasets via multi_datasets.
  4. Understand the DiffMode structure

    main

    The DiffMode type represents the state difference for an account during a transaction trace. It is parsed from Geth debug objects and contains two maps:

    • pre: A BTreeMap<Address, AccountState> representing the state before the transaction.
    • post: A BTreeMap<Address, AccountState> representing the state after the transaction.
  5. Configure U256 representations with U256Type

    main

    When working with u256 columns, you can specify how they should be represented using the U256Type enum. This affects both the underlying ColumnType and the naming convention used for the column suffixes.

    Available Representations

    U256TypeColumnTypeSuffixDescription
    BinaryBinary_binaryBinary representation
    StringString_stringString representation
    F32Float32_f3232-bit float
    F64Float64_f6464-bit float
    U32UInt32_u3232-bit unsigned integer
    U64UInt64_u6464-bit unsigned integer
    Decimal128Decimal128_d128Decimal128 representation
  6. Configure CLI execution environment via Args

    main

    The cryo CLI uses an ExecutionEnv to manage runtime behavior. This environment is constructed based on the following command-line arguments:

    • --dry: Enables dry-run mode.
    • --verbose / --no-verbose: Controls the logging verbosity level.
    • --report: Enables or disables reporting (controlled by --no-report).
    • --report-dir <DIR>: Specifies the directory where reports are saved.
    • --bar <N>: Controls the display of a progress bar (enabled if --no-verbose is not set).

    Verbosity levels are determined by the combination of --verbose and --no-verbose flags:

    • Both set: Error
    • --no-verbose only: Level 0
    • --verbose only: Level 2
    • Neither set: Level 1
  7. Understand the default sort order logic

    main

    If a Dataset implementation does not provide a custom sort order via default_sort(), cryo applies a fallback logic through base_default_sort().

    The fallback attempts to sort by the following columns in order, provided they exist in the dataset's column_types():

    1. block_number
    2. transaction_index (Note: if log_index is present, transaction_index is skipped to prioritize log-level ordering)
    3. log_index