-
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.
Co-authored-by: Harry Solovay <[email protected]>
- Loading branch information
1 parent
cf40b5d
commit a4c1d2f
Showing
23 changed files
with
281 additions
and
35 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,97 @@ | ||
name: checks | ||
on: | ||
pull_request: | ||
merge_group: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dsherret/rust-toolchain-file@v1 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-check-${{ hashFiles('**/Cargo.lock') }} | ||
- run: RUSTFLAGS="-D warnings" cargo check --all-targets | ||
|
||
clippy: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dsherret/rust-toolchain-file@v1 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-clippy-${{ hashFiles('**/Cargo.lock') }} | ||
- run: RUSTFLAGS="-D warnings" cargo clippy --all-targets | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dsherret/rust-toolchain-file@v1 | ||
- uses: extractions/setup-just@v2 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Setup | ||
run: | | ||
just get-mainnet-archive-db | ||
just pg | ||
just wait-for-pg | ||
- name: Test | ||
run: just test | ||
- name: Tear down | ||
run: just pg-down | ||
|
||
rustfmt: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dsherret/rust-toolchain-file@v1 | ||
- run: cargo fmt --check | ||
|
||
dprint: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-dprint | ||
- run: npm i -g sql-formatter | ||
- uses: actions/checkout@v4 | ||
- uses: dprint/[email protected] | ||
|
||
cspell: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: streetsidesoftware/cspell-action@v6 | ||
with: | ||
incremental_files_only: false |
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,2 +1,20 @@ | ||
pg: | ||
docker run -d --name mina-archive-db -p 5432:5432 -v $(pwd)/sql_scripts:/docker-entrypoint-initdb.d -e POSTGRES_PASSWORD=whatever -e POSTGRES_USER=mina postgres | ||
|
||
pg-up: | ||
docker start mina-archive-db | ||
|
||
pg-down: | ||
docker kill mina-archive-db | ||
|
||
pg-rm: | ||
docker rm mina-archive-db | ||
|
||
get-mainnet-archive-db: | ||
./scripts/get_archive_db.sh mainnet | ||
|
||
wait-for-pg: | ||
./scripts/wait_for_pg.sh | ||
|
||
test: | ||
SNAP_CHECK=1 cargo test |
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,5 +1,63 @@ | ||
# Mina Mesh | ||
|
||
An implementation of | ||
[the Coinbase Mesh specification](https://docs.cdp.coinbase.com/mesh/docs/welcome) for the | ||
[Mina](https://minaprotocol.com/) blockchain. | ||
[![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: | ||
|
||
```bash | ||
target/debug/mina_mesh | ||
``` | ||
|
||
## Testing | ||
|
||
### Setup PostgreSQL with Latest Mainnet Archive DB | ||
|
||
To set up the testing environment with a working PostgreSQL database, use the predefined `just` | ||
steps: | ||
|
||
```bash | ||
just get-mainnet-archive-db | ||
just pg | ||
just wait-for-pg | ||
``` | ||
|
||
> Note: This process sets up the environment using the latest mainnet archive database. | ||
### Run Tests | ||
|
||
Once the setup is complete, run the tests with: | ||
|
||
```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
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
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,14 +1,14 @@ | ||
edition = "2021" | ||
group_imports = "StdExternalCrate" | ||
ignore = ["mesh-generated"] | ||
ignore = ["mesh_generated/src/**"] | ||
imports_granularity = "Crate" | ||
max_width = 120 | ||
newline_style = "Unix" | ||
overflow_delimited_expr = true | ||
spaces_around_ranges = true | ||
style_edition = "2021" | ||
tab_spaces = 2 | ||
use_field_init_shorthand = true | ||
use_small_heuristics = "Max" | ||
use_try_shorthand = true | ||
version = "Two" | ||
wrap_comments = true |
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,36 @@ | ||
#!/bin/bash | ||
|
||
# This script is used to download the archive dump from the mina-archive-dumps bucket | ||
# and extract the archive dump to the sql_scripts directory | ||
# The script will download the archive dump for the last 5 days and extract the first available archive dump | ||
# Usage: ./scripts/get_archive_db.sh <MINA_NETWORK> | ||
# Example: ./scripts/get_archive_db.sh mainnet | ||
|
||
MINA_NETWORK=${1} | ||
MINA_ARCHIVE_DUMP_URL=${MINA_ARCHIVE_DUMP_URL:=https://storage.googleapis.com/mina-archive-dumps} | ||
DUMP_TIME=0000 | ||
SQL_SCRIPT_PATH=$(pwd)/sql_scripts | ||
TAR_FILE_PATH=${SQL_SCRIPT_PATH}/o1labs-archive-dump.tar.gz | ||
|
||
mkdir -p ${SQL_SCRIPT_PATH} | ||
|
||
MAX_DAYS_LOOKBACK=5 | ||
i=0 | ||
while [ $i -lt $MAX_DAYS_LOOKBACK ]; do | ||
DATE=$(date -d "$i days ago" +%G-%m-%d)_${DUMP_TIME} | ||
STATUS_CODE=$(curl -s -o /dev/null --head -w "%{http_code}" "${MINA_ARCHIVE_DUMP_URL}/${MINA_NETWORK}-archive-dump-${DATE}.sql.tar.gz") | ||
if [[ ! $STATUS_CODE =~ 2[0-9]{2} ]]; then | ||
i=$((i + 1)) | ||
else | ||
echo "Download ${MINA_NETWORK}-archive-dump-${DATE}.sql.tar.gz" | ||
curl "${MINA_ARCHIVE_DUMP_URL}/${MINA_NETWORK}-archive-dump-${DATE}.sql.tar.gz" -o ${TAR_FILE_PATH} | ||
break | ||
fi | ||
done | ||
|
||
[[ $STATUS_CODE =~ 2[0-9]{2} ]] || echo "[WARN] Unable to find archive dump for ${MINA_NETWORK}" | ||
|
||
tar -xvf ${SQL_SCRIPT_PATH}/o1labs-archive-dump.tar.gz -C ${SQL_SCRIPT_PATH} | ||
rm -f ${TAR_FILE_PATH} | ||
|
||
echo "Extracted ${MINA_NETWORK}-archive-dump-${DATE}.sql.tar.gz to ${SQL_SCRIPT_PATH}/${MINA_NETWORK}-archive-dump-${DATE}.sql" |
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,17 @@ | ||
#!/bin/bash | ||
|
||
# This script is used to check if PostgreSQL is available | ||
# Usage: ./scripts/pg_ready.sh <PG_HOST> <PG_PORT> | ||
# Example: ./scripts/pg_ready.sh localhost 5432 | ||
|
||
# Parameters | ||
PG_HOST="${1:-localhost}" | ||
PG_PORT="${2:-5432}" | ||
|
||
# Wait for PostgreSQL to become available | ||
until pg_isready -h "$PG_HOST" -p "$PG_PORT"; do | ||
echo "Waiting for PostgreSQL to become available at ${PG_HOST}:${PG_PORT}..." | ||
sleep 1 | ||
done | ||
|
||
echo "PostgreSQL is available at ${PG_HOST}:${PG_PORT}" |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.