Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: types in defaultConstitution #6307

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 32 additions & 35 deletions cardano-constitution/data/defaultConstitution.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"0": {
"type": "integer",
"type": "coin",
"predicates": [
{
"minValue": 30,
Expand All @@ -19,7 +19,7 @@
},

"1": {
"type": "integer",
"type": "coin",
"predicates": [
{
"minValue": 100000,
Expand All @@ -36,7 +36,6 @@
],
"$comment": "txFeeFixed"
},

"10": {
"type": "unit_interval",
"predicates": [
Expand Down Expand Up @@ -80,7 +79,7 @@
},

"16": {
"type": "integer",
"type": "coin",
"predicates": [
{
"minValue": 0,
Expand All @@ -94,7 +93,7 @@
},

"17": {
"type": "integer",
"type": "coin",
"predicates": [
{
"minValue": 3000,
Expand All @@ -115,9 +114,12 @@
],
"$comment": "utxoCostPerByte"
},

"18": {
"type": "costMdls",
"$comment": "costmodels for all plutus versions"
},
"19[0]": {
"type": "unit_interval",
"type": "nonnegative_interval",
"predicates": [
{
"maxValue": { "numerator": 2000, "denominator": 10000 },
Expand All @@ -132,7 +134,7 @@
},

"19[1]": {
"type": "unit_interval",
"type": "nonnegative_interval",
"predicates": [
{
"maxValue": { "numerator": 2000, "denominator": 10000000 },
Expand All @@ -147,7 +149,7 @@
},

"2": {
"type": "integer",
"type": "uint.size4",
"predicates": [
{
"maxValue": 122880,
Expand All @@ -162,7 +164,7 @@
},

"20[0]": {
"type": "integer",
"type": "uint",
"predicates": [
{
"maxValue": 40000000,
Expand All @@ -178,7 +180,7 @@
},

"20[1]": {
"type": "integer",
"type": "uint",
"predicates": [
{
"maxValue": 15000000000,
Expand All @@ -194,7 +196,7 @@
},

"21[0]": {
"type": "integer",
"type": "uint",
"predicates": [
{
"maxValue": 120000000,
Expand All @@ -209,7 +211,7 @@
},

"21[1]": {
"type": "integer",
"type": "uint",
"predicates": [
{
"maxValue": 40000000000,
Expand All @@ -224,7 +226,7 @@
},

"22": {
"type": "integer",
"type": "uint.size4",
"predicates": [
{
"maxValue": 12288,
Expand All @@ -240,7 +242,7 @@
},

"23": {
"type": "integer",
"type": "uint.size2",
"predicates": [
{
"minValue": 100,
Expand All @@ -264,7 +266,7 @@
},

"24": {
"type": "integer",
"type": "uint.size2",
"predicates": [
{
"minValue": 1,
Expand Down Expand Up @@ -604,7 +606,7 @@
},

"27": {
"type": "integer",
"type": "uint.size2",
"predicates": [
{
"minValue": 0,
Expand All @@ -623,7 +625,7 @@
},

"28": {
"type": "integer",
"type": "epoch_interval",
"predicates": [
{
"notEqual": 0,
Expand All @@ -646,7 +648,7 @@
},

"29": {
"type": "integer",
"type": "epoch_interval",
"predicates": [
{
"minValue": 1,
Expand All @@ -661,7 +663,7 @@
},

"3": {
"type": "integer",
"type": "uint.size4",
"predicates": [
{
"maxValue": 32768,
Expand All @@ -676,7 +678,7 @@
},

"30": {
"type": "integer",
"type": "coin",
"predicates": [
{
"minValue": 0,
Expand All @@ -695,7 +697,7 @@
},

"31": {
"type": "integer",
"type": "coin",
"predicates": [
{
"minValue": 0,
Expand All @@ -714,7 +716,7 @@
},

"32": {
"type": "integer",
"type": "epoch_interval",
"predicates": [
{
"minValue": 13,
Expand All @@ -733,7 +735,7 @@
},

"33": {
"type": "unit_interval",
"type": "nonnegative_interval",
"predicates": [
{
"maxValue": { "numerator": 1000, "denominator": 1 },
Expand All @@ -748,7 +750,7 @@
},

"4": {
"type": "integer",
"type": "uint.size2",
"predicates": [
{
"maxValue": 5000,
Expand All @@ -763,7 +765,7 @@
},

"5": {
"type": "integer",
"type": "coin",
"predicates": [
{
"minValue": 1000000,
Expand All @@ -782,7 +784,7 @@
},

"6": {
"type": "integer",
"type": "coin",
"predicates": [
{
"minValue": 250000000,
Expand All @@ -801,7 +803,7 @@
},

"7": {
"type": "integer",
"type": "epoch_interval",
"predicates": [
{
"minValue": 0,
Expand All @@ -812,7 +814,7 @@
},

"8": {
"type": "integer",
"type": "uint.size2",
"predicates": [
{
"minValue": 250,
Expand All @@ -835,7 +837,7 @@
},

"9": {
"type": "unit_interval",
"type": "nonnegative_interval",
"predicates": [
{
"minValue": { "numerator": 1, "denominator": 10 },
Expand All @@ -851,10 +853,5 @@
}
],
"$comment": "poolPledgeInfluence"
},

"18": {
"type": "any",
"$comment": "costmodels for all plutus versions"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,33 @@ parseParamValue = \case
-- if we parsed a sub-index, treat the param value as a `M.singleton subIndex value`
Just subIndex -> fmap (RawParamList . M.singleton subIndex) . parseTypedParamValue
where
parseTypedParamValue :: Value -> Parser RawParamValue
parseTypedParamValue = withObject "RawParamValue" $ \o -> do
String ty <- o .: typeKey
case ty of
"integer" -> RawParamInteger <$> (o .: predicatesKey)
-- NOTE: even if the Tx.Ratio.Rational constructor is not exposed, the 2 arguments to the constructor
-- will be normalized (co-primed) when Tx.lift is called on them.
-- SO there is no speed benefit to statically co-prime them ourselves for efficiency.
"unit_interval" -> RawParamRational <$> (o .: predicatesKey)
"any" -> pure RawParamAny
_ -> fail "invalid type tag"
ty <- o .: typeKey
parseSynonymType ty o

-- the base types we support
parseBaseType :: Key -> Object -> Parser RawParamValue
parseBaseType ty o = case ty of
"integer" -> RawParamInteger <$> (o .: predicatesKey)
-- NOTE: even if the Tx.Ratio.Rational constructor is not exposed, the 2 arguments to the constructor
-- will be normalized (co-primed) when Tx.lift is called on them.
-- SO there is no speed benefit to statically co-prime them ourselves for efficiency.
"rational" -> RawParamRational <$> (o .: predicatesKey)
"any" -> pure RawParamAny
_ -> fail "invalid type tag"

-- synonyms to ease the transition from cddl
parseSynonymType = \case
"coin" -> parseBaseType "integer"
"uint.size4" -> parseBaseType "integer"
"uint.size2" -> parseBaseType "integer"
"uint" -> parseBaseType "integer" -- For ex units
"epoch_interval" -> parseBaseType "integer" -- Rename of uint.size4
"unit_interval" -> parseBaseType "rational"
"nonnegative_interval" -> parseBaseType "rational"
"costMdls" -> parseBaseType "any"
x -> parseBaseType x -- didn't find synonym, try as basetype

-- | It is like an `mappend` when both inputs are ParamList's.
mergeParamValues :: MonadFail m => RawParamValue -> RawParamValue -> m RawParamValue
Expand Down
Loading