-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9926781
commit 4c1f4a5
Showing
3 changed files
with
57 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Contributing | ||
|
||
## Testing | ||
|
||
Running the tests requires having Archive database available [see: | ||
[Quick Start with Mainnet](#quick-start-with-mainnet)]. Once the setup is complete you can run tests | ||
using: | ||
|
||
```bash | ||
just test | ||
``` | ||
|
||
### Managing PostgreSQL | ||
|
||
- **Stop PostgreSQL**: To stop the PostgreSQL instance: | ||
|
||
```bash | ||
just pg-down | ||
``` | ||
|
||
- **Restart PostgreSQL**: To restart without reinitializing the database (useful if the database is | ||
already set up): | ||
|
||
```bash | ||
just pg-up | ||
``` | ||
|
||
> You only need to reinitialize the database if you want the latest data dump. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,52 @@ | ||
# Mina Mesh | ||
|
||
[![checks](https://github.com/MinaFoundation/MinaMesh/actions/workflows/checks.yaml/badge.svg)](https://github.com/MinaFoundation/MinaMesh/actions/workflows/checks.yaml) | ||
|
||
## Overview | ||
|
||
Mina Mesh is an implementation of the | ||
[Coinbase Mesh specification](https://docs.cdp.coinbase.com/mesh/docs/welcome) for the | ||
[Mina blockchain](https://minaprotocol.com/). | ||
|
||
## Building | ||
|
||
To build the project: | ||
|
||
```bash | ||
cargo build | ||
``` | ||
|
||
The binary will be available at: | ||
> Note: Mina Mesh is WIP and should not yet be used in production. | ||
```bash | ||
target/debug/mina_mesh | ||
``` | ||
|
||
## Running | ||
|
||
Mina Mesh requires access to a PostgreSQL Archive database and a Mina GraphQL endpoint. By default, | ||
the configuration points to the mainnet, making it easy to get started. You can override the | ||
configuration by either passing arguments or setting environment variables via a `.env` file (an | ||
example is provided as `.env.example`). | ||
## Installation | ||
|
||
### Quick Start with Mainnet | ||
```sh | ||
# Install the mina-mesh executable | ||
cargo install mina-mesh | ||
|
||
1. **Set up the PostgreSQL Archive Database** | ||
|
||
Use the predefined `just` commands to set up and start the PostgreSQL database: | ||
|
||
```bash | ||
just setup-archive-db | ||
# Confirm installation successful | ||
mina-mesh --help | ||
``` | ||
|
||
> Note: This process sets up the PostgreSQL docker using the latest mainnet archive database. | ||
2. **Run the Mina Mesh Server** | ||
## Fetch Genesis Block Identifier | ||
|
||
To start the server with default settings (mainnet configuration): | ||
Before running the server, we must first write genesis block identifier information to our `.env` | ||
file. | ||
|
||
```bash | ||
target/debug/mina_mesh serve | ||
```sh | ||
mina-mesh fetch-genesis-block-identifier >> .env | ||
``` | ||
|
||
The server will listen on `0.0.0.0:3000` by default. | ||
> Note: this command utilizes a default GraphQL endpoint | ||
> ("https://mainnet.minaprotocol.network/graphql"). You can override this default by specifying a | ||
> `PROXY_URL` in your `.env` file. | ||
### Playground Mode | ||
## Instantiate the Server | ||
|
||
You can enable a playground mode, which provides a simplified testing interface, by adding the | ||
`--playground` flag: | ||
Mina Mesh depends on a Postgres connection string for an archive database. | ||
|
||
```bash | ||
cargo run -- serve --playground | ||
``` | ||
|
||
When enabled, you can access the playground at the root URL (`/`). | ||
|
||
### Configuration | ||
Ensure that you also specify an archive `DATABASE_URL` in your `.env`. | ||
|
||
Mina Mesh can be configured through command-line options or by using environment variables. For | ||
convenience, you can use a `.env` file. To get started, copy the provided `.env.example`: | ||
|
||
```bash | ||
cp .env.example .env | ||
```sh | ||
mina-mesh serve --playground | ||
``` | ||
|
||
Then modify the `.env` file to suit your environment. The available configurations include: | ||
|
||
- **Mina GraphQL Endpoint**: `MINA_PROXY_URL` (default: | ||
`https://mainnet.minaprotocol.network/graphql`) | ||
- **PostgreSQL Archive Database URL**: `MINA_ARCHIVE_DATABASE_URL` (default: | ||
`postgres://mina:whatever@localhost:5432/archive`) | ||
- **Genesis Block Identifier**: `MINA_GENESIS_BLOCK_IDENTIFIER_HEIGHT`, | ||
`MINA_GENESIS_BLOCK_IDENTIFIER_STATE_HASH` | ||
|
||
> You can also pass these options as arguments to `mina_mesh serve` to override the defaults. | ||
> Note: you may want to exclude the `--playground` flag in production. This will disable the | ||
> playground, which renders when the server's root `/` route receives a GET request. | ||
## Testing | ||
Alternatively, you can supply the archive database URL via the command line. | ||
|
||
Running the tests requires having Archive database available [see: | ||
[Quick Start with Mainnet](#quick-start-with-mainnet)]. Once the setup is complete you can run tests | ||
using: | ||
|
||
```bash | ||
just test | ||
```sh | ||
mina-mesh serve --playground --database-url postgres://mina:whatever@localhost:5432/archive | ||
``` | ||
|
||
### Managing PostgreSQL | ||
|
||
- **Stop PostgreSQL**: To stop the PostgreSQL instance: | ||
|
||
```bash | ||
just pg-down | ||
``` | ||
|
||
- **Restart PostgreSQL**: To restart without reinitializing the database (useful if the database is | ||
already set up): | ||
|
||
```bash | ||
just pg-up | ||
``` | ||
|
||
> You only need to reinitialize the database if you want the latest data dump. | ||
Then visit [`http://0.0.0.0:3000`](http://0.0.0.0:3000) for an interactive playground with which you | ||
can explore and test endpoints. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters