Skip to content

Refactor delta proof generation code #262

Description

@murisi

@heueristik brought up the following points while reviewing #235 :

  1. Reduce the number of fuzzed variables. Constrain them only at the beginning of tests and don’t reset/replace/overwrite them in deeper levels of the test.
  2. Split delta generation code from tests into a separate contract (and later into a library containing only internal pure functions). The delta generation library code can check inputs and throw custom errors but can not contain fuzzing variable constraints.
  3. Remove the dependency of the delta proof generation code on vm (tests can and should still use vm)
    1. Move vm.assume(...) and bound(...) statements to the beginning of the fuzzing tests and deduplicate them. If they repeat, encapsulate them into functions with a meaningful names.
    2. Try to use elliptic curve library functions instead of vm.createWallet or vm.sign. Note that we can bring more functions from import {EllipticCurve} from "@elliptic-curve-solidity/contracts/EllipticCurve.sol"; into library EllipticCurveK256 if this is needed.
  4. Encapsulate repeated test code into functions.
  5. Rework the instance struct and replace int256 quantity by uint128 quantity and bool consumed
    • This should also simplify the transformations that need to be done

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions