From a7fd2a6015dc4872f6d0e9aef9607a7b5936bfae Mon Sep 17 00:00:00 2001 From: goku <118421317+gokutheengineer@users.noreply.github.com> Date: Mon, 17 Apr 2023 15:56:56 +0300 Subject: [PATCH] [Consensus] Log warnings if server module is not enabled (#679) ## Description Log a warning if the server module is not enabled rather than an error. ## Issue ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [ ] Bug fix - [X] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [ ] Other ## List of changes - Update `handleStateSyncMessage()` to log warnings ## Testing - [X] `make develop_test`; if any code changes were made - [ ] [Docker Compose LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md); if any major functionality was changed or introduced - [ ] [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any infrastructure or configuration changes were made ## Required Checklist - [X] I have performed a self-review of my own code - [X] I have commented my code, particularly in hard-to-understand areas - [X] I have added, or updated, [`godoc` format comments](https://go.dev/blog/godoc) on touched members (see: [tip.golang.org/doc/comment](https://tip.golang.org/doc/comment)) - [X] I have tested my changes using the available tooling - [X] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s) --- consensus/doc/CHANGELOG.md | 4 ++++ consensus/state_sync_handler.go | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/consensus/doc/CHANGELOG.md b/consensus/doc/CHANGELOG.md index 0d39daf16..deb86a6aa 100644 --- a/consensus/doc/CHANGELOG.md +++ b/consensus/doc/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.0.0.47] - 2023-04-17 + +- Log warnings in `handleStateSyncMessage()` + ## [0.0.0.46] - 2023-04-13 - Utilise the `TxResult` protobuf from `shared/core/types` diff --git a/consensus/state_sync_handler.go b/consensus/state_sync_handler.go index fbb2eabbb..d67e2832a 100644 --- a/consensus/state_sync_handler.go +++ b/consensus/state_sync_handler.go @@ -38,7 +38,8 @@ func (m *consensusModule) handleStateSyncMessage(stateSyncMessage *typesCons.Sta case *typesCons.StateSyncMessage_MetadataReq: m.logger.Info().Str("proto_type", "MetadataRequest").Msg("Handling StateSyncMessage MetadataReq") if !m.serverModeEnabled { - return fmt.Errorf("server module is not enabled") + m.logger.Warn().Msg("Node's server module is not enabled") + return nil } return m.stateSync.HandleStateSyncMetadataRequest(stateSyncMessage.GetMetadataReq()) case *typesCons.StateSyncMessage_MetadataRes: @@ -48,7 +49,8 @@ func (m *consensusModule) handleStateSyncMessage(stateSyncMessage *typesCons.Sta case *typesCons.StateSyncMessage_GetBlockReq: m.logger.Info().Str("proto_type", "GetBlockRequest").Msg("Handling StateSyncMessage GetBlockRequest") if !m.serverModeEnabled { - return fmt.Errorf("server module is not enabled") + m.logger.Warn().Msg("Node's server module is not enabled") + return nil } return m.stateSync.HandleGetBlockRequest(stateSyncMessage.GetGetBlockReq()) case *typesCons.StateSyncMessage_GetBlockRes: