threesigmaxyz / filplus-allocator-bot

A bot that tracks the state and events for the Fillecoin Plus program.
MIT License
0 stars 0 forks source link

Decode provider and client ID event fields #1

Open asynctomatic opened 1 month ago

asynctomatic commented 1 month ago

Description

Currently the bot is fetching allocation events using the GetActorsEventRaw JSON-RPC method. When decoded, the returned event has the following structure (eg. allocation event):

{
  "type": "allocation",
  "event": {
    "id": 65883265,
    "client": 3040398,
    "provider": 2822222,
    "pieceCid": "baga6ea4seaqc4u7wznlkovjf55v6snssjj52ric2zxym5xiwdz6warfyz3usiha",
    "pieceSize": 34359738368,
    "termMin": 1526400,
    "termMax": 1785600,
    "expiration": 4016174
  },
  "emitter": "f06",
  "height": 3995997,
  "msgCid": {
    "/": "bafy2bzacebewc5mryd4n45sc7kb3a5ofyyfqe5kxlrjoycg3pqv4mw6g2wuki"
  },
  "reverted": false,
  "tipsetKey": [
    {
      "/": "bafy2bzaced36z2o4i5s6yrvdkl7fthtvabi76wrnx7pnmhvfj4f4fjrwgldze"
    },
    {
      "/": "bafy2bzacea6hczn4vninljmhjfxrrml7v4hvg5likaveprjfuv2puqks3lco4"
    },
    {
      "/": "bafy2bzacecgaadnrw37zygyh3q6o4cz7p5nhtfump6lwlw76ukoejlv2dc3ki"
    },
    {
      "/": "bafy2bzacecfv6vlgip6lbm63r4y3xcehqq2vbomm7lcawhee4gr2566zg2esm"
    },
    {
      "/": "bafy2bzacedqbv6z7vbmoedqeeoxz42p3tlya2httfvvnvep6okz3zlyczwely"
    },
    {
      "/": "bafy2bzacechcl6nnlogw3po6w46ekcuwso3wspluqjxm2uizqcmauah2cqknc"
    }
  ]
}

For Filecoin Plus tracking, we are interested in events that originate from registered Allocators. The bot should be able to filter out events that are not related to Filecoin Plus, based on the client and provider fields.

❓ How to convert the client and provider fields to an address to check if it's a registered Allocator?

Acceptance Criteria

willscott commented 1 month ago

My understanding is that the numeric client and provider here are alternate forms of f0 addresses - https://github.com/filecoin-project/ref-fvm/blob/master/shared/src/address/mod.rs#L289-L299