Skip to content

Commit

Permalink
feat(cip-1694): epochs parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
1000101 committed Dec 18, 2023
1 parent 9f08cf4 commit 4156c30
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 28 deletions.
5 changes: 3 additions & 2 deletions src/routes/epochs/latest/parameters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSchemaForEndpoint } from '@blockfrost/openapi';
//import { getSchemaForEndpoint } from '@blockfrost/openapi';
import { FastifyInstance } from 'fastify';

import { SQLQuery } from '../../../sql/index.js';
Expand All @@ -12,7 +12,8 @@ async function route(fastify: FastifyInstance) {
fastify.route({
url: '/epochs/latest/parameters',
method: 'GET',
schema: getSchemaForEndpoint('/epochs/latest/parameters'),
// TODO: once it gets into openapi
//schema: getSchemaForEndpoint('/epochs/latest/parameters'),
handler: async (_request, reply) => {
const clientDbSync = await getDbSync(fastify);

Expand Down
5 changes: 3 additions & 2 deletions src/routes/epochs/number/parameters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSchemaForEndpoint } from '@blockfrost/openapi';
//import { getSchemaForEndpoint } from '@blockfrost/openapi';
import { FastifyInstance, FastifyRequest } from 'fastify';

import { SQLQuery } from '../../../sql/index.js';
Expand All @@ -13,7 +13,8 @@ async function route(fastify: FastifyInstance) {
fastify.route({
url: '/epochs/:number/parameters',
method: 'GET',
schema: getSchemaForEndpoint('/epochs/{number}/parameters'),
// TODO: once it gets into openapi
//schema: getSchemaForEndpoint('/epochs/{number}/parameters'),
handler: async (request: FastifyRequest<QueryTypes.RequestParameters>, reply) => {
const clientDbSync = await getDbSync(fastify);

Expand Down
55 changes: 43 additions & 12 deletions src/sql/epochs/epochs_latest_parameters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ SELECT epoch_no AS "epoch",
max_block_size AS "max_block_size",
max_tx_size AS "max_tx_size",
max_bh_size AS "max_block_header_size",
key_deposit::TEXT AS "key_deposit", -- cast to TEXT to avoid number overflow
pool_deposit::TEXT AS "pool_deposit", -- cast to TEXT to avoid number overflow
key_deposit::TEXT AS "key_deposit",
-- cast to TEXT to avoid number overflow
pool_deposit::TEXT AS "pool_deposit",
-- cast to TEXT to avoid number overflow
max_epoch AS "e_max",
optimal_pool_count AS "n_opt",
influence AS "a0",
Expand All @@ -15,23 +17,52 @@ SELECT epoch_no AS "epoch",
extra_entropy AS "extra_entropy",
protocol_major AS "protocol_major_ver",
protocol_minor AS "protocol_minor_ver",
min_utxo_value::TEXT AS "min_utxo", -- cast to TEXT to avoid number overflow
min_pool_cost::TEXT AS "min_pool_cost", -- cast to TEXT to avoid number overflow
min_utxo_value::TEXT AS "min_utxo",
-- cast to TEXT to avoid number overflow
min_pool_cost::TEXT AS "min_pool_cost",
-- cast to TEXT to avoid number overflow
encode(nonce, 'hex') AS "nonce",
cm.costs AS "cost_models",
price_mem AS "price_mem",
price_step AS "price_step",
max_tx_ex_mem::TEXT AS "max_tx_ex_mem", -- cast to TEXT to avoid number overflow
max_tx_ex_steps::TEXT AS "max_tx_ex_steps", -- cast to TEXT to avoid number overflow
max_block_ex_mem::TEXT AS "max_block_ex_mem", -- cast to TEXT to avoid number overflow
max_block_ex_steps::TEXT AS "max_block_ex_steps", -- cast to TEXT to avoid number overflow
max_val_size::TEXT AS "max_val_size", -- cast to TEXT to avoid number overflow
max_tx_ex_mem::TEXT AS "max_tx_ex_mem",
-- cast to TEXT to avoid number overflow
max_tx_ex_steps::TEXT AS "max_tx_ex_steps",
-- cast to TEXT to avoid number overflow
max_block_ex_mem::TEXT AS "max_block_ex_mem",
-- cast to TEXT to avoid number overflow
max_block_ex_steps::TEXT AS "max_block_ex_steps",
-- cast to TEXT to avoid number overflow
max_val_size::TEXT AS "max_val_size",
-- cast to TEXT to avoid number overflow
collateral_percent AS "collateral_percent",
max_collateral_inputs AS "max_collateral_inputs",
coins_per_utxo_size::TEXT AS "coins_per_utxo_size", -- cast to TEXT to avoid number overflow
coins_per_utxo_size::TEXT AS "coins_per_utxo_word" -- deprecated
coins_per_utxo_size::TEXT AS "coins_per_utxo_size",
-- cast to TEXT to avoid number overflow
coins_per_utxo_size::TEXT AS "coins_per_utxo_word",
-- deprecated
pvt_motion_no_confidence AS "pvt_motion_no_confidence",
pvt_committee_normal AS "pvt_committee_normal",
pvt_committee_no_confidence AS "pvt_committee_no_confidence",
pvt_hard_fork_initiation AS "pvt_hard_fork_initiation",
dvt_motion_no_confidence AS "dvt_motion_no_confidence",
dvt_committee_normal AS "dvt_committee_normal",
dvt_committee_no_confidence AS "dvt_committee_no_confidence",
dvt_update_to_constitution AS "dvt_update_to_constitution",
dvt_hard_fork_initiation AS "dvt_hard_fork_initiation",
dvt_p_p_network_group AS "dvt_p_p_network_group",
dvt_p_p_economic_group AS "dvt_p_p_economic_group",
dvt_p_p_technical_group AS "dvt_p_p_technical_group",
dvt_p_p_gov_group AS "dvt_p_p_gov_group",
dvt_treasury_withdrawal AS "dvt_treasury_withdrawal",
committee_min_size AS "committee_min_size",
committee_max_term_length AS "committee_max_term_length",
gov_action_lifetime AS "gov_action_lifetime",
gov_action_deposit AS "gov_action_deposit",
drep_deposit AS "drep_deposit",
drep_activity AS "drep_activity"
FROM epoch_param ep
LEFT JOIN cost_model cm ON (ep.cost_model_id = cm.id)
LEFT JOIN cost_model cm ON (ep.cost_model_id = cm.id)
WHERE epoch_no = (
SELECT MAX(no)
FROM epoch
Expand Down
55 changes: 43 additions & 12 deletions src/sql/epochs/epochs_number_parameters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ SELECT epoch_no AS "epoch",
max_block_size AS "max_block_size",
max_tx_size AS "max_tx_size",
max_bh_size AS "max_block_header_size",
key_deposit::TEXT AS "key_deposit", -- cast to TEXT to avoid number overflow
pool_deposit::TEXT AS "pool_deposit", -- cast to TEXT to avoid number overflow
key_deposit::TEXT AS "key_deposit",
-- cast to TEXT to avoid number overflow
pool_deposit::TEXT AS "pool_deposit",
-- cast to TEXT to avoid number overflow
max_epoch AS "e_max",
optimal_pool_count AS "n_opt",
influence AS "a0",
Expand All @@ -15,21 +17,50 @@ SELECT epoch_no AS "epoch",
extra_entropy AS "extra_entropy",
protocol_major AS "protocol_major_ver",
protocol_minor AS "protocol_minor_ver",
min_utxo_value::TEXT AS "min_utxo", -- cast to TEXT to avoid number overflow
min_pool_cost::TEXT AS "min_pool_cost", -- cast to TEXT to avoid number overflow
min_utxo_value::TEXT AS "min_utxo",
-- cast to TEXT to avoid number overflow
min_pool_cost::TEXT AS "min_pool_cost",
-- cast to TEXT to avoid number overflow
encode(nonce, 'hex') AS "nonce",
cm.costs AS "cost_models",
price_mem AS "price_mem",
price_step AS "price_step",
max_tx_ex_mem::TEXT AS "max_tx_ex_mem", -- cast to TEXT to avoid number overflow
max_tx_ex_steps::TEXT AS "max_tx_ex_steps", -- cast to TEXT to avoid number overflow
max_block_ex_mem::TEXT AS "max_block_ex_mem", -- cast to TEXT to avoid number overflow
max_block_ex_steps::TEXT AS "max_block_ex_steps", -- cast to TEXT to avoid number overflow
max_val_size::TEXT AS "max_val_size", -- cast to TEXT to avoid number overflow
max_tx_ex_mem::TEXT AS "max_tx_ex_mem",
-- cast to TEXT to avoid number overflow
max_tx_ex_steps::TEXT AS "max_tx_ex_steps",
-- cast to TEXT to avoid number overflow
max_block_ex_mem::TEXT AS "max_block_ex_mem",
-- cast to TEXT to avoid number overflow
max_block_ex_steps::TEXT AS "max_block_ex_steps",
-- cast to TEXT to avoid number overflow
max_val_size::TEXT AS "max_val_size",
-- cast to TEXT to avoid number overflow
collateral_percent AS "collateral_percent",
max_collateral_inputs AS "max_collateral_inputs",
coins_per_utxo_size::TEXT AS "coins_per_utxo_size", -- cast to TEXT to avoid number overflow
coins_per_utxo_size::TEXT AS "coins_per_utxo_word" -- deprecated
coins_per_utxo_size::TEXT AS "coins_per_utxo_size",
-- cast to TEXT to avoid number overflow
coins_per_utxo_size::TEXT AS "coins_per_utxo_word",
-- deprecated
pvt_motion_no_confidence AS "pvt_motion_no_confidence",
pvt_committee_normal AS "pvt_committee_normal",
pvt_committee_no_confidence AS "pvt_committee_no_confidence",
pvt_hard_fork_initiation AS "pvt_hard_fork_initiation",
dvt_motion_no_confidence AS "dvt_motion_no_confidence",
dvt_committee_normal AS "dvt_committee_normal",
dvt_committee_no_confidence AS "dvt_committee_no_confidence",
dvt_update_to_constitution AS "dvt_update_to_constitution",
dvt_hard_fork_initiation AS "dvt_hard_fork_initiation",
dvt_p_p_network_group AS "dvt_p_p_network_group",
dvt_p_p_economic_group AS "dvt_p_p_economic_group",
dvt_p_p_technical_group AS "dvt_p_p_technical_group",
dvt_p_p_gov_group AS "dvt_p_p_gov_group",
dvt_treasury_withdrawal AS "dvt_treasury_withdrawal",
committee_min_size AS "committee_min_size",
committee_max_term_length AS "committee_max_term_length",
gov_action_lifetime AS "gov_action_lifetime",
gov_action_deposit AS "gov_action_deposit",
drep_deposit AS "drep_deposit",
drep_activity AS "drep_activity"
FROM epoch_param ep
LEFT JOIN cost_model cm ON (ep.cost_model_id = cm.id)
LEFT JOIN cost_model cm ON (ep.cost_model_id = cm.id)
WHERE epoch_no = $1

0 comments on commit 4156c30

Please sign in to comment.