Commit Graph

618 Commits

Author SHA1 Message Date
Kasey
d5f8d3ab78 Cost model fixes with tests (#1030)
* Finish V1 corrections and fixes to initialize cost model

* Finish V2 corrections to be inline with mainnet today
2024-09-29 22:55:18 -04:00
microproofs
3d77b5c378 chore: Release 2024-09-20 14:05:15 -04:00
microproofs
e8cf43d7ec Format fix 2024-09-20 13:52:09 -04:00
microproofs
eb37ed0da5 Clippy fix 2024-09-20 13:47:56 -04:00
microproofs
4f1de2d3b5 Add test for flat error when encoding bls constant 2024-09-20 13:41:58 -04:00
microproofs
fa2aa0a3e8 When we find bls constants in UPLC convert them to their a hoisted compressed form with an uncompress call 2024-09-20 12:31:36 -04:00
Matthias Benkort
7155b4e45d Merge pull request #1023 from solidsnakedev/main
Add wrap constructor to V1/V2 StakeCredential
2024-09-20 14:47:08 +02:00
microproofs
43182721f5 Update PlutusV1 cost model 2024-09-19 10:36:36 -04:00
microproofs
b50fa91d4c Finish updating v2 models 2024-09-18 12:06:36 -04:00
microproofs
b26e16e319 Start updating v2 cost models 2024-09-18 12:06:36 -04:00
solidsnakedev
75b5332288 fix: Add wrap constructor to V1/V2 stake_credential when Purpose is Rewarding 2024-09-17 19:45:39 -06:00
microproofs
7047c7720e chore: Release 2024-09-13 16:52:20 -04:00
KtorZ
8a3bbfc89a Simplify optional datum extraction by removing duplication 2024-09-12 17:19:17 +02:00
solidsnakedev
defce9be4e fix: Plutus V3 NoDatum - Error: missing required inline datum or datum hash in script input 2024-09-11 15:25:20 -06:00
KtorZ
0905146140 chore: Release 2024-09-10 13:25:04 +02:00
rvcas
be31a7ce38 chore: Release 2024-09-03 17:01:41 -04:00
rvcas
20ac89fc33 chore: reset version 2024-09-03 17:01:24 -04:00
KtorZ
53af366b59 Ensure uniqueness of intermediate variables in expect_type_assign
For recursive structures like Tuples, the span itself isn't enough to
  ensure uniqueness of elements (in particular tuples) holding elements
  of the same type.
2024-09-01 18:10:15 +02:00
KtorZ
cd0a9440e8 Allow any expression as constants
This is only a start. It compiles, but with a few TODOs left open. In particular, it doesn't currently handle constants depending on other constants or functions; nor does it hoist constants.
2024-08-29 16:24:12 +02:00
KtorZ
c21466831c Bump versions to 1.1.0, in anticipation. 2024-08-29 09:12:37 +02:00
KtorZ
d74e36d0bc Introduce 'Never' type as a safe alternative to always None options
Unfortunately, as documented in:

  https://github.com/IntersectMBO/cardano-ledger/issues/4571

  Some Option fields in the script context certificates are going to
  remain set to None, at least until the next Hard fork. There's a risk
  that people permanently lock their funds if they expect deposits on
  registration credentials to ever be `Some`.

  So, we introduce a special type that emulate an `Option` that can only
  ever be `None`. We call it `Never` and it is the first type of this
  kind (i.e. with constructors indexes not starting at 0).
2024-08-27 14:40:39 +02:00
KtorZ
af9a785d65 Provide default annotation to validators (incl. fallback)
Without that, we may encounter weird error messages when writing
  validators without an explicit `else`. Since we automatically fill it
  with a `fail`; without annotation, it unifies to a generic parameter.

  The existing check that would look for the body being an error term is
  ill-advised as it doesn't work as soon as one adds tracing, or make
  the validator a parameterized validator. Plus, it may simply trigger
  the wrong behavior as one can now annotate a validator with _whatever_
  and get pass the type-checker by plucking a `fail` keyword as body.
2024-08-25 17:12:11 +02:00
KtorZ
0c9ea196be Format uplc crate 2024-08-25 16:20:45 +02:00
KtorZ
5943d94c6c Finish re-working machine errors display. 2024-08-25 16:20:06 +02:00
rvcas
e174532bfd chore: add more redacted values to machine errors 2024-08-25 16:20:05 +02:00
KtorZ
823492c27b Adjust v3 script context end-to-end tests to work with new syntax. 2024-08-25 16:20:04 +02:00
jmhrpr
c98e32d3e9 optional costmodel in eval p2 raw 2024-08-24 18:28:08 +02:00
KtorZ
8dfaa1bf90 Fix parsing of v3 cost model
Closes #1002.
2024-08-24 18:26:37 +02:00
KtorZ
9aa9070f56 Revise desugaring following feedback
- We now consistently desugar an expect in the last position as
    `Void`. Regardless of the pattern. Desugaring to a boolean value is
    deemed too confusing.

  - This commit also removes the desugaring for let-binding. It's only
    ever allowed for _expect_ which then behaves like a side effect.

  - We also now allow tests to return either `Bool` or `Void`. A test
    that returns `Void` is treated the same as a test returning `True`.
2024-08-23 16:04:40 +02:00
KtorZ
0f905045e7 Rename mk_nil_data, mk_pair_data & mk_nil_pair_data builtins. 2024-08-23 10:39:37 +02:00
KtorZ
42784965d2 Implement new costing function for {divide,quotient,mod,remainder}_integer
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.
2024-08-14 02:50:05 +02:00
KtorZ
2cb87f4f8f Add PlutusV3 conformance tests and also control budgets
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.
2024-08-14 02:42:04 +02:00
KtorZ
f879f6d183 Fix script context translations for withdrawals and validity intervals. 2024-08-13 23:43:47 +02:00
KtorZ
7501538053 Add script context translations for voting purpose. 2024-08-13 16:24:01 +02:00
KtorZ
bfc93bf076 Add script context translation for new Conway certificates 2024-08-13 10:56:29 +02:00
KtorZ
f244b9c496 Add support for protocol parameters (except cost models)
We can now simulate transactions with protocol parameters voting
  procedures. Cost models remain to be done, though.
2024-08-13 10:56:29 +02:00
KtorZ
cfca0da4e9 Add (partial) support for simulating contract with proposal procedures
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.
2024-08-13 10:56:29 +02:00
KtorZ
6b6bace8a5 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)
2024-08-13 10:56:29 +02:00
KtorZ
eea8dc7d0a Support multi-validator in script context accept test. 2024-08-13 10:56:28 +02:00
KtorZ
b158469144 Improve / fix machine and uplc error reporting. 2024-08-13 10:56:28 +02:00
KtorZ
62b1b932f9 Write down first e2e script context test for v3. 2024-08-13 10:56:28 +02:00
KtorZ
821f7bd8c7 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.
2024-08-13 10:55:23 +02:00
KtorZ
f848bad3f2 define UPLC machine default cost models for Plutus V3. 2024-08-13 10:55:23 +02:00
KtorZ
fdf7a81288 implement a strict subset of PlutusV3 transaction info
More specifically, that is simply mimicking the script context from
  v2, minus the new governance features.
2024-08-13 10:55:23 +02:00
KtorZ
c454dc72eb Actually decode Conway transaction in 'aiken tx simulate' 2024-08-13 10:55:22 +02:00
KtorZ
508d88035b Fix Plutus v3 validator hash calculation in blueprint. 2024-08-13 10:55:22 +02:00
KtorZ
445ffc483d Further remove todos for v3, and reduce duplication in transaction evaluation 2024-08-13 10:55:22 +02:00
KtorZ
ff4a480242 Upgrade pallas to v0.0.29, and start support for simulating transactions carrying Plutus v3 scripts. 2024-08-13 10:55:22 +02:00
microproofs
6fd9b34b92 Running examples as doc tests is not gonna work 2024-08-08 00:39:44 -04:00
microproofs
53c461294b Fix example that was throwing an error 2024-08-08 00:39:44 -04:00