plutus icon indicating copy to clipboard operation
plutus copied to clipboard

Add cardano open oracle protocol scripts for `plutus-benchmark`

Open SeungheonOh opened this issue 5 months ago • 1 comments

Implements Cardano Open Oracle Protocol scripts.

SeungheonOh avatar Jun 18 '25 18:06 SeungheonOh

PR Preview Action v1.6.2 :---: |

:rocket: View preview at
https://IntersectMBO.github.io/plutus/pr-preview/pr-7156/

|
Built to branch gh-pages at 2025-07-18 19:41 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

github-actions[bot] avatar Jun 18 '25 18:06 github-actions[bot]

The original scripts were V2 scripts; I replicated original script exactly for both ease of testing and following code

SeungheonOh avatar Jul 04 '25 15:07 SeungheonOh

The original scripts were V2 scripts;

It could be that we've improved something in V3 so I see no point in bringing something potentially sub-optimal.

I replicated original script exactly for both ease of testing and following code

Sorry, I don't understand how using V2 makes it easier to test or follow 🤷🏼‍♂️

Unisay avatar Jul 10 '25 12:07 Unisay

V2 makes comparison more effective in this case because of two reasons mainly:

  • Script context deconstruction cost can be differ between different plutus ledger api versions. For example, deconstructing script context in V1 context is often always more expensive than doing it for V2 even with data because they have a bunch of types like CurrencySymbol or PublicKeyHash wrapped in Constr 0. So when comparing costs between two implementations, it's better to keep ledger api version same for a pair comparison.
  • Secondly, It's much easier more so in this case because we have vendor provided generators for script contexts that will generate V2 script context. Having two script that shares same input ledger api format would be simple to do.

SeungheonOh avatar Jul 10 '25 13:07 SeungheonOh

  • Script context deconstruction cost can be differ between different plutus ledger api versions. For example, deconstructing script context in V1 context is often always more expensive than doing it for V2 even with data because they have a bunch of types like CurrencySymbol or PublicKeyHash wrapped in Constr 0. So when comparing costs between two implementations, it's better to keep ledger api version same for a pair comparison.

What is it you're comparing it against?

Unisay avatar Jul 10 '25 15:07 Unisay

The plutarch implementation: https://github.com/mlabs-haskell/cardano-open-oracle-protocol

SeungheonOh avatar Jul 10 '25 16:07 SeungheonOh

@zliu41 Do we want this comparison against plutarch to be inside of plutus-benchmark. If not, I'm just going to run it separately and report numbers here. Since Plutarch implementation won't change, we just need to run the numbers for plutarch scripts once

SeungheonOh avatar Jul 10 '25 16:07 SeungheonOh

@zliu41 Do we want this comparison against plutarch to be inside of plutus-benchmark. If not, I'm just going to run it separately and report numbers here. Since Plutarch implementation won't change, we just need to run the numbers for plutarch scripts once

I have a task to collect and write down such requirements, its in progress. For now I'd say it is enough to do a minimal thing, as we haven't agreed yet on what the maximal thing is going to be.

Unisay avatar Jul 11 '25 08:07 Unisay

@zliu41

Here are results from plutarch implementation:

authMpBurnApplied.flat
(con unit ())
CPU budget:    70_105_072
Memory budget: 196_783

authMpMintApplied.flat
(con unit ())
CPU budget:    430_521_147
Memory budget: 1_184_919

certMpBurnApplied.flat
An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: error
CPU budget:    1_229_697_221
Memory budget: 3_595_798

certMpMintApplied.flat
(con unit ())
CPU budget:    510_411_469
Memory budget: 1_457_063

fsMpBurnApplied.flat
An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: error
CPU budget:    474_651_914
Memory budget: 1_516_415

fsMpMintApplied.flat
An error has occurred:
The machine terminated because of an error, either from a built-in function or from an explicit use of 'error'.
Caused by: error
CPU budget:    768_545_412
Memory budget: 2_404_394

Some scripts fails, even though script context used here is provided by the plutarch implementation. I can research more if necessary, but I prefer not to since code there is archaic. In terms of result, Plinth implementation is 30~50% slower, but this is with current plinth implementation using slower plutus ledger api types that will deconstruct all fields at once.

SeungheonOh avatar Jul 22 '25 17:07 SeungheonOh