diff --git a/ethapi/api.go b/ethapi/api.go index 6d7ba5d7d..023daabe7 100644 --- a/ethapi/api.go +++ b/ethapi/api.go @@ -176,12 +176,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 ec22eeb3a..58e8dfd4b 100644 --- a/go.mod +++ b/go.mod @@ -44,6 +44,6 @@ require ( gopkg.in/urfave/cli.v1 v1.20.0 ) -replace github.com/ethereum/go-ethereum => github.com/faircrypto/go-ethereum v1.10.8-ftm-rc9.0.20240322234738-3d5e1d6e7883 +replace github.com/ethereum/go-ethereum => github.com/faircrypto/go-ethereum v1.10.8-ftm-rc9.0.20240326154128-612f38eade68 replace github.com/dvyukov/go-fuzz => github.com/guzenok/go-fuzz v0.0.0-20210103140116-f9104dfb626f diff --git a/go.sum b/go.sum index a9903f0cc..77e8fa3ac 100644 --- a/go.sum +++ b/go.sum @@ -162,8 +162,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.10.8-ftm-rc9.0.20240322234738-3d5e1d6e7883 h1:ajz2flH7mV4U4WwXAP6XKssEXL8W4i53d/a/2QLPRdc= -github.com/faircrypto/go-ethereum v1.10.8-ftm-rc9.0.20240322234738-3d5e1d6e7883/go.mod h1:IeQDjWCNBj/QiWIPosfF6/kRC6pHPNs7W7LfBzjj+P4= +github.com/faircrypto/go-ethereum v1.10.8-ftm-rc9.0.20240326154128-612f38eade68 h1:CJNZXs0JDx5kafKqlWzQf7uFgxvtnrC5jr6sZWLiGfw= +github.com/faircrypto/go-ethereum v1.10.8-ftm-rc9.0.20240326154128-612f38eade68/go.mod h1:IeQDjWCNBj/QiWIPosfF6/kRC6pHPNs7W7LfBzjj+P4= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=