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

[sui-execution] Verifier trait creates and accepts Meter #16941

Merged
merged 1 commit into from
Apr 4, 2024

Commits on Apr 4, 2024

  1. [sui-execution] Verifier trait creates and accepts Meter

    Supersede `Verifier::meter_compiled_modules_with_overrides` by:
    
    - Allowing `meter_compiled_modules` and `meter_compiled_bytes` to
      accept a custom meter.
    - Extracting the generation of `VerifierConfig` out to the
      `sui-protocol-config` crate.
    - Splitting up `VerifierConfig` into itself and `MeterConfig`.
    - Adding a `Verifier::meter` function for creating the meter that is
      used during signing.
    - Removed the meter as a field of each `Verifier`.
    
    This means that we can now pass a different meter type when we don't
    want to enforce metering, and no longer need to modify the config
    in-place to achieve the same result.
    
    To make this work, I needed to enable the use of a `&mut dyn Meter`
    trait object to instantiate what was previously a `&mut impl Meter`
    parameter everywhere. To do this, I created a forwarding trait
    implementation of `Meter` for `&mut dyn Meter` and added an extra
    relaxation of `+ ?Sized` to all the `&mut impl Meter` parameters to
    allow the trait object to instantiate them.
    
    This is in preparation for passing a custom meter into this new
    parameter when instantiated by the CLI to capture all information
    about scopes during metering.
    
    Today we don't do that which means:
    
    - We only report back information about the last module and function
      we verified.
    - We can incorrectly report that everything is fine, (package would
      pass verification) even if there was some previous module or
      function that exceeded the stated limits.
    
    Test Plan:
    
    ```
    sui$ cargo build --bin sui
    sui$ cargo simtest
    sui$ env SUI_SKIP_SIMTESTS=1 cargo nextest run
    external-crates$ ./tests.sh
    deepbook$ cargo run --bin sui -p sui -- client verify-bytecode-meter
    ```
    amnn committed Apr 4, 2024
    Configuration menu
    Copy the full SHA
    90628d9 View commit details
    Browse the repository at this point in the history