| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Protocol.CostModels
Description
Plutus cost models keyed by raw ledger language identifier. Unknown identifiers are retained. Parameter vectors preserve order and signed 64-bit costs; evaluator validity is a separate concern.
mkCostModel 0 [1, 2, 3] validates a three-parameter vector.
Synopsis
- data CostModel
- mkCostModel :: Word8 -> [Int64] -> Either Error CostModel
- languageId :: CostModel -> Word8
- costs :: CostModel -> [Int64]
- data CostModels
- empty :: CostModels
- fromList :: [CostModel] -> CostModels
- insert :: CostModel -> CostModels -> CostModels
- lookup :: Word8 -> CostModels -> Maybe CostModel
- toList :: CostModels -> [CostModel]
- encodeCostModelCbor :: CostModel -> ByteString
- decodeCostModelCbor :: Word8 -> ByteString -> Either Error CostModel
- encodeCbor :: CostModels -> ByteString
- encodeLanguageViews :: CostModels -> ByteString
- decodeCbor :: ByteString -> Either Error CostModels
Documentation
Raw ledger language id and ordered signed 64-bit costs. At most 2048 costs are supported. Construction does not establish evaluator validity.
Instances
| Show CostModel Source # | |
| Eq CostModel Source # | |
| Ord CostModel Source # | |
mkCostModel :: Word8 -> [Int64] -> Either Error CostModel Source #
Validate the native vector length bound. Unknown language ids are retained.
languageId :: CostModel -> Word8 Source #
Raw ledger language identifier from 0 through 255.
data CostModels Source #
One model per language id. Equality and ordering compare ascending entries.
Instances
| Show CostModels Source # | |
Defined in Cometa.Internal.CostModels Methods showsPrec :: Int -> CostModels -> ShowS # show :: CostModels -> String # showList :: [CostModels] -> ShowS # | |
| Eq CostModels Source # | |
Defined in Cometa.Internal.CostModels | |
| Ord CostModels Source # | |
Defined in Cometa.Internal.CostModels Methods compare :: CostModels -> CostModels -> Ordering # (<) :: CostModels -> CostModels -> Bool # (<=) :: CostModels -> CostModels -> Bool # (>) :: CostModels -> CostModels -> Bool # (>=) :: CostModels -> CostModels -> Bool # max :: CostModels -> CostModels -> CostModels # min :: CostModels -> CostModels -> CostModels # | |
empty :: CostModels Source #
No configured language models.
fromList :: [CostModel] -> CostModels Source #
Assemble models. Later models replace earlier models with the same language.
insert :: CostModel -> CostModels -> CostModels Source #
Replace the model for this language, preserving every other model.
lookup :: Word8 -> CostModels -> Maybe CostModel Source #
Find a model by raw language identifier, including unknown future languages.
toList :: CostModels -> [CostModel] Source #
Models in ascending language-id order.
encodeCostModelCbor :: CostModel -> ByteString Source #
Encode only the ordered cost array. The language is supplied by the enclosing ledger map and is deliberately absent from this encoding.
decodeCostModelCbor :: Word8 -> ByteString -> Either Error CostModel Source #
Decode one cost array for the supplied raw language id. Enforce signed 64-bit costs and the 2048-parameter bound; reject trailing data.
encodeCbor :: CostModels -> ByteString Source #
Encode a ledger map in ascending language-id order.
encodeLanguageViews :: CostModels -> ByteString Source #
Encode the script-integrity language-view map for known Plutus languages
V1 through V4 (identifiers 0 through 3). Unknown language identifiers are
omitted from the script-data commitment. Supply only languages
actually used by the transaction; this operation does not select them or
validate parameter counts for execution. V1 uses the historical bytestring
key and bytestring-wrapped indefinite cost array, after the other languages.
This encoding differs from the protocol parameter map returned by encodeCbor.
decodeCbor :: ByteString -> Either Error CostModels Source #
Decode exactly one map. Duplicate language keys are rejected;
indefinite maps and arrays are accepted. Invalid values return
InvalidProtocolCbor.