-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added node install to docker * run npm install correct * don't copy modules * use env variables for testnet * Update pr.yml * github workflows changes * Update pr.yml * Update pr.yml * Update pr.yml * Update pr.yml * Update pr.yml * Update pr.yml * Update pr.yml * Update pr.yml * Update pr.yml * Make search case-insensitive (#36) Modify variable names for clarity. * Query balance by denomination (#48) * colw/subscription-fix (#47) * Fix transaction destructure * Lint * Rename for consistency * Override method for V2 * Colw/fix denom and votes (#49) * Use larger denom for governance parameters * Lint * Fix: Leave in big number format for line #86 * Fabo/minor fixes (#51) * gracefully handle no rewards * always return balance * prevent error when no rewards * fix wrong delegation amount showing * log transaction if tag is empty (#58) * fix tally for running proposals (#54) * Fabo/move testnet definition into network configs file (#56) * move testnet definition into network configs file * use configs for endpoints * update cache key per block (#57) * colw/minor-fixes (#59) * Export testnet data for use in LunieDB Source * Fix get query * Mario/32 add proposal proposer (#52) * Add proposal proposer * Add proposer to proposals page * Revert package.js mod, use Promise.all * Call all queries at same time in getProposalById * Api error 500 fix * Fabo suggestions * Add cross-env * Resolve merge conflict * Fix merge error * deliver correct testnet url (#60) * Latest proposal should be on top (#61) * Colin's magic * const proposals * fix to not crash if no denom * Fabo/wait for stargate to be up (#62) * debug missing denom * do not call validators * await for the remote instance to be up before loading static data * remove logs * remove fallback * comment * Update cosmosV0-source.js * Update cosmosV0-source.js * Update cosmosV0-source.js * colw/subscription-refactor (#63) * Factor out subscription object * WIP * Reenable subs * Do not pre-populate cache (temp) This is run on every request. * Reenable static data * Fix * Remove comment * WIP * Use API class within subscription object * Update file and parameter naming * Load API classes once. * Revert "Load API classes once." ca567095360dbd7a8d81c7a53fe4fe885f3b63d2 * Set headers in separate method * format comment * Rename class variable * Split static data up * Adjust cache timing, default 5 * Update lib/schema.js Co-Authored-By: Fabian <[email protected]> * Change client name to TendermintClient * Comment and rename for clarity * Cache specific blocks longer * Move Tendermint client to CosmosNodeSubscription * Comments for clarity * Clear memory after handling each new block (#66) * Fix typo and no return. (#68) * Aleksei/sentry added (#67) * only sentry init code added * docker-compose changes * inspect removed * colw/Decrease validator list loading time (#69) * Fetch validators each new block and store them * Store block, and sync validator map with block * Add block to store * Remove unused parameters * Retrieve a single validator form the map * Review fix: remove height parameter * Review fix: Change variable name for clarity * Return delegations and rewards from store (#70) * Return delegations and rewards from store * overview values * Remove unnecessary Promise.all
- Loading branch information
Showing
25 changed files
with
970 additions
and
514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,6 @@ jobs: | |
- name: Installing Docker Compose | ||
run: ssh [email protected] "sudo curl -L \"https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose; sudo chmod +x /usr/local/bin/docker-compose" | ||
- name: Run on Digital Ocean | ||
run: ssh [email protected] "docker image prune -a -f; docker load < lunieapi.tgz; docker container stop lunieapi;docker container stop caddy; docker container stop node_exporter; docker container prune -f; export HASURA_URL="https://staging-db.lunie.io/v1/graphql"; export HASURA_ADMIN_KEY="${{ secrets.LUNIE_STAGING_DB_KEY }}"; docker-compose -f docker-compose.yml up --build -d" | ||
run: ssh [email protected] "docker image prune -a -f; docker load < lunieapi.tgz; docker container stop lunieapi;docker container stop caddy; docker container stop node_exporter; docker container prune -f; export HASURA_URL="https://staging-db.lunie.io/v1/graphql"; export HASURA_ADMIN_KEY="${{ secrets.LUNIE_STAGING_DB_KEY }}"; export SENTRY_DSN="${{ secrets.SENTRY_DSN }}"; docker-compose -f docker-compose.yml up --build -d" | ||
- name: Setting up cron job for pm2 metrics export | ||
run: ssh [email protected] "mkdir /logs -p; touch /logs/show; line='*/1 * * * * docker exec lunieapi pm2 show 0 > /logs/show; perl /root/pm2metrics.pl'; crontab -l | grep -q 'lunieapi pm2' && true || (crontab -l; echo "$line" ) | crontab -" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,10 @@ jobs: | |
- name: prepare to push to Digital Ocean | ||
run: mkdir -p ~/.ssh && echo "${{ secrets.DO_PRIVATE_KEY }}" | tr -d '\r' > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa && eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_rsa && ssh-keyscan -H 167.71.107.214 >> ~/.ssh/known_hosts | ||
- name: push to Digital Ocean | ||
run: rsync -4 lunieapi.tgz [email protected]:~/ && rsync -4 pm2metrics.pl [email protected]:~/ && rsync -4 docker-compose.prod.yml [email protected]:~/ && rsync -4 Caddyfile.prod [email protected]:~/ | ||
run: rsync -4 lunieapi.tgz [email protected]:~/ && rsync -4 pm2metrics.pl [email protected]:~/ && rsync -4 docker-compose.prod.yml [email protected]:~/docker-compose.yml && rsync -4 Caddyfile.prod [email protected]:~/Caddyfile | ||
- name: Installing Docker Compose | ||
run: ssh [email protected] "sudo curl -L \"https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose; sudo chmod +x /usr/local/bin/docker-compose" | ||
- name: Run on Digital Ocean | ||
run: ssh [email protected] "docker image prune -a -f; docker load < lunieapi.tgz; docker container stop lunieapi;docker container stop caddy; docker container stop node_exporter; docker container prune -f;export HASURA_URL="https://production-db.lunie.io/v1/graphql"; export HASURA_ADMIN_KEY="${{ secrets.LUNIE_PRODUCTION_DB_KEY }}"; docker-compose -f docker-compose.yml up --build -d" | ||
run: ssh [email protected] "docker image prune -a -f; docker load < lunieapi.tgz; docker container stop lunieapi;docker container stop caddy; docker container stop node_exporter; docker container prune -f;export HASURA_URL="https://production-db.lunie.io/v1/graphql"; export HASURA_ADMIN_KEY="${{ secrets.LUNIE_PRODUCTION_DB_KEY }}"; export SENTRY_DSN="${{ secrets.SENTRY_DSN }}"; docker-compose -f docker-compose.yml up --build -d" | ||
- name: Setting up cron job for pm2 metrics export | ||
run: ssh [email protected] "mkdir /logs -p; touch /logs/show; line='*/1 * * * * docker exec lunieapi pm2 show 0 > /logs/show; perl /root/pm2metrics.pl'; crontab -l | grep -q 'lunieapi pm2' && true || (crontab -l; echo "$line" ) | crontab -" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,7 @@ production-api.lunie.io { | |
websocket | ||
} | ||
} | ||
:9100 { | ||
basicauth / admin lunie1234 | ||
proxy / node_exporter:9100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class BlockStore { | ||
constructor(networkId) { | ||
this.networkId = networkId | ||
this.latestHeight = 0 | ||
this.block = {} | ||
this.stakingDenom = '' | ||
this.annualProvision = 0 | ||
this.signedBlocksWindow = 0 | ||
this.validators = {} | ||
} | ||
|
||
update({ | ||
height, | ||
block = this.block, | ||
stakingDenom = this.stakingDenom, | ||
annualProvision = this.annualProvision, | ||
signedBlocksWindow = this.signedBlocksWindow, | ||
validators = this.validators | ||
}) { | ||
this.latestHeight = Number(height) | ||
this.block = block | ||
this.stakingDenom = stakingDenom | ||
this.annualProvision = Number(annualProvision) | ||
this.signedBlocksWindow = Number(signedBlocksWindow) | ||
this.validators = validators | ||
} | ||
} | ||
|
||
module.exports = BlockStore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const _ = require('lodash') | ||
const Tendermint = require('./helpers/tendermint') | ||
const { | ||
publishBlockAdded, | ||
publishUserTransactionAdded | ||
} = require('./subscriptions') | ||
|
||
// This class establishes an rpc connection to Tendermint. | ||
// Used for listening to events, such as new blocks. | ||
class CosmosNodeSubscription { | ||
constructor(network, CosmosApiClass, store) { | ||
this.network = network | ||
this.cosmosAPI = new CosmosApiClass(network) | ||
this.store = store | ||
|
||
// Create a RPC subscription for each network that will react to new block events. | ||
Tendermint() | ||
.connect(this.network.rpc_url) | ||
.then(connectedClient => { | ||
connectedClient.subscribe({ query: "tm.event='NewBlock'" }, event => | ||
this.newBlockHandler(event.block.header.height) | ||
) | ||
}) | ||
} | ||
|
||
// For each block event, we fetch the block information and publish a message. | ||
// A GraphQL resolver is listening for these messages and sends the block to | ||
// each subscribed user. | ||
async newBlockHandler(height) { | ||
const block = await this.cosmosAPI.getBlockByHeight({ | ||
blockHeight: height | ||
}) | ||
const validatorMap = await this.getLatestBlockData() | ||
this.store.update({ height, block, validators: validatorMap }) | ||
publishBlockAdded(this.network.id, block) | ||
|
||
// For each transaction listed in a block we fetch the transaction and | ||
// extract the relevant addresses. This is published to the network. | ||
// A GraphQL resolver is listening for these messages and sends the | ||
// transaction to each subscribed user. | ||
const txs = await this.cosmosAPI.getTransactionsByHeight(height) | ||
txs.forEach(tx => { | ||
this.cosmosAPI.extractInvolvedAddresses(tx.raw).forEach(address => { | ||
publishUserTransactionAdded(this.network.id, address, tx) | ||
}) | ||
}) | ||
|
||
this.cosmosAPI.clearMemory() | ||
} | ||
|
||
async getLatestBlockData() { | ||
const validators = await this.cosmosAPI.getAllValidators() | ||
const validatorMap = _.keyBy(validators, 'operatorAddress') | ||
return validatorMap | ||
} | ||
} | ||
|
||
module.exports = CosmosNodeSubscription |
Oops, something went wrong.