Giter Club home page Giter Club logo

graphcast-cli's Introduction

Graphcast CLI

Docs crates.io

Introduction

This is a Graphcast CLI tailored for discontinuous participation on the Graphcast P2P network. The available message type is UpgradeIntentMessage from a subgraph owner, who can use the CLI to send a single message about subgraphs they own.

Upgrade Pre-sync

When developers publish a new version (subgraph deployment) to their subgraph, data service instability may occur while their API queries the pre-existing version. Indexers may require some time to sync a subgraph to the chainhead after they have stopped syncing the previous deployment. To decrease the upgrade friction, developers can send a message before publishing the subgraph on current deployment hash's Graphcast channel, which includes the subgraph id, corresponding new deployment hash, and the represented graph account that must be validated to be the subgraph's owner.

Indexers running the subgraph radio and listening to that channel will in turn receive the message and potentially start to offchain new deployment.

It is still at the subgraph developers' discretion to await for the indexers to sync upto chainhead, in which point they can publish the staged version without disrupting API usage. This tool provides a convinence function that allows subgraph developer to ....

๐Ÿ†™ Example usage

UpgradePresync

To send a message on Graphcast mainnet for the subgraph deployment "QmacQnSgia4iDPWHpeY6aWxesRFdb8o5DKZUx96zZqEWrB", we would need its subgraph id "CnJMdCkW3pr619gsJVtUPAWxspALPdCMw6o7obzYBNp3", private key to the graph account or an operator of the graph account, the subgraph owner's graph account, and the new deployment hash. You can supply them as an CLI argument

cargo run -- --private-key "abcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefg1" \
--graph-account "0xe9a1cabd57700b17945fd81feefba82340d9568f" \
upgrade-presync --new-hash "QmVVfLWowm1xkqc41vcygKNwFUvpsDSMbHdHghxmDVmH9x" \
--subgraph-id "CnJMdCkW3pr619gsJVtUPAWxspALPdCMw6o7obzYBNp3"

or assuming environmental variables are used for graph-account and private-key, simply use

cargo run upgrade-presync --subgraph-id CnJMdCkW3pr619gsJVtUPAWxspALPdCMw6o7obzYBNp3 --new-hash QmVVfLWowm1xkqc41vcygKNwFUvpsDSMbHdHghxmDVmH9x

The entire process from running the binary to sending the message should take ~45 seconds. One can expect the terminal to output the following:

2023-07-31T17:56:44.783866Z  INFO Creating Graphcast Agent, radio_name: "subgraph-radio", registry_subgraph: "https://api.thegraph.com/subgraphs/name/hopeyen/graphcast-registry-goerli", network_subgraph: "https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-goerli", graphcast_network: "testnet", max_retry: 5

2023-07-31T17:56:59.328490Z  INFO Sent message, msg_id: "0xc6b1131e0f8302abe48057f6fc69722ab46bd4285c2c4a8a8bdca6b221dcda96"

IndexingStatus

After sending UpgradeIntentMessage, a developer can periodically check the indexing status of the new subgraph deployment at the public APIs of the indexers who actively allocates on the current version of the subgraph.

Same arguments here can be used as the argument for UpgradeIntentMessage. However, gossips are not involved in this operation and the queries are made through deterministic queries.

cargo run indexing-status --subgraph-id "0x00000444e5a1a667663b0adfd853e8efa0470698-0" --new-hash QmfDJFYaDX7BdwT6rYa8Bx71vPjTueUVDN99pdwFgysDiZ

๐Ÿงช Testing

To run unit tests for the Radio. We recommend using nextest as your test runner. Once you have it installed you can run the tests using the following commands:

cargo nextest run

Contributing

We welcome and appreciate your contributions! Please see the Contributor Guide, Code Of Conduct and Security Notes for this repository.

graphcast-cli's People

Contributors

axiomatic-aardvark avatar hopeyen avatar

Watchers

 avatar

graphcast-cli's Issues

Add banner to Subgraph Studio to advertise Graphcast CLI

Migrated from graphops/subgraph-radio#21 by @axiomatic-aardvark

Expectation proposal
We should add a banner to Subgraph Studio that lets subgraph developers know that they can use our one-shot CLI to send messages about when they plan to publish a new version of their subgraph(s). That banner should direct them to our docs where we lay out the steps they need to take to send a message.

Alternative considerations
We could think of ways to integrate the one-shot CLI into Subgraph Studio itself, but that would require enormous effort since we would need to either 1. somehow wrap the existing one-shot CLI in WASM and create bindings for JS (which includes bundling the Go and C compilers) or 2. create a JS clone of one-shot CLI (using js-waku)

  • Prioritize after User Improvement Issue, communicate with E&N subgraph studio team so the integration can be timed appropriately
  • Add usage section in docs.graphops.xyz using the current README

[Feat.Req] User Improvement

moved from @axiomatic-aardvark graphops/subgraph-radio#20

Problem statement
The current one-shot CLI is perfect for sending one-off subgraph versioning update messages (as well as any message really, with a few tweaks), but we need it to be more user-friendly. This means possibly changing its name and adding a script that runs it within Docker, eliminating the need for users to install all pre-requisites like Go, Clang, etc. We also need to extract it to a separate repo.

Expectation proposal
Users (subgraph devs) should ideally be able to pull a Docker image (GHCR package) and run it with custom arguments.

Alternative considerations
We could also skip this and instead wait for graphcast-web to be functional before recommending the subgraph versioning feature to subgraph developers, but that will take a lot longer and getting early feedback is vital.

[Feat.Req] update subcommand categories

subcommand

  • send: for all commands that send various messages, such as upgrade-presync -> send upgrade-intent
  • monitor: for all commands that monitor for a certain status, such as indexing-status -> monitor indexing-status
    • can add one on monitor indexer-version

[Feat.Req] subcommands

Problem statement

After renaming one-shot-cli to graphcast-cli, we can consider a boarder scope for what the CLI can do

Expectation proposal

  • move sending upgrade intent message into a subcommand graphcast send upgradeIntentMessage subgraph_id ...
  • add simple commands relevant to upgrade presync functionality
    • query a list of indexers who has active allocation for the existing subgraph deployment
    • get public status APIs for a list of indexers
    • query indexingStatus from the public status APIs for the new deployment
    • summarize status

Rename to graphcast-cli

Problem statement

More straightforward naming

Expectation proposal

  • rename in codebase
  • rename in docs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.