Skip to content

Commit

Permalink
Add integerToByteString and byteStringToInteger to PlutusV2 at PV10 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zliu41 authored May 20, 2024
1 parent 0d8149c commit 1529ef8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

### Added

- Primitives `integerToByteString` and `byteStringToInteger` are added to PlutusV2,
enabled at protocol version 10.
18 changes: 17 additions & 1 deletion plutus-ledger-api/src/PlutusLedgerApi/Common/ProtocolVersions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module PlutusLedgerApi.Common.ProtocolVersions
, vasilPV
, valentinePV
, conwayPV
, conwayPlus1PV
, knownPVs
, futurePV
) where
Expand Down Expand Up @@ -68,10 +69,25 @@ valentinePV = MajorProtocolVersion 8
conwayPV :: MajorProtocolVersion
conwayPV = MajorProtocolVersion 9

-- | The next HF after Conway. It doesn't yet have a name, and it's not
-- yet known whether it will be an intra-era HF or introduce a new era.
conwayPlus1PV :: MajorProtocolVersion
conwayPlus1PV = MajorProtocolVersion 10

-- | The set of protocol versions that are "known", i.e. that have been released
-- and have actual differences associated with them.
knownPVs :: Set.Set MajorProtocolVersion
knownPVs = Set.fromList [ shelleyPV, allegraPV, maryPV, alonzoPV, vasilPV, valentinePV, conwayPV ]
knownPVs =
Set.fromList
[ shelleyPV
, allegraPV
, maryPV
, alonzoPV
, vasilPV
, valentinePV
, conwayPV
, conwayPlus1PV
]

-- | This is a placeholder for when we don't yet know what protocol version will
-- be used for something. It's a very high protocol version that should never
Expand Down
12 changes: 7 additions & 5 deletions plutus-ledger-api/src/PlutusLedgerApi/Common/Versions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ instance Pretty PlutusLedgerLanguage where
pretty = viaShow

{-| A map indicating which builtin functions were introduced in which 'MajorProtocolVersion'.
Each builtin function should appear at most once.
This __must__ be updated when new builtins are added.
See Note [New builtins/language versions and protocol versions]
Expand All @@ -107,6 +106,9 @@ builtinsIntroducedIn = Map.fromList [
((PlutusV2, valentinePV), Set.fromList [
VerifyEcdsaSecp256k1Signature, VerifySchnorrSecp256k1Signature
]),
((PlutusV2, conwayPlus1PV), Set.fromList [
IntegerToByteString, ByteStringToInteger
]),
((PlutusV3, conwayPV), Set.fromList [
Bls12_381_G1_add, Bls12_381_G1_neg, Bls12_381_G1_scalarMul,
Bls12_381_G1_equal, Bls12_381_G1_hashToGroup,
Expand Down Expand Up @@ -173,10 +175,10 @@ and 'MajorProtocolVersion'?
See Note [New builtins/language versions and protocol versions]
-}
builtinsAvailableIn :: PlutusLedgerLanguage -> MajorProtocolVersion -> Set.Set DefaultFun
builtinsAvailableIn thisLv thisPv = fold $ Map.elems $
Map.takeWhileAntitone builtinAvailableIn builtinsIntroducedIn
builtinsAvailableIn thisLv thisPv = fold $
Map.filterWithKey (const . alreadyIntroduced) builtinsIntroducedIn
where
builtinAvailableIn :: (PlutusLedgerLanguage, MajorProtocolVersion) -> Bool
builtinAvailableIn (introducedInLv,introducedInPv) =
alreadyIntroduced :: (PlutusLedgerLanguage, MajorProtocolVersion) -> Bool
alreadyIntroduced (introducedInLv,introducedInPv) =
-- both should be satisfied
introducedInLv <= thisLv && introducedInPv <= thisPv

1 comment on commit 1529ef8

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Plutus Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 1529ef8 Previous: 0d8149c Ratio
validation-decode-stablecoin_1-6 171.2 μs 159.9 μs 1.07

This comment was automatically generated by workflow using github-action-benchmark.

CC: @input-output-hk/plutus-core

Please sign in to comment.