Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host function generic_hash() with blake2b/blake3 support. #4412

Closed

Commits on Nov 13, 2023

  1. Install blake3 package in execution_engine.

    Will be used to introduce hashing method for runtime.
    koxu1996 committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    2dc1b1a View commit details
    Browse the repository at this point in the history
  2. Add blake3 hasher to execution engine.

    Placed in new `crypto` module under `runtime`.
    koxu1996 committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    930d0b8 View commit details
    Browse the repository at this point in the history
  3. Add HashAlgoType to base types.

    Will be used to switch between different hashing algorithms.
    koxu1996 committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    356b5ca View commit details
    Browse the repository at this point in the history
  4. Implement host function GenericHash.

    Note: no gas charging was introduced yet.
    koxu1996 committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    eb3eb45 View commit details
    Browse the repository at this point in the history
  5. Charge default cost for using generic_hash.

    Inspired by `FunctionIndex::Blake2b`, which is also not researched
    in terms of execution cost.
    koxu1996 committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    267873a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f27876d View commit details
    Browse the repository at this point in the history
  7. Add crypto::generic_hash() to contract API.

    Note: new module `crypto` was introduced.
    koxu1996 committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    ef78d59 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    5d400ec View commit details
    Browse the repository at this point in the history

Commits on Nov 15, 2023

  1. Configuration menu
    Copy the full SHA
    8bd8fbb View commit details
    Browse the repository at this point in the history
  2. Update HashAlgoType description.

    Improved type documentation.
    
    Co-authored-by: Michał Papierski <[email protected]>
    koxu1996 and mpapierski authored Nov 15, 2023
    Configuration menu
    Copy the full SHA
    d38140f View commit details
    Browse the repository at this point in the history
  3. Pass hash_algo_type directly by value.

    We can avoid working with bytes and serialization,
    as `HashAlgoType` enum is represented by simple `u8`.
    koxu1996 committed Nov 15, 2023
    Configuration menu
    Copy the full SHA
    2c70942 View commit details
    Browse the repository at this point in the history

Commits on Nov 16, 2023

  1. Fix signature (arguments length) in WASM resolver.

    After passing `hash_algo_type` directly, we have one less parameter.
    koxu1996 committed Nov 16, 2023
    Configuration menu
    Copy the full SHA
    4ec1f31 View commit details
    Browse the repository at this point in the history

Commits on Nov 20, 2023

  1. Change error type for HashAlgoType::try_from.

    It can be simple `()` instead of `bytesrepr::Error::Formatting`
    (the one commonly used for serialization related issues).
    koxu1996 committed Nov 20, 2023
    Configuration menu
    Copy the full SHA
    85885d0 View commit details
    Browse the repository at this point in the history
  2. Return ApiError::InvalidArgument for invalid hash_algo_type.

    Previous deserializiation error was confusing.
    
    NOTE: The code seems too complex for such a basic thing like
    returning API error.
    koxu1996 committed Nov 20, 2023
    Configuration menu
    Copy the full SHA
    d064e2c View commit details
    Browse the repository at this point in the history
  3. Fix formatting.

    Detected with `cargo fmt`.
    koxu1996 committed Nov 20, 2023
    Configuration menu
    Copy the full SHA
    4b85568 View commit details
    Browse the repository at this point in the history