Skip to content

Commit 0dbd531

Browse files
committed
Merge branch 'master' into koz/secp256k1
2 parents f825469 + 3f3f875 commit 0dbd531

File tree

28 files changed

+185
-6
lines changed

28 files changed

+185
-6
lines changed

README.adoc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,44 @@ The main documentation is located https://plutus.readthedocs.io/en/latest/[here]
6464
- https://hydra.iohk.io/job/Cardano/plutus/linux.docs.papers.utxoma/latest/download-by-type/doc-pdf/utxoma[UTXOma: UTXO with Multi-Asset Support]: a full presentation of the multi-asset ledger extension (https://doi.org/10.1007/978-3-030-61467-6_8[published version]).
6565
- https://hydra.iohk.io/job/Cardano/plutus/linux.docs.papers.eutxoma/latest/download-by-type/doc-pdf/eutxoma[Native Custom Tokens in the Extended UTXO Model]: a discussion of the interaction of the multi-asset support with EUTXO (https://doi.org/10.1007/978-3-030-61467-6_7[published version]).
6666

67+
== Versioning and releases
68+
69+
=== Versioning
70+
71+
The core `plutus` packages are versioned as follows:
72+
73+
* Package versioning follows the https://pvp.haskell.org/[PVP] on a best-effort basis (i.e. we will generally try to but we won't guarantee it).
74+
** The first-major-version component indicates the "era" which for our purposes means which major version of the *Cardano node* is being targeted.
75+
** The second-major-version component is used for releases which are major versions according to the PVP, but which are still compatible with the current "era".
76+
** The minor-version and below are used as normal.
77+
* Packages which are used downstream should all have the same version.
78+
* Other packages which are not used downstream (e.g. `plutus-benchmark`) can remain unversioned.
79+
80+
In principle we could just have a single major version, but using two makes it easier to avoid mistakes.
81+
82+
=== Branching and tagging
83+
84+
The following branching and tagging rules are followed:
85+
86+
* Version `X` is tagged as `vX`.
87+
* `master` is always targeting the next first-major-version.
88+
* First-major-version releases also have a release branch, `release/X`.
89+
** Changes will be backported from master to the release branch
90+
** Subsequent lesser releases will be made from that branch but do not create new branches.
91+
92+
=== Version ranges
93+
94+
Packages which depend on `plutus` packages should use version ranges to control which version of those packages they build against.
95+
96+
* Packages in `plutus` which are used downstream should pin the major-version of each other (e.g. `plutus-tx-1.0.1` should depend on `plutus-core ^>= 1.0`).
97+
* Downstream packages should pin at least the first-major-version of `plutus` packages.
98+
** Upgrading to a new second-major-version should always be safe, with at most code breakage (following the PVP). Users may of course want to pin this version as well to avoid such breakage.
99+
* Downstream packages pulling in `plutus` packages via `source-repository-package` stanzas should always take tagged commits, or potentially commits from a release branch.
100+
101+
=== Releases
102+
103+
Currently there is no release process beyond bumping the package versions and making a tag/branch as appropriate.
104+
67105
== Working with the project
68106

69107
=== How to submit an issue

doc/reference/builtin-parameters.csv

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ decodeUtf8,decodeUtf8-memory-arguments-slope,Linear model coefficient for the me
3535
divideInteger,divideInteger-cpu-arguments-constant,Constant CPU cost (argument sizes above diagonal)
3636
divideInteger,divideInteger-cpu-arguments-model-arguments-intercept,Linear model intercept for the CPU calculation (argument sizes on or below diagonal)
3737
divideInteger,divideInteger-cpu-arguments-model-arguments-slope,Linear model coefficient for the CPU calculation (argument sizes on or below diagonal)
38-
divideInteger,divideInteger-memory-arguments-intercept,Linear model intercept for the memory calculation (argument sizes on or below diagonal)
38+
divideInteger,divideInteger-memory-arguments-intercept,Linear model intercept for the memory calculation (argument sizes on or below diagonal)
3939
divideInteger,divideInteger-memory-arguments-minimum,Constant memory cost (argument sizes above diagonal)
4040
divideInteger,divideInteger-memory-arguments-slope,Linear model coefficient for the memory calculation (argument sizes on or below diagonal)
4141
encodeUtf8,encodeUtf8-cpu-arguments-intercept,Linear model intercept for the CPU calculation below diagonal
@@ -98,7 +98,7 @@ modInteger,modInteger-cpu-arguments-model-arguments-slope,Linear model coefficie
9898
modInteger,modInteger-memory-arguments-intercept,Linear model intercept for the memory calculation
9999
modInteger,modInteger-memory-arguments-minimum,Constant memory cost (argument sizes above diagonal)
100100
modInteger,modInteger-memory-arguments-slope,Linear model coefficient for the memory calculation (argument sizes on or below diagonal)
101-
multiplyInteger,multiplyInteger-cpu-arguments-intercept,Linear model intercept for the CPU calculation
101+
multiplyInteger,multiplyInteger-cpu-arguments-intercept,Linear model intercept for the CPU calculation
102102
multiplyInteger,multiplyInteger-cpu-arguments-slope,Linear model coefficient for the CPU calculation
103103
multiplyInteger,multiplyInteger-memory-arguments-intercept,Linear model intercept for the memory calculation
104104
multiplyInteger,multiplyInteger-memory-arguments-slope,Linear model coefficient for the memory calculation
@@ -116,6 +116,10 @@ remainderInteger,remainderInteger-cpu-arguments-model-arguments-slope,Linear mod
116116
remainderInteger,remainderInteger-memory-arguments-intercept,Linear model intercept for the memory calculation (argument sizes on or below diagonal)
117117
remainderInteger,remainderInteger-memory-arguments-minimum,Constant memory cost (argument sizes above diagonal)
118118
remainderInteger,remainderInteger-memory-arguments-slope,Linear model coefficient for the memory calculation (argument sizes on or below diagonal)
119+
serialiseData,serialiseData-cpu-arguments-intercept,TODO
120+
serialiseData,serialiseData-cpu-arguments-slope,TODO
121+
serialiseData,serialiseData-memory-arguments-intercept,TODO
122+
serialiseData,serialiseData-memory-arguments-slope,TODO
119123
sha2_256,sha2_256-cpu-arguments-intercept,Linear model intercept for the CPU calculation
120124
sha2_256,sha2_256-cpu-arguments-slope,Linear model coefficient for the CPU calculation
121125
sha2_256,sha2_256-memory-arguments,Constant memory cost

