PCP_costModels_KennethMacKenzie

The Plutus Core language, used for on-chain Cardano contract code, contains a large number of built-in functions (“builtins” for short) which provide capabilities such as integer arithmetic operations, cryptographic functions, operations on the data type, and bitwise operations on bytestrings. There care currently three Plutus ledger language versions (PlutusV1, PlutusV2, and PlutusV3) which differ in the interface between the Cardano ledger and on-chain scripts, but also in the built-in functions which are available. In the past it has not been possible to add new builtins to previous ledger language versions, which means that the builtins available in PlutusV1 are a strict subset of those available in PlutusV2, which are in turn a strict subset of those available in PlutusV3. This reduces the compatibilty of the different Plutus ledger language versions and complicates matters for smart contract developers.

Recent changes in the ledger code should enable us to relax this restriction and enable newer builtins in previous Plutus ledger language versions. As a trial run we propose to enable the integerToByteString and byteStringToInteger builtins (introduced in PlutusV3 at the Chang hard fork (protocol version 9.0)) in PlutusV2. The groundwork for this has already been laid in pull request #6056 in the Plutus GitHub repository, and the two extra builtins were enabled in principle at the Plomin hard fork at the end of January 2025. However they are currently unusable in practice because they effectively have infinite cost. In order to fully enable them it wiil be necessary to update the PlutusV2 field of the costModels protocol parameter. With this in mind we propose to append the following ten values to the end of the PlutusV2 field in a parameter update after the Plomin hard fork:

 1293828, ("integerToByteString-cpu-arguments-c0")
 28716,   ("integerToByteString-cpu-arguments-c1")
 63,      ("integerToByteString-cpu-arguments-c2")
 0,       ("integerToByteString-memory-arguments-intercept")
 1,       ("integerToByteString-memory-arguments-slope")

 1006041, ("byteStringToInteger-cpu-arguments-c0")
 43623,   ("byteStringToInteger-cpu-arguments-c1")
 251,     ("byteStringToInteger-cpu-arguments-c2")
 0,       ("byteStringToInteger-memory-arguments-intercept")
 1        ("byteStringToInteger-memory-arguments-slope")

Assuming that this experiment is successful (and we expect that it will be), we will carry out a larger update at a later date to enable all builtins in all Plutus ledger language versions. This will greatly increase the compatibility of the different versions, which will make things simpler both for Cardano contract developers and for Plutus Core maintainers.

@Joaquin There haven’t been any objections to this so I’ve filled out the template for an official proposal: see PCP_costModels_KennethMacKenzie - Google Docs.

The content is essentially the same as the first post above.