diff --git a/app/process/watcher/ethereum/watcher.go b/app/process/watcher/ethereum/watcher.go index 0b896db18..e13393f40 100644 --- a/app/process/watcher/ethereum/watcher.go +++ b/app/process/watcher/ethereum/watcher.go @@ -64,6 +64,7 @@ func (ew *Watcher) listenForEvents(q *pair.Queue) { select { case err := <-sub.Err(): ew.logger.Errorf("Burn Event Logs subscription failed. Error: [%s].", err) + go ew.listenForEvents(q) return case eventLog := <-events: go ew.handleLog(eventLog, q) diff --git a/app/process/watcher/message/watcher.go b/app/process/watcher/message/watcher.go index 798a712c7..d53a00ffa 100644 --- a/app/process/watcher/message/watcher.go +++ b/app/process/watcher/message/watcher.go @@ -37,12 +37,11 @@ type Watcher struct { topicID hedera.TopicID statusRepository repository.Status pollingInterval time.Duration - maxRetries int startTimestamp int64 logger *log.Entry } -func NewWatcher(client client.MirrorNode, topicID string, repository repository.Status, pollingInterval time.Duration, maxRetries int, startTimestamp int64) *Watcher { +func NewWatcher(client client.MirrorNode, topicID string, repository repository.Status, pollingInterval time.Duration, startTimestamp int64) *Watcher { id, err := hedera.TopicIDFromString(topicID) if err != nil { log.Fatalf("Could not start Consensus Topic Watcher for topic [%s] - Error: [%s]", topicID, err) @@ -54,7 +53,6 @@ func NewWatcher(client client.MirrorNode, topicID string, repository repository. statusRepository: repository, startTimestamp: startTimestamp, pollingInterval: pollingInterval, - maxRetries: maxRetries, logger: config.GetLoggerFor(fmt.Sprintf("[%s] Topic Watcher", topicID)), } } @@ -103,7 +101,7 @@ func (cmw Watcher) beginWatching(q *pair.Queue) { messages, err := cmw.client.GetMessagesAfterTimestamp(cmw.topicID, milestoneTimestamp) if err != nil { cmw.logger.Errorf("Error while retrieving messages from mirror node. Error [%s]", err) - cmw.restart(q) + go cmw.beginWatching(q) return } @@ -133,14 +131,3 @@ func (cmw Watcher) processMessage(topicMsg mirror_node.Message, q *pair.Queue) { q.Push(&pair.Message{Payload: msg}) } - -func (cmw *Watcher) restart(q *pair.Queue) { - if cmw.maxRetries > 0 { - cmw.maxRetries-- - cmw.logger.Infof("Watcher is trying to reconnect. Connections left [%d]", cmw.maxRetries) - time.Sleep(5 * time.Second) - go cmw.beginWatching(q) - return - } - cmw.logger.Errorf("Watcher failed: [Too many retries]") -} diff --git a/app/process/watcher/transfer/watcher.go b/app/process/watcher/transfer/watcher.go index 09e11dcfc..ff97d932e 100644 --- a/app/process/watcher/transfer/watcher.go +++ b/app/process/watcher/transfer/watcher.go @@ -39,7 +39,6 @@ type Watcher struct { accountID hedera.AccountID pollingInterval time.Duration statusRepository repository.Status - maxRetries int startTimestamp int64 logger *log.Entry contractService service.Contracts @@ -51,7 +50,6 @@ func NewWatcher( accountID string, pollingInterval time.Duration, repository repository.Status, - maxRetries int, startTimestamp int64, contractService service.Contracts, ) *Watcher { @@ -66,7 +64,6 @@ func NewWatcher( accountID: id, pollingInterval: pollingInterval, statusRepository: repository, - maxRetries: maxRetries, startTimestamp: startTimestamp, logger: config.GetLoggerFor(fmt.Sprintf("[%s] Transfer Watcher", accountID)), contractService: contractService, @@ -117,7 +114,7 @@ func (ctw Watcher) beginWatching(q *pair.Queue) { transactions, e := ctw.client.GetAccountCreditTransactionsAfterTimestamp(ctw.accountID, milestoneTimestamp) if e != nil { ctw.logger.Errorf("Suddenly stopped monitoring account - [%s]", e) - ctw.restart(q) + go ctw.beginWatching(q) return } @@ -162,14 +159,3 @@ func (ctw Watcher) processTransaction(tx mirror_node.Transaction, q *pair.Queue) transferMessage := transfer.New(tx.TransactionID, ethAddress, nativeAsset, wrappedAsset, amount, ctw.contractService.Address().String()) q.Push(&pair.Message{Payload: transferMessage}) } - -func (ctw *Watcher) restart(q *pair.Queue) { - if ctw.maxRetries > 0 { - ctw.maxRetries-- - ctw.logger.Infof("Watcher is trying to reconnect") - time.Sleep(5 * time.Second) - go ctw.beginWatching(q) - return - } - ctw.logger.Errorf("Watcher failed: [Too many retries]") -} diff --git a/app/services/contracts/service.go b/app/services/contracts/service.go index 9b9840306..ff48c42bc 100644 --- a/app/services/contracts/service.go +++ b/app/services/contracts/service.go @@ -129,6 +129,7 @@ func (bsc *Service) listenForMemberUpdatedEvent() { select { case err := <-sub.Err(): bsc.logger.Errorf("MemberUpdated Event Logs subscription failed. Error [%s].", err) + go bsc.listenForMemberUpdatedEvent() return case <-events: bsc.updateMembers() diff --git a/cmd/main.go b/cmd/main.go index 52c61de8b..0c32cc461 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -152,7 +152,6 @@ func addTransferWatcher(configuration *config.Config, account, configuration.Validator.Clients.MirrorNode.PollingInterval, *repository, - configuration.Validator.Clients.MirrorNode.MaxRetries, startTimestamp, contractService) } @@ -168,6 +167,5 @@ func addConsensusTopicWatcher(configuration *config.Config, topic, repository, configuration.Validator.Clients.MirrorNode.PollingInterval, - configuration.Validator.Clients.MirrorNode.MaxRetries, startTimestamp) } diff --git a/config/application.yml b/config/application.yml index 011d563e8..068b72ea6 100644 --- a/config/application.yml +++ b/config/application.yml @@ -25,10 +25,9 @@ validator: mirror_node: api_address: https://testnet.mirrornode.hedera.com/api/v1/ client_address: hcs.testnet.mirrornode.hedera.com:5600 - max_retries: 10 polling_interval: 5 log_level: info port: 5200 recovery: start_timestamp: - rest-api-only: false \ No newline at end of file + rest-api-only: false diff --git a/config/config.go b/config/config.go index 792a18758..786c18ca9 100644 --- a/config/config.go +++ b/config/config.go @@ -112,7 +112,6 @@ type MirrorNode struct { ClientAddress string `yaml:"client_address" env:"VALIDATOR_CLIENTS_MIRROR_NODE_CLIENT_ADDRESS"` ApiAddress string `yaml:"api_address" env:"VALIDATOR_CLIENTS_MIRROR_NODE_API_ADDRESS"` PollingInterval time.Duration `yaml:"polling_interval" env:"VALIDATOR_CLIENTS_MIRROR_NODE_POLLING_INTERVAL"` - MaxRetries int `yaml:"max_retries" env:"VALIDATOR_CLIENTS_MIRROR_NODE_TOPIC_ID"` } type Database struct { diff --git a/docs/configuration.md b/docs/configuration.md index 9737f8510..27d7c0998 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -37,7 +37,6 @@ Name | Default `validator.clients.hedera.topic_id` | "" | The topic id that the validators use to monitor for incoming hedera consensus messages. `validator.clients.mirror_node.api_address` | https://testnet.mirrornode.hedera.com/api/v1/ | The Hedera Rest API root endpoint. Depending on the Hedera network type, this will need to be changed. `validator.clients.mirror_node.client_address` | hcs.testnet.mirrornode.hedera.com:5600 | The HCS Mirror node endpoint. Depending on the Hedera network type, this will need to be changed. -`validator.clients.mirror_node.max_retries` | 10 | The maximum number of retries that the mirror node has to continue monitoring after a failure, before stopping completely. `validator.clients.mirror_node.polling_interval` | 5 | How often (in seconds) the application will poll the mirror node for new transactions. `validator.log_level` | info | The log level of the validator. Possible values: `info`, `debug`, `trace` case insensitive. `validator.port` | 5200 | The port on which the application runs. diff --git a/docs/testing.md b/docs/testing.md index 06ab85190..42781f01b 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -22,7 +22,6 @@ Name | Description `hedera.members` | The Hedera account ids of the validators, to which their bridge fees will be sent (if Bridge accepts Hedera Tokens, associations with these tokens will be required). Used to assert balances after transactions. `hedera.mirror_node.api_address` | The Hedera Rest API root endpoint. Depending on the Hedera network type, this will need to be changed. `hedera.mirror_node.client_address` | The HCS Mirror node endpoint. Depending on the Hedera network type, this will need to be changed. -`hedera.mirror_node.max_retries` | The maximum number of retries that the mirror node has to continue monitoring after a failure, before stopping completely. `hedera.mirror_node.polling_interval` | How often (in seconds) the application will poll the mirror node for new transactions. `hedera.network_type` | Which Hedera network to use. Can be either `mainnet`, `previewnet`, `testnet`. `hedera.sender.account` | The account that will be sending assets through the bridge.