plutus-core/cost-model/budgeting-bench/Benchmarks/Data.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ benchEqualsData =
126126
where args1 = dataSampleForEq -- 400 elements: should take about 35 minutes to benchmark
127127
args2 = fmap copyData args1
128128

129+
benchSerialiseData :: Benchmark
130+
benchSerialiseData =
131+
createOneTermBuiltinBench SerialiseData [] args
132+
where args = dataSampleForEq -- FIXME: is this a good sample for serialization?
129133

130134
makeBenchmarks :: StdGen -> [Benchmark]
131135
makeBenchmarks gen =
@@ -141,4 +145,5 @@ makeBenchmarks gen =
141145
, benchUnIData
142146
, benchUnBData
143147
, benchEqualsData
148+
, benchSerialiseData
144149
]

plutus-core/cost-model/create-cost-model/CostModelCreation.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ builtinCostModelNames = BuiltinCostModelBase
9595
, paramMkPairData = "mkPairDataModel"
9696
, paramMkNilData = "mkNilDataModel"
9797
, paramMkNilPairData = "mkNilPairDataModel"
98+
, paramSerialiseData = "serialiseDataModel"
9899
}
99100

100101

@@ -175,6 +176,7 @@ createBuiltinCostModel =
175176
paramUnIData <- getParams unIData paramUnIData
176177
paramUnBData <- getParams unBData paramUnBData
177178
paramEqualsData <- getParams equalsData paramEqualsData
179+
paramSerialiseData <- getParams serialiseData paramSerialiseData
178180
-- Misc constructors
179181
paramMkPairData <- getParams mkPairData paramMkPairData
180182
paramMkNilData <- getParams mkNilData paramMkNilData
@@ -676,6 +678,14 @@ equalsData cpuModelR = do
676678
worst case it may have to examine almost all of the smaller argument before
677679
realising that the two arguments are different. -}
678680

681+
serialiseData :: MonadR m => (SomeSEXP (Region m)) -> m (CostingFun ModelOneArgument)
682+
serialiseData cpuModelR = do
683+
-- FIXME: add cpumodel for serialisedata
684+
cpuModel <- ModelOneArgumentLinearCost <$> readModelLinearInX cpuModelR
685+
-- FIXME: add memmodel for serialisedata
686+
let memModel = ModelOneArgumentLinearCost $ ModelLinearSize 0 0
687+
pure $ CostingFun cpuModel memModel
688+
679689
---------------- Misc constructors ----------------
680690

681691
mkPairData :: MonadR m => (SomeSEXP (Region m)) -> m (CostingFun ModelTwoArguments)

