diff --git a/CIP-????/README.md b/CIP-????/README.md new file mode 100644 index 0000000000..73b85111f3 --- /dev/null +++ b/CIP-????/README.md @@ -0,0 +1,90 @@ +--- +CIP: ??? +Title: multi-arity uplc lambda node +Category: Plutus +Status: Proposed +Authors: + - Michele Nuzzi +Implementors: [] +Discussions: + - https://github.com/cardano-foundation/CIPs/pull/1043 +Created: 2025-06-02 +License: CC-BY-4.0 +--- + + + +## Abstract + +This CIP proposes a new node for an uplc tree. + +The node is intended to have the same effect of n consecutive lambda nodes for 1/n the cost. Improving contracts in all measurable metrics (size, cpu, memory) + +## Motivation: why is this CIP necessary? + + +Patterns like +```uplc +(lam a (lam b (lam c ))) +``` +are increasingly common in uplc contracts. + +These are not only used to represent functions with arity greater than 1, but also to destructure SoP enocded values, or to introduce multiple "letted" values in scope (witch in plutus v3 is done using a case/constr). + +## Specification + + +This CIP proposes the `func` node, which is encoded with arity n, intended to have the same effect as n consecutive lambda nodes. + +The new node should have tag `10` (in binary: `1010`). + +Once encountered, other 4 bits are expected indicating the arity of the function node. + +Because we already have the `lam` node to indicate a function with arity 1, and `delay` can be interpreted as arity 0, the 4 arity bits can specify arity between 2 and 17 inclusive on both sides. + +Encoding any arity greater than 17 will require at least 2 nodes, +for example arity 18 can be encoded as `(func 17 a b c ... (lam r ))`, +and arity 19 can be encoded as `(func 17 a b c ... (func 2 r s ))`. + +## Rationale: how does this CIP achieve its goals? + + +The proposal does not impact backward compatibility by choice. The original lambda nodes are left in plutus both for backward compatibility and to save 4 bits on arity 1 functions. + +## Path to Active + +Included in Plutus V4. + +### Acceptance Criteria + + +Included in Plutus V4. + +### Implementation Plan + +N/A + + + +## Copyright + + +This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode). +