Skip to content

Commit

Permalink
Merge pull request #1267 from edenia/chore/emv-add-env-variables
Browse files Browse the repository at this point in the history
Chore/emv add env variables
  • Loading branch information
xavier506 authored Aug 28, 2023
2 parents 35efac1 + 500f7ff commit f278080
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 11 deletions.
11 changes: 8 additions & 3 deletions .env.telos
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ HAPI_EVM_SERVER_ADDRESS=hapi-evm
HAPI_EVM_HASURA_URL=http://hasura:8080/v1/graphql
HAPI_EVM_HASURA_ADMIN_SECRET=myadminsecretkey
HAPI_EVM_DATABASE_URL=postgres://eoscr:password@postgres:5432/localdb
HAPI_EVM_ENDPOINT=https://testnet.telos.net/evm
HAPI_EVM_ENDPOINT=https://mainnet.telos.net/evm
HAPI_EVM_API_ENDPOINTS=["https://telos.greymass.com","https://telos.eosphere.io","telos.caleos.io","mainnet.telosusa.io"]
HAPI_EVM_NETWORK_CHAIN_ID=4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11
HAPI_EVM_EOS_EVM_ACCOUNT=eosio.evm
HAPI_EVM_BLOCK_INTERVAL_SEC=0.3
HAPI_EVM_BLOCK_INTERVAL_SEC=0.5
HAPI_EVM_OLD_BLOCK_INTERVAL_SEC=0.1
HAPI_EVM_ATH_INTERVAL_SEC=60
HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC=86400
HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC=86400
HAPI_EVM_KEEP_HISTORY_FOR_YEARS=1
HAPI_EVM_HYPERION_API=https://telos.eosusa.io
HAPI_EVM_HYPERION_START_AT=2021-06-02T00:00:00.000+00:00

Expand Down Expand Up @@ -102,6 +107,6 @@ REACT_APP_STATE_HISTORY_ENABLED=false
REACT_APP_GOOGLE_ANALITIC_PAGE_ID=G-E6Y0EC9FT8
REACT_APP_PUBLIC_RE_CAPTCHA_KEY=key
REACT_APP_EOS_INCLUDE_TRANSACTION=
REACT_APP_EVM_ENDPOINT='https://mainnet.telos.net/evm'
REACT_APP_EVM_ENDPOINT=https://mainnet.telos.net/evm
REACT_APP_EVM_BLOCK_EXPLORER_URL=https://www.teloscan.io/block/(block)
REACT_APP_EVM_ENDPOINTS=["https://mainnet.telos.net/evm","https://rpc1.eu.telos.net/evm","https://rpc1.us.telos.net/evm","https://rpc2.us.telos.net/evm","https://api.kainosbp.com/evm","https://rpc2.eu.telos.net/evm","https://evm.teloskorea.com/evm","https://rpc2.teloskorea.com/evm","https://rpc01.us.telosunlimited.io/evm"]
8 changes: 7 additions & 1 deletion .env.telostestnet
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ HASURA_GRAPHQL_DATABASE_URL=postgres://eoscr:password@postgres:5432/localdb
HASURA_GRAPHQL_ADMIN_SECRET=myadminsecretkey
HASURA_GRAPHQL_UNAUTHORIZED_ROLE=guest
HASURA_GRAPHQL_ACTION_BASE_URL=http://hapi:9090
HASURA_GRAPHQL_ACTION_EVM_URL=http://hapi-evm:9090