plutus-core/cost-model/data/builtinCostModel.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,22 @@
389389
"type": "constant_cost"
390390
}
391391
},
392+
"serialiseData": {
393+
"memory": {
394+
"arguments": {
395+
"slope": 0,
396+
"intercept": 0
397+
},
398+
"type": "linear_cost"
399+
},
400+
"cpu": {
401+
"arguments": {
402+
"slope": 0,
403+
"intercept": 0
404+
},
405+
"type": "linear_cost"
406+
}
407+
},
392408
"addInteger": {
393409
"memory": {
394410
"arguments": {

plutus-core/cost-model/data/models.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ arity <- function(name) {
7777
"AppendString" = 2,
7878
"EqualsString" = 2,
7979
"EncodeUtf8" = 1,
80+
"SerialiseData" = 1,
8081
"DecodeUtf8" = 1,
8182
"IfThenElse" = 3,
8283
"ChooseUnit" = 2,
@@ -550,6 +551,12 @@ modelFun <- function(path) {
550551
adjustModel(m2,fname)
551552
}
552553

554+
serialiseDataModel <- {
555+
fname <- "SerialiseData"
556+
#FIXME
557+
}
558+
559+
553560
mkPairDataModel <- constantModel ("MkPairData")
554561
mkNilDataModel <- constantModel ("MkNilData")
555562
mkNilPairDataModel <- constantModel ("MkNilPairData")
@@ -605,6 +612,7 @@ modelFun <- function(path) {
605612
equalsDataModel = equalsDataModel,
606613
mkPairDataModel = mkPairDataModel,
607614
mkNilDataModel = mkNilDataModel,
608-
mkNilPairDataModel = mkNilPairDataModel
615+
mkNilPairDataModel = mkNilPairDataModel,
616+
serialiseDataModel = serialiseDataModel
609617
)
610618
}

plutus-core/cost-model/test/TestCostModels.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ main =
345345
, $(genTest 1 "unIData")
346346
, $(genTest 1 "unBData")
347347
, $(genTest 2 "equalsData") Everywhere
348+
, $(genTest 1 "serialiseData")
348349

349350
-- Misc constructors
350351
, $(genTest 2 "mkPairData") Everywhere

plutus-core/plutus-core/src/PlutusCore/Default/Builtins.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ import PlutusCore.Evaluation.Machine.ExMemory
2323
import PlutusCore.Evaluation.Result
2424
import PlutusCore.Pretty
2525

26+
import Codec.Serialise (serialise)
2627
import Crypto (verifyEcdsaSecp256k1Signature, verifySchnorrSecp256k1Signature, verifySignature)
2728
import Data.ByteString qualified as BS
2829
import Data.ByteString.Hash qualified as Hash
30+
import Data.ByteString.Lazy qualified as BS (toStrict)
2931
import Data.Char
3032
import Data.Ix
3133
import Data.Text (Text)
@@ -104,6 +106,7 @@ data DefaultFun
104106
| UnIData
105107
| UnBData
106108
| EqualsData
109+
| SerialiseData
107110
-- Misc constructors
108111
-- Constructors that we need for constructing e.g. Data. Polymorphic builtin
109112
-- constructors are often problematic (See note [Representable built-in
@@ -982,6 +985,10 @@ instance uni ~ DefaultUni => ToBuiltinMeaning uni DefaultFun where
982985
makeBuiltinMeaning
983986
((==) @Data)
984987
(runCostingFunTwoArguments . paramEqualsData)
988+
toBuiltinMeaning SerialiseData =
989+
makeBuiltinMeaning
990+
(BS.toStrict . serialise @Data)
991+
(runCostingFunOneArgument . paramSerialiseData)
985992
-- Misc constructors
986993
toBuiltinMeaning MkPairData =
987994
makeBuiltinMeaning
@@ -1073,10 +1080,10 @@ instance Flat DefaultFun where
10731080
UnIData -> 45
10741081
UnBData -> 46
10751082
EqualsData -> 47
1076-
10771083
MkPairData -> 48
10781084
MkNilData -> 49
10791085
MkNilPairData -> 50
1086+
SerialiseData -> 51
10801087

10811088
decode = go =<< decodeBuiltin
10821089
where go 0 = pure AddInteger
@@ -1130,6 +1137,7 @@ instance Flat DefaultFun where
11301137
go 48 = pure MkPairData
11311138
go 49 = pure MkNilData
11321139
go 50 = pure MkNilPairData
1140+
go 51 = pure SerialiseData
11331141
go 52 = pure VerifyEcdsaSecp256k1Signature
11341142
go 53 = pure VerifySchnorrSecp256k1Signature
11351143
go t = fail $ "Failed to decode builtin tag, got: " ++ show t

plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/BuiltinCostModel.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ data BuiltinCostModelBase f =
153153
, paramMkPairData :: f ModelTwoArguments
154154
, paramMkNilData :: f ModelOneArgument
155155
, paramMkNilPairData :: f ModelOneArgument
156+
, paramSerialiseData :: f ModelOneArgument
156157
}
157158
deriving stock (Generic)
158159
deriving anyclass (FunctorB, TraversableB, ConstraintsB)

plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/ExBudgetingDefaults.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,5 @@ unitCostBuiltinCostModel = BuiltinCostModelBase
163163
, paramMkPairData = unitCostTwoArguments
164164
, paramMkNilData = unitCostOneArgument
165165
, paramMkNilPairData = unitCostOneArgument
166+
, paramSerialiseData = unitCostOneArgument
166167
}

0 commit comments

Comments
 (0)