Skip to content

Commit 8273f89

Browse files
authored
feat: refine miner_sector_deal_v2 performance issue (#1300)
* Integrate sectorNumber to dealState and get the sectorID * Use dealProposal to find the providerID
1 parent 661d756 commit 8273f89

File tree

18 files changed

+144
-44
lines changed

18 files changed

+144
-44
lines changed

chain/actors/builtin/market/actor.go.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type State interface {
7777
DealStatesAmtBitwidth() int
7878

7979
GetProviderSectors() (map[abi.SectorID][]abi.DealID, error)
80-
GetProviderSectorsByDealID(map[abi.DealID]bool) (map[abi.DealID]abi.SectorID, error)
80+
GetProviderSectorsByDealID(map[abi.DealID]bool, map[abi.SectorNumber]bool) (map[abi.DealID]abi.SectorID, error)
8181
}
8282

8383
type BalanceTable interface {
@@ -106,6 +106,7 @@ type DealProposal = markettypes.DealProposal
106106
type DealLabel = markettypes.DealLabel
107107

108108
type DealState interface {
109+
SectorNumber() abi.SectorNumber
109110
SectorStartEpoch() abi.ChainEpoch // -1 if not yet included in proven sector
110111
LastUpdatedEpoch() abi.ChainEpoch // -1 if deal state never updated
111112
SlashEpoch() abi.ChainEpoch // -1 if deal never slashed

chain/actors/builtin/market/market.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/market/state.go.template

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ func (d dealStateV{{.v}}) SectorStartEpoch() abi.ChainEpoch {
156156
return d.ds{{.v}}.SectorStartEpoch
157157
}
158158

159+
func (d dealStateV{{.v}}) SectorNumber() abi.SectorNumber {
160+
{{if ge .v 13}}
161+
return d.ds{{.v}}.SectorNumber
162+
{{else}}
163+
return 0
164+
{{end}}
165+
}
166+
159167
func (d dealStateV{{.v}}) LastUpdatedEpoch() abi.ChainEpoch {
160168
return d.ds{{.v}}.LastUpdatedEpoch
161169
}
@@ -348,7 +356,7 @@ func (s *state{{.v}}) GetProviderSectors() (map[abi.SectorID][]abi.DealID, error
348356
{{end}}
349357
}
350358

351-
func (s *state{{.v}}) GetProviderSectorsByDealID(dealIDMap map[abi.DealID]bool) (map[abi.DealID]abi.SectorID, error) {
359+
func (s *state{{.v}}) GetProviderSectorsByDealID(dealIDMap map[abi.DealID]bool, sectorIDMap map[abi.SectorNumber]bool) (map[abi.DealID]abi.SectorID, error) {
352360
{{if (le .v 12)}}
353361
return nil, nil
354362
{{else}}
@@ -376,6 +384,10 @@ func (s *state{{.v}}) GetProviderSectorsByDealID(dealIDMap map[abi.DealID]bool)
376384
return err
377385
}
378386

387+
if _, found := sectorIDMap[abi.SectorNumber(sectorNumber)]; !found {
388+
return nil
389+
}
390+
379391
dealIDsCopy := make([]abi.DealID, len(dealIDs))
380392
copy(dealIDsCopy, dealIDs)
381393

chain/actors/builtin/market/v0.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/market/v10.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/market/v11.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/market/v12.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/market/v13.go

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/market/v2.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/market/v3.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)