Merge pull request #9365 from filecoin-project/asr/deflake

feat: dealpublisher: check for duplicate deals before adding
This commit is contained in:
Aayush Rajasekaran 2022-09-26 13:18:06 -04:00 committed by GitHub
commit 583ce6d1dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -101,7 +101,7 @@ func testDealsRetryLackOfFunds(t *testing.T, publishStorageAccountFunds abi.Toke
propcid := *deal
go func() {
time.Sleep(3 * time.Second)
time.Sleep(30 * time.Second)
kit.SendFunds(ctx, t, minerFullNode, publishStorageDealKey.Address, types.FromFil(1))

View File

@ -204,6 +204,26 @@ func (p *DealPublisher) processNewDeal(pdeal *pendingDeal) {
return
}
pdealPropCid, err := pdeal.deal.Proposal.Cid()
if err != nil {
log.Warn("failed to calculate proposal CID for new pending Deal with piece cid %s", pdeal.deal.Proposal.PieceCID)
return
}
// Sanity check that new deal isn't already in the queue
for _, pd := range p.pending {
pdPropCid, err := pd.deal.Proposal.Cid()
if err != nil {
log.Warn("failed to calculate proposal CID for pending Deal already in publish queue with piece cid %s", pd.deal.Proposal.PieceCID)
return
}
if pdPropCid.Equals(pdealPropCid) {
log.Warn("tried to process new pending deal with piece CID %s that is already in publish queue; returning", pdeal.deal.Proposal.PieceCID)
return
}
}
// Add the new deal to the queue
p.pending = append(p.pending, pdeal)
log.Infof("add deal with piece CID %s to publish deals queue - %d deals in queue (max queue size %d)",