Skip to content

Commit

Permalink
Merge pull request #1375 from edenia/perf/eos-evm
Browse files Browse the repository at this point in the history
Perf/eos evm
  • Loading branch information
xavier506 authored Nov 3, 2023
2 parents 8bde3a8 + b5a8b1a commit f771c8c
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 78 deletions.
25 changes: 23 additions & 2 deletions .env.jungle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# global
STAGE=dev
APP_NAME=eosio-dashboard
APP_NAME=antelope-tools

# wallet
WALLET_DATA=./wallet_data
Expand All @@ -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=jungle
Expand Down Expand Up @@ -56,7 +57,27 @@ HAPI_RE_CAPTCHA_PROJECT_ID=
HAPI_PUBLIC_RE_CAPTCHA_KEY=
HAPI_CREATE_ACCOUNT_ACTION_NAME=

#webapp
# hapi-evm
HAPI_EVM_SERVER_PORT=9090
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://api.testnet.evm.eosnetwork.com
HAPI_EVM_API_ENDPOINTS=["https://jungle.edenia.cloud","https://jungle4.eosphere.io","https://jungle4.api.eosnation.io","https://jungle4.eossweden.org"]
HAPI_EVM_NETWORK=EOSIO# EOSIO, TELOS
HAPI_EVM_NETWORK_CHAIN_ID=73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d
HAPI_EVM_EOS_EVM_ACCOUNT=eosio.evm
HAPI_EVM_BLOCK_INTERVAL_SEC=1
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://jungle.eosusa.io
HAPI_EVM_HYPERION_START_AT=2023-10-25T00:00:00.000+00:00

# webapp
PORT=3000
REACT_APP_VERSION=dev
REACT_APP_NAME=$npm_package_name
Expand Down
25 changes: 23 additions & 2 deletions .env.local
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# global
STAGE=dev
APP_NAME=eosio-dashboard
APP_NAME=antelope-tools

# wallet
WALLET_DATA=./wallet_data
Expand All @@ -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=
HASURA_GRAPHQL_ACTION_EVM_URL=

# hapi
HAPI_EOS_API_NETWORK_NAME=lacchain
Expand Down Expand Up @@ -56,7 +57,27 @@ HAPI_PUBLIC_RE_CAPTCHA_KEY=
HAPI_CREATE_ACCOUNT_ACTION_NAME=
HAPI_EOS_GET_FAUCET_ACCOUNT=

#webapp
# hapi-evm
HAPI_EVM_SERVER_PORT=9090
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://api.evm.eosnetwork.com
HAPI_EVM_API_ENDPOINTS=["https://eos.edenia.cloud","https://api.main.alohaeos.com","https://eos.api.eosnation.io","https://eos.greymass.com","https://eos.eosphere.io","https://api.eosrio.io"]
HAPI_EVM_NETWORK=EOSIO# EOSIO, TELOS
HAPI_EVM_NETWORK_CHAIN_ID=aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906
HAPI_EVM_EOS_EVM_ACCOUNT=eosio.evm
HAPI_EVM_BLOCK_INTERVAL_SEC=1
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://eos.eosusa.io
HAPI_EVM_HYPERION_START_AT=2022-01-01T00:00:00.000+00:00

# webapp
PORT=3000
REACT_APP_VERSION=dev
REACT_APP_NAME=$npm_package_name
Expand Down
23 changes: 22 additions & 1 deletion .env.mainnet
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=mainnet
Expand Down Expand Up @@ -56,7 +57,27 @@ HAPI_RE_CAPTCHA_PROJECT_ID=
HAPI_PUBLIC_RE_CAPTCHA_KEY=
HAPI_CREATE_ACCOUNT_ACTION_NAME=

#webapp
# hapi-evm
HAPI_EVM_SERVER_PORT=9090
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://api.evm.eosnetwork.com
HAPI_EVM_API_ENDPOINTS=["https://eos.edenia.cloud","https://api.main.alohaeos.com","https://eos.api.eosnation.io","https://eos.greymass.com","https://eos.eosphere.io","https://api.eosrio.io"]
HAPI_EVM_NETWORK=EOSIO# EOSIO, TELOS
HAPI_EVM_NETWORK_CHAIN_ID=aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906
HAPI_EVM_EOS_EVM_ACCOUNT=eosio.evm
HAPI_EVM_BLOCK_INTERVAL_SEC=1
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://eos.eosusa.io
HAPI_EVM_HYPERION_START_AT=2022-01-01T00:00:00.000+00:00

# webapp
PORT=3000
REACT_APP_VERSION=dev
REACT_APP_NAME=$npm_package_name
Expand Down
4 changes: 2 additions & 2 deletions .env.telostestnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# global
STAGE=dev
APP_NAME=eosio-dashboard
APP_NAME=antelope-tools

# wallet
WALLET_DATA=./wallet_data
Expand Down Expand Up @@ -76,7 +76,7 @@ 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

#webapp
# webapp
PORT=3000
REACT_APP_VERSION=dev
REACT_APP_NAME=$npm_package_name
Expand Down
2 changes: 1 addition & 1 deletion .env.ultratestnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# global
STAGE=dev
APP_NAME=eosio-dashboard
APP_NAME=antelope-tools

