Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
}
],
"submission": {
"date": "2026-07-08T07:23:46Z",
"date": "2026-07-08T14:14:37Z",
"source_available": true,
"source_repository": "https://github.com/Unisay/plinth-cape-submissions",
"source_commit_hash": "f9ef6bdf4ed08ec16039600903d8af7e6c22046b",
"implementation_notes": "Two-party escrow validator written in `do`-notation on `Plinth.Validator`, a zero-cost early-termination monad, together with the zero-cost typed decoding DSL `Plinth.Decoder.Named`. `QualifiedDo` keeps `V.do` (decode-or-abort stages) beside `N.do` (Named walk regions); `IxDecoder` tracks the walk cursor in the type via a Peano-indexed fundep class (`FieldAt`), so each `ScriptContext`/datum field is decoded with a single `Constr` walk, and a value that is only compared is never structurally decoded (`Plinth.Encoded`). Retains the escrow security hardening: the escrow input is tied to the script's own payment credential, and the incomplete-withdrawal guard compares the payment credential only (ignoring the staking part). Re-optimised for CAPE metrics schema 2.0.0, whose aggregates cover only the happy-path (accept) measurements. total_fee 311093 to 101588 lovelace (-67.3%); promoted to the default artifact for this line, with the previous asdata implementation retained as Plinth_1.65.0.0_Unisay_asdata. Source: lib/TwoPartyEscrow.hs (+ `lib/Plinth/Validator.hs`, `lib/Plinth/Decoder/Named.hs`, `lib/Plinth/Decoder/Named/ScriptContext.hs`, `lib/Plinth/Encoded.hs`) in plinth-cape-submissions @ f9ef6bdf4ed08ec16039600903d8af7e6c22046b (branch main)."
"source_commit_hash": "d078652f03d31ed728c1fb63f1d9f8824218494c",
"implementation_notes": "Two-party escrow validator written in `do`-notation on `Plinth.Validator`, a zero-cost early-termination monad, together with the zero-cost typed decoding DSL `Plinth.Decoder.Named` (`V.do`/`N.do` via `QualifiedDo`; `IxDecoder`/`FieldAt` Peano-indexed cursor; `Plinth.Encoded` compare-without-decode). Retains the escrow security hardening: the escrow input is tied to the script's own payment credential, and the incomplete-withdrawal guard compares the payment credential only (ignoring the staking part). This round further cuts the accept path: it compares the compile-time script credential instead of locating the own input by out-ref, fuses the withdrawal scan into the seller-payment fold, shares one `TxInfo` spine walk across inputs/outputs/signatories, reads lovelace positionally with `adaOf` instead of an assetAmount key lookup, and locates the single deposit output with `findUniqueE` in one pass. total_fee 101588 to 73594 lovelace (-27.6%, CAPE changPV measurement). The previous asdata implementation stays as Plinth_1.65.0.0_Unisay_asdata. Source: lib/TwoPartyEscrow.hs (+ `lib/Plinth/Validator.hs`, `lib/Plinth/Decoder/Named.hs`, `lib/Plinth/Decoder/Named/ScriptContext.hs`, `lib/Plinth/Encoded.hs`) in plinth-cape-submissions @ d078652f03d31ed728c1fb63f1d9f8824218494c (branch main)."
}
}
145 changes: 72 additions & 73 deletions submissions/two_party_escrow/Plinth_1.65.0.0_Unisay/metrics.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
{
"evaluations": [
{
"cpu_units": 26183226,
"cpu_units": 17262689,
"description": "Deposit with buyer signature and exactly 75 ADA should succeed",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 69411,
"memory_units": 47483,
"name": "deposit_successful"
},
{
"cpu_units": 36885524,
"cpu_units": 21066127,
"description": "Accept with seller signature and 75 ADA to seller should succeed",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 91434,
"memory_units": 53810,
"name": "accept_successful"
},
{
"cpu_units": 36885524,
"cpu_units": 21066127,
"description": "Accept with multiple script inputs (ambiguous state - expects pass)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 91434,
"memory_units": 53810,
"name": "accept_with_multiple_inputs"
},
{
"cpu_units": 36885524,
"cpu_units": 21066127,
"description": "Accept with datum attached to seller's payment (expects pass)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 91434,
"memory_units": 53810,
"name": "accept_with_datum_attached"
},
{
"cpu_units": 48602311,
"cpu_units": 26875359,
"description": "Accept with payment split across two outputs to seller (50+25 ADA - expects pass)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 115264,
"memory_units": 63556,
"name": "accept_with_multiple_outputs_to_seller"
},
{
"cpu_units": 32280683,
"cpu_units": 23276107,
"description": "Refund after deadline with buyer signature should succeed",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 83118,
"memory_units": 63126,
"name": "refund_successful"
},
{
"cpu_units": 32280683,
"cpu_units": 23276107,
"description": "Refund exactly 1 second after deadline expiry should succeed",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 83118,
"memory_units": 63126,
"name": "refund_after_exact_deadline"
},
{
"cpu_units": 32280683,
"cpu_units": 23276107,
"description": "Refund with multiple script inputs should succeed (no single input validation)",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 83118,
"memory_units": 63126,
"name": "refund_with_multiple_inputs"
},
{
"cpu_units": 32280683,
"cpu_units": 23276107,
"description": "Refund with datum attached to buyer's output should succeed",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 83118,
"memory_units": 63126,
"name": "refund_with_datum_attached"
},
{
"cpu_units": 41114658,
"cpu_units": 27559794,
"description": "Refund split across two outputs to buyer (50+25 ADA) should succeed",
"execution_result": "success",
"included_in_aggregates": true,
"memory_units": 101758,
"memory_units": 71470,
"name": "refund_with_multiple_outputs_to_buyer"
},
{
Expand Down Expand Up @@ -153,83 +153,83 @@
"name": "simple_builtin_data_redeemer_0"
},
{
"cpu_units": 7669457,
"cpu_units": 7568249,
"description": "Deposit without buyer signature should fail",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 21099,
"memory_units": 21097,
"name": "deposit_without_buyer_signature"
},
{
"cpu_units": 16949378,
"cpu_units": 9376709,
"description": "Deposit with buyer signature but wrong amount (50 ADA) should fail",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 41591,
"memory_units": 21194,
"name": "deposit_with_incorrect_amount"
},
{
"cpu_units": 8937714,
"cpu_units": 4024157,
"description": "Deposit fails when ADA goes to pubkey address instead of script",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 21165,
"memory_units": 1032,
"name": "deposit_to_wrong_address"
},
{
"cpu_units": 9521521,
"cpu_units": 6486992,
"description": "Accept operation fails when seller signature is missing",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 21805,
"memory_units": 21227,
"name": "accept_without_seller_signature"
},
{
"cpu_units": 47002311,
"cpu_units": 23659359,
"description": "Accept operation fails with wrong payment amount (50 ADA instead of 75 ADA)",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 105264,
"memory_units": 43456,
"name": "accept_with_incorrect_payment_amount"
},
{
"cpu_units": 1770967,
"cpu_units": 1687817,
"description": "Accept operation fails when payment goes to impostor address instead of seller",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 712,
"memory_units": 680,
"name": "accept_with_payment_to_wrong_address"
},
{
"cpu_units": 1770967,
"cpu_units": 1687817,
"description": "Accept operation without valid deposit UTXO (should fail - invalid escrow state)",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 712,
"memory_units": 680,
"name": "accept_without_prior_deposit"
},
{
"cpu_units": 1770967,
"cpu_units": 1687817,
"description": "Accept with only 50 ADA payment to seller (insufficient - expects fail)",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 712,
"memory_units": 680,
"name": "accept_with_partial_payment_to_seller"
},
{
"cpu_units": 1770967,
"cpu_units": 1687817,
"description": "Accept with 100 ADA payment to seller (excess amount - expects fail due to exact validation)",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 712,
"memory_units": 680,
"name": "accept_with_excess_payment_to_seller"
},
{
"cpu_units": 1770967,
"cpu_units": 1687817,
"description": "Accept while leaving funds in script (should fail - incomplete withdrawal)",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 712,
"memory_units": 680,
"name": "accept_with_remaining_script_output"
},
{
Expand Down Expand Up @@ -337,11 +337,11 @@
"name": "refund_after_accept_should_fail"
},
{
"cpu_units": 2065832,
"cpu_units": 1982682,
"description": "Accept attempt after buyer has already refunded should fail (state validation)",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 778,
"memory_units": 746,
"name": "accept_after_refund_should_fail"
},
{
Expand All @@ -353,19 +353,19 @@
"name": "double_refund_should_fail"
},
{
"cpu_units": 2065832,
"cpu_units": 1982682,
"description": "Multiple accept attempts should fail (double spending prevention)",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 778,
"memory_units": 746,
"name": "double_accept_should_fail"
},
{
"cpu_units": 24325280,
"cpu_units": 15644743,
"description": "Deposit with no upper bound (+inf) should fail; the upper bound must be finite to record the deposit time safely",
"execution_result": "success",
"included_in_aggregates": false,
"memory_units": 62783,
"memory_units": 42355,
"name": "deposit_infinite_upper_bound"
},
{
Expand All @@ -381,43 +381,42 @@
"evaluator": "PlutusTx.Eval-1.45.0.0"
},
"measurements": {
"block_cpu_budget_pct": 0.1215057775,
"block_memory_budget_pct": 0.18590967741935485,
"block_cpu_budget_pct": 0.068899485,
"block_memory_budget_pct": 0.1152741935483871,
"cpu_units": {
"maximum": 48602311,
"median": 34583103,
"minimum": 26183226,
"sum": 355679499
"maximum": 27559794,
"median": 23276107,
"minimum": 17262689,
"sum": 228000651
},
"excluded": {
"count": 37,
"cpu_units": {
"maximum": 47002311,
"sum": 167625741
"maximum": 23659359,
"sum": 119398239
},
"memory_units": {
"maximum": 105264,
"sum": 331921
"maximum": 43456,
"sum": 208351
}
},
"execution_fee_lovelace": 77183,
"execution_fee_lovelace": 50854,
"memory_units": {
"maximum": 115264,
"median": 87276,
"minimum": 69411,
"sum": 893207
},
"reference_script_fee_lovelace": 24405,
"script_size_bytes": 1627,
"scripts_per_block": 537,
"scripts_per_tx": 121,
"term_size": 1188,
"total_fee_lovelace": 101588,
"tx_cpu_budget_pct": 0.48602311,
"tx_memory_budget_pct": 0.8233142857142858
"maximum": 71470,
"median": 63126,
"minimum": 47483,
"sum": 596443
},
"reference_script_fee_lovelace": 22740,
"script_size_bytes": 1516,
"scripts_per_block": 867,
"scripts_per_tx": 195,
"term_size": 1059,
"total_fee_lovelace": 73594,
"tx_cpu_budget_pct": 0.27559794,
"tx_memory_budget_pct": 0.5105000000000001
},
"scenario": "two_party_escrow",
"timestamp": "2026-07-08T07:23:46Z",
"version": "2.0.0",
"notes": "Generated using UPLC-CAPE measure tool"
"timestamp": "2026-07-08T14:20:29Z",
"version": "2.0.0"
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# two_party_escrow Plinth 1.65.0.0 source
# two_party_escrow Plinth 1.65.0.0 (monadic) source

**Repository**: <https://github.com/Unisay/plinth-cape-submissions>

**Branch**: `main`

**Commit**: `f9ef6bdf4ed08ec16039600903d8af7e6c22046b`
**Commit**: `d078652f03d31ed728c1fb63f1d9f8824218494c`

**Path**: `lib/TwoPartyEscrow.hs` (+ `lib/Plinth/Validator.hs`, `lib/Plinth/Decoder/Named.hs`, `lib/Plinth/Decoder/Named/ScriptContext.hs`, `lib/Plinth/Encoded.hs`)

Two-party escrow validator written in `do`-notation on `Plinth.Validator`, a zero-cost early-termination monad, together with the zero-cost typed decoding DSL `Plinth.Decoder.Named`. `QualifiedDo` keeps `V.do` (decode-or-abort stages) beside `N.do` (Named walk regions); `IxDecoder` tracks the walk cursor in the type via a Peano-indexed fundep class (`FieldAt`), so each `ScriptContext`/datum field is decoded with a single `Constr` walk, and a value that is only compared is never structurally decoded (`Plinth.Encoded`). Retains the escrow security hardening: the escrow input is tied to the script's own payment credential, and the incomplete-withdrawal guard compares the payment credential only (ignoring the staking part). Re-optimised for CAPE metrics schema 2.0.0 (happy-path aggregates only): total_fee 311093 to 101588 lovelace (-67.3%), promoted to the default for this line.
The monadic two-party escrow validator; see the submission `metadata.json` for the accept-path optimization list. This is the default artifact for the mainnet 1.65.0.0 line.

## Reproducing the compilation

```bash
git clone https://github.com/Unisay/plinth-cape-submissions
cd plinth-cape-submissions
git checkout f9ef6bdf4ed08ec16039600903d8af7e6c22046b
git checkout d078652f03d31ed728c1fb63f1d9f8824218494c
```

`CAPE_REPO` must point at the sibling UPLC-CAPE checkout (build aborts if unset); set it in `.envrc.local` (gitignored). Then:
`CAPE_REPO` must point at the sibling UPLC-CAPE checkout; the build aborts if the variable is unset. The recommended place is `.envrc.local` (gitignored), e.g.:

```sh
export CAPE_REPO="$HOME/src/UPLC-CAPE"
```

Then enter the dev shell and run the generator:

```bash
nix develop
cabal run plinth-submissions
```

The generator writes `$CAPE_REPO/submissions/two_party_escrow/Plinth_1.65.0.0_Unisay/two_party_escrow.uplc` (monadic is the default on `main`; the previous asdata implementation is retained as `Plinth_1.65.0.0_Unisay_asdata`).
Loading
Loading