Skip to content

Commit

Permalink
Merge pull request #1272 from edenia/dev
Browse files Browse the repository at this point in the history
Production Release
  • Loading branch information
xavier506 authored Aug 30, 2023
2 parents 8be7ca6 + 4d9c6d8 commit 79324e4
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 31 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/deploy-telos-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
REACT_APP_PUBLIC_RE_CAPTCHA_KEY: ${{ secrets.REACT_APP_PUBLIC_RE_CAPTCHA_KEY }}
REACT_APP_EVM_ENDPOINT: 'https://testnet.telos.net/evm'
REACT_APP_EVM_BLOCK_EXPLORER_URL: 'https://testnet.teloscan.io/block/(block)'
REACT_APP_EVM_ENDPOINTS: '[\"https://testnet.telos.net/evm\"]'
REACT_APP_EVM_ENDPOINTS: '["https://testnet.telos.net/evm"]'

- name: Build and deploy kubernetes files
id: build_kubernetes_files
Expand Down Expand Up @@ -117,15 +117,15 @@ jobs:
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: ${{ 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 }}
HAPI_EVM_EOS_EVM_ACCOUNT: eosio.evm
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
# hasura
HASURA_GRAPHQL_ENABLE_CONSOLE: 'true'
HASURA_GRAPHQL_DATABASE_URL: ${{ secrets.HASURA_GRAPHQL_DATABASE_URL }}
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/deploy-telos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
REACT_APP_PUBLIC_RE_CAPTCHA_KEY: ${{ secrets.REACT_APP_PUBLIC_RE_CAPTCHA_KEY }}
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://rpc1.eu.telos.net/evm\",\"https://api.kainosbp.com/evm\",\"https://mainnet.telos.net/evm\",\"https://rpc1.us.telos.net/evm\",\"https://rpc2.eu.telos.net/evm\",\"https://rpc2.us.telos.net/evm\",\"https://evm.teloskorea.com/evm\",\"https://rpc2.teloskorea.com/evm\",\"https://rpc01.us.telosunlimited.io/evm\"]'
REACT_APP_EVM_ENDPOINTS: '["https://rpc1.eu.telos.net/evm","https://api.kainosbp.com/evm","https://mainnet.telos.net/evm","https://rpc1.us.telos.net/evm","https://rpc2.eu.telos.net/evm","https://rpc2.us.telos.net/evm","https://evm.teloskorea.com/evm","https://rpc2.teloskorea.com/evm","https://rpc01.us.telosunlimited.io/evm"]'

- name: Build and deploy kubernetes files
id: build_kubernetes_files
Expand Down Expand Up @@ -117,15 +117,15 @@ jobs:
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: ${{ 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 }}
HAPI_EVM_EOS_EVM_ACCOUNT: eosio.evm
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: 2020-11-29T08:45:00.000+00:00
# hasura
HASURA_GRAPHQL_ENABLE_CONSOLE: 'true'
HASURA_GRAPHQL_DATABASE_URL: ${{ secrets.HASURA_GRAPHQL_DATABASE_URL }}
Expand Down
43 changes: 33 additions & 10 deletions hapi-evm/src/services/block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,16 @@ const syncFullBlock = async (blockNumber: number | bigint) => {

if (blockExist) return

const transactionsCount = block.transactions?.length

if (transactionsCount) {
await historicalStatsModel.queries.saveOrIncrement({
total_transactions: transactionsCount
})
}

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

if (isBefore) return
if (isBefore) {
await incrementTotalTransactions(block.transactions?.length)

return
}

const cappedBlock = {
hash: block.hash.toString(),
Expand All @@ -63,7 +59,26 @@ const syncFullBlock = async (blockNumber: number | bigint) => {
timestamp: blockTimestamp
}

await blockModel.queries.add_or_modify(cappedBlock)
try {
await blockModel.queries.add_or_modify(cappedBlock)
} catch (error: any) {
const CONSTRAINT_VIOLATION = 'constraint-violation'
const errorDetails = error?.response?.errors[0]?.extensions

if (errorDetails) {
if (errorDetails?.code === CONSTRAINT_VIOLATION) {
console.log('error: trying to insert a duplicated block')
} else {
console.log(errorDetails.message)
}
} else {
console.log(error)
}

return
}

await incrementTotalTransactions(block.transactions?.length)

// TODO: review this logic

Expand Down Expand Up @@ -102,6 +117,14 @@ const syncFullBlock = async (blockNumber: number | bigint) => {
await Promise.all(transactionsPromises)
}

const incrementTotalTransactions = async (transactionsCount: number) => {
if (transactionsCount) {
await historicalStatsModel.queries.saveOrIncrement({
total_transactions: transactionsCount
})
}
}

const getBlock = async () => {
let blockNumber: bigint
const lastBlockInDB = (await blockModel.queries.default.get(
Expand Down
4 changes: 4 additions & 0 deletions hasura/metadata/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ actions:
definition:
kind: ""
handler: '{{HASURA_GRAPHQL_ACTION_EVM_URL}}/evm-token-history'
permissions:
- role: guest
- name: evm_transactions_history
definition:
kind: ""
handler: '{{HASURA_GRAPHQL_ACTION_EVM_URL}}/evm-transactions-history'
permissions:
- role: guest
- name: getProducersInfo
definition:
kind: synchronous
Expand Down
10 changes: 9 additions & 1 deletion webapp/src/config/evm.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { eosConfig } from 'config'

let _avgBlockTime = 'N/A'
let _endpoints

switch (eosConfig.networkName) {
case 'telos-testnet':
Expand All @@ -15,9 +16,16 @@ switch (eosConfig.networkName) {
break
}

try {
_endpoints = JSON.parse(process.env.REACT_APP_EVM_ENDPOINTS || '[]') || []
} catch (error) {
console.error(error)
_endpoints = []
}

export const avgBlockTime = _avgBlockTime
export const maxTPSDataSize = 30 / _avgBlockTime || 0
export const account = 'eosio.evm'
export const endpoint = process.env.REACT_APP_EVM_ENDPOINT
export const blockExplorerUrl = process.env.REACT_APP_EVM_BLOCK_EXPLORER_URL
export const endpoints = JSON.parse(process.env.REACT_APP_EVM_ENDPOINTS || '[]') || []
export const endpoints = _endpoints

0 comments on commit 79324e4

Please sign in to comment.