Skip to content

Commit

Permalink
Update hard fork names had Haddock (#6427)
Browse files Browse the repository at this point in the history
  • Loading branch information
zliu41 authored Aug 21, 2024
1 parent d3e4252 commit 3a5a162
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 53 deletions.
27 changes: 14 additions & 13 deletions plutus-ledger-api/src/PlutusLedgerApi/Common/ProtocolVersions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module PlutusLedgerApi.Common.ProtocolVersions
, alonzoPV
, vasilPV
, valentinePV
, conwayPV
, conwayPlus1PV
, changPV
, changPlus1PV
, knownPVs
, futurePV
) where
Expand Down Expand Up @@ -55,22 +55,23 @@ maryPV = MajorProtocolVersion 4
alonzoPV :: MajorProtocolVersion
alonzoPV = MajorProtocolVersion 5

-- | Vasil era was introduced in protocol version 7.0
-- | The Vasil HF introduced the Babbage era and Plutus V2
vasilPV :: MajorProtocolVersion
vasilPV = MajorProtocolVersion 7

-- | Protocol version 8.0 was the Valentine intra-era HF
-- | Valentine was an intra-era HF where builtin functions @VerifyEcdsaSecp256k1Signature@ and
-- @VerifySchnorrSecp256k1Signature@ were enabled.
valentinePV :: MajorProtocolVersion
valentinePV = MajorProtocolVersion 8

-- | Conway era was introduced in protocol version 9.0
conwayPV :: MajorProtocolVersion
conwayPV = MajorProtocolVersion 9
-- | The Chang HF introduced the Conway era and Plutus V3
changPV :: MajorProtocolVersion
changPV = 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 Chang+1 HF will be an intra-era HF where some new builtin functions
-- are introduced in Plutus V2 and V3.
changPlus1PV :: MajorProtocolVersion
changPlus1PV = MajorProtocolVersion 10

-- | The set of protocol versions that are "known", i.e. that have been released
-- and have actual differences associated with them.
Expand All @@ -83,8 +84,8 @@ knownPVs =
, alonzoPV
, vasilPV
, valentinePV
, conwayPV
, conwayPlus1PV
, changPV
, changPlus1PV
]

