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

CIP-???? | On-Chain Parameter Application #934

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

keyan-m
Copy link

@keyan-m keyan-m commented Nov 6, 2024

We propose a new builtin Plutus function, builtinApplyParams, to reduce the costs and complexity of instantiating parameterized scripts on-chain.

A sample use-case for performing this computation on-chain would be enabling validation by a minting policy for the destinations of its tokens, ensuring that only instances of a specific script can be the recipients.

Without this builtin, apart from development complexities, script instances need to be limited to hashed parameters that must be resolved via the redeemer in each transaction, and therefore bloat the chain with duplicate data.


(latest version in branch)

@rphair rphair added Category: Plutus Proposals belonging to the 'Plutus' category. State: Triage Applied to new PR afer editor cleanup on GitHub, pending CIP meeting introduction. labels Nov 7, 2024
Copy link
Collaborator

@rphair rphair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @keyan-m - I've tagged for Triage to put it on the agenda for our next CIP meeting (https://hackmd.io/@cip-editors/100). @MicroProofs I hope you will also be with us this time to help introduce it & likewise @colll78 if you can make it.

CIP-param-application/README.md Show resolved Hide resolved
@keyan-m keyan-m changed the title CIP-???? | New Plutus Builtin builtinApplyParams CIP-???? | On-Chain Parameter Application Nov 10, 2024
@colll78
Copy link
Contributor

colll78 commented Nov 11, 2024

This proposed solution solves:

#354
#385

We propose the Plutus builtin function `builtinApplyParams`, with the following
type signature:
```hs
builtinApplyParams :: BuiltinByteString -> [BuiltinData] -> ScriptHash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you return a ScriptHash and not a BuiltinByteString? Besides this ScriptHash not being a plutus type, would it not be nice to return the applied CBOR, so that one can apply parameters over multiple transactions.


### Cost Model

TODO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what the impact here would be, since this suggested built-in is effectively running the plutus machinery inside an already running instance of it.

My intuition tells me that this is okay, since the complexity of this calculation is always bound by the complexity of any possible other script. But looking forward to more insight from @kwxm :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tagging @bezirg for his opinion

Also changed the output to be the script CBOR rather than its hash, as
suggested by Thomas. This will allow for partial application of the
arguments, and subsequently not being limited to performing the whole
computation in a single transaction.
Copy link
Contributor

@colll78 colll78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arguments changed to cborHex now allows SOP parameters to be applied.

@rphair
Copy link
Collaborator

rphair commented Nov 14, 2024

@kwxm we decided the last CIP meeting 2 days ago to wait as per #934 (comment) until you had gone over this to confirm feasibility & desirability of this change... once that's done we would confirm this as a candidate & assign a CIP number. (cc @keyan-m @bezirg @perturbing)

@rphair rphair added State: Unconfirmed Triaged at meeting but not confirmed (or assigned CIP number) yet. and removed State: Triage Applied to new PR afer editor cleanup on GitHub, pending CIP meeting introduction. labels Nov 26, 2024
@colll78
Copy link
Contributor

colll78 commented Dec 2, 2024

@kwxm we decided the last CIP meeting 2 days ago to wait as per #934 (comment) until you had gone over this to confirm feasibility & desirability of this change... once that's done we would confirm this as a candidate & assign a CIP number. (cc @keyan-m @bezirg @perturbing)

Costing should just be the sum of:

  1. the setup cost for the CEK machine with the script we want to apply arguments to
  2. the cost of one apply
  3. overhead?

I think the above can be fully ignored though, and the costing process can be identical the process used to bench any other external functional call (ie. validateSignature). Just run large amounts of tests to see the impact the input size has on CPU/MEM and determine a function that accurately models that data as closely as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Plutus Proposals belonging to the 'Plutus' category. State: Unconfirmed Triaged at meeting but not confirmed (or assigned CIP number) yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants