Skip to content

Commit

Permalink
fix!: add ProtocolParams type to better represent current protocol pa…
Browse files Browse the repository at this point in the history
…rams

- Up to this point, `ShelleyProtocolParams` type has been used, but this is an invalid model.
- This commit also changes `coinsPerUtxoSize` -> `coinsPerUtxoByte`, ready for the Babbage era.
  • Loading branch information
rhyslbw committed Jul 7, 2022
1 parent f61d199 commit 73cf785
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@
manual_configuration:
remote_table:
schema: public
name: ShelleyEpochProtocolParams
name: ProtocolParams
column_mapping:
number: epoch_no
array_relationships:
Expand Down Expand Up @@ -490,13 +490,13 @@
allow_aggregations: true
- table:
schema: public
name: ShelleyEpochProtocolParams
name: ProtocolParams
select_permissions:
- role: cardano-graphql
permission:
columns:
- a0
- coinsPerUtxoSize
- coinsPerUtxoByte
- collateralPercent
- costModels
- decentralisationParam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ DROP VIEW IF EXISTS
"Collateral",
"Delegation",
"Epoch",
"ProtocolParams",
"Redeemer",
"Reward",
"Script",
"ShelleyEpochProtocolParams",
"SlotLeader",
"StakeDeregistration",
"StakePool",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ SELECT
FROM epoch
LEFT JOIN epoch_param on epoch.no = epoch_param.epoch_no;

CREATE OR REPLACE VIEW "ShelleyEpochProtocolParams" AS
CREATE OR REPLACE VIEW "ProtocolParams" AS
SELECT
epoch_param.influence AS "a0",
epoch_param.coins_per_utxo_size AS "coinsPerUtxoSize",
epoch_param.coins_per_utxo_size AS "coinsPerUtxoByte",
epoch_param.collateral_percent AS "collateralPercent",
cost_model.costs AS "costModels",
epoch_param.decentralisation AS "decentralisationParam",
Expand Down
26 changes: 23 additions & 3 deletions packages/api-cardano-db-hasura/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,9 @@ type ShelleyGenesisStaking {
stake: JSONObject!
}

type ShelleyProtocolParams {
type ProtocolParams {
a0: Float!
coinsPerUtxoSize: Int
coinsPerUtxoByte: Int
collateralPercent: Int
costModels: JSONObject
decentralisationParam: Float!
Expand Down Expand Up @@ -769,6 +769,26 @@ type ShelleyProtocolParams {
tau: Float!
}

type ShelleyProtocolParams {
a0: Float!
decentralisationParam: Float!
eMax: Int!
extraEntropy: JSONObject
keyDeposit: Int!
maxBlockBodySize: Int!
maxBlockHeaderSize: Int!
maxTxSize: Int!
minFeeA: Int!
minFeeB: Int!
minPoolCost: Int!
minUTxOValue: Int!
nOpt: Int!
poolDeposit: Int!
protocolVersion: JSONObject!
rho: Float!
tau: Float!
}

input StakeAddress_comparison_exp {
_eq: StakeAddress
_in: [StakeAddress]
Expand Down Expand Up @@ -1532,7 +1552,7 @@ type Epoch {
output: String!
nonce: Hash32Hex
number: Int!
protocolParams: ShelleyProtocolParams
protocolParams: ProtocolParams
transactionsCount: String!
startedAt: DateTime!
lastBlockTime: DateTime!
Expand Down
4 changes: 2 additions & 2 deletions packages/api-cardano-db-hasura/src/HasuraClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
AssetSupply,
Block,
PaymentAddressSummary,
ShelleyProtocolParams,
ProtocolParams,
Token,
TransactionOutput
} from './graphql_types'
Expand Down Expand Up @@ -272,7 +272,7 @@ export class HasuraClient {
return result.delete_assets.affected_rows
}

public async getCurrentProtocolVersion (): Promise<ShelleyProtocolParams['protocolVersion']> {
public async getCurrentProtocolVersion (): Promise<ProtocolParams['protocolVersion']> {
const result = await this.client.request(
gql`query {
epochs (limit: 1, order_by: { number: desc }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ query epochProtocolParams (
epochs( where: $where ) {
protocolParams {
a0
coinsPerUtxoSize
coinsPerUtxoByte
collateralPercent
costModels
decentralisationParam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Object {
Object {
"protocolParams": Object {
"a0": 0.3,
"coinsPerUtxoSize": 34482,
"coinsPerUtxoByte": 34482,
"collateralPercent": 150,
"costModels": Object {
"PlutusV1": Object {
Expand Down

0 comments on commit 73cf785

Please sign in to comment.