From f263721067a71739c6f0037a1d78edfe92ee22e7 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Wed, 30 Aug 2023 14:01:32 +0800 Subject: [PATCH] feat: handle PreCommitSectorBatch2 message --- storageprovider/ondealsectorcommitted.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/storageprovider/ondealsectorcommitted.go b/storageprovider/ondealsectorcommitted.go index c888c9da..1c08415b 100644 --- a/storageprovider/ondealsectorcommitted.go +++ b/storageprovider/ondealsectorcommitted.go @@ -15,6 +15,7 @@ import ( "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/builtin/v8/miner" + miner2 "github.com/filecoin-project/go-state-types/builtin/v11/miner" "github.com/filecoin-project/venus/pkg/constants" "github.com/filecoin-project/venus/pkg/events" "github.com/filecoin-project/venus/venus-shared/actors/builtin/market" @@ -107,7 +108,9 @@ func (mgr *SectorCommittedManager) OnDealSectorPreCommitted(ctx context.Context, // Watch for a pre-commit message to the provider. matchEvent := func(msg *types.Message) (bool, error) { - matched := msg.To == provider && (msg.Method == builtin.MethodsMiner.PreCommitSector || msg.Method == builtin.MethodsMiner.PreCommitSectorBatch) + matched := msg.To == provider && (msg.Method == builtin.MethodsMiner.PreCommitSector || + msg.Method == builtin.MethodsMiner.PreCommitSectorBatch || msg.Method == builtin.MethodsMiner.PreCommitSectorBatch2 || + msg.Method == builtin.MethodsMiner.ProveReplicaUpdates) return matched, nil } @@ -333,6 +336,21 @@ func dealSectorInPreCommitMsg(msg *types.Message, res CurrentDealInfo) (*abi.Sec return nil, fmt.Errorf("unmarshal pre commit: %w", err) } + for _, precommit := range params.Sectors { + // Check through the deal IDs associated with this message + for _, did := range precommit.DealIDs { + if did == res.DealID { + // Found the deal ID in this message. Callback with the sector ID. + return &precommit.SectorNumber, nil + } + } + } + case builtin.MethodsMiner.PreCommitSectorBatch2: + var params miner2.PreCommitSectorBatchParams2 + if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { + return nil, fmt.Errorf("unmarshal pre commit: %w", err) + } + for _, precommit := range params.Sectors { // Check through the deal IDs associated with this message for _, did := range precommit.DealIDs {