Skip to content

Commit 455f510

Browse files
authored
feat(f3): integrate MapReduce cache (#13134)
* Start integrating MapReduce cache Signed-off-by: Jakub Sztandera <[email protected]> * Integrate new state-types Signed-off-by: Jakub Sztandera <[email protected]> * Update hamt and go-state-types Signed-off-by: Jakub Sztandera <[email protected]> * remove symbolic links Signed-off-by: Jakub Sztandera <[email protected]> * add changelog Signed-off-by: Jakub Sztandera <[email protected]> --------- Signed-off-by: Jakub Sztandera <[email protected]>
1 parent 760d2e0 commit 455f510

File tree

23 files changed

+358
-39
lines changed

23 files changed

+358
-39
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- chore: return `method not supported` via Gateway when /v2 isn't supported by the backend ([filecoin-project/lotus#13121](https://github.com/filecoin-project/lotus/pull/13121))
1313
- chore: disable F3 participation via gateway ([filecoin-project/lotus#13123](https://github.com/filecoin-project/lotus/pull/13123)
1414
- chore: increase the F3 GMessage buffer size to 1024 ([filecoin-project/lotus#13126](https://github.com/filecoin-project/lotus/pull/13126))
15+
- feat(f3): integrate cached MapReduce from go-hamt-ipld, which improves performance of F3 power table calculation by 6-10x ([filecoin-project/lotus#13134](https://github.com/filecoin-project/lotus/pull/13134))
1516

1617
# Node v1.33.0 / 2025-05-08
1718
The Lotus v1.33.0 release introduces experimental v2 APIs with F3 awareness, featuring a new TipSet selection mechanism that significantly enhances how applications interact with the Filecoin blockchain. This release candidate also adds F3-aware Ethereum APIs via the /v2 endpoint. All of the /v2 APIs implement intelligent fallback mechanisms between F3 and Expected Consensus and are exposed through the Lotus Gateway.
@@ -30,7 +31,7 @@ The Lotus V2 APIs introduce a powerful new TipSet selection mechanism that signi
3031
> [!NOTE]
3132
> V2 APIs are highly experimental and subject to change without notice.
3233
33-
See [Filecoin v2 APIs docs](https://filoznotebook.notion.site/Filecoin-V2-APIs-1d0dc41950c1808b914de5966d501658) for an in-depth overview. /v2 APIs are exposed through Lotus Gateway.
34+
See [Filecoin v2 APIs docs](https://filoznotebook.notion.site/Filecoin-V2-APIs-1d0dc41950c1808b914de5966d501658) for an in-depth overview. /v2 APIs are exposed through Lotus Gateway.
3435

3536
This work was primarily done in ([filecoin-project/lotus#13003](https://github.com/filecoin-project/lotus/pull/13003)), ([filecoin-project/lotus#13027](https://github.com/filecoin-project/lotus/pull/13027)), ([filecoin-project/lotus#13034](https://github.com/filecoin-project/lotus/pull/13034)), ([filecoin-project/lotus#13075](https://github.com/filecoin-project/lotus/pull/13075)), ([filecoin-project/lotus#13066](https://github.com/filecoin-project/lotus/pull/13066))
3637

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ type State interface {
105105
// before returning the actor.
106106
ForEachClaim(cb func(miner address.Address, claim Claim) error, onlyEligible bool) error
107107
ClaimsChanged(State) (bool, error)
108+
CollectEligibleClaims(cacheInOut *builtin{{.latestVersion}}.MapReduceCache) ([]builtin{{.latestVersion}}.OwnedClaim, error)
108109

109110
// Testing or genesis setup only
110111
SetTotalQualityAdjPower(abi.StoragePower) error

chain/actors/builtin/power/power.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ type State interface {
189189
// before returning the actor.
190190
ForEachClaim(cb func(miner address.Address, claim Claim) error, onlyEligible bool) error
191191
ClaimsChanged(State) (bool, error)
192+
CollectEligibleClaims(cacheInOut *builtin16.MapReduceCache) ([]builtin16.OwnedClaim, error)
192193

193194
// Testing or genesis setup only
194195
SetTotalQualityAdjPower(abi.StoragePower) error

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
power{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}power"
2727
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt"
2828
{{end}}
29+
builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin"
2930
)
3031

3132
var _ State = (*state{{.v}})(nil)
@@ -147,6 +148,27 @@ func (s *state{{.v}}) ListAllMiners() ([]address.Address, error) {
147148
return miners, nil
148149
}
149150

151+
func (s *state{{.v}}) CollectEligibleClaims(cacheInOut *builtin{{.latestVersion}}.MapReduceCache) ([]builtin{{.latestVersion}}.OwnedClaim, error) {
152+
{{if (ge .v 16)}}
153+
return s.State.CollectEligibleClaims(s.store, cacheInOut)
154+
{{else}}
155+
var res []builtin{{.latestVersion}}.OwnedClaim
156+
err := s.ForEachClaim(func(miner address.Address, claim Claim) error {
157+
res = append(res, builtin{{.latestVersion}}.OwnedClaim{
158+
Address: miner,
159+
RawBytePower: claim.RawBytePower,
160+
QualityAdjPower: claim.QualityAdjPower,
161+
})
162+
return nil
163+
}, true)
164+
if err != nil {
165+
return nil, fmt.Errorf("collecting claims: %w", err)
166+
}
167+
return res, nil
168+
{{end}}
169+
}
170+
171+
150172
func (s *state{{.v}}) ForEachClaim(cb func(miner address.Address, claim Claim) error, onlyEligible bool) error {
151173
claims, err := s.claims()
152174
if err != nil {

chain/actors/builtin/power/v0.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/power/v10.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/power/v11.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/power/v12.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/power/v13.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/power/v14.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/power/v15.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/power/v16.go

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

chain/actors/builtin/power/v2.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/actors/builtin/power/v3.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)