bnb-chain / bsc-relayer

An implementation of relay service to relay cross chain packages from BNB Beacon Chain to BNB Smart Chain
GNU Lesser General Public License v3.0
101 stars 51 forks source link

ERROR main websocket client is dialing or stopped, can't send any request #38

Closed tdiesler closed 3 years ago

tdiesler commented 3 years ago

When starting the relayer, I now see ...

bash-5.0# bsc-relayer --bbc-network-type 0 --config-type local --config-path /opt/app/config/config.json
2021-06-29 09:43:40 INFO Serve start admin server at 0.0.0.0:8080
2021-06-29 09:43:40 ERROR main websocket client is dialing or stopped, can't send any request

with ...

bash-5.0# cat /opt/app/config/config.json
{
  "cross_chain_config": {
    "source_chain_id": 1,
    "dest_chain_id": 2,
    "monitor_channel_list": [1, 2, 3, 8, 9],
    "competition_mode": false
  },
  "bbc_config": {
    "rpc_addrs": [
      "http://data-seed-prealpha-1-s1.binance.org:80"
    ],
    "mnemonic_type": "local_mnemonic",
    "aws_region": "",
    "aws_secret_name": "",
    "mnemonic": "",
    "sleep_millisecond_for_wait_block": 500,
    "clean_up_block_interval": 20,
    "block_interval_for_clean_up_undelivered_packages": 1000,
    "behind_block_threshold": 100
  },
  "bsc_config": {
    "key_type": "local_private_key",
    "aws_region": "",
    "aws_secret_name": "",
    "private_key": "xxx",
    "providers": [
      "https://data-seed-prebsc-1-s1.binance.org:8545"
    ],
    "gas_limit": 4700000,
    "gas_price": 20000000000,
    "monitor_data_seed_list": [],
    "unconfirmed_tx_threshold": 500
  },
  "log_config": {
    "level": "DEBUG",
    "filename": "",
    "max_file_size_in_mb": 0,
    "max_backups_of_log_files": 0,
    "max_age_to_retain_log_files_in_days": 0,
    "use_console_logger": true,
    "use_file_logger": false,
    "compress": false
  },
  "db_config": {
    "dialect": "sqlite3",
    "db_path": ""
  },
  "admin_config": {
    "listen_addr": "0.0.0.0:8080"
  },
  "alert_config": {
    "enable_alert": true,
    "enable_heart_beat": false,
    "interval": 300,
    "identity": "your_service_name",
    "telegram_bot_id": "your_bot_id",
    "telegram_chat_id": "your_chat_id",
    "balance_threshold": "1000000000000000000",
    "sequence_gap_threshold": 10
  }
}
yutianwu commented 3 years ago

use tcp://data-seed-prealpha-1-s1.binance.org:80

tdiesler commented 3 years ago

Using ...

  "bbc_config": {
    "rpc_addrs": [
      "http://data-seed-prealpha-1-s1.binance.org:80"
    ],

  "bsc_config": {
    "providers": [
      "tcp://data-seed-prealpha-1-s1.binance.org:80"
    ],

gives ...

2021-06-29 10:19:54 INFO Serve start admin server at 0.0.0.0:8080
panic: new eth client error

goroutine 1 [running]:
github.com/binance-chain/bsc-relayer/executor.initClients(0xc0004757c0, 0x1, 0x4, 0xc00000e7a0, 0x306e99d6dc1b05f9, 0xb0cfa6e3cba80702)
    /opt/app/executor/bsc_executor.go:81 +0x2d2
github.com/binance-chain/bsc-relayer/executor.NewBSCExecutor(0x0, 0xc0000828a0, 0xc00001e600, 0x0, 0x0, 0xc000ba9e40)
    /opt/app/executor/bsc_executor.go:109 +0xc4
main.main()
    /opt/app/main.go:120 +0x384

BTW, thanks for continuing support. Once we have this working, I'll do a writeup for the benefit of others.

yutianwu commented 3 years ago

? why use the same endpoint ???????????

tdiesler commented 3 years ago

Well, I can only use what is documented here and what you told me here

Do you have a complete config.json that is working, perhaps both for mainnet & testnet? This could speed up the process quite a bit.

yutianwu commented 3 years ago

"bbc_config": { "rpc_addrs": [ "tcp://data-seed-pre-0-s1.binance.org:80" ],

"bsc_config": { "providers": [ "https://data-seed-prebsc-1-s1.binance.org:8545" ],

tdiesler commented 3 years ago

Ok, now I get ...

bash-5.0# bsc-relayer --bbc-network-type 0 --config-type local --config-path config/config.json
2021-06-29 11:19:50 INFO Serve start admin server at 0.0.0.0:8080
2021-06-29 11:19:51 INFO main Starting relayer
2021-06-29 11:19:52 INFO registerRelayerHub Register this relayer to RelayerHub
panic: insufficient funds for gas * price + value
goroutine 1 [running]:
github.com/binance-chain/bsc-relayer/relayer.(*Relayer).registerRelayerHub(0xc0001a8ea0)
        /opt/app/relayer/register.go:22 +0x26d
github.com/binance-chain/bsc-relayer/relayer.(*Relayer).Start(0xc0001a8ea0, 0xd328eb, 0xc0000f7780, 0x20, 0x40)
        /opt/app/relayer/relayer.go:29 +0x2f
main.main()
        /opt/app/main.go:140 +0xbdc

which brings me back to not (easily) being able to obtain 100+ BNB for the testnet.

Let's assume testing works fine and I actually want to give this a try on the mainnet. I would then have to fund the account associated with the private key in the config with 100+ BNB. A potential attacker, who gains access to the box that holds the local config would immediately also gain access to those 100+ BNB (i.e. $30000 atm). Moving the config to AWS would not help, because the AWS secret key is also exposed - or am I missing something?

How are folks running these nodes in practise?

Shall we have a feature request that separates the registration fee from the Tx fee, so that a running node would only expose the account that holds the BNB to pay Tx fees?

I assume that "Register this relayer to RelayerHub" would be automatically done by the node when sufficiently funded. Is this a deposit that I can get back? Do I need to go through some special deregistration process or do I keep control over these 100 BNB i.e. can I withdraw any time?

tdiesler commented 3 years ago

I found this ...

yutianwu commented 3 years ago

actually, this is an opensource project and designed to relay the cross chain packages in time. you can change it as you want and you will compete with the other community members, so do your own optimization.