From 1e5265c6fc9c5260364be4cf41418883c29525bd Mon Sep 17 00:00:00 2001 From: Mak Muftic Date: Mon, 25 Jan 2021 12:29:17 +0100 Subject: [PATCH 1/5] Add buffer for target block threshold --- internal/active/active.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/active/active.go b/internal/active/active.go index bc9c9202..10e2099e 100644 --- a/internal/active/active.go +++ b/internal/active/active.go @@ -10,6 +10,7 @@ import ( const ( IntervalFromLastPing = 10 * time.Second AllowedBlocksBehind = 10 + TargetBlockBuffer = 10 ) // CheckIfNodeActive checks if nodes last recorded ping is in last IntervalFromLastPing and if nodes last recorded @@ -52,7 +53,7 @@ func CheckIfMetricsValid(nodeID string, repos *repositories.Repos) (bool, error) return false, err } // check if node synced - if metrics.BestBlockHeight != metrics.TargetBlockHeight { + if (metrics.BestBlockHeight + TargetBlockBuffer) < metrics.TargetBlockHeight { log.Debugf( "Node %s not synced. Best block: %d, Target block: %d", nodeID, metrics.BestBlockHeight, metrics.TargetBlockHeight, From b93adaa2ce35f272780c2a55f54ece563a03df54 Mon Sep 17 00:00:00 2001 From: Mak Muftic Date: Mon, 25 Jan 2021 12:44:52 +0100 Subject: [PATCH 2/5] Code cleanup --- internal/active/active.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/active/active.go b/internal/active/active.go index 10e2099e..ec47537e 100644 --- a/internal/active/active.go +++ b/internal/active/active.go @@ -10,7 +10,7 @@ import ( const ( IntervalFromLastPing = 10 * time.Second AllowedBlocksBehind = 10 - TargetBlockBuffer = 10 + TargetBlockBuffer = 10 ) // CheckIfNodeActive checks if nodes last recorded ping is in last IntervalFromLastPing and if nodes last recorded @@ -60,11 +60,12 @@ func CheckIfMetricsValid(nodeID string, repos *repositories.Repos) (bool, error) ) return false, nil } - + // get best metrics from pool of nodes latestBlockMetrics, err := repos.MetricsRepo.GetLatestBlockMetrics() if err != nil { return false, err } + // check if node falling behind if metrics.BestBlockHeight <= (latestBlockMetrics.BestBlockHeight-AllowedBlocksBehind) || metrics.FinalizedBlockHeight <= (latestBlockMetrics.FinalizedBlockHeight-AllowedBlocksBehind) { log.Debugf( @@ -77,7 +78,6 @@ func CheckIfMetricsValid(nodeID string, repos *repositories.Repos) (bool, error) ) return false, nil } - return true, nil } From ac5e3bb531ec4c79bb1329cf04c69c8da59e1abc Mon Sep 17 00:00:00 2001 From: Mak Muftic Date: Mon, 25 Jan 2021 12:52:48 +0100 Subject: [PATCH 3/5] Update CHANGELOG file --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fadfc73..f5a9013b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ ## [unreleased]((https://github.com/NodeFactoryIo/vedran/tree/HEAD)) [Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.0...HEAD) +### Added + +### Fix +- Add buffer for target block metric [\#184](https://github.com/NodeFactoryIo/vedran/pull/184) ([MakMuftic](https://github.com/MakMuftic)) + +### Changed ## [v0.5.0]((https://github.com/NodeFactoryIo/vedran/tree/v0.5.0)) [Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.4.3...v0.5.0) From 2d824b3308654054fb317d61034c72a56d182803 Mon Sep 17 00:00:00 2001 From: Mak Muftic Date: Mon, 25 Jan 2021 13:42:35 +0100 Subject: [PATCH 4/5] Fix bug when starting with no root dir --- cmd/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/start.go b/cmd/start.go index 2297f2f5..d5a896d4 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -59,7 +59,7 @@ var startCmd = &cobra.Command{ PreRunE: func(cmd *cobra.Command, args []string) error { DisplayBanner() // create root dir - if _, err := os.Stat(rootDir); os.IsNotExist(err) { + if _, err := os.Stat(rootDir); os.IsNotExist(err) && rootDir != "" { err = os.Mkdir(rootDir, 0700) if err != nil { log.Fatal("Unable to create root dir ", err) From 282a8625684a7dc37996304a4d3336c6f4e9312a Mon Sep 17 00:00:00 2001 From: Mak Muftic Date: Mon, 25 Jan 2021 13:44:30 +0100 Subject: [PATCH 5/5] Update CHANGELOG and version file --- .version | 2 +- CHANGELOG.md | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.version b/.version index 59a78457..51fb2415 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -version=0.5.0 +version=0.5.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index f5a9013b..7ccca15c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,16 @@ # Changelog ## [unreleased]((https://github.com/NodeFactoryIo/vedran/tree/HEAD)) -[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.0...HEAD) +[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.1...HEAD) + +### Added + +### Fix + +### Changed + +## [v0.5.1]((https://github.com/NodeFactoryIo/vedran/tree/v0.5.1)) +[Full Changelog](https://github.com/NodeFactoryIo/vedran/compare/v0.5.0...v0.5.1) ### Added