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

Tx simulate plutus v3 #997

Merged
merged 25 commits into from
Aug 14, 2024
Merged

Tx simulate plutus v3 #997

merged 25 commits into from
Aug 14, 2024

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Aug 7, 2024

  • 📍 Move script context e2e tests under a nested 'v2' directory.
    And rework scripts to run them in anticipation of new v3 contexts.

  • 📍 Upgrade pallas to v0.0.29, and start support for simulating transactions carrying Plutus v3 scripts.

  • 📍 Further remove todos for v3, and reduce duplication in transaction evaluation

  • 📍 Fix Plutus v3 validator hash calculation in blueprint.

  • 📍 Actually decode Conway transaction in 'aiken tx simulate'

  • 📍 implement a strict subset of PlutusV3 transaction info
    More specifically, that is simply mimicking the script context from
    v2, minus the new governance features.

  • 📍 define UPLC machine default cost models for Plutus V3.

  • 📍 Fix ToPlutusData serializer for V3
    This is intense, as we still want to preserve the serializer for V1 &
    V2, and I've tried as much as possible to avoid polluting the
    application layer with many enum types such as:

    pub enum TxOut {
      V1(TransactionOutput),
      V2(TransactionOutput),
      V3(TransactionOutput),
    }
    

    Those types make working with the script context cumbersome, and are
    only truly required to provide different serialisation strategies. So
    instead, we keep one top-level TxInfo V1/V2/V3 type, and we ensure
    to pass serialization strategies as type wrappers.

    This way, the strategy propagates through the structure up until it's
    eliminated when it reaches the relevant types.

    All-in-all, this strikes a correct balance between maintainability and
    repetition; and it makes it possible to define different but mostly
    identical
    encoders for the various versions.

    With it, I've been able to successfully encode a V3 script context and
    match it against one produced using the Haskell libraries. More to
    come.

  • 📍 Write down first e2e script context test for v3.

  • 📍 Rename function variable in parser
    Better reflect its actual semantic. The name probably slipped through a wrong copy pasting.

  • 📍 Improve / fix machine and uplc error reporting.

  • 📍 Support multi-validator in script context accept test.

  • 📍 test 'mint' purpose and script context creation.
    Alongside a bunch of other stuff from the coverage list. In
    particular, the mint transaction contains:

    • reference inputs
    • multiple outputs, with assets, and type-0, type-1 and type-6
      addresses.
    • an output with a datum hash
    • an output with an inline script
    • carries an extra datum witness, preimage of the embedded hash
    • mint, with 2 policies purposely ordered wrongly, with 1 and 2
      assets purposely ordered wrong. One of the mint is actually a
      burn (i.e. negative quantity)

@KtorZ KtorZ force-pushed the tx-simulate-plutus-v3 branch 3 times, most recently from bbd9516 to 81c0152 Compare August 10, 2024 14:07
@KtorZ KtorZ self-assigned this Aug 12, 2024
  And rework scripts to run them in anticipation of new v3 contexts.
  More specifically, that is simply mimicking the script context from
  v2, minus the new governance features.
  This is intense, as we still want to preserve the serializer for V1 &
  V2, and I've tried as much as possible to avoid polluting the
  application layer with many enum types such as:

  ```
  pub enum TxOut {
    V1(TransactionOutput),
    V2(TransactionOutput),
    V3(TransactionOutput),
  }
  ```

  Those types make working with the script context cumbersome, and are
  only truly required to provide different serialisation strategies. So
  instead, we keep one top-level `TxInfo V1/V2/V3` type, and we ensure
  to pass serialization strategies as type wrappers.

  This way, the strategy propagates through the structure up until it's
  eliminated when it reaches the relevant types.

  All-in-all, this strikes a correct balance between maintainability and
  repetition; and it makes it possible to define _different but mostly
  identical_ encoders for the various versions.

  With it, I've been able to successfully encode a V3 script context and
  match it against one produced using the Haskell libraries. More to
  come.
  Better reflect its actual semantic. The name probably slipped through a wrong copy pasting.
  Alongside a bunch of other stuff from the coverage list. In
  particular, the mint transaction contains:

  - reference inputs
  - multiple outputs, with assets, and type-0, type-1 and type-6
    addresses.
  - an output with a datum hash
  - an output with an inline script
  - carries an extra datum witness, preimage of the embedded hash
  - mint, with 2 policies purposely ordered wrongly, with 1 and 2
    assets purposely ordered wrong. One of the mint is actually a
    burn (i.e. negative quantity)
  This covers every proposal procedures but protocol parameters, this
  one is yet to be done. It spans over 30+ fields, and felt like it is a
  big enough piece to tackle it on its own.
  We can now simulate transactions with protocol parameters voting
  procedures. Cost models remain to be done, though.
  There were some odd discrepancy for `integerToByteString` on the mem
  side. Either 1 or about 1000 mem units off; which I couldn't quite
  figure out. Yet, it proves useful to validate builtin at large and
  ensure we have a valid cost model for v3.
…teger

  As well as fixing a couple of other issues thanks to conformance
  tests. Some functions like multiply_integer or verify_ed25519_signature
  have also slightly changed their costing function.
@KtorZ KtorZ merged commit 32e6705 into main Aug 14, 2024
11 of 12 checks passed
@KtorZ KtorZ deleted the tx-simulate-plutus-v3 branch August 14, 2024 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ In Next Release
Development

Successfully merging this pull request may close these issues.

1 participant