Commit Graph

73 Commits

Author SHA1 Message Date
KtorZ
961e323c36 Enable iterating over validator's parameters with a callback
This is how we'll construct parameters interactively. We need to lookup the definition, and provide a data representation for it.
2023-08-19 13:39:39 -04:00
microproofs
90c7753201 update tests for new recursion optmization 2023-08-07 19:00:39 -04:00
microproofs
36c80f36c1 fix tests 2023-08-07 12:02:44 -04:00
rvcas
8a7df7f66b test: add empty list test 2023-07-04 17:19:29 -04:00
microproofs
db369da96e feat: Make traces produced by expect dependent on
the value of the tracing flag.
2023-06-23 14:03:23 -04:00
rvcas
cf6d04e95b chore: some clippy warnings 2023-06-02 19:47:52 -04:00
rvcas
9c29f4f26b fix: blueprints gen failing on List
closes #569

* added new methods to Definitions
  it doesn't use expect
* lookup was failing for the special map/pair case
  when resolving list generics

Co-authored-by: Pi <pi@sundaeswap.finance>
2023-06-02 17:53:10 -04:00
microproofs
b36cf1c029 chore: refactor default functions in uplc_code_gen.
feat: Add an identity optimization to remove functions that return the argument only.
2023-05-08 16:15:09 -04:00
microproofs
0d0c96deda commit validator changes and tests 2023-04-28 17:05:46 -04:00
microproofs
b050018a37 test fix: blueprint change 2023-04-25 02:06:56 -04:00
microproofs
9bb1a88f23 fix: expect [] on a non-empty list now fails. 2023-04-21 17:39:21 -04:00
microproofs
c2ee631d07 feat: new setup for the gen_uplc testing
* new test only module aiken_project::tests
* move TestProject to tests/mod.rs
* new tests go in gen_uplc.rs
2023-04-19 16:08:55 -04:00
microproofs
23a7e7e680 chore: convert acceptance test 5
Also constructors with no fields are now converted to a constant data term.
2023-04-19 16:08:55 -04:00
microproofs
022d557906 chore: convert acceptance test 4 2023-04-19 16:08:55 -04:00
microproofs
7da3ac2c99 chore: convert acceptance test 3 2023-04-19 16:08:55 -04:00
microproofs
7dd13f8d73 feat: add end to end tests to replace acceptance tests with strict uplc comparison.
Add acceptance tests 1,2, 6 as end to end tests
2023-04-19 16:08:55 -04:00
Kasey White
02d57cc076 tests pass now after adding in final wrapper as air elements 2023-04-09 17:43:56 -04:00
Kasey White
9e95e24624 now tests are passing 2023-04-09 17:43:56 -04:00
Kasey White
4d97719e6d update blueprint tests with new hashes and script outputs 2023-04-09 17:43:56 -04:00
Kasey White
abd97f0ade changed assert_on_list from being defined at uplc level to being defined at air level to enable proper hoisting 2023-04-09 17:43:56 -04:00
KtorZ
4799af3242 Rework 'blueprint apply' command and wrap up wiring up validation.
The apply command now works only from a serialized CBOR data (instead of a UPLC syntax). So it is no longer possible to specify arbitrary cbor terms through the CLI. I believe it to be an acceptable limitation for now; especially given that Aiken will never generate blueprints with non-data terms at the interface boundary.
2023-04-08 08:57:40 +02:00
KtorZ
d58ef1a079 Implement blueprint schema & data validations. 2023-04-08 08:57:03 +02:00
KtorZ
ee220881b6 Generalize schema definition to work from inline schema or reference. 2023-04-08 08:57:03 +02:00
KtorZ
d620f6367c Bootstrap schema validation for simple constants. 2023-04-08 08:57:03 +02:00
KtorZ
cdc7ebf9a0 Remove now-unnecessary blueprint generics.
These were needed before as a way to _partially deserialize_
  blueprints. Indeed, some commands required accessing information of
  the blueprint, but not necessarily the schema. So out of laziness (or
  cleverness?), we only deserialized validators as serde::Value and
  achieved that through the use of generics.

  Now that validators and schemas have proper deserialisers, we can
  simply deserialize a blueprint.

  TODO: Our serialisation/deserialisation is safe with regards to
  itself; i.e. it roundtrips. However, we only supports a subset of the
  specified blueprint format. For example, we would fail to deserialize
  blueprints that have inline data-schemas (we only use references).
2023-04-08 08:53:51 +02:00
rvcas
3e6f688e2d feat: refactor some methods and modules
* move uplc::ast::builder to uplc::builder
* rename aiken_lang::uplc to aiken_lang::gen_uplc
* move aiken_lang::air and aiken_lang::builder to aiken_lang::gen_uplc
  as submodules

