GithubHelp home page GithubHelp logo

elielnfinic / hdp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from herodotusdev/hdp

0.0 0.0 0.0 2.39 MB

Herodotus Data Processor Toolkit. Enhance zk-offchain compute for verifiable onchain data using zkVMs

Home Page: https://docs.herodotus.dev/herodotus-docs/developers/herodotus-data-processor-hdp

License: GNU General Public License v3.0

Shell 2.18% Rust 97.82%

hdp's Introduction

Herodotus Data Processor (HDP)

CI

Warning: This codebase is experimental and not audited. Use at your own risk.

HDP enhances off-chain compute capabilities with zkVMs for verifiable on-chain data integration. For more, visit our documentation.

Introduction

The HDP CLI is designed to process human-readable requests and convert them into a format acceptable to Cairo programs. This conversion is a crucial part of the preprocessing step, which prepares data for subsequent off-chain computations in zkVM environments. The CLI not only facilitates this transformation but also offers additional features to support development and testing.

Features

  • Development Tools: Encode and decode data lakes and computational tasks.
  • Core Processing: Compile data from various sources and compute aggregate functions.
  • Extensibility: Support for multiple blockchain integrations and various ZKVM backends is planned.
  • Ease of Use: Provides a CLI for easy interaction with the system.

Install HDP

Install with cargo

# Install with cargo
cargo install --git https://github.com/HerodotusDev/hdp --locked --force

Build from source

# clone repo
git clone https://github.com/HerodotusDev/hdp.git

# install hdp
cargo install --path cli -f

Getting Started

To launch the interactive CLI:

# Start the HDP
hdp start

Expected output:

Welcome to Herodotus Data Processor interactive CLI! ๐Ÿ›ฐ๏ธ

                _   _   ____    ____
                | | | | |  _ \  |  _ \
                | |_| | | | | | | |_) |
                |  _  | | |_| | |  __/
                |_| |_| |____/  |_|

? Step 1. What's your datalake type?

Usage Examples

The following examples demonstrate how to use the HDP CLI to encode various blockchain data elements into a format suitable for processing. Each command highlights a different function of the HDP system, from averaging values to counting values based on specific criteria.

Header value with AVG:

hdp encode "avg" -b 4952100 4952110 "header.base_fee_per_gas" 1

Account value with SUM:

hdp encode "sum" -b 4952100 4952110 "account.0x7f2c6f930306d3aa736b3a6c6a98f512f74036d4.nonce" 2

Storage value with AVG:

hdp encode "avg" -b 5382810 5382820 "storage.0x75CeC1db9dCeb703200EAa6595f66885C962B920.0x0000000000000000000000000000000000000000000000000000000000000002" 1

Account value with COUNT:

hdp encode "count" "gt.1000" -b 4952100 4952110 "account.0x7f2c6f930306d3aa736b3a6c6a98f512f74036d4.nonce" 2

After encoding, you can directly run processing tasks using environmental configurations for RPC and Chain ID, as shown below:

# pro tip: run herodotus data processing with `.env`
hdp run
# run herodotus data processing
hdp run ${Encoded Task} ${Encoded Datalake} ${Input your RPC Provider -- this example is Etherum Sepolia} ${Input Chain ID that you are target on}

For a more comprehensive guide on commands available within HDP CLI:

hdp --help

Expected output :

Interact Herodotus Data Processor via CLI

Usage: `hdp <COMMAND>`

Commands:
  start       New to the HDP CLI? Start here!
  encode      Encode the task and datalake in batched format test purposes
  decode      Decode batch tasks and datalakes
  decode-one  Decode one task and one datalake (not batched format)
  run         Run the evaluator
  help        Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

Integration Testing

Integration testing in HDP ensures that the functionality of aggregate functions such as SUM, AVG, MIN, MAX, and COUNT operates correctly across various numeric fields within the blockchain data structure. These functions are designed specifically for numeric data types, ensuring accurate and reliable computations.

Testing Environment

Our integration tests utilize script/integration.sh to verify the correct operation of each function across the supported fields. To execute these tests locally, refer to the Integration Test Guide for detailed instructions.