-- | This is a placeholder for when we don't yet know what protocol version will
Expand Down
8 changes: 4 additions & 4 deletions plutus-ledger-api/src/PlutusLedgerApi/Common/Versions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ builtinsIntroducedIn = Map.fromList [
((PlutusV2, valentinePV), Set.fromList [
VerifyEcdsaSecp256k1Signature, VerifySchnorrSecp256k1Signature
]),
((PlutusV2, conwayPlus1PV), Set.fromList [
((PlutusV2, changPlus1PV), Set.fromList [
IntegerToByteString, ByteStringToInteger
]),
((PlutusV3, conwayPV), Set.fromList [
((PlutusV3, changPV), Set.fromList [
Bls12_381_G1_add, Bls12_381_G1_neg, Bls12_381_G1_scalarMul,
Bls12_381_G1_equal, Bls12_381_G1_hashToGroup,
Bls12_381_G1_compress, Bls12_381_G1_uncompress,
Expand All @@ -137,7 +137,7 @@ See Note [New builtins/language versions and protocol versions]
plcVersionsIntroducedIn :: Map.Map (PlutusLedgerLanguage, MajorProtocolVersion) (Set.Set Version)
plcVersionsIntroducedIn = Map.fromList [
((PlutusV1, alonzoPV), Set.fromList [ plcVersion100 ]),
((PlutusV3, conwayPV), Set.fromList [ plcVersion110 ])
((PlutusV3, changPV), Set.fromList [ plcVersion110 ])
]

{-| Query the protocol version that a specific Plutus ledger language was first introduced in.
Expand All @@ -146,7 +146,7 @@ ledgerLanguageIntroducedIn :: PlutusLedgerLanguage -> MajorProtocolVersion
ledgerLanguageIntroducedIn = \case
PlutusV1 -> alonzoPV
PlutusV2 -> vasilPV
PlutusV3 -> conwayPV
PlutusV3 -> changPV

{-| Which Plutus language versions are available in the given 'MajorProtocolVersion'?
Expand Down
4 changes: 2 additions & 2 deletions plutus-ledger-api/src/PlutusLedgerApi/V1/EvaluationContext.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module PlutusLedgerApi.V1.EvaluationContext
) where

import PlutusLedgerApi.Common
import PlutusLedgerApi.Common.Versions (conwayPV)
import PlutusLedgerApi.Common.Versions (changPV)
import PlutusLedgerApi.V1.ParamName as V1

import PlutusCore.Default (BuiltinSemanticsVariant (DefaultFunSemanticsVariantA, DefaultFunSemanticsVariantB))
Expand Down Expand Up @@ -41,6 +41,6 @@ mkEvaluationContext =
PlutusV1
[DefaultFunSemanticsVariantA, DefaultFunSemanticsVariantB]
-- See Note [Mapping of protocol versions and ledger languages to semantics variants].
(\pv -> if pv < conwayPV
(\pv -> if pv < changPV
then DefaultFunSemanticsVariantA
else DefaultFunSemanticsVariantB)
4 changes: 2 additions & 2 deletions plutus-ledger-api/src/PlutusLedgerApi/V2/EvaluationContext.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module PlutusLedgerApi.V2.EvaluationContext
) where

import PlutusLedgerApi.Common
import PlutusLedgerApi.Common.Versions (conwayPV)
import PlutusLedgerApi.Common.Versions (changPV)
import PlutusLedgerApi.V2.ParamName as V2

import PlutusCore.Default (BuiltinSemanticsVariant (DefaultFunSemanticsVariantA, DefaultFunSemanticsVariantB))
Expand Down Expand Up @@ -41,6 +41,6 @@ mkEvaluationContext =
PlutusV2
[DefaultFunSemanticsVariantA, DefaultFunSemanticsVariantB]
-- See Note [Mapping of protocol versions and ledger languages to semantics variants].
(\pv -> if pv < conwayPV
(\pv -> if pv < changPV
then DefaultFunSemanticsVariantA
else DefaultFunSemanticsVariantB)
4 changes: 2 additions & 2 deletions plutus-ledger-api/test-plugin/Spec/ReturnUnit/V1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ expectSuccess name code arg = testCase name $ case res of
Right _ -> pure ()
where
sScript = serialiseCompiledCode code
script = either (error . show) id $ V1.deserialiseScript conwayPV sScript
(_, res) = V1.evaluateScriptCounting conwayPV V1.Quiet evalCtx script [arg]
script = either (error . show) id $ V1.deserialiseScript changPV sScript
(_, res) = V1.evaluateScriptCounting changPV V1.Quiet evalCtx script [arg]

good :: CompiledCode (BuiltinData -> BuiltinUnit)
good =
Expand Down
4 changes: 2 additions & 2 deletions plutus-ledger-api/test-plugin/Spec/ReturnUnit/V2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ expectSuccess name code arg = testCase name $ case res of
Right _ -> pure ()
where
sScript = serialiseCompiledCode code
script = either (error . show) id $ V2.deserialiseScript conwayPV sScript
(_, res) = V2.evaluateScriptCounting conwayPV V2.Quiet evalCtx script [arg]
script = either (error . show) id $ V2.deserialiseScript changPV sScript
(_, res) = V2.evaluateScriptCounting changPV V2.Quiet evalCtx script [arg]

good :: CompiledCode (BuiltinData -> BuiltinUnit)
good =
Expand Down
8 changes: 4 additions & 4 deletions plutus-ledger-api/test-plugin/Spec/ReturnUnit/V3.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ expectSuccess name code arg = testCase name $ case res of
Right _ -> pure ()
where
sScript = serialiseCompiledCode code
script = either (error . show) id $ V3.deserialiseScript conwayPV sScript
(_, res) = V3.evaluateScriptCounting conwayPV V3.Quiet evalCtx script arg
script = either (error . show) id $ V3.deserialiseScript changPV sScript
(_, res) = V3.evaluateScriptCounting changPV V3.Quiet evalCtx script arg

expectFailure ::
forall a.
Expand All @@ -68,8 +68,8 @@ expectFailure name code arg = testCase name $ case res of
Right _ -> assertFailure "evaluation succeeded"
where
sScript = serialiseCompiledCode code
script = either (error . show) id $ V3.deserialiseScript conwayPV sScript
(_, res) = V3.evaluateScriptCounting conwayPV V3.Quiet evalCtx script arg
script = either (error . show) id $ V3.deserialiseScript changPV sScript
(_, res) = V3.evaluateScriptCounting changPV V3.Quiet evalCtx script arg

good :: CompiledCode (BuiltinData -> BuiltinUnit)
good =
Expand Down
4 changes: 2 additions & 2 deletions plutus-ledger-api/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ availableBuiltins = testCase "builtins are available after Alonzo" $

integerToByteStringExceedsBudget :: TestTree
integerToByteStringExceedsBudget = testCase "integerToByteString should exceed budget" $
let script = either (error . show) id $ V3.deserialiseScript conwayPV integerToByteStringFunction
(_, res) = V3.evaluateScriptCounting conwayPV V3.Quiet v3_evalCtxTooFewParams script (I 1)
let script = either (error . show) id $ V3.deserialiseScript changPV integerToByteStringFunction
(_, res) = V3.evaluateScriptCounting changPV V3.Quiet v3_evalCtxTooFewParams script (I 1)
in case res of
Left _ -> assertFailure "fails"
Right (ExBudget cpu _mem) -> assertBool "did not exceed budget" (cpu >= fromIntegral (maxBound :: Int64))
Expand Down
20 changes: 10 additions & 10 deletions plutus-ledger-api/test/Spec/Data/Versions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ testLedgerLanguages :: TestTree
testLedgerLanguages = testGroup "ledger languages"
[ testProperty "v1 not before but after" $ prop_notBeforeButAfter V1.deserialiseScript alonzoPV
, testProperty "v2 not before but after" $ prop_notBeforeButAfter V2.deserialiseScript vasilPV
, testProperty "v3 not before but after" $ prop_notBeforeButAfter V3.deserialiseScript conwayPV
, testProperty "v3 not before but after" $ prop_notBeforeButAfter V3.deserialiseScript changPV
, testProperty "protocol-versions can add but not remove ledger languages" $
\pvA pvB -> pvA < pvB ==> ledgerLanguagesAvailableIn pvA `Set.isSubsetOf` ledgerLanguagesAvailableIn pvB
]
Expand Down Expand Up @@ -90,13 +90,13 @@ testRmdr = testGroup "rmdr"
[ testCase "remdr" $ do
assertBool "remdr1" $ isRight $ V1.deserialiseScript valentinePV $ errorScript <> "remdr1"
assertBool "remdr2" $ isRight $ V2.deserialiseScript valentinePV $ errorScript <> "remdr2"
assertBool "remdr1c" $ isRight $ V1.deserialiseScript conwayPV $ errorScript <> "remdr1"
assertBool "remdr2c" $ isRight $ V2.deserialiseScript conwayPV $ errorScript <> "remdr2"
assertEqual "remdr3" (RemainderError "remdr3") $ fromLeft (Prelude.error "Expected Reft, got Right") $ V3.deserialiseScript conwayPV $ errorScript <> "remdr3"
assertBool "remdr1c" $ isRight $ V1.deserialiseScript changPV $ errorScript <> "remdr1"
assertBool "remdr2c" $ isRight $ V2.deserialiseScript changPV $ errorScript <> "remdr2"
assertEqual "remdr3" (RemainderError "remdr3") $ fromLeft (Prelude.error "Expected Reft, got Right") $ V3.deserialiseScript changPV $ errorScript <> "remdr3"
, testProperty "remdr1gen"$ \remdr -> isRight $ V1.deserialiseScript valentinePV $ errorScript <> BSS.pack remdr
, testProperty "remdr2gen"$ \remdr -> isRight $ V2.deserialiseScript valentinePV $ errorScript <> BSS.pack remdr
, testProperty "remdr1genc"$ \remdr -> isRight $ V1.deserialiseScript conwayPV $ errorScript <> BSS.pack remdr
, testProperty "remdr2genc"$ \remdr -> isRight $ V2.deserialiseScript conwayPV $ errorScript <> BSS.pack remdr
, testProperty "remdr1genc"$ \remdr -> isRight $ V1.deserialiseScript changPV $ errorScript <> BSS.pack remdr
, testProperty "remdr2genc"$ \remdr -> isRight $ V2.deserialiseScript changPV $ errorScript <> BSS.pack remdr
-- we cannot make the same property as above for remdr3gen because it may generate valid bytestring append extensions to the original script
-- a more sophisticated one could work though
]
Expand All @@ -108,12 +108,12 @@ testLanguageVersions = testGroup "Plutus Core language versions"
-- `LedgerLanguageNotAvailableError` is checked in `deserialiseScript`
assertBool "in l3,Vasil" $ isLeft $ uplcToScriptForEvaluation PlutusV3 vasilPV v110script
-- `PlutusCoreLanguageNotAvailableError` is checked in `mkTermToEvaluate`
assertBool "in l2,future" $ isLeft $ mkTermToEvaluate PlutusV2 conwayPV (either (Prelude.error . show) id (V2.deserialiseScript conwayPV $ serialiseUPLC v110script)) []
assertBool "in l2,future" $ isLeft $ mkTermToEvaluate PlutusV2 changPV (either (Prelude.error . show) id (V2.deserialiseScript changPV $ serialiseUPLC v110script)) []
-- Both `deserialiseScript` and `mkTermToEvaluate` should succeed
assertBool "not in l3,future" $ isRight $ mkTermToEvaluate PlutusV3 conwayPV (either (Prelude.error . show) id (V3.deserialiseScript conwayPV $ serialiseUPLC v110script)) []
assertBool "not in l3,future" $ isRight $ mkTermToEvaluate PlutusV3 changPV (either (Prelude.error . show) id (V3.deserialiseScript changPV $ serialiseUPLC v110script)) []
-- The availability of `case` and `constr` is checked in `deserialise`
, testCase "constr is not available with v1.0.0 ever" $ assertBool "in l3,future" $ isLeft $ uplcToScriptForEvaluation PlutusV3 conwayPV badConstrScript
, testCase "case is not available with v1.0.0 ever" $ assertBool "in l3,future" $ isLeft $ uplcToScriptForEvaluation PlutusV3 conwayPV badCaseScript
, testCase "constr is not available with v1.0.0 ever" $ assertBool "in l3,future" $ isLeft $ uplcToScriptForEvaluation PlutusV3 changPV badConstrScript
, testCase "case is not available with v1.0.0 ever" $ assertBool "in l3,future" $ isLeft $ uplcToScriptForEvaluation PlutusV3 changPV badCaseScript
]

-- * UPLC written examples to test
Expand Down
4 changes: 2 additions & 2 deletions plutus-ledger-api/test/Spec/ScriptDecodeError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Spec.ScriptDecodeError where
import Codec.Extras.SerialiseViaFlat (DeserialiseFailureInfo (..), DeserialiseFailureReason (..))
import PlutusCore.Version (plcVersion100)
import PlutusLedgerApi.Common (ScriptDecodeError (..))
import PlutusLedgerApi.Common.Versions (PlutusLedgerLanguage (..), conwayPV, vasilPV)
import PlutusLedgerApi.Common.Versions (PlutusLedgerLanguage (..), changPV, vasilPV)
import Prettyprinter (Pretty (pretty))
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (Assertion, testCase, (@?=))
Expand Down Expand Up @@ -56,7 +56,7 @@ prettyLedgerLanguageNotAvailableError =
err =
LedgerLanguageNotAvailableError
{ sdeAffectedLang = PlutusV2
, sdeIntroPv = conwayPV
, sdeIntroPv = changPV
, sdeThisPv = vasilPV
}

Expand Down
20 changes: 10 additions & 10 deletions plutus-ledger-api/test/Spec/Versions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ testLedgerLanguages :: TestTree
testLedgerLanguages = testGroup "ledger languages"
[ testProperty "v1 not before but after" $ prop_notBeforeButAfter V1.deserialiseScript alonzoPV
, testProperty "v2 not before but after" $ prop_notBeforeButAfter V2.deserialiseScript vasilPV
, testProperty "v3 not before but after" $ prop_notBeforeButAfter V3.deserialiseScript conwayPV
, testProperty "v3 not before but after" $ prop_notBeforeButAfter V3.deserialiseScript changPV
, testProperty "protocol-versions can add but not remove ledger languages" $
\pvA pvB -> pvA < pvB ==> ledgerLanguagesAvailableIn pvA `Set.isSubsetOf` ledgerLanguagesAvailableIn pvB
]
Expand Down Expand Up @@ -90,13 +90,13 @@ testRmdr = testGroup "rmdr"
[ testCase "remdr" $ do
assertBool "remdr1" $ isRight $ V1.deserialiseScript valentinePV $ errorScript <> "remdr1"
assertBool "remdr2" $ isRight $ V2.deserialiseScript valentinePV $ errorScript <> "remdr2"
assertBool "remdr1c" $ isRight $ V1.deserialiseScript conwayPV $ errorScript <> "remdr1"
assertBool "remdr2c" $ isRight $ V2.deserialiseScript conwayPV $ errorScript <> "remdr2"
assertEqual "remdr3" (RemainderError "remdr3") $ fromLeft (Prelude.error "Expected Reft, got Right") $ V3.deserialiseScript conwayPV $ errorScript <> "remdr3"
assertBool "remdr1c" $ isRight $ V1.deserialiseScript changPV $ errorScript <> "remdr1"
assertBool "remdr2c" $ isRight $ V2.deserialiseScript changPV $ errorScript <> "remdr2"
assertEqual "remdr3" (RemainderError "remdr3") $ fromLeft (Prelude.error "Expected Reft, got Right") $ V3.deserialiseScript changPV $ errorScript <> "remdr3"
, testProperty "remdr1gen"$ \remdr -> isRight $ V1.deserialiseScript valentinePV $ errorScript <> BSS.pack remdr
, testProperty "remdr2gen"$ \remdr -> isRight $ V2.deserialiseScript valentinePV $ errorScript <> BSS.pack remdr
, testProperty "remdr1genc"$ \remdr -> isRight $ V1.deserialiseScript conwayPV $ errorScript <> BSS.pack remdr
, testProperty "remdr2genc"$ \remdr -> isRight $ V2.deserialiseScript conwayPV $ errorScript <> BSS.pack remdr
, testProperty "remdr1genc"$ \remdr -> isRight $ V1.deserialiseScript changPV $ errorScript <> BSS.pack remdr
, testProperty "remdr2genc"$ \remdr -> isRight $ V2.deserialiseScript changPV $ errorScript <> BSS.pack remdr
-- we cannot make the same property as above for remdr3gen because it may generate valid bytestring append extensions to the original script
-- a more sophisticated one could work though
]
Expand All @@ -108,12 +108,12 @@ testLanguageVersions = testGroup "Plutus Core language versions"
-- `LedgerLanguageNotAvailableError` is checked in `deserialiseScript`
assertBool "in l3,Vasil" $ isLeft $ uplcToScriptForEvaluation PlutusV3 vasilPV v110script
-- `PlutusCoreLanguageNotAvailableError` is checked in `mkTermToEvaluate`
assertBool "in l2,future" $ isLeft $ mkTermToEvaluate PlutusV2 conwayPV (either (Prelude.error . show) id (V2.deserialiseScript conwayPV $ serialiseUPLC v110script)) []
assertBool "in l2,future" $ isLeft $ mkTermToEvaluate PlutusV2 changPV (either (Prelude.error . show) id (V2.deserialiseScript changPV $ serialiseUPLC v110script)) []
-- Both `deserialiseScript` and `mkTermToEvaluate` should succeed
assertBool "not in l3,future" $ isRight $ mkTermToEvaluate PlutusV3 conwayPV (either (Prelude.error . show) id (V3.deserialiseScript conwayPV $ serialiseUPLC v110script)) []
assertBool "not in l3,future" $ isRight $ mkTermToEvaluate PlutusV3 changPV (either (Prelude.error . show) id (V3.deserialiseScript changPV $ serialiseUPLC v110script)) []
-- The availability of `case` and `constr` is checked in `deserialise`
, testCase "constr is not available with v1.0.0 ever" $ assertBool "in l3,future" $ isLeft $ uplcToScriptForEvaluation PlutusV3 conwayPV badConstrScript
, testCase "case is not available with v1.0.0 ever" $ assertBool "in l3,future" $ isLeft $ uplcToScriptForEvaluation PlutusV3 conwayPV badCaseScript
, testCase "constr is not available with v1.0.0 ever" $ assertBool "in l3,future" $ isLeft $ uplcToScriptForEvaluation PlutusV3 changPV badConstrScript
, testCase "case is not available with v1.0.0 ever" $ assertBool "in l3,future" $ isLeft $ uplcToScriptForEvaluation PlutusV3 changPV badCaseScript
]

-- * UPLC written examples to test
Expand Down

1 comment on commit 3a5a162

@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: 3a5a162 Previous: d3e4252 Ratio
validation-decode-pubkey-1 182.5 μs 168.8 μs 1.08

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

CC: @IntersectMBO/plutus-core

Please sign in to comment.