Co-authored-by: Kasey White <kwhitemsg@gmail.com>
2023-03-27 20:00:32 -04:00
KtorZ
bc690c5410 Generated wrapped schemas for multi-validators' redeemers 2023-03-17 18:40:49 -04:00
Kasey White
bb6fc76971 start on registering redeemer wrapper type in definitions 2023-03-17 18:40:49 -04:00
KtorZ
7e1403a3b2 Complete generation of blueprint multi-validators. 2023-03-17 18:40:49 -04:00
Kasey White
fe92b27d50 start on refactoring validator to support multi-validators in blueprint 2023-03-17 18:40:49 -04:00
KtorZ
61113cd7b9 distinguish between multi vs single validator case in blueprint schema generation. 2023-03-17 18:40:48 -04:00
rvcas
c3870e340e feat(codegen): support multi-validators
* rename force_wrap to force
* add a bunch of builder methods to Term<Name>
* refactor one tiny location to show off builder methods
* split generate into `generate` and `generate_test`
* create wrap_as_multi_validator function

Co-authored-by: Kasey White <kwhitemsg@gmail.com>
2023-03-17 18:40:44 -04:00
rvcas
ed92869fb9 feat(validator): parsing and typechecking for double validators 2023-03-17 18:38:24 -04:00
KtorZ
ae981403c6 Re-introduce field title & description in referenced schemas. 2023-03-12 12:44:49 -04:00
KtorZ
451737237e Fix blueprint generation for recursive types.
This was a bit tricky and I ended up breaking things down a lot and
  trying different path. This commit is the result of the most
  satisfying one.

  It introduces a new 'concept' and types: Definitions and Reference.
  These elements are meant to reflect JSON pointers and JSON-schema
  definitions which we now use for pretty much all user-defined
  data-types.

  In fact, Schemas are no longer inlined, but are always referencing
  some schema under "definitions".

  This indirection is necessary in order to cope with recursive types.
  And while it's only truly necessary for recursive types, using it
  consistently makes it both easier to produce and easier to consume.

  ---

  The blueprint generation for recursive types here also works thanks to
  the 'Definitions' data-structure wrapper around a BTreeMap. This uses
  a strategy where:

  (1) schemas are only generated if they haven't been seen before
  (2) schemas are marked as seen BEFORE actually being generated (to
  effectively stop a recursive generation).

  This relies on one important aspect: the key must be uniquely
  identifying a given schema. Which means that we have to monomorphize
  data-types with generic parameters also here, and use keys that are
  specialized in one data-type.

  ---

  In this large overhaul we've also lost one thing which I didn't bother
  re-introducing yet to keep the work manageable: title for record
  fields. Before, we use to pull those from record constructor when
  available, yet now, every record constructor has been replaced by a
  `$ref`. We could theoritically attach a title to the reference. I'll
  try to quickly add that in a later commit.
2023-03-12 12:44:49 -04:00
KtorZ
e44f18bae5 Add failing test scenario for recursive types. 2023-03-12 12:44:49 -04:00
KtorZ
a66c9bd2c3 Remove redundant match on tuple blueprint generation. 2023-03-08 16:40:03 +01:00
KtorZ
6d098a4571 Fix blueprint generation for nested fields with Data
Having the data's schema be optional at the level of the 'Schema' did not allow to represent cases where there would be an opaque data at an arbitrary nesting. So I introduced a new variant 'Opaque' on 'Data' to fill that gap.
2023-03-02 15:25:17 -05:00
rvcas
a40f88b918 fix: test never used Foo 2023-03-02 15:25:17 -05:00
KtorZ
65c336cb82 Update blueprint outputs to reflect latest specification.
Schemas of datums, redeemers and parameters are now nested under a field 'schema'. This allows to define a field 'purpose' at the same level.
2023-03-02 17:17:27 +01:00
KtorZ
70cdf3cb26 Add 'exported_data' test and revert 413a056 2023-03-02 16:09:08 +01:00
KtorZ
82a32a082b Remove 'purpose' from blueprint's schema.
This has been removed from the CIP-0057 specification since validators
  are often re-used for multiple purposes (especially validators with
  arity 2). It's misleading to assign a validator a purpose since the
  purpose distinction actually happens _within_ the validator itself.
2023-02-21 15:30:41 +01:00
KtorZ
db0dfbbec1 Fix blueprint schema for tuples. 2023-02-21 15:29:33 +01:00
rvcas
815d7d80c6 feat(lsp): hover and goto definition 2023-02-20 15:30:25 -05:00
KtorZ
e9e3f4f50a Implement TraceIfFalse type-checking and AST transformation.
This caused me some trouble. In my first approach, I ended up having
  multiple traces because nested values would be evaluated twice; once
  as condition, and once as part of the continuation.

  To prevent this, we can simply evaluate the condition once, and return
  plain True / False boolean as outcome. So this effectively transforms any
  expression:

  ```
  expr
  ```

  as

  ```
  if expr { True } else { trace("...", False) }
  ```
2023-02-16 20:29:41 -05:00
rvcas
2e78b7100c fix: blueprint tests 2023-02-16 00:05:55 -05:00
rvcas
673b57b81c feat: get bluprint stuff compiling again 2023-02-16 00:05:55 -05:00
Kasey White
ddef61a855 fix: blueprint tests 2023-02-10 19:45:44 -05:00
rvcas
fd14da0720 chore: fix blueprint tests 2023-02-09 00:09:23 -05:00
KtorZ
95a62f7172 Fix oversights in blueprint / schema generation. 2023-02-08 19:04:50 +01:00