diff --git a/ethapi/api.go b/ethapi/api.go index a6050ff8c..5beeeaafb 100644 --- a/ethapi/api.go +++ b/ethapi/api.go @@ -207,12 +207,20 @@ func (s *PublicEthereumAPI) Health(blockTimeSecThreshold uint64, uptimeSecThresh peerCount := s.b.PeerCount() log.Debug("Health check", "peerCount", peerCount, "peerCountThreshold", peerCountThreshold, "uptime", uptime, "uptimeThreshold", uptimeThreshold, "progress", progress, "currentBlockTime", time.Since(progress.CurrentBlockTime.Time()), "blockTime", blockTime) - if uptime < uptimeThreshold || progress.CurrentBlock < progress.HighestBlock || peerCount < int(peerCountThreshold) { - return false, nil + if uptime < uptimeThreshold { + return false, errors.New(fmt.Sprintf("Uptime threshold not reached")) + } + + if progress.CurrentBlock < progress.HighestBlock { + return false, errors.New(fmt.Sprintf("The current block is less than the highest block")) + } + + if peerCount < int(peerCountThreshold) { + return false, errors.New(fmt.Sprintf("Peer count threshold not reached")) } if blockTime > 0 && time.Since(progress.CurrentBlockTime.Time()) > blockTime { - return false, nil + return false, errors.New("block time threshold exceeded") } return true, nil diff --git a/go.mod b/go.mod index c74978f8b..4784a9cb6 100644 --- a/go.mod +++ b/go.mod @@ -109,7 +109,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/ethereum/go-ethereum => github.com/faircrypto/go-ethereum v1.1.4-rc1-5 +replace github.com/ethereum/go-ethereum => github.com/faircrypto/go-ethereum v1.1.4-rc1-6 replace github.com/Fantom-foundation/lachesis-base => github.com/faircrypto/lachesis-base v0.0.0-20230817040848-1326ba9aa59b diff --git a/go.sum b/go.sum index 283ee9143..720612975 100644 --- a/go.sum +++ b/go.sum @@ -190,8 +190,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/evalphobia/logrus_sentry v0.8.2 h1:dotxHq+YLZsT1Bb45bB5UQbfCh3gM/nFFetyN46VoDQ= github.com/evalphobia/logrus_sentry v0.8.2/go.mod h1:pKcp+vriitUqu9KiWj/VRFbRfFNUwz95/UkgG8a6MNc= -github.com/faircrypto/go-ethereum v1.1.4-rc1-5 h1:CQu2ZtQHeTROdJse4+FzwQ+qrJO297HrVIup+3yCc1I= -github.com/faircrypto/go-ethereum v1.1.4-rc1-5/go.mod h1:ah5rnRobPJSTUKXIETbrkyrrEhWPTUPfmF1gPPNr0Tg= +github.com/faircrypto/go-ethereum v1.1.4-rc1-6 h1:74OcB2uM0q7sCyW2k52vvP4ALdJjSYWvEVpE+poCOGs= +github.com/faircrypto/go-ethereum v1.1.4-rc1-6/go.mod h1:ah5rnRobPJSTUKXIETbrkyrrEhWPTUPfmF1gPPNr0Tg= github.com/faircrypto/lachesis-base v0.0.0-20230817040848-1326ba9aa59b h1:mEofwrV6bMlbuneVS8tnZmNZut7WY2YH++2GI7DxzHg= github.com/faircrypto/lachesis-base v0.0.0-20230817040848-1326ba9aa59b/go.mod h1:Ogv5etzSmM2rQ4eN3OfmyitwWaaPjd4EIDiW/NAbYGk= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=