Skip to content

Commit

Permalink
Koios v1.1.1 (#279)
Browse files Browse the repository at this point in the history
## Description

Finalise v1.1.1 release for tagging:
- [x] Fix active stake cache for first run
- [x] Update script hash example guild.koios.rest
- [x] Update epoch info cache to run epoch summary (in case restore was
from a bad snapshot)
  • Loading branch information
rdlrt committed May 6, 2024
1 parent b68c894 commit 859b283
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 24 deletions.
11 changes: 3 additions & 8 deletions files/grest/cron/jobs/active-stake-cache-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ tip=$(psql ${DB_NAME} -qbt -c "select extract(epoch from time)::integer from blo

echo "$(date +%F_%H:%M:%S) Running active stake cache update..."

# High level check in db to see if update needed at all (should be updated only once on epoch transition)
# High level check in db to see if update needed at all (should be updated only once for next epoch once epoch stake for it is available)
[[ $(psql ${DB_NAME} -qbt -c "SELECT grest.active_stake_cache_update_check();" | tail -2 | tr -cd '[:alnum:]') != 't' ]] &&
echo "No update needed, exiting..." &&
exit 0

db_next_epoch_no=$(psql ${DB_NAME} -qbt -c "SELECT MAX(NO)+1 from EPOCH;" | tr -cd '[:alnum:]')
db_epoch_stakes_no=$(psql ${DB_NAME} -qbt -c "SELECT MAX(epoch_no) FROM EPOCH_STAKE;" | tr -cd '[:alnum:]')
next_epoch_no=$(psql ${DB_NAME} -qbt -c "SELECT MAX(epoch_no) FROM epoch_stake_progress WHERE completed='t'" | tr -cd '[:alnum:]')

[[ ${db_next_epoch_no} -gt ${db_epoch_stakes_no} ]] &&
echo "Epoch Stake is not populated for epoch ${db_next_epoch_no}, exiting..." &&
exit 1

psql ${DB_NAME} -qbt -c "SELECT GREST.active_stake_cache_update(${db_epoch_stakes_no});" 1>/dev/null
psql ${DB_NAME} -qbt -c "SELECT GREST.active_stake_cache_update(${next_epoch_no});" 1>/dev/null
echo "$(date +%F_%H:%M:%S) Job done!"
10 changes: 2 additions & 8 deletions files/grest/rpc/01_cached_tables/active_stake_cache.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,9 @@ BEGIN
SELECT MAX(no) INTO _current_epoch_no
FROM epoch;
RAISE NOTICE 'Next epoch: %', _current_epoch_no+1;
RAISE NOTICE 'Latest epoch in active stake cache: %', _last_active_stake_validated_epoch;
IF _current_epoch_no > COALESCE(_last_active_stake_validated_epoch::integer, 0) THEN
RAISE NOTICE 'Latest epoch in active stake cache: %', COALESCE(_last_active_stake_validated_epoch::integer, '0');
IF (SELECT MAX(epoch_no) FROM epoch_stake_progress WHERE completed='t')::integer > COALESCE(_last_active_stake_validated_epoch,'0')::integer THEN
RETURN TRUE;
ELSE
-- If last active stake cache is same as current epoch_no, check if we're beyond 60% within epoch to populate next epoch stake, only valid as of dbsync 13.2.0.0
IF _current_epoch_no = _last_active_stake_validated_epoch::integer
AND (SELECT MAX(epoch_no) FROM epoch_stake_progress WHERE completed='t')::integer > _last_active_stake_validated_epoch::integer THEN
RETURN TRUE;
END IF;
END IF;
RAISE NOTICE 'Active Stake cache is up to date with DB!';
RETURN FALSE;
Expand Down
1 change: 1 addition & 0 deletions files/grest/rpc/01_cached_tables/epoch_info_cache.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ BEGIN

IF _latest_epoch_no_in_cache = 0 THEN
RAISE NOTICE 'Epoch info cache table is empty, starting initial population...';
PERFORM grest.epoch_summary_corrections_update();
PERFORM grest.epoch_info_cache_update(0);
RETURN;
END IF;
Expand Down
2 changes: 1 addition & 1 deletion files/grest/rpc/assets/asset_nft_address.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BEGIN
sa.view AS stake_address
FROM tx_out AS txo
LEFT JOIN stake_address AS sa ON txo.stake_address_id = sa.id
WHERE id = (
WHERE txo.id = (
SELECT MAX(tx_out_id)
FROM ma_tx_out
WHERE ident = _asset_id
Expand Down
4 changes: 2 additions & 2 deletions specs/results/koiosapi-guild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.1.1rc
version: v1.1.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.
Expand Down Expand Up @@ -1833,7 +1833,7 @@ components:
description: Script hash in hexadecimal format (hex)
schema:
type: string
example: "1392eec7d575292ae1523da65ff1b4b021886e917c8c43de54aa7cbd"
example: "f6c13b1bd68219ffb6a1e6d77bd23ec5982f3da2d93007aa5956a142"
in: query
required: true
allowEmptyValue: false
Expand Down
2 changes: 1 addition & 1 deletion specs/results/koiosapi-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.1.1rc
version: v1.1.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.
Expand Down
2 changes: 1 addition & 1 deletion specs/results/koiosapi-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.1.1rc
version: v1.1.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.
Expand Down
2 changes: 1 addition & 1 deletion specs/results/koiosapi-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.1.1rc
version: v1.1.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.
Expand Down
2 changes: 1 addition & 1 deletion specs/templates/1-api-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.1.1rc
version: v1.1.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.
Expand Down
2 changes: 1 addition & 1 deletion specs/templates/example-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
},
"_script_hash": {
"m": "d8480dc869b94b80e81ec91b0abe307279311fe0e7001a9488f61ff8",
"g": "1392eec7d575292ae1523da65ff1b4b021886e917c8c43de54aa7cbd",
"g": "f6c13b1bd68219ffb6a1e6d77bd23ec5982f3da2d93007aa5956a142",
"pv": "f758cf422ca0cbed7d9d6fad1eb5a3c70537d62e661ad450dd2a3810",
"pp": "14abafb323de75b7266fd0eab29b6ef562305e8a0dfbb64b07ef32c7"
}
Expand Down

0 comments on commit 859b283

Please sign in to comment.