# hapi
HAPI_EOS_API_NETWORK_NAME=telos
Expand Down Expand Up @@ -66,7 +67,12 @@ HAPI_EVM_ENDPOINT=https://testnet.telos.net/evm
HAPI_EVM_API_ENDPOINTS=["https://telos-testnet.edenia.cloud","https://telos-testnet.cryptolions.io","https://testnet.telos.eosrio.io","https://test.telos.eosusa.io"]
HAPI_EVM_NETWORK_CHAIN_ID=1eaa0824707c8c16bd25145493bf062aecddfeb56c736f6ba6397f3195f33c9f
HAPI_EVM_EOS_EVM_ACCOUNT=eosio.evm
HAPI_EVM_BLOCK_INTERVAL_SEC=0.3
HAPI_EVM_BLOCK_INTERVAL_SEC=0.5
HAPI_EVM_OLD_BLOCK_INTERVAL_SEC=0.1
HAPI_EVM_ATH_INTERVAL_SEC=60
HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC=86400
HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC=86400
HAPI_EVM_KEEP_HISTORY_FOR_YEARS=1
HAPI_EVM_HYPERION_API=https://test.telos.eosusa.io
HAPI_EVM_HYPERION_START_AT=2021-06-02T00:00:00.000+00:00

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/deploy-telos-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ jobs:
HAPI_EVM_NETWORK_CHAIN_ID: 1eaa0824707c8c16bd25145493bf062aecddfeb56c736f6ba6397f3195f33c9f
HAPI_EVM_EOS_EVM_ACCOUNT: ${{ secrets.HAPI_EVM_EOS_EVM_ACCOUNT }}
HAPI_EVM_BLOCK_INTERVAL_SEC: ${{ secrets.HAPI_EVM_BLOCK_INTERVAL_SEC }}
HAPI_EVM_OLD_BLOCK_INTERVAL_SEC: ${{ secrets.HAPI_EVM_OLD_BLOCK_INTERVAL_SEC }}
HAPI_EVM_ATH_INTERVAL_SEC: ${{ secrets.HAPI_EVM_ATH_INTERVAL_SEC }}
HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC: ${{ secrets.HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC }}
HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC: ${{ secrets.HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC }}
HAPI_EVM_KEEP_HISTORY_FOR_YEARS: ${{ secrets.HAPI_EVM_KEEP_HISTORY_FOR_YEARS }}
HAPI_EVM_HYPERION_API: ${{ secrets.HAPI_EVM_HYPERION_API }}
HAPI_EVM_HYPERION_START_AT: ${{ secrets.HAPI_EVM_HYPERION_START_AT }}
# hasura
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/deploy-telos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ jobs:
HAPI_EVM_NETWORK_CHAIN_ID: 4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11
HAPI_EVM_EOS_EVM_ACCOUNT: ${{ secrets.HAPI_EVM_EOS_EVM_ACCOUNT }}
HAPI_EVM_BLOCK_INTERVAL_SEC: ${{ secrets.HAPI_EVM_BLOCK_INTERVAL_SEC }}
HAPI_EVM_OLD_BLOCK_INTERVAL_SEC: ${{ secrets.HAPI_EVM_OLD_BLOCK_INTERVAL_SEC }}
HAPI_EVM_ATH_INTERVAL_SEC: ${{ secrets.HAPI_EVM_ATH_INTERVAL_SEC }}
HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC: ${{ secrets.HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC }}
HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC: ${{ secrets.HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC }}
HAPI_EVM_KEEP_HISTORY_FOR_YEARS: ${{ secrets.HAPI_EVM_KEEP_HISTORY_FOR_YEARS }}
HAPI_EVM_HYPERION_API: ${{ secrets.HAPI_EVM_HYPERION_API }}
HAPI_EVM_HYPERION_START_AT: ${{ secrets.HAPI_EVM_HYPERION_START_AT }}
# hasura
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ services:
HAPI_EVM_BLOCK_INTERVAL_SEC: '${HAPI_EVM_BLOCK_INTERVAL_SEC}'
HAPI_EVM_HYPERION_API: '${HAPI_EVM_HYPERION_API}'
HAPI_EVM_HYPERION_START_AT: '${HAPI_EVM_HYPERION_START_AT}'
HAPI_EVM_OLD_BLOCK_INTERVAL_SEC: '${HAPI_EVM_OLD_BLOCK_INTERVAL_SEC}'
HAPI_EVM_ATH_INTERVAL_SEC: '${HAPI_EVM_ATH_INTERVAL_SEC}'
HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC: '${HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC}'
HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC: '${HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC}'
HAPI_EVM_KEEP_HISTORY_FOR_YEARS: '${HAPI_EVM_KEEP_HISTORY_FOR_YEARS}'
hasura:
container_name: '${STAGE}-${APP_NAME}-hasura'
image: hasura/graphql-engine:v2.16.0.cli-migrations-v3
Expand Down
15 changes: 15 additions & 0 deletions hapi-evm/src/config/network.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,18 @@ export const eosEndpoints =
export const blockIntervalSec = parseFloat(
process.env.HAPI_EVM_BLOCK_INTERVAL_SEC || '0.5'
)
export const oldBlockIntervalSec = parseFloat(
process.env.HAPI_EVM_OLD_BLOCK_INTERVAL_SEC || '0.1'
)
export const ATHIntervalSec = parseFloat(
process.env.HAPI_EVM_ATH_INTERVAL_SEC || '60'
)
export const cleanOldBlockIntervalSec = parseFloat(
process.env.HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC || '86400'
)
export const cleanOldTransferIntervalSec = parseFloat(
process.env.HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC || '86400'
)
export const keepHistoryForYears = parseInt(
process.env.HAPI_EVM_KEEP_HISTORY_FOR_YEARS || '1'
)
5 changes: 4 additions & 1 deletion hapi-evm/src/models/block/queries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import moment from 'moment'
import { gql } from 'graphql-request'

