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: api: new verified registry methods to get all allocations and claims #11631

Merged

Conversation

LexLuthr
Copy link
Contributor

@LexLuthr LexLuthr commented Feb 19, 2024

Related Issues

Fixes #11614

Proposed Changes

  • This PR create 2 new methods in verified registry actor called GetAllAllocations and GetAllClaims which lists all the available allocations and claims in the actor.
  • These methods are further plugged into Lotus API methods StateGetAllAllocations and StateGetAllClaims.
  • Lotus CLI has been updated to get the same information.
  • Lotus geteway API has also been updated to support the new methods.

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • If the PR affects users (e.g., new feature, bug fix, system requirements change), update the CHANGELOG.md and add details to the UNRELEASED section.
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@LexLuthr LexLuthr requested a review from a team as a code owner February 19, 2024 14:53
@LexLuthr LexLuthr requested review from snadrus and aarshkshah1992 and removed request for a team February 19, 2024 14:53
cli/filplus.go Outdated
@@ -799,3 +801,149 @@ var filplusSignRemoveDataCapProposal = &cli.Command{
return nil
},
}

var filplusListAllAllocationsCmd = &cli.Command{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really suggestions, just thoughts inviting discussion: These could be integrated into list-allocations and list-claims just by making the client optional. Also as they are, I'm not sure the --expired makes as much sense for these all listings as stand-alone commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I has a similar initial though but I wasn't sure if that would make things easier or more tricky. I will update the CLI as per your suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the CLI and added a JSON flag to allow json output as well.

@rvagg
Copy link
Member

rvagg commented Feb 20, 2024

lgtm, with some suggestions

Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, the only thing I'd note for other reviewers is that this is a breaking change in that the filplus list-allocations and filplus list-claims CLI commands are going to output tables with ClaimID and AllocationID instead of just ID now. I'd assume that this is minor enough, and also an improvement, so it shouldn't be a problem for people to adapt to if they're using this output programatically.

@@ -145,6 +145,21 @@ func (s *state{{.v}}) GetAllocations(clientIdAddr address.Address) (map[Allocati
{{end}}
}

func (s *state{{.v}}) GetAllAllocations() (map[AllocationId]Allocation, error) {
{{if (le .v 12)}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{if (le .v 12)}}
{{if (le .v 8)}}

@@ -170,6 +185,22 @@ func (s *state{{.v}}) GetClaims(providerIdAddr address.Address) (map[ClaimId]Cla
{{end}}
}

func (s *state{{.v}}) GetAllClaims() (map[ClaimId]Claim, error) {
{{if (le .v 12)}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{if (le .v 12)}}
{{if (le .v 8)}}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, late review but after trying this out I realised this could be supported all the way back to v9, so there's no point in holding it off until we get to v13.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was being too conservative here. I will update the method to support back till v9. The underlying state methods are there so no point in holding back the functionality.

@jennijuju jennijuju added this to the Network v22 milestone Feb 21, 2024
@jennijuju jennijuju added the P2 P2: Should be resolved label Feb 21, 2024
@Stebalien
Copy link
Member

@LexLuthr could you add a quick note in the CHANGELOG.md about the changes to the filplus list-allocations and filplus list-claims command output? With that it should be good to go.

@rvagg
Copy link
Member

rvagg commented Feb 22, 2024

@willscott FYI.

After a bit of messing around (long story) I managed to use these APIs to get some data. Mainnet right now has allocations as a ~190Mb JSON file and claims as a ~12Gb JSON file.

Allocations is a map of the allocation ID to the Allocation struct:

{
  "1": {
    "Client": 215074,
    "Provider": 1353593,
    "Data": {
      "/": "baga6ea4seaqimrrmdbqi6yomnkjpwonkeuvmcmqzgf4dnosdsagetxcddify4di"
    },
    "Size": 17179869184,
    "TermMin": 1463040,
    "TermMax": 1555200,
    "Expiration": 2414101
  },
  "10": {
    "Client": 215074,
    "Provider": 1353593,
    "Data": {
      "/": "baga6ea4seaqiix3rs3p3qkkitpggsuq276qwxz7mu22mx35wxq35snt7l3dk2di"
    },
    "Size": 17179869184,
    "TermMin": 1463040,
    "TermMax": 1555200,
    "Expiration": 2414101
  },
...

Claims is a map of claim ID to the Claim struct:

{
  "100000": {
    "Provider": 1970213,
    "Client": 1948518,
    "Data": {
      "/": "baga6ea4seaqhmk73sc4kewlkdwhxlrvr3eyqyvmky7hhr2v2shqjmrlylgk22fi"
    },
    "Size": 34359738368,
    "TermMin": 1512000,
    "TermMax": 1771200,
    "TermStart": 2385954,
    "Sector": 110733
  },
  "1000000": {
    "Provider": 1964215,
    "Client": 1940441,
    "Data": {
      "/": "baga6ea4seaqdiugqdshc7ejkn2rypywiuth4auvx5bijf4hhll7hbswsxpk5mbq"
    },
    "Size": 34359738368,
    "TermMin": 1541862,
    "TermMax": 1801062,
    "TermStart": 2417926,
    "Sector": 11634
  },
...

Should be enough info there for piece accounting. But it's a very hefty way to consume it. Thankfully it's straight out of state with very little munging so it's not too inefficient to dump if you have the resources.

Events are going to be the most efficient way to consume these though - maybe start with a snapshot of this then consume events from that point on to update your local mirror of claim state. See #11618 which has an itest with both allocation and claim events.

Comment on lines 68 to 71
StateGetAllAllocations(ctx context.Context, tsk types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error)
StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifregtypes.ClaimId, tsk types.TipSetKey) (*verifregtypes.Claim, error)
StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error)
StateGetAllClaims(ctx context.Context, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new endpoints return too much data at once to safely add to the gateway (requires too much buffering). Do you need these on an API gateway? If so, we need to make them stream their results back via a channel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect these to end up being accessed in the same way as statemarketdeals is today - e.g. https://lotus.filecoin.io/lotus/developers/glif-nodes/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. you are right - I mixed glifs customized end point for statemarketdeal vs their gateway endpoint in my original issue. @LexLuthr could you please remove gateways? Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the gateway APIs.

@LexLuthr
Copy link
Contributor Author

@Stebalien I have updated the CHANGELOG.md with API and CLI changes.

Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, just noticed these

cli/filplus.go Outdated Show resolved Hide resolved
cli/filplus.go Outdated Show resolved Hide resolved
cli/filplus.go Outdated Show resolved Hide resolved
cli/filplus.go Outdated Show resolved Hide resolved
cli/filplus.go Outdated Show resolved Hide resolved
cli/filplus.go Outdated Show resolved Hide resolved
cli/filplus.go Outdated Show resolved Hide resolved
cli/filplus.go Outdated Show resolved Hide resolved
cli/filplus.go Outdated Show resolved Hide resolved
cli/filplus.go Outdated Show resolved Hide resolved
@LexLuthr
Copy link
Contributor Author

@rvagg This was entirely my fault. I created the JSON output for Allocations and forgot to rename the internals for claims. I have updated the internals for claims.

@LexLuthr LexLuthr requested a review from rvagg February 22, 2024 10:24
Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine by me

I don't have an opinion on the json output but I'll note that it'll be different from an API call's output which is what I've pasted the example of above, i.e. a map with claim/allocation ID as the key rather than an array. Maybe it's good to have alternative output? 🤷 Maybe we'll find out what's actually wanted.

@LexLuthr LexLuthr self-assigned this Feb 22, 2024
@LexLuthr LexLuthr linked an issue Feb 22, 2024 that may be closed by this pull request
@Stebalien Stebalien merged commit 9250307 into filecoin-project:feat/nv22 Feb 22, 2024
90 checks passed
@LexLuthr LexLuthr deleted the lexluthr/add-new-verifreg-apis branch February 23, 2024 08:55
rjan90 pushed a commit that referenced this pull request Mar 6, 2024
…laims (#11631)

* new verireg methods

* update changelog and add itest

* update itest and cli

* update new method's support till v9

* remove gateway APIs

* fix cli internal var names
rjan90 added a commit that referenced this pull request Mar 12, 2024
* [WIP] feat: Add nv22 skeleton

Addition of Network Version 22 skeleton

* update FFI

* feat: drand: refactor round verification

* feat: sealing: Support nv22 DDO features in the sealing pipeline (#11226)

* Initial work supporting DDO pieces in lotus-miner

* sealing: Update pipeline input to operate on UniversalPiece

* sealing: Update pipeline checks/sealing states to operate on UniversalPiece

* sealing: Make pipeline build with UniversalPiece

* move PieceDealInfo out of api

* make gen

* make sealing pipeline unit tests pass

* fix itest ensemble build

* don't panic in SectorsStatus with deals

* stop linter from complaining about checkPieces

* fix sector import tests

* mod tidy

* sealing: Add logic for (pre)committing DDO sectors

* sealing: state-types with method defs

* DDO non-snap pipeline works(?), DDO Itests

* DDO support in snapdeals pipeline

* make gen

* update actor bundles

* update the gst market fix

* fix: chain: use PreCommitSectorsBatch2 when setting up genesis

* some bug fixes

* integration working changes

* update actor bundles

* Make TestOnboardRawPieceSnap pass

* Appease the linter

* Make deadlines test pass with v12 actors

* Update go-state-types, abstract market DealState

* make gen

* mod tidy, lint fixes

* Fix some more tests

* Bump version in master

Bump version in master

* Make gen

Make gen

* fix sender

* fix: lotus-provider: Fix winning PoSt

* fix: sql Scan cannot write to an object

* Actually show miner-addrs in info-log

Actually show miner-addrs in lotus-provider info-log

* [WIP] feat: Add nv22 skeleton

Addition of Network Version 22 skeleton

* update FFI

* ddo is now nv22

* make gen

* temp actor bundle with ddo

* use working go-state-types

* gst with v13 market migration

* update bundle, builtin.MethodsMiner.ProveCommitSectors2 -> 3

* actually working v13 migration, v13 migration itest

* Address review

* sealing: Correct DDO snap pledge math

* itests: Mixed ddo itest

* pipeline: Fix sectorWeight

* sealing: convert market deals into PAMs in mixed sectors

* sealing: make market to ddo conversion work

* fix lint

* update gst

* Update actors and GST to lastest integ branch

* commit batcher: Update ProveCommitSectors3Params builder logic

* make gen

* use builtin-actors master

* ddo: address review

* itests: Add commd assertions to ddo tests

* make gen

* gst with fixed types

* config knobs for RequireActivationSuccess

* storage: Drop obsolete flaky tasts

---------

Co-authored-by: Jennifer Wang <[email protected]>
Co-authored-by: Aayush <[email protected]>
Co-authored-by: Shrenuj Bansal <[email protected]>
Co-authored-by: Phi <[email protected]>
Co-authored-by: Andrew Jackson (Ajax) <[email protected]>
Co-authored-by: TippyFlits <[email protected]>

* feat: implement FIP-0063

* chore: deps: update to go-multiaddr v0.12.2 (#11602)

* feat: fvm: update the FVM/FFI to v4.1 (#11608) (#11612)

This:

1. Adds nv22 support.
2. Updates the message tracing format.

Co-authored-by: Steven Allen <[email protected]>

* AggregateProofType nil when doing batch updates

Use latest nv22 go-state-types version with matching update

* Update to v13.0.0-rc.2 bundle

* chore: Upgrade heights and codename

Update upgrade heights

Co-Authored-By: Steven Allen <[email protected]>

* Update epoch after nv22 DRAND switch

Update epoch after nv22 DRAND switch

* Update Mango codename to Phoneix

Make the codename for the Drand-change inline with Dragon style.

* Add UpgradePhoenixHeight to API params

* set UpgradePhoenixHeight to be one hour after Dragon

* Make gen

Make gen and UpgradePhoenixHeight in butterfly and local devnet to be in line with Calibration and Mainnet

* Update epoch heights (#11637)

Update epoch heights

* new: add forest bootstrap nodes (#11636)

Signed-off-by: samuelarogbonlo <[email protected]>

* Merge pull request #11491 from filecoin-project/fix/remove-decommissioned-pl-bootstrap-nodes

Remove PL operated bootstrap nodes from mainnet.pi

* feat: api: new verified registry methods to get all allocations and claims (#11631)

* new verireg methods

* update changelog and add itest

* update itest and cli

* update new method's support till v9

* remove gateway APIs

* fix cli internal var names

* chore:: backport #11609 to the feat/nv22 branch (#11644)

* feat: api: improve the correctness of Eth's trace_block (#11609)

* Improve the correctness of Eth's trace_block

- Improve encoding/decoding of parameters and return values:
  - Encode "native" parameters and return values with Solidity ABI.
  - Correctly decode parameters to "create" calls.
  - Use the correct (ish) output for "create" calls.
  - Handle all forms of "create".
- Make robust with respect to reverts:
  - Use the actor ID/address from the trace instead of looking it up in
    the state-tree (may not exist in the state-tree due to a revert).
  - Gracefully handle failed actor/contract creation.
- Improve performance:
  - We avoid looking anything up in the state-tree when translating the
    trace, which should significantly improve performance.
- Improve code readability:
  - Remove all "backtracking" logic.
  - Use an "environment" struct to store temporary state instead of
    attaching it to the trace.
- Fix random bugs:
  - Fix an allocation bug in the "address" logic (need to set the
    capacity before modifying the slice).
  - Improved error checking/handling.
- Use correct types for `trace_block` action/results (create, call, etc.).
  - And use the correct types for Result/Action structs instead of reusing the same "Call" action every time.
- Improve error messages.

* Make gen

Make gen

---------

Co-authored-by: Steven Allen <[email protected]>

* fix: add UpgradePhoenixHeight to StateGetNetworkParams (#11648)

* chore: deps: update to go-state-types v13.0.0-rc.1

* do NOT update the cache when running the real migration

* Merge pull request #11632 from hanabi1224/hm/drand-test

feat: drand quicknet: allow scheduling drand quicknet upgrade before nv22 on 2k devnet

* chore: deps: update to go-state-types v13.0.0-rc.2

chore: deps: update to go-state-types v13.0.0-rc.2

* feat: set migration config UpgradeEpoch for v13 actors upgrade

* Built-in actor events first draft

* itest for DDO non-market verified data w/ builtin actor events

* Tests for builtin actor events API

* Clean up DDO+Events tests, add lots of explainer comments

* Minor tweaks to events types

* Avoid duplicate messages when looking for receipts

* Rename internal events modules for clarity

* Adjust actor event API after review

* s/ActorEvents/Events/g in global config

* Manage event sending rate for SubscribeActorEvents

* Terminate SubscribeActorEvents chan when at max height

* Document future API changes

* More clarity in actor event API docs

* More post-review changes, lots of tests for SubscribeActorEvents

Use BlockDelay as the window for receiving events on the SubscribeActorEvents
channel. We expect the user to have received the initial batch of historical
events (if any) in one block's time. For real-time events we expect them to
not fall behind by roughly one block's time.

* Remove duplicate code from actor event type marshalling tests

Reduce verbosity and remove duplicate test logic from actor event types
JSON marshalling tests.

* Rename actor events test to follow go convention

Add missing `s` to `actor_events` test file to follow golang convention
used across the repo.

* Run actor events table tests in deterministic order

Refactor `map` usage for actor event table tests to ensure deterministic
test execution order, making debugging potential issues easier. If
non-determinism is a target, leverage Go's built-in parallel testing
capabilities.

* Reduce scope for filter removal failure when getting actor events

Use a fresh context to remove the temporary filter installed solely to
get the actor events. This should reduce chances of failure in a case
where the original context may be expired/cancelled.

Refactor removal into a `defer` statement for a more readable, concise
return statement.

* Use fixed RNG seed for actor event tests

Improve determinism in actor event tests by using a fixed RNG seed. This
makes up a more reproducible test suit.

* Use provided libraries to assert eventual conditions

Use the functionalities already provided by `testify` to assert eventual
conditions, and remove the use of `time.Sleep`.

Remove duplicate code in utility functions that are already defined.

Refactor assertion helper functions to use consistent terminology:
"require" implies fatal error, whereas "assert" implies error where the
test may proceed executing.

* Update changelog for actor events APIs

* Fix concerns and docs identified by review

* Update actor bundle to v13.0.0-rc3

Update actor bundle to v13.0.0-rc3

* Prep Lotus v1.26.0-rc1

- For sanity reverting the mainnet upgrade epoch to 99999999, and then only set it when cutting the final release

-Update Calibnet CIDs to v13.0.0-rc3

- Add GetActorEvents, SubscribeActorEvents, GetAllClaims and GetAllAllocations methods to the changelog

Co-Authored-By: Jiaying Wang <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Masih H. Derkani <[email protected]>

* Make gen

Make gen

* fix: beacon: validate drand change at nv16 correctly

* bump to v1.26.0-rc2

* test: cleanup ddo verified itest, extract steps to functions

also add allocation-removed event case

* test: extract verified DDO test to separate file, add more checks

* test: add additional actor events checks

* Add verification for "deal-activated" actor event

* docs(drand): document the meaning of "IsChained" (#11692)

* Resolve conflicts

I encountered multiple issues when trying to run make gen. And these changes fixed a couple of them:
- go mod tidy
- Remove RaftState/RaftLeader
- Revert `if ts.Height() > claim.TermMax+claim.TermStart || !cctx.IsSet("expired")` to the what is in the release/v1.26.0: `if tsHeight > val.TermMax || !expired`

* fixup imports, make jen

* Update version

Update version in master to v1.27.0-dev

* Update node/impl/full/dummy.go

Co-authored-by: Łukasz Magiera <[email protected]>

* Adjust ListClaimsCmd

Adjust ListClaimsCmd according to review

---------

Signed-off-by: samuelarogbonlo <[email protected]>
Co-authored-by: TippyFlits <[email protected]>
Co-authored-by: Aayush <[email protected]>
Co-authored-by: Łukasz Magiera <[email protected]>
Co-authored-by: Jennifer Wang <[email protected]>
Co-authored-by: Shrenuj Bansal <[email protected]>
Co-authored-by: Andrew Jackson (Ajax) <[email protected]>
Co-authored-by: Steven Allen <[email protected]>
Co-authored-by: Rod Vagg <[email protected]>
Co-authored-by: Samuel Arogbonlo <[email protected]>
Co-authored-by: LexLuthr <[email protected]>
Co-authored-by: tom123222 <[email protected]>
Co-authored-by: Aarsh Shah <[email protected]>
Co-authored-by: Masih H. Derkani <[email protected]>
Co-authored-by: Jiaying Wang <[email protected]>
rjan90 pushed a commit that referenced this pull request Mar 22, 2024
…laims (#11631)

* new verireg methods

* update changelog and add itest

* update itest and cli

* update new method's support till v9

* remove gateway APIs

* fix cli internal var names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 P2: Should be resolved
Projects
Status: ☑️ Done (Archive)
Development

Successfully merging this pull request may close these issues.

Add Verifreg APIs to support tooling migration
5 participants