cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Documentation

data CostModel Source #

Raw ledger language id and ordered signed 64-bit costs. At most 2048 costs are supported. Construction does not establish evaluator validity.

Instances

Instances details
Show CostModel Source # 
Instance details

Defined in Cometa.Internal.CostModels

Eq CostModel Source # 
Instance details

Defined in Cometa.Internal.CostModels

Ord CostModel Source # 
Instance details

Defined in Cometa.Internal.CostModels

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.

costs :: CostModel -> [Int64] Source #

Ordered signed 64-bit parameters, with at most 2048 entries.

data CostModels Source #

One model per language id. Equality and ordering compare ascending entries.

Instances

Instances details
Show CostModels Source # 
Instance details

Defined in Cometa.Internal.CostModels

Eq CostModels Source # 
Instance details

Defined in Cometa.Internal.CostModels

Ord CostModels Source # 
Instance details

Defined in Cometa.Internal.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.