filecoin-project / filplus-backend

Other
2 stars 1 forks source link

Support for upcoming smart-contract-based allocators. #176

Closed kacperzuk-neti closed 4 months ago

kacperzuk-neti commented 6 months ago

Pull Request Template

Description

What: this PR stores "address" and "tooling" fields from allocator JSON files in database and exposes to clients via API.

Why: smart-contract allocators will need to make a different call on-chain to grant datacap to a client. Instead of calling verifreg directly, they'll need to call smart contract which will do it on their behalf. Address of this smart contract is stored in the "address" field and we need the "tooling" field to know when to use the new approach.

Type of Change

Please delete options that are not relevant.

How Has This Been Tested?

  1. I've setup my own "Allocator-Governance" repo with some JSONs in it: https://github.com/Neti-Test/filplus-allocator-governance/tree/main/active
  2. Configured the backend to use this repo
  3. curl -H "Content-Type: application/json" -d '{"files_changed":["active/msig-classic.json","active/msig-contract.json"]}' localhost:8080/allocator/create
    • NOTE - it did fail to me at this point due to null installation_id of the allocator. This seems unrelated to my changes though and I've worked it around by setting the installation_id manually in the DB and rerunning the create endpoint.
  4. curl -s localhost:8080/allocators, verified that it now includes address and tooling in the response.

Checklist:

Before submitting your pull request, please review the following checklist:

Additional Information

I'm not sure if this change needs a change to documentation. Is there a documentation somewhere? I also weren't able to run fplus-lib tests as they seem to depend on some specific repo (keyko-io/test-philip-second). Please provide some guidance if you deem it necessary for this change.

Also this needs a database schema migration, to add address and tooling text columns to allocators table. How should this be handled?