Skip to content

subsquid-quests/lido-subgraph-migration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Subsquid Logo

docs.rs Discord

Website | Docs | Discord

Lido Subgraph Migration

This quest is to migrate the Lido Finance Subgraph to Squid SDK. The resulting squid should match the GraphQL API of the subgraph as close as possible, by migrating schema.graphql. The judges reserve the right to request improvements afther the initial review of the submission. Reach out to the Discord Channel for any tech questions regarding this quest. Use template squid as a starter.

Quest Info

Category Skill Level Time required (hours) Max Participants Reward Status End date
Squid Deployment $\textcolor{orange}{\textsf{Medium}}$ ~20 5 $\textcolor{red}{\textsf{3000tSQD}}$ open 20/12/2023

Acceptance critera

Ultimately, the solutions are accepted at the discretion of judges following a manual review. This sections is a rough guide that is in no way binding on our side.

Some of the reasons why the solution will not be accepted include:

  • squid does not start
  • squid fails to sync fully due to internal errors
  • batch handler filters are not set up correctly (leads to a late sync failure in RPC-ingesting squids)
  • data returned for any query is not consistent with subgraph data

You may find this tool to be useful for squid to subgraph API comparisons.

It is desirable that your solution:

  • includes a suite of test GraphQL queries that touches every schema entity and, if used, every custom resolver at least once, with corresponding subgraph queries (listing in README is enough)
  • has high code quality (readability, simplicity, comments where necessary)
  • uses batch processing consistently
  • avoids any "sleeping bugs": logic errors that accidentally happen to not break the data
  • follows the standard squid startup procedure:
    git clone <repo_url>
    cd <repo_url>
    npm ci
    sqd up
    sqd process &
    sqd serve
    
    If it does not, describe your startup procedure in the README.

Please test your solutions before submitting. We do allow some corrections, but judges' time is not limitless.

To submit, invite the following github accounts to your private repo : @dariaag, @belopash, @abernatskiy and @dzhelezov.

Rewards

tSQD rewards will be delivered via the quests page of Subsquid Cloud. Make sure you use the same GitHub handle to make a submission and when linking to that page.

Winners will be listed at the quest repository README. If you do not wish to be listed please tell us that in an issue in your submission repo.

Useful links

Setup and Common errors

  1. Install Node v16.x or newer https://nodejs.org/en/download

  2. Install Docker https://docs.docker.com/engine/install/

  3. Install git https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

  4. Install Squid CLI

    npm i -g @subsquid/cli@latest

How to run a squid:

Full startup procedure for newly developed squids:

  1. Install dependecies:
npm ci
  1. Generate model
sqd codegen
  1. Generate types
sqd typegen
  1. Build the squid
sqd build
  1. Open docker and run:
sqd up
  1. Generate migrations:
sqd migration:generate
  1. Start processing:
sqd process
  1. Start a local GraphQL server in a separate terminal:
sqd serve

Types (./src/abi), models (./src/model) and migrations ('./db') are typically kept within squid repos after they become stable. Then the startup procedure simplifies to

npm ci
sqd up
sqd process &
sqd serve

Possible Errors:

  1. Docker not installed
X db Error × query-gateway Error
Error response from daemon: Get "https://registry-1.docker.jo/v2/": uri ting to 127.0.0.1:8888: dial cp 127.0.0.1:8888: connectex: No connection
  1. Git not installed
Error: Error: spawn git ENOENT
at ChildProcess._handle.onexit (node: internal/child_process: 284:19)
at onErrorNT (node: internal/child_process:477:16)
at process.processTicksAndRejections (node: internal/process/task_queues:82:21)
  1. Dependencies not installed. Run npm ci
sqd typegen
TYPEGEN
    Error: spawn squid-evm-typegen ENOENT
    Code: ENOENT
  1. Rate-limiting. Get a private RPC endpoint from any node provider, then change the rpcUrl in processor.ts
will pause new requests for 20000ms {"rpcUrl":"https://rpc.ankr.com/eth",
"reason" : "HttpError: got 429 from https://rpc.ankr.com/eth"}

If necessary, rate limit your RPC queries.

Best practices:

  1. Batch saving
let transfers: Transfers[] = [];
...
ctx.store.save(transfers);
  1. Using map instead of array to avoid duplicate values
let transfers: Map<string, Transfer> = new Map();
...
ctx.store.upsert([...transfers.values()]);
  1. Verify log addresses, not only topics.
 if (log.topics[0] === erc721.events.Transfer.topic && log.address === CONTRACT_ADDRESS) {
...
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published