From f97c52f422f50842a5c3191b190acb0ed48d7bd6 Mon Sep 17 00:00:00 2001 From: LexLuthr <88259624+LexLuthr@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:40:54 +0400 Subject: [PATCH] fix: check provider for ddo deals (#1973) * check provider for ddo deals * github action don't fail early --- .github/workflows/ci.yml | 1 + storagemarket/direct_deals_provider.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ceaaf4d49..5afa0e456 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,7 @@ jobs: runs-on: [self-hosted, docker] needs: [setup-params] strategy: + fail-fast: false # Continue running even if one test fails matrix: test-suite: - name: test-itest-dummydeal_offline diff --git a/storagemarket/direct_deals_provider.go b/storagemarket/direct_deals_provider.go index 1447b30ae..bff8f5077 100644 --- a/storagemarket/direct_deals_provider.go +++ b/storagemarket/direct_deals_provider.go @@ -149,6 +149,22 @@ func (ddp *DirectDealsProvider) Accept(ctx context.Context, entry *types.DirectD log.Infow("found allocation for client", "allocation", spew.Sdump(allocation)) + mid, err := address.IDFromAddress(ddp.Address) + if err != nil { + log.Warnw("failed to get miner ID from address", "err", err) + return &api.ProviderDealRejectionInfo{ + Accepted: false, + Reason: "server error: miner address to ID conversion", + }, nil + } + + if allocation.Provider != abi.ActorID(mid) { + return &api.ProviderDealRejectionInfo{ + Accepted: false, + Reason: fmt.Sprintf("allocation provider %s does not match miner address %s", allocation.Provider, ddp.Address), + }, nil + } + // If the TermMin is longer than initial sector duration, the deal will be dropped from the sector if allocation.TermMin > miner13types.MaxSectorExpirationExtension-policy.SealRandomnessLookback { return &api.ProviderDealRejectionInfo{