Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle PreCommitSectorBatch2 message #420

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion storageprovider/ondealsectorcommitted.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down