# wallet
WALLET_DATA=./wallet_data
Expand Down
23 changes: 22 additions & 1 deletion .github/workflows/deploy-jungle-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ jobs:
id: build_kubernetes_files
run: |
make \
build-kubernetes
build-kubernetes \
build-kubernetes-evm
env:
# general
NAMESPACE: jungle-dashboard
Expand Down Expand Up @@ -106,12 +107,32 @@ jobs:
HAPI_EOSRATE_GET_STATS_URL: ${{ secrets.HAPI_EOSRATE_GET_STATS_URL }}
HAPI_EOSRATE_GET_STATS_USER: ${{ secrets.HAPI_EOSRATE_GET_STATS_USER }}
HAPI_EOSRATE_GET_STATS_PASSWORD: ${{ secrets.HAPI_EOSRATE_GET_STATS_PASSWORD }}
# hapi-evm
HAPI_EVM_SERVER_PORT: '9090'
HAPI_EVM_SERVER_ADDRESS: '0.0.0.0'
HAPI_EVM_HASURA_URL: 'http://dashboard-hasura:8080/v1/graphql'
HAPI_EVM_HASURA_ADMIN_SECRET: ${{ secrets.HAPI_EVM_HASURA_ADMIN_SECRET }}
HAPI_EVM_DATABASE_URL: ${{ secrets.HAPI_EVM_DATABASE_URL }}
HAPI_EVM_ENDPOINT: 'https://api.testnet.evm.eosnetwork.com'
HAPI_EVM_API_ENDPOINTS: '["https://jungle.edenia.cloud","https://jungle4.eosphere.io","https://jungle4.api.eosnation.io","https://jungle4.eossweden.org"]'
HAPI_EVM_NETWORK: EOSIO
HAPI_EVM_NETWORK_CHAIN_ID: 73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d
HAPI_EVM_EOS_EVM_ACCOUNT: eosio.evm
HAPI_EVM_BLOCK_INTERVAL_SEC: 1
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://jungle.eosusa.io
HAPI_EVM_HYPERION_START_AT: 2022-01-01T00:00:00.000+00:00
# hasura
HASURA_GRAPHQL_ENABLE_CONSOLE: true
HASURA_GRAPHQL_DATABASE_URL: ${{ secrets.HASURA_GRAPHQL_DATABASE_URL }}
HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: guest
HASURA_GRAPHQL_ACTION_BASE_URL: http://dashboard-hapi:9090
HASURA_GRAPHQL_ACTION_EVM_URL: http://dashboard-hapi-evm:9091

- name: Setup and deploy kubernetes environment
uses: steebchen/kubectl@v1.1.0
Expand Down
24 changes: 22 additions & 2 deletions .github/workflows/deploy-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ jobs:
id: build_kubernetes_files
run: |
make \
build-kubernetes
build-kubernetes \
build-kubernetes-evm
env:
# general
NAMESPACE: mainnet-dashboard
Expand Down Expand Up @@ -104,13 +105,32 @@ jobs:
HAPI_EOSRATE_GET_STATS_URL: ${{ secrets.HAPI_EOSRATE_GET_STATS_URL }}
HAPI_EOSRATE_GET_STATS_USER: ${{ secrets.HAPI_EOSRATE_GET_STATS_USER }}
HAPI_EOSRATE_GET_STATS_PASSWORD: ${{ secrets.HAPI_EOSRATE_GET_STATS_PASSWORD }}

# hapi-evm
HAPI_EVM_SERVER_PORT: '9090'
HAPI_EVM_SERVER_ADDRESS: '0.0.0.0'
HAPI_EVM_HASURA_URL: 'http://dashboard-hasura:8080/v1/graphql'
HAPI_EVM_HASURA_ADMIN_SECRET: ${{ secrets.HAPI_EVM_HASURA_ADMIN_SECRET }}
HAPI_EVM_DATABASE_URL: ${{ secrets.HAPI_EVM_DATABASE_URL }}
HAPI_EVM_ENDPOINT: 'https://api.evm.eosnetwork.com'
HAPI_EVM_API_ENDPOINTS: '["https://eos.edenia.cloud","https://api.main.alohaeos.com","https://eos.api.eosnation.io","https://eos.greymass.com","https://eos.eosphere.io","https://api.eosrio.io"]'
HAPI_EVM_NETWORK: EOSIO
HAPI_EVM_NETWORK_CHAIN_ID: aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906
HAPI_EVM_EOS_EVM_ACCOUNT: eosio.evm
HAPI_EVM_BLOCK_INTERVAL_SEC: 1
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://eos.eosusa.io
HAPI_EVM_HYPERION_START_AT: 2022-01-01T00:00:00.000+00:00
# hasura
HASURA_GRAPHQL_ENABLE_CONSOLE: 'true'
HASURA_GRAPHQL_DATABASE_URL: ${{ secrets.HASURA_GRAPHQL_DATABASE_URL }}
HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.HASURA_GRAPHQL_ADMIN_SECRET }}
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: guest
HASURA_GRAPHQL_ACTION_BASE_URL: http://dashboard-hapi:9090
HASURA_GRAPHQL_ACTION_EVM_URL: http://dashboard-hapi-evm:9091