Supported Aggregate Functions

  • SUM, AVG, MIN, MAX, COUNT: These functions are supported only for fields with numeric values.

Function Support Matrix

Here is the support matrix indicating which blockchain elements are tested for each aggregate function. The matrix highlights fields where these functions are applicable.

Field Description SUM AVG MIN MAX COUNT
account.nonce โœ… โœ… โœ… โœ… โœ…
account.balance โœ… โœ… โœ… โœ… โœ…
account.storage_root - - - - -
account.code_hash - - - - -
storage.key (numeric value) โœ… โœ… โœ… โœ… โœ…
storage.key (hash value) - - - - -
header.difficulty โœ… โœ… โœ… โœ… โœ…
header.gas_limit โœ… โœ… โœ… โœ… โœ…
header.gas_used โœ… โœ… โœ… โœ… โœ…
header.timestamp โœ… โœ… โœ… โœ… โœ…
header.base_fee_per_gas โœ… โœ… โœ… โœ… โœ…
header.blob_gas_used โœ… โœ… โœ… โœ… โœ…
header.excess_blob_gas โœ… โœ… โœ… โœ… โœ…
header.nonce โœ… โœ… โœ… โœ… โœ…
Other header elements - - - - -
tx.nonce โœ… โœ… โœ… โœ… โœ…
tx.gas_price โœ… โœ… โœ… โœ… โœ…
tx.gas_limit โœ… โœ… โœ… โœ… โœ…
tx.value โœ… โœ… โœ… โœ… โœ…
tx.v โœ… โœ… โœ… โœ… โœ…
tx.r โœ… โœ… โœ… โœ… โœ…
tx.s โœ… โœ… โœ… โœ… โœ…
tx.chain_id โœ… โœ… โœ… โœ… โœ…
tx.max_fee_per_gas โœ… โœ… โœ… โœ… โœ…
tx.max_priority_fee_per_gas โœ… โœ… โœ… โœ… โœ…
tx.max_fee_per_blob_gas โœ… โœ… โœ… โœ… โœ…
Other tx elements - - - - -

Note: Fields marked with "-" are not applicable for the specified aggregate functions because they do not contain numeric data or the data type is not suitable for these calculations.

Additional Notes

  • Please ensure that the data fields you are applying these functions contain numeric values to avoid computational errors.
  • For details on how these tests are performed or to contribute to the further development of tests, please refer to the Integration Test Guide.

Development

# CI check
cargo clippy --all --all-targets -- -D warnings && cargo fmt -- --check && cargo test --all --all-targets -- --nocapture

Defining Your Own Module

For developers interested in extending the functionality of HDP by adding new modules, follow the steps outlined below. This guide assumes a basic understanding of Rust and its module system.

Getting Started

  1. Module Location: Start by creating a new module within the aggregate_fn directory. You can find this at aggregation_fn/mod.rs.

  2. Define Enum: Define your new function as an enum in the file. Make sure to add match arms for the new enum variants in the implementation.

  3. Handle Data Types: Depending on the expected input type for your function:

    • Integer Inputs: Use U256 for handling large integers compatible with Ethereum's numeric constraints.
    • String Inputs: Use Rust's standard String type for text data.

Context Required Operation

For a practical example of how to implement context-sensitive operations, refer to the implementation of the COUNT function. This example shows how to pass and utilize additional context for operations, which can be particularly useful for conditional processing or complex calculations.

Testing Your Module

After implementing your new function, it's crucial to verify its functionality:

  • Create Unit Tests: Add tests in the corresponding test file in the tests directory. Ensure your tests cover all new logic to maintain stability and reliability.
  • Test for Integer Types: Pay special attention to functions that handle integer types, ensuring they correctly process and output values fitting within a bytes32 length, reflecting Ethereum's data type constraints.

License

hdp is licensed under the GNU General Public License v3.0.


Herodotus Dev Ltd - 2024

hdp's People

Contributors

rkdud007 avatar elielnfinic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.