From 1ce61baa977387bcd51b835468ed6e14d61c5cfa Mon Sep 17 00:00:00 2001 From: Piotr Macek <4007944+piotrm50@users.noreply.github.com> Date: Fri, 3 Nov 2023 15:31:45 +0100 Subject: [PATCH 1/5] Remove unnecessary checks --- pkg/protocol/engine/tipmanager/v1/tipmanager.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/protocol/engine/tipmanager/v1/tipmanager.go b/pkg/protocol/engine/tipmanager/v1/tipmanager.go index 671e45327..22dcf6e37 100644 --- a/pkg/protocol/engine/tipmanager/v1/tipmanager.go +++ b/pkg/protocol/engine/tipmanager/v1/tipmanager.go @@ -140,25 +140,22 @@ func (t *TipManager) setupBlockMetadata(tipMetadata *TipMetadata) { // forEachParentByType iterates through the parents of the given block and calls the consumer for each parent. func (t *TipManager) forEachParentByType(block *blocks.Block, consumer func(parentType iotago.ParentsType, parentMetadata *TipMetadata)) { - if block == nil || block.ProtocolBlock() == nil { - return - } - for _, parent := range block.ParentsWithType() { if metadataStorage := t.metadataStorage(parent.ID.Slot()); metadataStorage != nil { - // Make sure we don't add rootblocks back to the tips. + // Make sure we don't add root blocks back to the tips. parentBlock, exists := t.retrieveBlock(parent.ID) + if !exists || parentBlock.IsRootBlock() { continue } - if parentMetadata, created := metadataStorage.GetOrCreate(parent.ID, func() *TipMetadata { return NewBlockMetadata(parentBlock) }); parentMetadata.Block() != nil { - consumer(parent.Type, parentMetadata) + parentMetadata, created := metadataStorage.GetOrCreate(parent.ID, func() *TipMetadata { return NewBlockMetadata(parentBlock) }) + consumer(parent.Type, parentMetadata) - if created { - t.setupBlockMetadata(parentMetadata) - } + if created { + t.setupBlockMetadata(parentMetadata) } + } } } From e29210a1a1184f9a04b87caf26acf3bc4b876193 Mon Sep 17 00:00:00 2001 From: Piotr Macek <4007944+piotrm50@users.noreply.github.com> Date: Fri, 3 Nov 2023 15:32:48 +0100 Subject: [PATCH 2/5] Panic and log block metadata before nil pointer exception happens. --- pkg/protocol/engine/tipmanager/v1/tipmanager.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/protocol/engine/tipmanager/v1/tipmanager.go b/pkg/protocol/engine/tipmanager/v1/tipmanager.go index 22dcf6e37..ee9ae2cdf 100644 --- a/pkg/protocol/engine/tipmanager/v1/tipmanager.go +++ b/pkg/protocol/engine/tipmanager/v1/tipmanager.go @@ -1,6 +1,8 @@ package tipmanagerv1 import ( + "fmt" + "github.com/iotaledger/hive.go/ds/randommap" "github.com/iotaledger/hive.go/ds/shrinkingmap" "github.com/iotaledger/hive.go/lo" @@ -149,6 +151,10 @@ func (t *TipManager) forEachParentByType(block *blocks.Block, consumer func(pare continue } + if parentBlock.ModelBlock() == nil { + panic(fmt.Sprintf(">> parentBlock exists, but parentBlock.ProtocolBlock() == nil, %s", parentBlock.String())) + } + parentMetadata, created := metadataStorage.GetOrCreate(parent.ID, func() *TipMetadata { return NewBlockMetadata(parentBlock) }) consumer(parent.Type, parentMetadata) From b1e02f17e6e4ed1ae642963619ba11c9d2804e2d Mon Sep 17 00:00:00 2001 From: Piotr Macek <4007944+piotrm50@users.noreply.github.com> Date: Fri, 3 Nov 2023 15:36:35 +0100 Subject: [PATCH 3/5] Replace a panic with a print, since a panic will happen anyway. --- pkg/protocol/engine/tipmanager/v1/tipmanager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/protocol/engine/tipmanager/v1/tipmanager.go b/pkg/protocol/engine/tipmanager/v1/tipmanager.go index ee9ae2cdf..2e5bef0fc 100644 --- a/pkg/protocol/engine/tipmanager/v1/tipmanager.go +++ b/pkg/protocol/engine/tipmanager/v1/tipmanager.go @@ -152,7 +152,7 @@ func (t *TipManager) forEachParentByType(block *blocks.Block, consumer func(pare } if parentBlock.ModelBlock() == nil { - panic(fmt.Sprintf(">> parentBlock exists, but parentBlock.ProtocolBlock() == nil, %s", parentBlock.String())) + fmt.Printf(">> parentBlock exists, but parentBlock.ProtocolBlock() == nil\n %s\n", parentBlock.String()) } parentMetadata, created := metadataStorage.GetOrCreate(parent.ID, func() *TipMetadata { return NewBlockMetadata(parentBlock) }) From d3768e03ec84783a67512d0f3827d84fdc8782d2 Mon Sep 17 00:00:00 2001 From: Piotr Macek <4007944+piotrm50@users.noreply.github.com> Date: Mon, 6 Nov 2023 11:07:13 +0100 Subject: [PATCH 4/5] Print the source block as well. --- pkg/protocol/engine/tipmanager/v1/tipmanager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/protocol/engine/tipmanager/v1/tipmanager.go b/pkg/protocol/engine/tipmanager/v1/tipmanager.go index 2e5bef0fc..2b12cc40c 100644 --- a/pkg/protocol/engine/tipmanager/v1/tipmanager.go +++ b/pkg/protocol/engine/tipmanager/v1/tipmanager.go @@ -152,7 +152,7 @@ func (t *TipManager) forEachParentByType(block *blocks.Block, consumer func(pare } if parentBlock.ModelBlock() == nil { - fmt.Printf(">> parentBlock exists, but parentBlock.ProtocolBlock() == nil\n %s\n", parentBlock.String()) + fmt.Printf(">> parentBlock exists, but parentBlock.ProtocolBlock() == nil\n ParentBlock: %s\n Block: %s\n", parentBlock.String(), block.String()) } parentMetadata, created := metadataStorage.GetOrCreate(parent.ID, func() *TipMetadata { return NewBlockMetadata(parentBlock) }) From f195974c06d4eb5f59e07effc30d49d754d535d2 Mon Sep 17 00:00:00 2001 From: Andrea V <1577639+karimodm@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:31:40 +0100 Subject: [PATCH 5/5] Always succeed on killing and tearing down network --- .github/workflows/docker-network-health.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-network-health.yml b/.github/workflows/docker-network-health.yml index ee5b1b08b..b2ac8c32b 100644 --- a/.github/workflows/docker-network-health.yml +++ b/.github/workflows/docker-network-health.yml @@ -62,5 +62,5 @@ jobs: - name: Cleanup run: | cd ./tools/docker-network - docker compose kill - docker compose down -v + docker compose kill || true + docker compose down -t 1 -v || true