Skip to content

Commit 3d0d88e

Browse files
Merge branch 'cartesi:Staging' into Staging
2 parents c9a7118 + 5da8d2e commit 3d0d88e

13 files changed

Lines changed: 588 additions & 393 deletions

File tree

cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ An **Inspect** request involves making an external HTTP API call to the rollups
213213

214214
You can make a simple inspect call from your frontend client to retrieve reports.
215215

216-
To perform an Inspect call, use an HTTP POST request to `<address of the node>/inspect/<application name or address>` with a body containing the request payload. For example:
216+
To perform an Inspect call, make an HTTP POST request to `<address of the node>/inspect/<application name or address>` with a body containing the request payload. For example:
217217

218218
```shell
219219
curl -X POST http://localhost:8080/inspect/0xb483897a2790a5D1a1C5413690bC5933f269b3A9 \

cartesi-rollups_versioned_docs/version-2.0/deployment/introduction.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ resources:
99

1010
Applications built on Cartesi Rollups are intended to be deployed to public blockchains so users can access them. This can be done by taking advantage of a cloud-based infrastructure.
1111

12-
Deploying a Cartesi dApp involves two steps: deploying a smart contract that defines your dApp on-chain and then instantiating a node that runs the applications intended backend logic.
12+
Deploying a Cartesi dApp involves two steps: deploying a smart contract that defines your dApp on-chain and then instantiating a node that runs the application's intended backend logic.
1313

1414
To facilitate the instantiation of such nodes, Cartesi provides an infrastructure for quickly getting them running in the cloud so the node can be run 24/7. This server will expose a single port to the internet so client applications can communicate with the node.
1515

16-
The Cartesi rollups node is distributed as a Docker image. Any popular cloud provider, like AWS, GCP, Azure, Digital Ocean, or Linode, can run docker containers and hence can be used to host the rollups node.
16+
## Public snapshots
17+
18+
For production deployments, applications must use **public snapshots** that are built through public workflows and published as public releases. This ensures transparency, reproducibility, trust, and auditability - essential for the trustless nature of blockchain applications.
19+
20+
[Learn more about public snapshots](./snapshot.md)
1721

1822
## Deployment process
1923

@@ -23,23 +27,20 @@ The `cartesi build` command produces the Cartesi genesis machine, which contains
2327

2428
After deployment, any changes to the application code will generate a different hash and, hence, require another deployment.
2529

26-
The smart contract that represents the application on the base layer can be deployed using the [`CartesiDAppFactory`](../api-reference/contracts/application-factory.md) smart contract.
27-
2830
There are two methods to deploy an application:
2931

30-
1. [Self-hosted deployment](../deployment/self-hosted.md): Deploy the application node using your infrastructure.
31-
32-
2. Third-party service provider: Outsource running the application node to a service provider.
32+
1. [Self-hosted deployment](./self-hosted.md): Deploy the application node using your infrastructure
33+
2. Third-party service provider: Outsource running the application node to a service provider
3334

3435
:::caution important
35-
Deployment with a third-party service provider is under development and will be available in a future release.
36+
Deployment with a third-party service provider is under development and will be available soon.
3637
:::
3738

3839
## Supported networks
3940

4041
As stated above, the first step in deploying a new Cartesi dApp to a blockchain requires creating a smart contract on that network that uses the Cartesi Rollups smart contracts. Cartesi has already deployed the Rollups smart contracts to several networks for convenience.
4142

42-
The table below shows the list of all [networks that are currently supported](https://github.com/cartesi/rollups-contracts/tree/v1.4.0/onchain/rollups/deployments) in the latest release:
43+
The table below shows the list of all [networks that are currently supported](https://usecannon.com/packages/cartesi-rollups) in the latest release:
4344

4445
| Network Name | Chain ID |
4546
| ---------------- | -------- |
Lines changed: 64 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,109 @@
11
---
22
id: self-hosted
33
title: Self-hosted deployment
4-
resources:
5-
- url: https://www.codecademy.com/article/installing-and-using-postgresql-locally
6-
title: Installing and Using PostgreSQL Locally
7-
- url: https://docs.digitalocean.com/products/databases/postgresql/how-to/create/
8-
title: How to Create PostgreSQL Database Clusters
9-
- url: https://www.amazonaws.cn/en/getting-started/tutorials/deploy-docker-containers/
10-
title: How to Deploy Docker Container - AWS
11-
- url: https://www.digitalocean.com/solutions/docker-hosting
12-
title: Deploy Docker Containers on Digital Ocean
13-
- url: https://docs.docker.com/reference/cli/docker/image/tag/
14-
title: Docker Tag
154
---
165

17-
The self-hosted deployment involves running your infrastructure locally or on a remote cloud server to host your application node.
6+
This guide explains how to run a Cartesi Rollups node locally on your machine for development and testing purposes on **testnet**.
187

19-
Here are the requirements:
8+
:::warning Production Warning
9+
**This self-hosted approach should NOT be used in *production*.**
2010

21-
- Wallet with sufficient funds on the chosen network.
22-
- A cloud server
23-
- A PostgreSQL database
24-
- A web3 provider for interacting with the selected network
11+
While this setup works with testnet environments, it's designed exclusively for development purposes. It lacks critical production requirements such as:
2512

26-
## Initiating deployment
27-
28-
1. Compile your application into RISC-V architecture and consequently build a Cartesi machine by running:
29-
30-
```shell
31-
cartesi build
32-
```
33-
34-
2. Run the command below to start the deployment process.
35-
36-
```shell
37-
cartesi deploy --hosting self-hosted --webapp https://sunodo.io/deploy
38-
```
39-
40-
The command generates a Docker image containing the rollups node and machine. You will be redirected to a web application to deploy the necessary smart contracts.
41-
42-
![img](../../../static/img/v1.3/deploy.png)
43-
44-
## Deploying the contracts
45-
46-
On the deploy web interface, the hash of the Cartesi machine will be automatically configured.
47-
48-
1. Connect your wallet to set the application chain’s base layer and deployer account.
49-
50-
2. Create a wallet specifically for Cartesi rollups node transactions. The Cartesi rollups node will use this wallet to submit transactions to the base layer. Paste the public address of this wallet.
51-
52-
:::note create a wallet
53-
You can use [Cast](https://book.getfoundry.sh/reference/cast/cast-wallet-new-mnemonic) to create a new wallet by running `cast wallet new-mnemonic --words 24`. For increased security, you can use a wallet managed by [AWS KMS](https://aws.amazon.com/blogs/database/part1-use-aws-kms-to-securely-manage-ethereum-accounts/).
54-
:::
55-
56-
3. After successful deployment, the node’s configuration is presented in a `.env` file and a `.toml` format. This config file includes the addresses of the deployed smart contracts and information on the base layer chain.
57-
58-
You will need the `.env` when [hosting the node on the cloud provider](./self-hosted.md/#hosting-on-a-cloud-provider) and the `.toml` file when [hosting on Fly.io](./self-hosted.md/#hosting-on-flyio).
59-
60-
<!-- <video width="100%" controls poster="/static/img/v1.3/deploy.png">
61-
<source src="/videos/Deploy_Success.mp4" type="video/mp4" />
62-
Your browser does not support video tags.
63-
</video> -->
64-
65-
66-
## Hosting the node
67-
68-
You’ll need a server to host the application node and keep it operational 24/7. This server will expose a single port for client access to the rollups node APIs through GraphQL or Inspect requests.
69-
70-
71-
The server requirements depend on your application's expected usage and the specifications of the Cartesi machine you're using, such as its RAM size and total capacity. Consider a minimum of 8GB of RAM, and adjust as needed.
72-
73-
74-
The Cartesi rollups node is distributed as a Docker image. Any popular cloud provider, like AWS, GCP, Azure, Digital Ocean, or Linode, can run docker containers and hence can be used to host the rollups node.
75-
76-
Alternatively, you can use a service like [Fly.io](https://fly.io/) to deploy your application node.
77-
78-
### Hosting on a cloud provider
79-
80-
1. Download the `.env` configuration file into the root directory of your application.
81-
82-
1. Obtain HTTP and WebSocket URLs from a web3 provider for the `CARTESI_BLOCKCHAIN_HTTP_ENDPOINT` and `CARTESI_BLOCKCHAIN_WS_ENDPOINT` variables.
83-
84-
Here is an example from [Alchemy](https://dashboard.alchemy.com/):
85-
86-
![img](../../../static/img/v1.3/alchemy.png)
87-
88-
:::caution important
89-
The web3 provider URLs and wallet mnemonic are sensitive information that can compromise your application and funds. You should keep it **secure** and **private** at all times.
90-
:::
13+
- Public snapshot verification
14+
- Proper security hardening
15+
- Production-grade infrastructure
16+
:::
9117

92-
1. Create a PostgreSQL database and configure the connection string in the `.env` file.
18+
## Prerequisites
9319

94-
The connection string for a PostgreSQL database must be configured at the `CARTESI_POSTGRES_ENDPOINT` variable.
20+
Before starting, ensure you have the following installed:
9521

96-
You can use any PostgreSQL database, whether managed by a cloud provider or set up on your local infrastructure. The key configuration required is the connection string, encompassing the database URL, username, password, and name. The node necessitates a PostgreSQL database to store the application state, which is accessible via the [GraphQL API](../api-reference/graphql/basics.md).
22+
- Cartesi CLI: An easy-to-use tool for developing and deploying your dApps.
9723

98-
1. With all the config variables set, here is how you can run the node on your local machine:
24+
- Docker Desktop 4.x: The required tool to distribute the Cartesi Rollups framework and its dependencies.
9925

100-
```
101-
docker run --env-file <env-file> -p 10000:10000 <image-id>
102-
```
26+
For more details about the installation process for each of these tools, please refer to the [this section](../development/installation.md).
10327

104-
Replace `<env-file>` and `<image-id>` with the `.env` file name and `sha256` hash of your Cartesi machine.
28+
## Configuration
10529

106-
The image can be tagged using [docker tag](https://docs.docker.com/reference/cli/docker/image/tag/).
30+
Before running the node, you need to configure your `.env` file with the following environment variables:
10731

108-
You can deploy your node with a cloud provider or use any managed container solution, like Kubernetes.
32+
```shell
33+
BLOCKCHAIN_ID=<blockchain-id>
34+
AUTH_KIND="private_key_file"
35+
PRIVATE_KEY_FILE="/run/secrets/pk"
36+
BLOCKCHAIN_WS_ENDPOINT="<ws-endpoint>"
37+
BLOCKCHAIN_HTTP_ENDPOINT="<http-endpoint>"
38+
```
10939

110-
### Hosting on fly.io
40+
**Important notes:**
11141

112-
Fly.io is a platform where you can conveniently deploy applications packaged as Docker containers.
42+
| Variable | Description |
43+
|----------|-------------|
44+
| `BLOCKCHAIN_ID` | Replace `<blockchain-id>` with your blockchain network ID |
45+
| `BLOCKCHAIN_WS_ENDPOINT` | Replace `<ws-endpoint>` with your WebSocket endpoint |
46+
| `BLOCKCHAIN_HTTP_ENDPOINT` | Replace `<http-endpoint>` with your HTTP endpoint |
47+
| `PRIVATE_KEY_FILE` | Points to the private key file created in [**step 2**](#setting-up-the-local-node) |
48+
| `AUTH_KIND` | Set to `"private_key_file"` for local development |
11349

114-
:::caution important
115-
If deploying to Fly.io from macOS with Apple Silicon, create a Docker image for `linux/amd64` with: `cartesi deploy build --platform linux/amd64`
116-
:::
50+
## Setting up the local node
11751

118-
1. [Install the flyctl CLI](https://fly.io/docs/hands-on/install-flyctl/)
52+
1. **Download the Cartesi Rollups Node docker compose file in your project root:**
11953

120-
1. [Create an account](https://fly.io/docs/hands-on/sign-up-sign-in/)
54+
```shell
55+
curl -L https://raw.githubusercontent.com/cartesi/docs/refs/heads/docs/deployment/cartesi-rollups_versioned_docs/version-2.0/deployment/src/compose.local.yaml -o compose.local.yaml
56+
```
12157

122-
1. Create an application:
58+
2. **Create a secret for private key storage:**
12359

12460
```shell
125-
$ fly app create <app-name>
126-
New app created: <app-name>
61+
mkdir -p secrets
62+
echo "YOUR_PRIVATE_KEY" > secrets/pk
12763
```
12864

129-
1. Create a Postgres database application:
65+
:::danger Security
66+
Ensure the `secrets/` directory is in a secure location and has restricted permissions, different from the project root to avoid leaking your private key.
67+
:::
68+
69+
3. **Build the application with the Cartesi CLI:**
13070

13171
```shell
132-
fly postgres create --initial-cluster-size 1 --name <app-name>-database --vm-size shared-cpu-1x --volume-size 1
72+
cartesi build
13373
```
13474

135-
Save the connection string provided by the command output.
75+
This command compiles your application into RISC-V architecture and creates a Cartesi machine snapshot locally.
13676

137-
1. Attach database to the node application:
77+
4. **Run the Cartesi Rollups Node with the application's initial snapshot attached:**
13878

13979
```shell
140-
fly postgres attach <app-name>-database -a <app-name>
80+
docker compose -f compose.local.yaml --env-file .env up -d
14181
```
14282

143-
1. Download `fly.toml` file from deploying the contracts and move it to your application directory:
83+
This starts the local node using the configuration from your `.env` file.
14484

145-
![deploy self-hosted config](../../../static/img/v1.3/fly.png)
85+
5. **Deploy and register the application to the node:**
14686

147-
1. Edit the `fly.toml` file to change all occurrences of `<app-name>` to the name of your application
87+
```shell
88+
docker compose --project-name cartesi-rollups-node \
89+
exec advancer cartesi-rollups-cli deploy application <app-name> /var/lib/cartesi-rollups-node/snapshot \
90+
--epoch-length 720 \
91+
--self-hosted \
92+
--salt <salt> \
93+
--json
94+
```
14895

149-
1. Create secrets for sensitive configuration with the actual values:
96+
Replace `<app-name>` with your application name and `<salt>` with a unique identifier. The salt must be unique for each deployment and cannot be repeated. You can generate a unique salt using:
15097

15198
```shell
152-
fly secrets set -a <app-name> CARTESI_BLOCKCHAIN_HTTP_ENDPOINT=<web3-provider-http-endpoint>
153-
fly secrets set -a <app-name> CARTESI_BLOCKCHAIN_WS_ENDPOINT=<web3-provider-ws-endpoint>
154-
fly secrets set -a <app-name> CARTESI_AUTH_MNEMONIC=`<mnemonic>`
155-
fly secrets set -a <app-name> CARTESI_POSTGRES_ENDPOINT=<connection_string>
99+
cast keccak256 "your-unique-string"
156100
```
157101

158-
Set value of the `connection_string` as provided by step 4.
159-
160-
1. Deploy the node:
102+
After this process, you'll have your application deployed and registered to the node.
161103

162-
Tag the image produced at the beginning of the process and push it to the Fly.io registry:
104+
## Accessing the node
163105

164-
```shell
165-
flyctl auth docker
166-
docker image tag <image-id> registry.fly.io/<app-name>
167-
docker image push registry.fly.io/<app-name>
168-
fly deploy -a <app-name>
169-
```
106+
Once running, your local Cartesi Rollups Node will be accessible through the standard APIs:
170107

171-
108+
- Inspect endpoint: `http://localhost:10012`
109+
- JSON-RPC endpoint: `http://localhost:10011`

0 commit comments

Comments
 (0)