- name: Setup and deploy kubernetes environment
uses: steebchen/kubectl@v1.1.0
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-telos-testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
HAPI_EVM_DATABASE_URL: ${{ secrets.HAPI_EVM_DATABASE_URL }}
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: TELOS
HAPI_EVM_NETWORK_CHAIN_ID: 1eaa0824707c8c16bd25145493bf062aecddfeb56c736f6ba6397f3195f33c9f
HAPI_EVM_EOS_EVM_ACCOUNT: eosio.evm
HAPI_EVM_BLOCK_INTERVAL_SEC: 0.5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-telos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
HAPI_EVM_DATABASE_URL: ${{ secrets.HAPI_EVM_DATABASE_URL }}
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: TELOS
HAPI_EVM_NETWORK_CHAIN_ID: 4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11
HAPI_EVM_EOS_EVM_ACCOUNT: eosio.evm
HAPI_EVM_BLOCK_INTERVAL_SEC: 0.5
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ services:
HAPI_EVM_DATABASE_URL: '${HAPI_EVM_DATABASE_URL}'
HAPI_EVM_ENDPOINT: '${HAPI_EVM_ENDPOINT}'
HAPI_EVM_API_ENDPOINTS: '${HAPI_EVM_API_ENDPOINTS}'
HAPI_EVM_NETWORK: '${HAPI_EVM_NETWORK}'
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}'
Expand Down
4 changes: 4 additions & 0 deletions hapi-evm/src/config/network.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { AllowedNetworkType } from '../models/default.model'

export const evmEndpoint =
process.env.HAPI_EVM_ENDPOINT || 'http://localhost/evm'
export const network: AllowedNetworkType =
(process.env.HAPI_EVM_NETWORK as AllowedNetworkType) || 'EOSIO'
export const chainId = process.env.HAPI_EVM_NETWORK_CHAIN_ID || 'chainid1'
export const evmAccount = process.env.HAPI_EVM_EOS_EVM_ACCOUNT || 'eosio.evm'
export const eosEndpoints =
Expand Down
13 changes: 13 additions & 0 deletions hapi-evm/src/models/default.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@ export interface Worker {
intervalSec?: number
action: () => Promise<void>
}

export const AllowedNetwork = {
EOSIO: 'EOSIO',
TELOS: 'TELOS'
} as const

export type AllowedNetworkType = keyof typeof AllowedNetwork

export interface BuilderListener {
type: string
notified_account: string
apply: (action: any) => Promise<void>
}
24 changes: 0 additions & 24 deletions hapi-evm/src/services/block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ import moment from 'moment'
const httpProvider = new Web3.providers.HttpProvider(networkConfig.evmEndpoint)
const web3 = new Web3(httpProvider)

// const test = async () => {
// const tempBlock: Block = await web3.eth.getBlock(0)
// console.log('🚀 ~ tempBlock:', tempBlock)

// const trx: TransactionInfo = await web3.eth.getTransaction(
// '0x4b00d79018d46210b31829285541ae72653e03229a9cff67f362416e5a1c274c'
// )
// console.log('🚀 ~ trx:', trx)
// console.log('🚀 ~ gas:', Number(trx.gas))
// }

// test()

// TODO: syncronize passed blocks
const syncFullBlock = async (blockNumber: number | bigint) => {
const block: Block = await web3.eth.getBlock(blockNumber)

Expand Down Expand Up @@ -80,8 +66,6 @@ const syncFullBlock = async (blockNumber: number | bigint) => {

await incrementTotalTransactions(block.transactions?.length)

// TODO: review this logic

const transactionsPromises = [
cappedBlock.transactions.reduce(
async (
Expand Down Expand Up @@ -143,27 +127,21 @@ const getBlock = async () => {

const syncOldBlocks = async (): Promise<void> => {
const paramStats = await paramModel.queries.getState()

if (paramStats.isSynced) return

const nextBlock = paramStats.nextBlock
const isUpToDate = await blockModel.queries.default.get({
number: { _eq: nextBlock }
})

if (!isUpToDate) {
const nextBlockTo = await blockModel.queries.default.getNextBlock(nextBlock)
const nextBlockToNumber = nextBlockTo[0]?.number || 0

if (nextBlockToNumber > nextBlock) {
console.log(
`🚦 Syncing blocks behind, pending ${nextBlockToNumber - nextBlock} `
)
}

await syncFullBlock(nextBlock)
}

await paramModel.queries.saveOrUpdate(
nextBlock + 1 * Number(!isUpToDate),
!!isUpToDate
Expand All @@ -181,9 +159,7 @@ const cleanOldBlocks = async () => {
const syncATH = async () => {
const currentState = await historicalStatsModel.queries.getState()
const partialATH = await StatsModel.queries.getPartialATH()

if (!partialATH) return

if (
currentState.tps_all_time_high.transactions_count ||
0 < partialATH.ath_transactions_count
Expand Down
Loading

0 comments on commit f771c8c

Please sign in to comment.