From bf2d6161d1222dce6b273dff9e9ff827247d212a Mon Sep 17 00:00:00 2001 From: Peter-Jan Brone Date: Thu, 27 Jun 2024 09:36:59 +0200 Subject: [PATCH] Ignore sector roots range prune alert on old hosts (#1343) The sector roots RPC used to return all sector roots, this was fixed in https://github.com/SiaFoundation/hostd/commit/e6dfc96fa0f8aab45ce0c87de0f87ffe477f83a5 and released in https://github.com/SiaFoundation/hostd/releases/tag/v1.0.2-beta.4 . We should ignore the error for old hosts. --- autopilot/contract_pruning.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/autopilot/contract_pruning.go b/autopilot/contract_pruning.go index e89c6b80a..2f491249b 100644 --- a/autopilot/contract_pruning.go +++ b/autopilot/contract_pruning.go @@ -18,6 +18,7 @@ var ( errInvalidHandshake = errors.New("couldn't read host's handshake") errInvalidHandshakeSignature = errors.New("host's handshake signature was invalid") errInvalidMerkleProof = errors.New("host supplied invalid Merkle proof") + errInvalidSectorRootsRange = errors.New("number of roots does not match range") ) const ( @@ -237,9 +238,10 @@ func humanReadableSize(b int) string { } func shouldSendPruneAlert(err error, version, release string) bool { - merkleRootIssue := utils.IsErr(err, errInvalidMerkleProof) && - (build.VersionCmp(version, "1.6.0") < 0 || version == "1.6.0" && release == "") - return err != nil && !(merkleRootIssue || + oldHost := (build.VersionCmp(version, "1.6.0") < 0 || version == "1.6.0" && release == "") + sectorRootsIssue := utils.IsErr(err, errInvalidSectorRootsRange) && oldHost + merkleRootIssue := utils.IsErr(err, errInvalidMerkleProof) && oldHost + return err != nil && !(sectorRootsIssue || merkleRootIssue || utils.IsErr(err, utils.ErrConnectionRefused) || utils.IsErr(err, utils.ErrConnectionTimedOut) || utils.IsErr(err, utils.ErrConnectionResetByPeer) ||