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

feat(#58): add conway related protocol parameters #59

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
46 changes: 45 additions & 1 deletion blockfrost-api/src/Blockfrost/Types/Cardano/Epochs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,32 @@ data ProtocolParams = ProtocolParams
, _protocolParamsMaxCollateralInputs :: Integer -- ^ The maximum number of collateral inputs allowed in a transaction
, _protocolParamsCoinsPerUtxoSize :: Lovelaces -- ^ The cost per UTxO size. Cost per UTxO *word* for Alozno. Cost per UTxO *byte* for Babbage and later
, _protocolParamsCoinsPerUtxoWord :: Lovelaces -- ^ The cost per UTxO word (DEPRECATED)
, _protocolParamsPvtMotionNoConfidence :: Maybe Rational
, _protocolParamsPvtCommitteeNormal :: Maybe Rational
, _protocolParamsPvtCommitteeNoConfidence :: Maybe Rational
, _protocolParamsPvtHardForkInitiation :: Maybe Rational
, _protocolParamsPvtppSecurityGroup :: Maybe Rational
, _protocolParamsDvtMotionNoConfidence :: Maybe Rational
, _protocolParamsDvtCommitteeNormal :: Maybe Rational
, _protocolParamsDvtCommitteeNoConfidence :: Maybe Rational
, _protocolParamsDvtUpdateToConstitution :: Maybe Rational
, _protocolParamsDvtHardForkInitiation :: Maybe Rational
, _protocolParamsDvtPPNetworkGroup :: Maybe Rational
, _protocolParamsDvtPPEconomicGroup :: Maybe Rational
, _protocolParamsDvtPPTechnicalGroup :: Maybe Rational
, _protocolParamsDvtPPGovGroup :: Maybe Rational
, _protocolParamsDvtTreasuryWithdrawal :: Maybe Rational
, _protocolParamsCommitteeMinSize :: Maybe Quantity
, _protocolParamsCommitteeMaxTermLength :: Maybe Quantity
, _protocolParamsGovActionLifetime :: Maybe Quantity
, _protocolParamsGovActionDeposit :: Maybe Lovelaces
, _protocolParamsDrepDeposit :: Maybe Lovelaces
, _protocolParamsDrepActivity :: Maybe Quantity
, _protocolParamsMinFeeRefScriptCostPerByte :: Maybe Rational
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is chosen as Maybe Rational instead of Maybe Integer as corresponding type defined in cardano-ledger codebase is (loosely put) Ratio Word64.

}
deriving stock (Show, Eq, Generic)
deriving (FromJSON, ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_protocolParams", CamelToSnake]] ProtocolParams
via CustomJSON '[FieldLabelModifier '[StripPrefix "_protocolParams", CamelToSnake, Rename "dvt_pp_network_group" "dvt_p_p_network_group", Rename "dvt_pp_economic_group" "dvt_p_p_economic_group", Rename "dvt_pp_technical_group" "dvt_p_p_technical_group", Rename "dvt_pp_gov_group" "dvt_p_p_gov_group"]] ProtocolParams

instance ToSample ProtocolParams where
toSamples = pure $ singleSample
Expand Down Expand Up @@ -128,6 +150,28 @@ instance ToSample ProtocolParams where
, _protocolParamsMaxCollateralInputs = 3
, _protocolParamsCoinsPerUtxoSize = 34482
, _protocolParamsCoinsPerUtxoWord = 34482
, _protocolParamsPvtMotionNoConfidence = Just 0.51
, _protocolParamsPvtCommitteeNormal = Just 0.51
, _protocolParamsPvtCommitteeNoConfidence = Just 0.51
, _protocolParamsPvtHardForkInitiation = Just 0.51
, _protocolParamsPvtppSecurityGroup = Just 0.51
, _protocolParamsDvtMotionNoConfidence = Just 0.67
, _protocolParamsDvtCommitteeNormal = Just 0.67
, _protocolParamsDvtCommitteeNoConfidence = Just 0.6
, _protocolParamsDvtUpdateToConstitution = Just 0.75
, _protocolParamsDvtHardForkInitiation = Just 0.6
, _protocolParamsDvtPPNetworkGroup = Just 0.67
, _protocolParamsDvtPPEconomicGroup = Just 0.67
, _protocolParamsDvtPPTechnicalGroup = Just 0.67
, _protocolParamsDvtPPGovGroup = Just 0.75
, _protocolParamsDvtTreasuryWithdrawal = Just 0.67
, _protocolParamsCommitteeMinSize = Just 7
, _protocolParamsCommitteeMaxTermLength = Just 146
, _protocolParamsGovActionLifetime = Just 6
, _protocolParamsGovActionDeposit = Just 100000000000
, _protocolParamsDrepDeposit = Just 500000000
, _protocolParamsDrepActivity = Just 20
, _protocolParamsMinFeeRefScriptCostPerByte = Just 15
}

