From cf9820137cbc1bea526256f4ac861530341a0d94 Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 11 Sep 2020 20:32:52 +0300 Subject: [PATCH 1/3] don't prune locally published messages --- chain/messagepool/pruning.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chain/messagepool/pruning.go b/chain/messagepool/pruning.go index 76b183808..cd20b462b 100644 --- a/chain/messagepool/pruning.go +++ b/chain/messagepool/pruning.go @@ -56,6 +56,13 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro priority[actor] = struct{}{} } + // we also never prune locally published messages + mp.lk.Lock() + for actor := range mp.localAddrs { + priority[actor] = struct{}{} + } + mp.lk.Unlock() + // Collect all messages to track which ones to remove and create chains for block inclusion pruneMsgs := make(map[cid.Cid]*types.SignedMessage, mp.currentSize) keepCount := 0 From bf1036c78fa694f9fe8f4cad5cbce3d88d06c61c Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 11 Sep 2020 21:12:11 +0300 Subject: [PATCH 2/3] rename priority variable to protected --- chain/messagepool/pruning.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/chain/messagepool/pruning.go b/chain/messagepool/pruning.go index cd20b462b..f40007f34 100644 --- a/chain/messagepool/pruning.go +++ b/chain/messagepool/pruning.go @@ -50,16 +50,18 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro pending, _ := mp.getPendingMessages(ts, ts) - // priority actors -- not pruned - priority := make(map[address.Address]struct{}) + // protected actors -- not pruned + protected := make(map[address.Address]struct{}) + + // we never prune priority addresses for _, actor := range mp.cfg.PriorityAddrs { - priority[actor] = struct{}{} + protected[actor] = struct{}{} } // we also never prune locally published messages mp.lk.Lock() for actor := range mp.localAddrs { - priority[actor] = struct{}{} + protected[actor] = struct{}{} } mp.lk.Unlock() @@ -69,14 +71,14 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro var chains []*msgChain for actor, mset := range pending { - // we never prune priority actors - _, keep := priority[actor] + // we never prune protected actors + _, keep := protected[actor] if keep { keepCount += len(mset) continue } - // not a priority actor, track the messages and create chains + // not a protected actor, track the messages and create chains for _, m := range mset { pruneMsgs[m.Message.Cid()] = m } From b78fe0b8980bbac20dd980d793cf006b2fd7f35c Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 11 Sep 2020 21:40:25 +0300 Subject: [PATCH 3/3] fix deadlock --- chain/messagepool/pruning.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/chain/messagepool/pruning.go b/chain/messagepool/pruning.go index f40007f34..fd8199b89 100644 --- a/chain/messagepool/pruning.go +++ b/chain/messagepool/pruning.go @@ -59,11 +59,9 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro } // we also never prune locally published messages - mp.lk.Lock() for actor := range mp.localAddrs { protected[actor] = struct{}{} } - mp.lk.Unlock() // Collect all messages to track which ones to remove and create chains for block inclusion pruneMsgs := make(map[cid.Cid]*types.SignedMessage, mp.currentSize)