Skip to content

Commit

Permalink
Merge branch '0xPolygon:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sanketsaagar authored Jan 9, 2025
2 parents 1b9c577 + 8a153fd commit 3b1babc
Show file tree
Hide file tree
Showing 13 changed files with 215 additions and 143 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,4 @@ docker compose up

- For docs issues (technical or language) open an issue here.
- For technical issues with the software, either raise an issue here and we will follow up, or check https://support.polygon.technology/support/home.

## The team

- Anthony Matlala [(@EmpieichO)](https://github.com/EmpieichO)
- Hans Bodani [(@hsutaiyu)](https://github.com/hsutaiyu)
- Katharine Murphy [(@kmurphypolygon)](https://github.com/kmurphypolygon)

4 changes: 2 additions & 2 deletions docs/agglayer/agglayer-go.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The AggLayer-go is a service designed to receive zero-knowledge (ZK) proofs fro

## Architecture

The AggLayer Golang architecture supports interactions with multiple CDK chains for proof-verification. It uses a PostgreSQL database for storage and interacts with both L1 and L2 chains through configured RPC nodes.
The Agglayer Golang architecture supports interactions with multiple CDK chains for proof-verification. It uses a PostgreSQL database for storage and interacts with both L1 and L2 chains through configured RPC nodes.

The diagram below shows the full start-up, running, and shutdown sequence for the application and its components.

Expand Down Expand Up @@ -95,4 +95,4 @@ Refer to the `cmd` and `client` directories for API implementation details. Docu
---
For more information, visit the [AggLayer-go repository](https://github.com/AggLayer/agglayer-go).
For more information, visit the [AggLayer-go repository](https://github.com/AggLayer/agglayer-go).
4 changes: 2 additions & 2 deletions docs/agglayer/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Here's a list of chains connected to the alpha version of the AggLayer:
| Gateway FM | Haust | 938 | haust-network |
| Gateway FM | Lumia | 1952959480 | Lumia Testnet |
| Gateway FM | Lumia | 994873017 | prism |
| Gateway FM | Moonveil | 1297206718 | moonveil-testnet |
| Gateway FM | Moonveil | 1093502521 | moonveil-testnet |
| OKX | OKX | 196 | X Layer |
| Gateway FM | Silicon | 1722641160 | silicon-sepolia-testnet |
| Gateway FM | Silicon | 2355 | silicon-zk |
Expand All @@ -44,4 +44,4 @@ The unified bridge is a single bridge contract for all AggLayer-connected chains

### AggLayer service

The AggLayer service is designed to receive ZK proofs from various CDK and non-CDK chains, and verify their validity before sending them to the L1 Ethereum for final settlement. Currently, the AggLayer service has two implementations: [agglayer-go](agglayer-go.md) and [agglayer-rs](agglayer-rs.md).
The AggLayer service is designed to receive ZK proofs from various CDK and non-CDK chains, and verify their validity before sending them to the L1 Ethereum for final settlement. Currently, the AggLayer service has two implementations: [agglayer-go](agglayer-go.md) and [agglayer-rs](agglayer-rs.md).
2 changes: 1 addition & 1 deletion docs/cdk/architecture/cdk-pp-highlevel-arch.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The figure below depicts a simplified, high-level view of the CDK chain architecture using pessimistic proofs and the flow of transactions through the system.

![Figure: CDK Architecture](../../img/cdk/CDK-pessimistic-proof-chain.jpg)
![Figure: CDK Architecture](../../img/cdk/Pessimistic-proofs-diagram.jpg)

## Transaction Flow

Expand Down
2 changes: 1 addition & 1 deletion docs/cdk/architecture/high-level-views.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The diagram below depicts a simplified architectural layout of the CDK FEP stack and indicates at a high level how components communicate.

![High level view of CDK stack](../../img/cdk/cdk-stack.svg)
![High level view of CDK stack](../../img/cdk/Full-execution-proofs-diagram.jpg)

### Component interactions

Expand Down
Binary file removed docs/img/cdk/CDK-pessimistic-proof-chain.jpg
Binary file not shown.
Binary file added docs/img/cdk/Full-execution-proofs-diagram.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/cdk/Pessimistic-proofs-diagram.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 0 additions & 125 deletions docs/img/cdk/cdk-stack.svg

This file was deleted.

2 changes: 1 addition & 1 deletion docs/pos/how-to/validator/validator-ansible.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ First, start the Heimdall service. Once the Heimdall service is fully synced, st

!!! note "Syncing node using snapshots"

The Heimdall service takes several days to fully sync from scratch. Alternatively, you can use a maintained snapshot, which will reduce the sync time to a few hours. For detailed instructions, see [<ins>Snapshot Instructions for Heimdall and Bor</ins>](https://forum.polygon.technology/t/snapshot-instructions-for-heimdall-and-bor/9233).
The Heimdall service takes several days to fully sync from scratch. Alternatively, you can use a maintained snapshot, which will reduce the sync time to a few hours. For detailed instructions, see [<ins>Snapshot Instructions for Heimdall and Bor</ins>](https://docs.polygon.technology/pos/how-to/snapshots/).


### Start the Heimdall service
Expand Down
4 changes: 2 additions & 2 deletions docs/pos/how-to/validator/validator-binaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ First, start the Heimdall service. Then, once the Heimdall service syncs, start
The Heimdall service can take several days to sync from scratch fully.

Alternatively, you can use a maintained snapshot, which will reduce the sync time to a few hours.
For detailed instructions, see [<ins>Snapshot Instructions for Heimdall and Bor</ins>](https://forum.polygon.technology/t/snapshot-instructions-for-heimdall-and-bor/9233).
For detailed instructions, see [<ins>Snapshot Instructions for Heimdall and Bor</ins>](https://docs.polygon.technology/pos/how-to/snapshots/).

### Starting the Heimdall service

Expand Down Expand Up @@ -461,4 +461,4 @@ Check the Bor service logs using the following command:

```sh
journalctl -u bor.service -f
```
```
202 changes: 202 additions & 0 deletions docs/tools/data/thegraph.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@

!!! note "Content disclaimer"

Please view the third-party content disclaimer [here](https://github.com/0xPolygon/polygon-docs/blob/main/CONTENT_DISCLAIMER.md).

# The Graph

Getting historical data on a smart contract can be frustrating when building a dapp. [The Graph](https://thegraph.com/) provides an easy way to query smart contract data through APIs known as subgraphs. The Graph’s infrastructure relies on a decentralized network of indexers, enabling your dapp to become truly decentralized.

The Graph supports:
- Polygon Mainnet
- Polygon zkEVM Mainnet
- Polygon Amoy Testnet
- Polygon zkEVM Cardona Testnet

## Quick Start

These subgraphs only take a few minutes to set up. To get started, follow these three steps:

1. Initialize your subgraph project
2. Deploy & Publish
3. Query from your dapp

Here’s a step by step walk through:

## 1. Initialize your subgraph project

### Create a subgraph on Subgraph Studio⁠

Go to the [Subgraph Studio](https://thegraph.com/studio/) and connect your wallet. Once your wallet is connected, you can begin by clicking “Create a Subgraph”. When choosing a name, it is recommended to use Title Case: “Subgraph Name Chain Name.”

![Create a Subgraph](https://lh7-us.googleusercontent.com/docsz/AD_4nXf8OTdwMxlKQGKzIF_kYR7NPKeh9TmWnZBYxb7ft_YbdOdx_VVtbp6PslN7N1KGUzNpIDCmaXppdrllM1cw_J4L8Na03BXOWzJTK1POCve0nkRjQYgWJ60QHAdtQ4Niy83SMM8m0F0f-N-AJj4PDqDPlA5M?key=fnI6SyFgXU9SZRNX5C5vPQ)


You will then land on your subgraph’s page. All the CLI commands you need will be visible on the right side of the page:

![CLI commands](https://lh7-us.googleusercontent.com/docsz/AD_4nXe3YvCxiOH_LupSWe8zh9AmP-VrV4PlOq3f7Ix6hNlBUYcANUFuLuVIWR74OGiBs0nrugTyT0v3o6RPmTsgHONdv_ZJNWtcDWEkRntXPHlQGFcqmEBa-D6j4aoIPzUKYdOJMVUPu8O3fwjdZ4IaXXZoTzY?key=fnI6SyFgXU9SZRNX5C5vPQ)


### Install the Graph CLI⁠

On your local machine run the following:
```
npm install -g @graphprotocol/graph-cli
```

### Initialize your Subgraph⁠

You can copy this directly from your subgraph page to include your specific subgraph slug:
```
graph init --studio <SUBGRAPH_SLUG>
```
You’ll be prompted to provide some info on your subgraph like this:

![cli sample](https://lh7-us.googleusercontent.com/docsz/AD_4nXdTAUsUb5vbs3GtCrhKhuXM1xYoqqooYTxw6lfJfYtLJNP8GKVOhTPmjxlM1b6Qpx-pXNVOzRuc8BL12wZXqy4MIj8ja0tp15znfuJD_Mg84SSNj3JpQ4d31lNTxPYnpba4UOzZx8pmgOIsbI7vCz70v9gC?key=fnI6SyFgXU9SZRNX5C5vPQ)


Simply have your contract verified on the block explorer and the CLI will automatically obtain the ABI and set up your subgraph. The default settings will generate an entity for each event.

## 2. Deploy & Publish

### Deploy to Subgraph Studio⁠

First run these commands:

```bash
$ graph codegen
$ graph build
```

Then run these to authenticate and deploy your subgraph. You can copy these commands directly from your subgraph’s page in Studio to include your specific deploy key and subgraph slug:

```bash
$ graph auth --studio <DEPLOY_KEY>
$ graph deploy --studio <SUBGRAPH_SLUG>
```

You will be asked for a version label. You can enter something like v0.0.1, but you’re free to choose the format.

### Test your subgraph⁠

You can test your subgraph by making a sample query in the playground section. The Details tab will show you an API endpoint. You can use that endpoint to test from your dapp.

![Playground](https://lh7-us.googleusercontent.com/docsz/AD_4nXf3afwSins8_eO7BceGPN79VvwolDxmFNUnkPk0zAJCaUA-3-UAAjVvrMzwr7q9vNYWdrEUNgm2De2VfQpWauiT87RkFc-cVfoPSsQbYSgsmwhyY1-tpPdv2J1H4JAMq70nfWBhb8PszZBFjsbDAaJ5eto?key=fnI6SyFgXU9SZRNX5C5vPQ)


### Publish Your Subgraph to The Graph’s Decentralized Network

Once your subgraph is ready to be put into production, you can publish it to the decentralized network. On your subgraph’s page in Subgraph Studio, click on the Publish button:

![publish button](https://edgeandnode.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fa7d6afae-8784-4b15-a90e-ee8f6ee007ba%2F2f9c4526-123d-4164-8ea8-39959c8babbf%2FUntitled.png?table=block&id=37005371-76b4-4780-b044-040a570e3af6&spaceId=a7d6afae-8784-4b15-a90e-ee8f6ee007ba&width=1420&userId=&cache=v2)


Before you can query your subgraph, Indexers need to begin serving queries on it. In order to streamline this process, you can curate your own subgraph using GRT.

When publishing, you’ll see the option to curate your subgraph. As of May 2024, it is recommended that you curate your own subgraph with at least 3,000 GRT to ensure that it is indexed and available for querying as soon as possible.

![Publish screen](https://lh7-us.googleusercontent.com/docsz/AD_4nXerUr-IgWjwBZvp9Idvz5hTq8AFB0n_VlXCzyDtUxKaCTANT4gkk-2O77oW-a0ZWOh3hnqQsY7zcSaLeCQin9XU1NTX1RVYOLFX9MuVxBEqcMryqgnGQKx-MbDnOWKuMoLBhgyVWQereg3cdWtCPcTQKFU?key=fnI6SyFgXU9SZRNX5C5vPQ)

> **Note:** The Graph's smart contracts are all on Arbitrum One, even though your subgraph is indexing data from Ethereum, BSC or any other [supported chain](https://thegraph.com/docs/en/developing/supported-networks/).
## 3. Query your Subgraph

Congratulations! You can now query your subgraph on the decentralized network!

For any subgraph on the decentralized network, you can start querying it by passing a GraphQL query into the subgraph’s query URL which can be found at the top of its Explorer page.

Here’s an example from the [CryptoPunks Ethereum subgraph](https://thegraph.com/explorer/subgraphs/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK) by Messari:

![Query URL](https://lh7-us.googleusercontent.com/docsz/AD_4nXebivsPOUjPHAa3UVtvxoYTFXaGBao9pQOAJvFK0S7Uv0scfL6TcTVjmNCzT4DgsIloAQyrPTCqHjFPtmjyrzoKkfSeV28FjS32F9-aJJm0ILAHey2gqMr7Seu4IqPz2d__QotsWG3OKv2dEghiD74eypzs?key=fnI6SyFgXU9SZRNX5C5vPQ)


The query URL for this subgraph is:

`https://gateway-arbitrum.network.thegraph.com/api/`**[api-key]**`/subgraphs/id/HdVdERFUe8h61vm2fDyycgxjsde5PbB832NHgJfZNqK`

Now, you simply need to  fill in your own API Key to start sending GraphQL queries to this endpoint.

### Getting your own API Key

![API keys](https://lh7-us.googleusercontent.com/docsz/AD_4nXdz7H8hSRf2XqrU0jN3p3KbmuptHvQJbhRHOJh67nBfwh8RVnhTsCFDGA_JQUFizyMn7psQO0Vgk6Vy7cKYH47OyTq5PqycB0xxLyF4kSPsT7hYdMv2MEzAo433sJT6VlQbUAzgPnSxKI9a5Tn3ShSzaxI?key=fnI6SyFgXU9SZRNX5C5vPQ)


In Subgraph Studio, you’ll see the “API Keys” menu at the top of the page. Here you can create API Keys.

## Appendix

### Sample Query

This query shows the most expensive CryptoPunks sold.

```graphql
{
trades(orderBy: priceETH, orderDirection: desc) {
priceETH
tokenId
}
}

```

Passing this into the query URL returns this result:

```
{
"data": {
"trades": [
{
"priceETH": "124457.067524886018255505",
"tokenId": "9998"
},
{
"priceETH": "8000",
"tokenId": "5822"
},
// ...
```

<aside>
💡 Trivia: Looking at the top sales on [CryptoPunks website](https://cryptopunks.app/cryptopunks/topsales) it looks like the top sale is Punk #5822, not #9998. Why? Because they censor the flash-loan sale that happened.

</aside>

### Sample code

```jsx
const axios = require('axios');

const graphqlQuery = `{
trades(orderBy: priceETH, orderDirection: desc) {
priceETH
tokenId
}
}`;
const queryUrl = 'https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK'

const graphQLRequest = {
method: 'post',
url: queryUrl,
data: {
query: graphqlQuery,
},
};

// Send the GraphQL query
axios(graphQLRequest)
.then((response) => {
// Handle the response here
const data = response.data.data
console.log(data)

})
.catch((error) => {
// Handle any errors
console.error(error);
});
```

### Additional resources:

- To explore all the ways you can optimize & customize your subgraph for a better performance, read more about [creating a subgraph here](https://thegraph.com/docs/en/developing/creating-a-subgraph/).
- For more information about querying data from your subgraph, read more [here](https://thegraph.com/docs/en/querying/querying-the-graph/).
7 changes: 4 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ nav:
- CDK:
- Polygon CDK Home: cdk/index.md
- Overview: cdk/overview.md
- Release Notes:
- Fork ID 12: cdk/releases/release-notes.md
- Current Release:
- Release Notes: cdk/releases/release-notes.md
- Get Started:
- Local Deployment Guide: cdk/getting-started/local-deployment.md
- Quickstart: cdk/getting-started/local-deployment.md
- CLI Tool: cdk/getting-started/cli-tool.md
- CDK Erigon:
- Overview: cdk/getting-started/cdk-erigon/index.md
Expand Down Expand Up @@ -527,6 +527,7 @@ nav:
- PARSIQ: tools/data/parsiq.md
- SQD (Subsquid): tools/data/sqd.md
- SubQuery: tools/data/subquery.md
- The Graph: tools/data/thegraph.md
- Storage:
- IPFS: tools/storage/ipfs.md
- Filecoin: tools/storage/filecoinhelpers.md
Expand Down

0 comments on commit 3b1babc

Please sign in to comment.