newtype CostModels = CostModels { unCostModels :: Map ScriptType (Map Text Integer) }
Expand Down
46 changes: 45 additions & 1 deletion blockfrost-api/test/Cardano/Epochs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,29 @@ protocolParamsSample = [r|
"collateral_percent": 150,
"max_collateral_inputs": 3,
"coins_per_utxo_size": "34482",
"coins_per_utxo_word": "34482"
"coins_per_utxo_word": "34482",
"pvt_motion_no_confidence": 0.51,
"pvt_committee_normal": 0.51,
"pvt_committee_no_confidence": 0.51,
"pvt_hard_fork_initiation": 0.51,
"dvt_motion_no_confidence": 0.67,
"dvt_committee_normal": 0.67,
"dvt_committee_no_confidence": 0.6,
"dvt_update_to_constitution": 0.75,
"dvt_hard_fork_initiation": 0.6,
"dvt_p_p_network_group": 0.67,
"dvt_p_p_economic_group": 0.67,
"dvt_p_p_technical_group": 0.67,
"dvt_p_p_gov_group": 0.75,
"dvt_treasury_withdrawal": 0.67,
"committee_min_size": "7",
"committee_max_term_length": "146",
"gov_action_lifetime": "6",
"gov_action_deposit": "100000000000",
"drep_deposit": "500000000",
"drep_activity": "20",
"pvtpp_security_group": 0.51,
"min_fee_ref_script_cost_per_byte": 15
}
|]

Expand Down Expand Up @@ -164,6 +186,28 @@ protocolParamsExpected =
, _protocolParamsCoinsPerUtxoSize = 34482
-- deprecated
, _protocolParamsCoinsPerUtxoWord = 34482
, _protocolParamsPvtMotionNoConfidence = Just 0.51
, _protocolParamsPvtCommitteeNormal = Just 0.51
, _protocolParamsPvtCommitteeNoConfidence = Just 0.51
, _protocolParamsPvtHardForkInitiation = Just 0.51
, _protocolParamsPvtppSecurityGroup = Just 0.51
, _protocolParamsDvtMotionNoConfidence = Just 0.67
, _protocolParamsDvtCommitteeNormal = Just 0.67
, _protocolParamsDvtCommitteeNoConfidence = Just 0.6
, _protocolParamsDvtUpdateToConstitution = Just 0.75
, _protocolParamsDvtHardForkInitiation = Just 0.6
, _protocolParamsDvtPPNetworkGroup = Just 0.67
, _protocolParamsDvtPPEconomicGroup = Just 0.67
, _protocolParamsDvtPPTechnicalGroup = Just 0.67
, _protocolParamsDvtPPGovGroup = Just 0.75
, _protocolParamsDvtTreasuryWithdrawal = Just 0.67
, _protocolParamsCommitteeMinSize = Just 7
, _protocolParamsCommitteeMaxTermLength = Just 146
, _protocolParamsGovActionLifetime = Just 6
, _protocolParamsGovActionDeposit = Just 100000000000
, _protocolParamsDrepDeposit = Just 500000000
, _protocolParamsDrepActivity = Just 20
, _protocolParamsMinFeeRefScriptCostPerByte = Just 15
}

stakeDistributionSample = [r|
Expand Down