From 14d02de3d2f509ec56e41c91a5b2e03cc0f79daa Mon Sep 17 00:00:00 2001 From: Tim Wu Date: Wed, 2 Feb 2022 12:36:45 -0500 Subject: [PATCH 1/4] add mismatch genesis peer reporting --- dot/network/block_announce.go | 5 +++++ dot/peerset/constants.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/dot/network/block_announce.go b/dot/network/block_announce.go index 5edf37f104..2a06a0843c 100644 --- a/dot/network/block_announce.go +++ b/dot/network/block_announce.go @@ -8,6 +8,7 @@ import ( "fmt" "math/big" + "github.com/ChainSafe/gossamer/dot/peerset" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/lib/common" "github.com/ChainSafe/gossamer/pkg/scale" @@ -176,6 +177,10 @@ func (s *Service) validateBlockAnnounceHandshake(from peer.ID, hs Handshake) err } if bhs.GenesisHash != s.blockState.GenesisHash() { + s.host.cm.peerSetHandler.ReportPeer(peerset.ReputationChange{ + Value: peerset.GenesisMismatch, + Reason: peerset.GenesisMismatchReason, + }, from) return errors.New("genesis hash mismatch") } diff --git a/dot/peerset/constants.go b/dot/peerset/constants.go index d46922e692..c4011d534d 100644 --- a/dot/peerset/constants.go +++ b/dot/peerset/constants.go @@ -62,4 +62,9 @@ const ( BadJustificationValue Reputation = -(1 << 16) // BadJustificationReason is used when peer send invalid justification. BadJustificationReason = "Bad justification" + + // GenesisMismatch is used when peer has a different genesis + GenesisMismatch Reputation = math.MinInt32 + // GenesisMismatchReason used when a peer has a different genesis + GenesisMismatchReason = "Genesis mismatch" ) From 29b913fb963e49377974e100de019291f70cb4b8 Mon Sep 17 00:00:00 2001 From: Tim Wu Date: Fri, 11 Feb 2022 11:22:44 -0500 Subject: [PATCH 2/4] double timeout in compareBlocksByNumberWithRetry --- tests/stress/helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stress/helpers.go b/tests/stress/helpers.go index c3841089ce..acc843e0b1 100644 --- a/tests/stress/helpers.go +++ b/tests/stress/helpers.go @@ -113,7 +113,7 @@ func compareBlocksByNumberWithRetry(t *testing.T, nodes []*utils.Node, num strin var hashes map[common.Hash][]string var err error - timeout := time.After(30 * time.Second) + timeout := time.After(60 * time.Second) doneBlockProduction: for { time.Sleep(time.Second) From 6180c0ee78ffae4859959862e25fe28ebfc63262 Mon Sep 17 00:00:00 2001 From: Tim Wu Date: Fri, 11 Feb 2022 11:56:00 -0500 Subject: [PATCH 3/4] add more timeout --- tests/stress/stress_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stress/stress_test.go b/tests/stress/stress_test.go index 58afc5823d..4f112c2eb8 100644 --- a/tests/stress/stress_test.go +++ b/tests/stress/stress_test.go @@ -102,7 +102,7 @@ func TestSync_SingleBlockProducer(t *testing.T) { require.NoError(t, err) nodes = append(nodes, node) - time.Sleep(time.Second * 30) + time.Sleep(time.Second * 60) defer func() { errList := utils.StopNodes(t, nodes) From 588045314c5a5be65814b69e42692611648bcc52 Mon Sep 17 00:00:00 2001 From: Tim Wu Date: Fri, 11 Feb 2022 17:35:48 -0500 Subject: [PATCH 4/4] try to fix checks --- .github/workflows/checks.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 69a8b5f751..ef57cdfa36 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,9 +1,5 @@ on: pull_request: - types: - - opened - - edited - - reopened paths: - .github/workflows/checks.yml - .github/PULL_REQUEST/pull_request.go