import { networkConfig } from '../../config'
import { coreUtil } from '../../utils'
import { OperationType, TableType, Operation } from '../default.model'
import { CappedBlock } from './interfaces'
Expand Down Expand Up @@ -139,7 +140,9 @@ export const deleteOldBlocks = async () => {
`

await coreUtil.hasura.default.request<BlockDeleteResponse>(mutation, {
date: moment().subtract(1, 'years').format('YYYY-MM-DD')
date: moment()
.subtract(networkConfig.keepHistoryForYears, 'years')
.format('YYYY-MM-DD')
})
}

Expand Down
5 changes: 4 additions & 1 deletion hapi-evm/src/models/transfer/queries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import moment from 'moment'
import { gql } from 'graphql-request'

import { networkConfig } from '../../config'
import { coreUtil } from '../../utils'
import { Transfer, Type } from './interfaces'
import { historicalStatsModel } from '..'
Expand Down Expand Up @@ -59,6 +60,8 @@ export const deleteOldTransfers = async () => {
`

await coreUtil.hasura.default.request<TransferDeleteResponse>(mutation, {
date: moment().subtract(1, 'years').format('YYYY-MM-DD')
date: moment()
.subtract(networkConfig.keepHistoryForYears, 'years')
.format('YYYY-MM-DD')
})
}
8 changes: 4 additions & 4 deletions hapi-evm/src/services/block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const syncFullBlock = async (blockNumber: number | bigint) => {

const blockTimestamp = new Date(Number(block.timestamp) * 1000)
const isBefore = moment(blockTimestamp).isBefore(
moment().subtract(1, 'years')
moment().subtract(networkConfig.keepHistoryForYears, 'years')
)

if (isBefore) return
Expand Down Expand Up @@ -186,23 +186,23 @@ const syncBlockWorker = (): defaultModel.Worker => {
const syncOldBlockWorker = (): defaultModel.Worker => {
return {
name: 'SYNC OLD BLOCK WORKER',
intervalSec: 0.1,
intervalSec: networkConfig.oldBlockIntervalSec,
action: syncOldBlocks
}
}

const syncATHWorker = (): defaultModel.Worker => {
return {
name: 'SYNC ATH WORKER',
intervalSec: 60,
intervalSec: networkConfig.ATHIntervalSec,
action: syncATH
}
}

const cleanOldBlocksWorker = (): defaultModel.Worker => {
return {
name: 'CLEAN UP OLD BLOCKS WORKER',
intervalSec: 86400,
intervalSec: networkConfig.cleanOldBlockIntervalSec,
action: cleanOldBlocks
}
}
Expand Down
3 changes: 2 additions & 1 deletion hapi-evm/src/services/transfer.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { defaultModel, transferModel } from '../models'
import { networkConfig } from '../config'

const cleanOldTransfersWorker = (): defaultModel.Worker => {
return {
name: 'CLEAN UP OLD TRANSFER WORKER',
intervalSec: 86400,
intervalSec: networkConfig.cleanOldTransferIntervalSec,
action: async () => {
await transferModel.queries.deleteOldTransfers()
}
Expand Down
5 changes: 5 additions & 0 deletions kubernetes/configmap-dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ data:
HAPI_EVM_NETWORK_CHAIN_ID: '${HAPI_EVM_NETWORK_CHAIN_ID}'
HAPI_EVM_EOS_EVM_ACCOUNT: '${HAPI_EVM_EOS_EVM_ACCOUNT}'
HAPI_EVM_BLOCK_INTERVAL_SEC: '${HAPI_EVM_BLOCK_INTERVAL_SEC}'
HAPI_EVM_OLD_BLOCK_INTERVAL_SEC: '${HAPI_EVM_OLD_BLOCK_INTERVAL_SEC}'
HAPI_EVM_ATH_INTERVAL_SEC: '${HAPI_EVM_ATH_INTERVAL_SEC}'
HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC: '${HAPI_EVM_CLEAN_OLD_BLOCK_INTERVAL_SEC}'
HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC: '${HAPI_EVM_CLEAN_OLD_TRANSFER_INTERVAL_SEC}'
HAPI_EVM_KEEP_HISTORY_FOR_YEARS: '${HAPI_EVM_KEEP_HISTORY_FOR_YEARS}'
HAPI_EVM_HYPERION_API: '${HAPI_EVM_HYPERION_API}'
HAPI_EVM_HYPERION_START_AT: '${HAPI_EVM_HYPERION_START_AT}'
---
Expand Down

0 comments on commit f278080

Please sign in to comment.