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: refine miner_sector_deal_v2 performance issue #1300

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion chain/actors/builtin/market/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type State interface {
DealStatesAmtBitwidth() int

GetProviderSectors() (map[abi.SectorID][]abi.DealID, error)
GetProviderSectorsByDealID(map[abi.DealID]bool) (map[abi.DealID]abi.SectorID, error)
GetProviderSectorsByDealID(map[abi.DealID]bool, map[abi.SectorNumber]bool) (map[abi.DealID]abi.SectorID, error)
}

type BalanceTable interface {
Expand Down Expand Up @@ -106,6 +106,7 @@ type DealProposal = markettypes.DealProposal
type DealLabel = markettypes.DealLabel

type DealState interface {
SectorNumber() abi.SectorNumber
SectorStartEpoch() abi.ChainEpoch // -1 if not yet included in proven sector
LastUpdatedEpoch() abi.ChainEpoch // -1 if deal state never updated
SlashEpoch() abi.ChainEpoch // -1 if deal never slashed
Expand Down
7 changes: 6 additions & 1 deletion chain/actors/builtin/market/market.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion chain/actors/builtin/market/state.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ func (d dealStateV{{.v}}) SectorStartEpoch() abi.ChainEpoch {
return d.ds{{.v}}.SectorStartEpoch
}

func (d dealStateV{{.v}}) SectorNumber() abi.SectorNumber {
{{if ge .v 13}}
return d.ds{{.v}}.SectorNumber
{{else}}
return 0
{{end}}
}

func (d dealStateV{{.v}}) LastUpdatedEpoch() abi.ChainEpoch {
return d.ds{{.v}}.LastUpdatedEpoch
}
Expand Down Expand Up @@ -348,7 +356,7 @@ func (s *state{{.v}}) GetProviderSectors() (map[abi.SectorID][]abi.DealID, error
{{end}}
}

func (s *state{{.v}}) GetProviderSectorsByDealID(dealIDMap map[abi.DealID]bool) (map[abi.DealID]abi.SectorID, error) {
func (s *state{{.v}}) GetProviderSectorsByDealID(dealIDMap map[abi.DealID]bool, sectorIDMap map[abi.SectorNumber]bool) (map[abi.DealID]abi.SectorID, error) {
{{if (le .v 12)}}
return nil, nil
{{else}}
Expand Down Expand Up @@ -376,6 +384,10 @@ func (s *state{{.v}}) GetProviderSectorsByDealID(dealIDMap map[abi.DealID]bool)
return err
}

if _, found := sectorIDMap[abi.SectorNumber(sectorNumber)]; !found {
return nil
}

dealIDsCopy := make([]abi.DealID, len(dealIDs))
copy(dealIDsCopy, dealIDs)

Expand Down
8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v0.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v10.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v11.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v12.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion chain/actors/builtin/market/v13.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v3.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v4.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v5.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v6.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v7.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v8.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion chain/actors/builtin/market/v9.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lens/util/builtinactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package util
import (
"strconv"

"github.com/filecoin-project/lotus/chain/types"
"github.com/fxamacker/cbor/v2"
"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/codec/dagcbor"
"github.com/ipld/go-ipld-prime/node/basicnode"
"github.com/ipld/go-ipld-prime/node/bindnode"

"github.com/filecoin-project/lotus/chain/types"
)

type KVEvent struct {
Expand Down
Loading