diff --git a/api/types.go b/api/types.go index 6f5bb80f..c2839893 100644 --- a/api/types.go +++ b/api/types.go @@ -503,6 +503,7 @@ type BlockRaw struct { // BlockbookInfo contains information about the running blockbook instance type BlockbookInfo struct { Coin string `json:"coin"` + Network string `json:"network"` Host string `json:"host"` Version string `json:"version"` GitCommit string `json:"gitCommit"` diff --git a/api/worker.go b/api/worker.go index ed5a76da..799c90e8 100644 --- a/api/worker.go +++ b/api/worker.go @@ -2413,6 +2413,7 @@ func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error) { } blockbookInfo := &BlockbookInfo{ Coin: w.is.Coin, + Network: w.is.GetNetwork(), Host: w.is.Host, Version: vi.Version, GitCommit: vi.GitCommit, diff --git a/blockbook-api.ts b/blockbook-api.ts index b69be708..2f08c6e7 100644 --- a/blockbook-api.ts +++ b/blockbook-api.ts @@ -33,6 +33,10 @@ export interface EthereumSpecific { gasLimit: number; gasUsed?: number; gasPrice?: string; + l1Fee?: number; + l1FeeScalar?: string; + l1GasPrice?: string; + l1GasUsed?: number; data?: string; parsedData?: EthereumParsedInputData; internalTransfers?: EthereumInternalTransfer[]; @@ -351,6 +355,7 @@ export interface WsBackendInfo { export interface WsInfoRes { name: string; shortcut: string; + network: string; decimals: number; version: string; bestHeight: number; diff --git a/build/templates/blockbook/blockchaincfg.json b/build/templates/blockbook/blockchaincfg.json index 525937c5..7d8fe75c 100644 --- a/build/templates/blockbook/blockchaincfg.json +++ b/build/templates/blockbook/blockchaincfg.json @@ -7,6 +7,8 @@ {{end}} "coin_name": "{{.Coin.Name}}", "coin_shortcut": "{{.Coin.Shortcut}}", +{{- if .Coin.Network}} + "network": "{{.Coin.Network}}",{{end}} "coin_label": "{{.Coin.Label}}", "rpc_url": "{{template "IPC.RPCURLTemplate" .}}", "rpc_user": "{{.IPC.RPCUser}}", diff --git a/build/tools/templates.go b/build/tools/templates.go index f414e5e1..8dfb9fb0 100644 --- a/build/tools/templates.go +++ b/build/tools/templates.go @@ -44,6 +44,7 @@ type Config struct { Coin struct { Name string `json:"name"` Shortcut string `json:"shortcut"` + Network string `json:"network,omitempty"` Label string `json:"label"` Alias string `json:"alias"` } `json:"coin"` diff --git a/common/config.go b/common/config.go index a0429805..2252b602 100644 --- a/common/config.go +++ b/common/config.go @@ -12,6 +12,7 @@ type Config struct { CoinName string `json:"coin_name"` CoinShortcut string `json:"coin_shortcut"` CoinLabel string `json:"coin_label"` + Network string `json:"network"` FourByteSignatures string `json:"fourByteSignatures"` FiatRates string `json:"fiat_rates"` FiatRatesParams string `json:"fiat_rates_params"` diff --git a/common/internalstate.go b/common/internalstate.go index 7c5c95ae..29a7a333 100644 --- a/common/internalstate.go +++ b/common/internalstate.go @@ -57,6 +57,7 @@ type InternalState struct { CoinShortcut string `json:"coinShortcut"` CoinLabel string `json:"coinLabel"` Host string `json:"host"` + Network string `json:"network,omitempty"` DbState uint32 `json:"dbState"` ExtendedIndex bool `json:"extendedIndex"` @@ -305,6 +306,15 @@ func (is *InternalState) computeAvgBlockPeriod() { is.AvgBlockPeriod = (is.BlockTimes[last] - is.BlockTimes[first]) / avgBlockPeriodSample } +// GetNetwork returns network. If not set returns the same value as CoinShortcut +func (is *InternalState) GetNetwork() string { + network := is.Network + if network == "" { + return is.CoinShortcut + } + return network +} + // SetBackendInfo sets new BackendInfo func (is *InternalState) SetBackendInfo(bi *BackendInfo) { is.mux.Lock() diff --git a/configs/coins/bsc.json b/configs/coins/bsc.json index a22923d8..8d15e80d 100644 --- a/configs/coins/bsc.json +++ b/configs/coins/bsc.json @@ -2,6 +2,7 @@ "coin": { "name": "BNB Smart Chain", "shortcut": "BNB", + "network": "BNB", "label": "BNB Smart Chain", "alias": "bsc" }, diff --git a/configs/coins/bsc_archive.json b/configs/coins/bsc_archive.json index b40584ea..df80c6d0 100644 --- a/configs/coins/bsc_archive.json +++ b/configs/coins/bsc_archive.json @@ -2,6 +2,7 @@ "coin": { "name": "BNB Smart Chain Archive", "shortcut": "BNB", + "network": "BNB", "label": "BNB Smart Chain", "alias": "bsc_archive" }, diff --git a/configs/coins/optimism.json b/configs/coins/optimism.json index 1c6c8ae9..07ab65ec 100644 --- a/configs/coins/optimism.json +++ b/configs/coins/optimism.json @@ -1,66 +1,67 @@ { - "coin": { - "name": "Optimism", - "shortcut": "ETH", - "label": "Optimism", - "alias": "optimism" - }, - "ports": { - "backend_rpc": 8200, - "backend_p2p": 38400, - "backend_http": 8300, - "backend_authrpc": 8400, - "blockbook_internal": 9200, - "blockbook_public": 9300 - }, - "ipc": { - "rpc_url_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}", - "rpc_timeout": 25 - }, - "backend": { - "package_name": "backend-optimism", - "package_revision": "satoshilabs-1", - "system_user": "optimism", - "version": "1.101315.1", - "binary_url": "https://github.com/ethereum-optimism/op-geth/archive/refs/tags/v1.101315.1.tar.gz", - "verification_type": "sha256", - "verification_source": "f0f31ef2982f87f9e3eb90f2b603f5fcd9d680e487d35f5bdcf5aeba290b153f", - "extract_command": "mkdir backend/source && tar -C backend/source --strip 1 -xf v1.101315.1.tar.gz && cd backend/source && make geth && mv build/bin/geth ../ && rm -rf ../source && echo", - "exclude_files": [], - "exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/optimism_exec.sh 2>> {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'", - "exec_script": "optimism.sh", - "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log", - "postinst_script_template": "openssl rand -hex 32 > {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/jwtsecret", - "service_type": "simple", - "service_additional_params_template": "", - "protect_memory": true, - "mainnet": true, - "server_config_file": "", - "client_config_file": "" - }, - "blockbook": { - "package_name": "blockbook-optimism", - "system_user": "blockbook-optimism", - "internal_binding_template": ":{{.Ports.BlockbookInternal}}", - "public_binding_template": ":{{.Ports.BlockbookPublic}}", - "explorer_url": "", - "additional_params": "", - "block_chain": { - "parse": true, - "mempool_workers": 8, - "mempool_sub_workers": 2, - "block_addresses_to_keep": 300, - "additional_params": { - "mempoolTxTimeoutHours": 48, - "queryBackendOnMempoolResync": false, - "fiat_rates": "coingecko", - "fiat_rates_vs_currencies": "AED,ARS,AUD,BDT,BHD,BMD,BRL,CAD,CHF,CLP,CNY,CZK,DKK,EUR,GBP,HKD,HUF,IDR,ILS,INR,JPY,KRW,KWD,LKR,MMK,MXN,MYR,NGN,NOK,NZD,PHP,PKR,PLN,RUB,SAR,SEK,SGD,THB,TRY,TWD,UAH,USD,VEF,VND,ZAR,BTC,ETH", - "fiat_rates_params": "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"ethereum\",\"platformIdentifier\": \"ethereum\",\"platformVsCurrency\": \"eth\",\"periodSeconds\": 900}" - } + "coin": { + "name": "Optimism", + "shortcut": "ETH", + "network": "OP", + "label": "Optimism", + "alias": "optimism" + }, + "ports": { + "backend_rpc": 8200, + "backend_p2p": 38400, + "backend_http": 8300, + "backend_authrpc": 8400, + "blockbook_internal": 9200, + "blockbook_public": 9300 + }, + "ipc": { + "rpc_url_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}", + "rpc_timeout": 25 + }, + "backend": { + "package_name": "backend-optimism", + "package_revision": "satoshilabs-1", + "system_user": "optimism", + "version": "1.101315.1", + "binary_url": "https://github.com/ethereum-optimism/op-geth/archive/refs/tags/v1.101315.1.tar.gz", + "verification_type": "sha256", + "verification_source": "f0f31ef2982f87f9e3eb90f2b603f5fcd9d680e487d35f5bdcf5aeba290b153f", + "extract_command": "mkdir backend/source && tar -C backend/source --strip 1 -xf v1.101315.1.tar.gz && cd backend/source && make geth && mv build/bin/geth ../ && rm -rf ../source && echo", + "exclude_files": [], + "exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/optimism_exec.sh 2>> {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'", + "exec_script": "optimism.sh", + "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log", + "postinst_script_template": "openssl rand -hex 32 > {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/jwtsecret", + "service_type": "simple", + "service_additional_params_template": "", + "protect_memory": true, + "mainnet": true, + "server_config_file": "", + "client_config_file": "" + }, + "blockbook": { + "package_name": "blockbook-optimism", + "system_user": "blockbook-optimism", + "internal_binding_template": ":{{.Ports.BlockbookInternal}}", + "public_binding_template": ":{{.Ports.BlockbookPublic}}", + "explorer_url": "", + "additional_params": "", + "block_chain": { + "parse": true, + "mempool_workers": 8, + "mempool_sub_workers": 2, + "block_addresses_to_keep": 300, + "additional_params": { + "mempoolTxTimeoutHours": 48, + "queryBackendOnMempoolResync": false, + "fiat_rates": "coingecko", + "fiat_rates_vs_currencies": "AED,ARS,AUD,BDT,BHD,BMD,BRL,CAD,CHF,CLP,CNY,CZK,DKK,EUR,GBP,HKD,HUF,IDR,ILS,INR,JPY,KRW,KWD,LKR,MMK,MXN,MYR,NGN,NOK,NZD,PHP,PKR,PLN,RUB,SAR,SEK,SGD,THB,TRY,TWD,UAH,USD,VEF,VND,ZAR,BTC,ETH", + "fiat_rates_params": "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"ethereum\",\"platformIdentifier\": \"ethereum\",\"platformVsCurrency\": \"eth\",\"periodSeconds\": 900}" + } + } + }, + "meta": { + "package_maintainer": "IT", + "package_maintainer_email": "it@satoshilabs.com" } - }, - "meta": { - "package_maintainer": "IT", - "package_maintainer_email": "it@satoshilabs.com" - } -} \ No newline at end of file +} diff --git a/configs/coins/optimism_archive.json b/configs/coins/optimism_archive.json index 9d9daac0..46967e5e 100644 --- a/configs/coins/optimism_archive.json +++ b/configs/coins/optimism_archive.json @@ -1,69 +1,70 @@ { - "coin": { - "name": "Optimism Archive", - "shortcut": "ETH", - "label": "Optimism", - "alias": "optimism_archive" - }, - "ports": { - "backend_rpc": 8202, - "backend_p2p": 38402, - "backend_http": 8302, - "backend_authrpc": 8402, - "blockbook_internal": 9202, - "blockbook_public": 9302 - }, - "ipc": { - "rpc_url_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}", - "rpc_timeout": 25 - }, - "backend": { - "package_name": "backend-optimism-archive", - "package_revision": "satoshilabs-1", - "system_user": "optimism", - "version": "1.101315.1", - "binary_url": "https://github.com/ethereum-optimism/op-geth/archive/refs/tags/v1.101315.1.tar.gz", - "verification_type": "sha256", - "verification_source": "f0f31ef2982f87f9e3eb90f2b603f5fcd9d680e487d35f5bdcf5aeba290b153f", - "extract_command": "mkdir backend/source && tar -C backend/source --strip 1 -xf v1.101315.1.tar.gz && cd backend/source && make geth && mv build/bin/geth ../ && rm -rf ../source && echo", - "exclude_files": [], - "exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/optimism_archive_exec.sh 2>> {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'", - "exec_script": "optimism_archive.sh", - "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log", - "postinst_script_template": "openssl rand -hex 32 > {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/jwtsecret", - "service_type": "simple", - "service_additional_params_template": "", - "protect_memory": true, - "mainnet": true, - "server_config_file": "", - "client_config_file": "" - }, - "blockbook": { - "package_name": "blockbook-optimism-archive", - "system_user": "blockbook-optimism", - "internal_binding_template": ":{{.Ports.BlockbookInternal}}", - "public_binding_template": ":{{.Ports.BlockbookPublic}}", - "explorer_url": "", - "additional_params": "-workers=16", - "block_chain": { - "parse": true, - "mempool_workers": 8, - "mempool_sub_workers": 2, - "block_addresses_to_keep": 600, - "additional_params": { - "address_aliases": true, - "mempoolTxTimeoutHours": 48, - "processInternalTransactions": true, - "queryBackendOnMempoolResync": false, - "fiat_rates": "coingecko", - "fiat_rates_vs_currencies": "AED,ARS,AUD,BDT,BHD,BMD,BRL,CAD,CHF,CLP,CNY,CZK,DKK,EUR,GBP,HKD,HUF,IDR,ILS,INR,JPY,KRW,KWD,LKR,MMK,MXN,MYR,NGN,NOK,NZD,PHP,PKR,PLN,RUB,SAR,SEK,SGD,THB,TRY,TWD,UAH,USD,VEF,VND,ZAR,BTC,ETH", - "fiat_rates_params": "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"ethereum\",\"platformIdentifier\": \"ethereum\",\"platformVsCurrency\": \"eth\",\"periodSeconds\": 900}", - "fourByteSignatures": "https://www.4byte.directory/api/v1/signatures/" - } + "coin": { + "name": "Optimism Archive", + "shortcut": "ETH", + "network": "OP", + "label": "Optimism", + "alias": "optimism_archive" + }, + "ports": { + "backend_rpc": 8202, + "backend_p2p": 38402, + "backend_http": 8302, + "backend_authrpc": 8402, + "blockbook_internal": 9202, + "blockbook_public": 9302 + }, + "ipc": { + "rpc_url_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}", + "rpc_timeout": 25 + }, + "backend": { + "package_name": "backend-optimism-archive", + "package_revision": "satoshilabs-1", + "system_user": "optimism", + "version": "1.101315.1", + "binary_url": "https://github.com/ethereum-optimism/op-geth/archive/refs/tags/v1.101315.1.tar.gz", + "verification_type": "sha256", + "verification_source": "f0f31ef2982f87f9e3eb90f2b603f5fcd9d680e487d35f5bdcf5aeba290b153f", + "extract_command": "mkdir backend/source && tar -C backend/source --strip 1 -xf v1.101315.1.tar.gz && cd backend/source && make geth && mv build/bin/geth ../ && rm -rf ../source && echo", + "exclude_files": [], + "exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/optimism_archive_exec.sh 2>> {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'", + "exec_script": "optimism_archive.sh", + "logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log", + "postinst_script_template": "openssl rand -hex 32 > {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/jwtsecret", + "service_type": "simple", + "service_additional_params_template": "", + "protect_memory": true, + "mainnet": true, + "server_config_file": "", + "client_config_file": "" + }, + "blockbook": { + "package_name": "blockbook-optimism-archive", + "system_user": "blockbook-optimism", + "internal_binding_template": ":{{.Ports.BlockbookInternal}}", + "public_binding_template": ":{{.Ports.BlockbookPublic}}", + "explorer_url": "", + "additional_params": "-workers=16", + "block_chain": { + "parse": true, + "mempool_workers": 8, + "mempool_sub_workers": 2, + "block_addresses_to_keep": 600, + "additional_params": { + "address_aliases": true, + "mempoolTxTimeoutHours": 48, + "processInternalTransactions": true, + "queryBackendOnMempoolResync": false, + "fiat_rates": "coingecko", + "fiat_rates_vs_currencies": "AED,ARS,AUD,BDT,BHD,BMD,BRL,CAD,CHF,CLP,CNY,CZK,DKK,EUR,GBP,HKD,HUF,IDR,ILS,INR,JPY,KRW,KWD,LKR,MMK,MXN,MYR,NGN,NOK,NZD,PHP,PKR,PLN,RUB,SAR,SEK,SGD,THB,TRY,TWD,UAH,USD,VEF,VND,ZAR,BTC,ETH", + "fiat_rates_params": "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"ethereum\",\"platformIdentifier\": \"ethereum\",\"platformVsCurrency\": \"eth\",\"periodSeconds\": 900}", + "fourByteSignatures": "https://www.4byte.directory/api/v1/signatures/" + } + } + }, + "meta": { + "package_maintainer": "IT", + "package_maintainer_email": "it@satoshilabs.com" } - }, - "meta": { - "package_maintainer": "IT", - "package_maintainer_email": "it@satoshilabs.com" - } -} \ No newline at end of file +} diff --git a/configs/coins/polygon.json b/configs/coins/polygon.json index 1044b1e3..0237926a 100644 --- a/configs/coins/polygon.json +++ b/configs/coins/polygon.json @@ -2,6 +2,7 @@ "coin": { "name": "Polygon", "shortcut": "MATIC", + "network": "MATIC", "label": "Polygon", "alias": "polygon_bor" }, diff --git a/configs/coins/polygon_archive.json b/configs/coins/polygon_archive.json index 860dd01b..2533c9f3 100644 --- a/configs/coins/polygon_archive.json +++ b/configs/coins/polygon_archive.json @@ -2,6 +2,7 @@ "coin": { "name": "Polygon Archive", "shortcut": "MATIC", + "network": "MATIC", "label": "Polygon", "alias": "polygon_archive_bor" }, diff --git a/db/rocksdb.go b/db/rocksdb.go index 9c5a3b2f..58e269d7 100644 --- a/db/rocksdb.go +++ b/db/rocksdb.go @@ -1962,6 +1962,7 @@ func (d *RocksDB) LoadInternalState(config *common.Config) (*common.InternalStat } else { is.CoinLabel = config.CoinLabel } + is.Network = config.Network return is, nil } diff --git a/server/public_test.go b/server/public_test.go index 107a4a9c..84d5e1ca 100644 --- a/server/public_test.go +++ b/server/public_test.go @@ -1039,7 +1039,7 @@ var websocketTestsBitcoinType = []websocketTest{ req: websocketReq{ Method: "getInfo", }, - want: `{"id":"0","data":{"name":"Fakecoin","shortcut":"FAKE","decimals":8,"version":"unknown","bestHeight":225494,"bestHash":"00000000eb0443fd7dc4a1ed5c686a8e995057805f9a161d9a5a77a95e72b7b6","block0Hash":"","testnet":true,"backend":{"version":"001001","subversion":"/Fakecoin:0.0.1/"}}}`, + want: `{"id":"0","data":{"name":"Fakecoin","shortcut":"FAKE","network":"FAKE","decimals":8,"version":"unknown","bestHeight":225494,"bestHash":"00000000eb0443fd7dc4a1ed5c686a8e995057805f9a161d9a5a77a95e72b7b6","block0Hash":"","testnet":true,"backend":{"version":"001001","subversion":"/Fakecoin:0.0.1/"}}}`, }, { name: "websocket getBlockHash", @@ -1681,7 +1681,7 @@ var websocketTestsBitcoinTypeExtendedIndex = []websocketTest{ req: websocketReq{ Method: "getInfo", }, - want: `{"id":"0","data":{"name":"Fakecoin","shortcut":"FAKE","decimals":8,"version":"unknown","bestHeight":225494,"bestHash":"00000000eb0443fd7dc4a1ed5c686a8e995057805f9a161d9a5a77a95e72b7b6","block0Hash":"","testnet":true,"backend":{"version":"001001","subversion":"/Fakecoin:0.0.1/"}}}`, + want: `{"id":"0","data":{"name":"Fakecoin","shortcut":"FAKE","network":"FAKE","decimals":8,"version":"unknown","bestHeight":225494,"bestHash":"00000000eb0443fd7dc4a1ed5c686a8e995057805f9a161d9a5a77a95e72b7b6","block0Hash":"","testnet":true,"backend":{"version":"001001","subversion":"/Fakecoin:0.0.1/"}}}`, }, { name: "websocket getBlockHash", diff --git a/server/websocket.go b/server/websocket.go index cba5f27d..9e628222 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -277,8 +277,8 @@ var requestHandlers = map[string]func(*WebsocketServer, *websocketChannel, *WsRe c.getAddressInfoDescriptorsMux.Unlock() if l > s.is.WsGetAccountInfoLimit { if s.closeChannel(c) { - glog.Info("Client ", c.id, " exceeded getAddressInfo limit, ", c.ip) - s.is.AddWsLimitExceedingIP(c.ip) + glog.Info("Client ", c.id, " exceeded getAddressInfo limit, ", c.ip) + s.is.AddWsLimitExceedingIP(c.ip) } return } @@ -580,6 +580,7 @@ func (s *WebsocketServer) getInfo() (*WsInfoRes, error) { return &WsInfoRes{ Name: s.is.Coin, Shortcut: s.is.CoinShortcut, + Network: s.is.GetNetwork(), Decimals: s.chainParser.AmountDecimals(), BestHeight: int(height), BestHash: hash, diff --git a/server/ws_types.go b/server/ws_types.go index d91a2a56..0ebe0d19 100644 --- a/server/ws_types.go +++ b/server/ws_types.go @@ -36,6 +36,7 @@ type WsBackendInfo struct { type WsInfoRes struct { Name string `json:"name"` Shortcut string `json:"shortcut"` + Network string `json:"network"` Decimals int `json:"decimals"` Version string `json:"version"` BestHeight int `json:"bestHeight"`