diff --git a/.github/workflows/deploy-telos-testnet.yaml b/.github/workflows/deploy-telos-testnet.yaml index 3cbd1e9a..2091f567 100644 --- a/.github/workflows/deploy-telos-testnet.yaml +++ b/.github/workflows/deploy-telos-testnet.yaml @@ -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 @@ -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 }} diff --git a/.github/workflows/deploy-telos.yaml b/.github/workflows/deploy-telos.yaml index 3cf0807e..c66ba6a4 100644 --- a/.github/workflows/deploy-telos.yaml +++ b/.github/workflows/deploy-telos.yaml @@ -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 @@ -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 }} diff --git a/hapi-evm/src/services/block.service.ts b/hapi-evm/src/services/block.service.ts index 55feedcb..e8b6fa81 100644 --- a/hapi-evm/src/services/block.service.ts +++ b/hapi-evm/src/services/block.service.ts @@ -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(), @@ -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 @@ -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( diff --git a/hasura/metadata/actions.yaml b/hasura/metadata/actions.yaml index a4fdf99e..d214f69e 100644 --- a/hasura/metadata/actions.yaml +++ b/hasura/metadata/actions.yaml @@ -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 diff --git a/webapp/src/config/evm.config.js b/webapp/src/config/evm.config.js index 972b2fde..b16e4c09 100644 --- a/webapp/src/config/evm.config.js +++ b/webapp/src/config/evm.config.js @@ -1,6 +1,7 @@ import { eosConfig } from 'config' let _avgBlockTime = 'N/A' +let _endpoints switch (eosConfig.networkName) { case 'telos-testnet': @@ -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