From 46b2c6d8e3dfd273bb27d5a43e62ea22483624e1 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Wed, 25 Sep 2024 17:02:08 +0200 Subject: [PATCH 01/24] Initial CI workflow --- .github/workflows/build.yaml | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..7d7caf7 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,39 @@ +name: Build + +on: + push: + branches: + - main + tags: + - '*' + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: minafoundation-default-runners + + steps: + - name: ๐Ÿ“ฅ Checkout + uses: actions/checkout@v4 + + - name: โœ… Format + run: cargo fmt --all -- --check + + - name: ๐Ÿ” Lint + run: cargo clippy --all-targets --all-features -- -D warnings + + - name: ๐Ÿ› ๏ธ Build + run: | + if [[ ${{ github.ref }} == "refs/heads/main" ]] || [[ "${{ github.ref }}" == refs/tags/* ]]; then + cargo build --verbose --release + else + cargo build --verbose + fi + + - name: ๐Ÿงช Test + run: cargo test --verbose \ No newline at end of file From 4fd054592d954d2ec5c1aebcc9ff92008144bd12 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Wed, 25 Sep 2024 17:11:20 +0200 Subject: [PATCH 02/24] comment out Test (for now) --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7d7caf7..c8fd198 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -35,5 +35,5 @@ jobs: cargo build --verbose fi - - name: ๐Ÿงช Test - run: cargo test --verbose \ No newline at end of file + # - name: ๐Ÿงช Test + # run: cargo test --verbose \ No newline at end of file From 06c8c5166bc82b91a3df7447cd8a2b81099abf21 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Wed, 25 Sep 2024 17:41:45 +0200 Subject: [PATCH 03/24] ignore mesh_generated/src from fmt --- rustfmt.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustfmt.toml b/rustfmt.toml index 593347b..10bd85a 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,6 +1,6 @@ edition = "2021" group_imports = "StdExternalCrate" -ignore = ["mesh-generated"] +ignore = ["mesh_generated/src/**"] imports_granularity = "Crate" max_width = 120 newline_style = "Unix" From 30ad25d1e99921e6d25642e209387b18e37e0f99 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Wed, 25 Sep 2024 17:48:04 +0200 Subject: [PATCH 04/24] satisfy clippy --- src/error.rs | 12 +++--------- src/util.rs | 1 + 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/error.rs b/src/error.rs index 31bb719..2da2857 100644 --- a/src/error.rs +++ b/src/error.rs @@ -101,9 +101,7 @@ pub enum PartialReason { impl MinaMeshError { pub fn error_code(&self) -> u8 { - match self { - _ => unimplemented!(), - } + unimplemented!(); } pub fn description(&self) -> String { @@ -114,15 +112,11 @@ impl MinaMeshError { } pub fn is_retriable(&self) -> bool { - match self { - _ => unimplemented!(), - } + unimplemented!(); } pub fn context(&self) -> Option { - match self { - _ => unimplemented!(), - } + unimplemented!(); } } diff --git a/src/util.rs b/src/util.rs index 5256e7a..27a233b 100644 --- a/src/util.rs +++ b/src/util.rs @@ -35,6 +35,7 @@ impl Wrapper> { // cspell:disable-next-line const DEFAULT_TOKEN_ID: &str = "wSHV2S4qX9jFsLjQo8r1BsMLH2ZRKsZx6EJd1sbozGPieEC4Jf"; +#[allow(clippy::to_string_trait_impl)] impl ToString for Wrapper<&PartialBlockIdentifier> { fn to_string(&self) -> String { match &self.0.hash { From 9b36b1929ffec69b4e710ad49a174ac51790334e Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Wed, 25 Sep 2024 15:15:27 -0400 Subject: [PATCH 05/24] misc tweaks --- .github/workflows/build.yaml | 39 ----------------- .github/workflows/checks.yaml | 80 +++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 39 deletions(-) delete mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/checks.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index c8fd198..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Build - -on: - push: - branches: - - main - tags: - - '*' - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: minafoundation-default-runners - - steps: - - name: ๐Ÿ“ฅ Checkout - uses: actions/checkout@v4 - - - name: โœ… Format - run: cargo fmt --all -- --check - - - name: ๐Ÿ” Lint - run: cargo clippy --all-targets --all-features -- -D warnings - - - name: ๐Ÿ› ๏ธ Build - run: | - if [[ ${{ github.ref }} == "refs/heads/main" ]] || [[ "${{ github.ref }}" == refs/tags/* ]]; then - cargo build --verbose --release - else - cargo build --verbose - fi - - # - name: ๐Ÿงช Test - # run: cargo test --verbose \ No newline at end of file diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml new file mode 100644 index 0000000..5d6deaf --- /dev/null +++ b/.github/workflows/checks.yaml @@ -0,0 +1,80 @@ +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: 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 }}-test-${{ hashFiles('**/Cargo.lock') }} + - run: SNAP_CHECK=1 cargo test + + 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/checkout@v4 + - uses: dprint/check@v2.2 + + cspell: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - uses: streetsidesoftware/cspell-action@v6 + with: + incremental_files_only: false From 38a068a1880574a4b2a4652b5a2985e1b513e93a Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 26 Sep 2024 12:07:34 +0200 Subject: [PATCH 06/24] add scripts for CI --- scripts/get_archive_db.sh | 36 ++++++++++++++++++++++++++++++++++++ scripts/wait_for_pg.sh | 17 +++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100755 scripts/get_archive_db.sh create mode 100755 scripts/wait_for_pg.sh diff --git a/scripts/get_archive_db.sh b/scripts/get_archive_db.sh new file mode 100755 index 0000000..2cba484 --- /dev/null +++ b/scripts/get_archive_db.sh @@ -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 +# 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" diff --git a/scripts/wait_for_pg.sh b/scripts/wait_for_pg.sh new file mode 100755 index 0000000..edd8fff --- /dev/null +++ b/scripts/wait_for_pg.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# This script is used to check if PostgreSQL is available +# Usage: ./scripts/pg_ready.sh +# 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}" \ No newline at end of file From b08354f03212497221b4d05dde9a2f0e776df2e3 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 26 Sep 2024 12:07:49 +0200 Subject: [PATCH 07/24] update Justfile --- Justfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Justfile b/Justfile index 8f7c3e0..b97956c 100644 --- a/Justfile +++ b/Justfile @@ -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 \ No newline at end of file From 3b1e08b3ca693dd619894eb5b04f39fd5113b9dc Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 26 Sep 2024 12:08:06 +0200 Subject: [PATCH 08/24] update test workflow --- .github/workflows/checks.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 5d6deaf..0398873 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -53,7 +53,13 @@ jobs: ~/.cargo/git target key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }} - - run: SNAP_CHECK=1 cargo test + - run: | + cargo install just + just get-mainnet-archive-db + just pg + just wait-for-pg + just test + just pg-down rustfmt: runs-on: ubuntu-latest From aad8519e2ce8ff86329a788f417faaaaa0d8eba0 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 26 Sep 2024 12:25:23 +0200 Subject: [PATCH 09/24] remove timeout from test --- .github/workflows/checks.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 0398873..b66fefd 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -42,7 +42,6 @@ jobs: test: runs-on: ubuntu-latest - timeout-minutes: 5 steps: - uses: actions/checkout@v4 - uses: dsherret/rust-toolchain-file@v1 From 9d4f5ee89bc42bf7104595358a6520a10b901872 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 26 Sep 2024 12:48:51 +0200 Subject: [PATCH 10/24] Test workflow: Setup-Test-Teardown --- .github/workflows/checks.yaml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index b66fefd..498ef9e 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -45,6 +45,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dsherret/rust-toolchain-file@v1 + - uses: extractions/setup-just@v2 - uses: actions/cache@v4 with: path: | @@ -52,13 +53,18 @@ jobs: ~/.cargo/git target key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }} - - run: | - cargo install just + + - name: โš™๏ธ Setup + run: | just get-mainnet-archive-db just pg just wait-for-pg - just test - just pg-down + + - name: ๐Ÿงช Test + run: just test + + - name: ๐Ÿ‘จโ€๐Ÿ”ง Tear down + run: just pg-down rustfmt: runs-on: ubuntu-latest From 0fc163015640925d3257ee43e836167eb7a5206e Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:12:29 -0400 Subject: [PATCH 11/24] tweaking cspell and misc. --- cspell.json | 11 +++++++++-- dprint.json | 6 +++--- tests/account_balance.rs | 4 +++- words.txt | 1 + 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cspell.json b/cspell.json index e03ab19..427442c 100644 --- a/cspell.json +++ b/cspell.json @@ -8,6 +8,13 @@ } ], "enableGlobDot": true, - "dictionaries": ["project-words"], - "ignorePaths": [".git", ".sqlx", "mesh-generated", "target"] + "dictionaries": ["project-words", "rust"], + "ignorePaths": [ + ".git", + ".sqlx", + "mesh-generated", + "src/graphql/schema/mina_schema.graphql", + "target" + ], + "useGitignore": true } diff --git a/dprint.json b/dprint.json index 113811c..c57d574 100644 --- a/dprint.json +++ b/dprint.json @@ -17,9 +17,9 @@ "plugins": [ "https://plugins.dprint.dev/dockerfile-0.3.2.wasm", "https://plugins.dprint.dev/exec-0.5.0.json@8d9972eee71fa1590e04873540421f3eda7674d0f1aae3d7c788615e7b7413d0", - "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.4.0.wasm", - "https://plugins.dprint.dev/json-0.19.2.wasm", - "https://plugins.dprint.dev/markdown-0.16.4.wasm", + "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm", + "https://plugins.dprint.dev/json-0.19.3.wasm", + "https://plugins.dprint.dev/markdown-0.17.8.wasm", "https://plugins.dprint.dev/toml-0.6.2.wasm" ] } diff --git a/tests/account_balance.rs b/tests/account_balance.rs index 7873d3f..687da1e 100644 --- a/tests/account_balance.rs +++ b/tests/account_balance.rs @@ -10,10 +10,12 @@ use mina_mesh::{ async fn responses() -> Result<()> { let mina_mesh = MinaMeshConfig::default().to_mina_mesh().await?; let futures: Vec<_> = [ + // cspell:disable "B62qmjJeM4Fd4FVghfhgwoE1fkEexK2Rre8WYKMnbxVwB5vtKUwvgMv", "B62qrQKS9ghd91shs73TCmBJRW9GzvTJK443DPx2YbqcyoLc56g1ny9", - // TODO: reenable // "B62qooos8xGyqtJGpT7eaoyGrABCf4vcAnzCtxPLNrf26M7FwAxHg1i", + // cspell:enable + // TODO: reenable ] .into_iter() .map(|address| { diff --git a/words.txt b/words.txt index f61db36..35f6245 100644 --- a/words.txt +++ b/words.txt @@ -7,6 +7,7 @@ graphviz hardfork harrysolovay indoc +initdb insta joaosreis johnmarcou From 05a5de33ef5a3836ad083dcb147b881e83efbdf9 Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:17:55 -0400 Subject: [PATCH 12/24] misc. formatter tweak --- rustfmt.toml | 2 +- src/api/account_balance.rs | 2 +- src/api/block.rs | 2 +- src/api/mempool.rs | 2 +- src/api/mempool_transaction.rs | 2 +- src/api/network_health_check.rs | 2 +- src/api/network_list.rs | 2 +- src/api/network_status.rs | 2 +- src/commands/fetch_genesis_block_identifier.rs | 4 ++-- src/commands/serve.rs | 4 ++-- src/config.rs | 2 +- tests/block.rs | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 10bd85a..2883285 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -6,9 +6,9 @@ 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 diff --git a/src/api/account_balance.rs b/src/api/account_balance.rs index dd18af8..689d721 100644 --- a/src/api/account_balance.rs +++ b/src/api/account_balance.rs @@ -5,9 +5,9 @@ pub use mesh::models::{ }; use crate::{ - MinaMesh, MinaMeshError, graphql::{Account, AnnotatedBalance, Balance, Length, QueryBalance, QueryBalanceVariables, StateHash}, util::Wrapper, + MinaMesh, MinaMeshError, }; /// https://github.com/MinaProtocol/mina/blob/985eda49bdfabc046ef9001d3c406e688bc7ec45/src/app/rosetta/lib/account.ml#L11 diff --git a/src/api/block.rs b/src/api/block.rs index 2478a48..8ea8f17 100644 --- a/src/api/block.rs +++ b/src/api/block.rs @@ -3,8 +3,8 @@ use cynic::QueryBuilder; pub use mesh::models::{BlockRequest, BlockResponse, PartialBlockIdentifier}; use crate::{ - MinaMesh, MinaMeshError, Wrapper, graphql::{QueryBlockTransactions, QueryBlockTransactionsVariables}, + MinaMesh, MinaMeshError, Wrapper, }; #[derive(sqlx::Type, Debug, PartialEq, Eq)] diff --git a/src/api/mempool.rs b/src/api/mempool.rs index 339f0e6..6b4570e 100644 --- a/src/api/mempool.rs +++ b/src/api/mempool.rs @@ -6,7 +6,7 @@ use anyhow::Result; use cynic::QueryBuilder; pub use mesh::models::{MempoolResponse, TransactionIdentifier}; -use crate::{MinaMesh, graphql::QueryMempool}; +use crate::{graphql::QueryMempool, MinaMesh}; /// https://github.com/MinaProtocol/mina/blob/985eda49bdfabc046ef9001d3c406e688bc7ec45/src/app/rosetta/lib/mempool.ml#L56 impl MinaMesh { diff --git a/src/api/mempool_transaction.rs b/src/api/mempool_transaction.rs index 62bade6..2f0cbab 100644 --- a/src/api/mempool_transaction.rs +++ b/src/api/mempool_transaction.rs @@ -2,8 +2,8 @@ use cynic::QueryBuilder; pub use mesh::models::{MempoolTransactionRequest, MempoolTransactionResponse, Transaction, TransactionIdentifier}; use crate::{ - MinaMesh, MinaMeshError, graphql::{QueryMempoolTransactions, QueryMempoolTransactionsVariables}, + MinaMesh, MinaMeshError, }; /// https://github.com/MinaProtocol/mina/blob/985eda49bdfabc046ef9001d3c406e688bc7ec45/src/app/rosetta/lib/mempool.ml#L137 diff --git a/src/api/network_health_check.rs b/src/api/network_health_check.rs index d8e3f21..e5caa90 100644 --- a/src/api/network_health_check.rs +++ b/src/api/network_health_check.rs @@ -2,7 +2,7 @@ use anyhow::Result; use cynic::QueryBuilder; use mesh::models::NetworkIdentifier; -use crate::{MinaMesh, graphql::QueryNetworkId}; +use crate::{graphql::QueryNetworkId, MinaMesh}; impl MinaMesh { pub async fn network_health_check(self, network_identifier: NetworkIdentifier) -> Result { diff --git a/src/api/network_list.rs b/src/api/network_list.rs index 8803c8b..6ef4656 100644 --- a/src/api/network_list.rs +++ b/src/api/network_list.rs @@ -2,7 +2,7 @@ use anyhow::Result; use cynic::QueryBuilder; pub use mesh::models::{NetworkIdentifier, NetworkListResponse}; -use crate::{MinaMesh, graphql::QueryNetworkId}; +use crate::{graphql::QueryNetworkId, MinaMesh}; /// https://github.com/MinaProtocol/mina/blob/985eda49bdfabc046ef9001d3c406e688bc7ec45/src/app/rosetta/lib/network.ml#L162 impl MinaMesh { diff --git a/src/api/network_status.rs b/src/api/network_status.rs index d90aff9..4011353 100644 --- a/src/api/network_status.rs +++ b/src/api/network_status.rs @@ -4,8 +4,8 @@ use cynic::QueryBuilder; pub use mesh::models::{BlockIdentifier, NetworkStatusResponse, Peer}; use crate::{ - MinaMesh, MinaMeshError, graphql::{Block3, DaemonStatus3, QueryNetworkStatus}, + MinaMesh, MinaMeshError, }; /// https://github.com/MinaProtocol/mina/blob/985eda49bdfabc046ef9001d3c406e688bc7ec45/src/app/rosetta/lib/network.ml#L201 diff --git a/src/commands/fetch_genesis_block_identifier.rs b/src/commands/fetch_genesis_block_identifier.rs index 5ca5825..11b1bf2 100644 --- a/src/commands/fetch_genesis_block_identifier.rs +++ b/src/commands/fetch_genesis_block_identifier.rs @@ -1,6 +1,6 @@ -use anyhow::{Result, bail}; +use anyhow::{bail, Result}; use clap::Args; -use cynic::{QueryBuilder, http::ReqwestExt}; +use cynic::{http::ReqwestExt, QueryBuilder}; use crate::graphql::QueryGenesisBlockIdentifier; diff --git a/src/commands/serve.rs b/src/commands/serve.rs index 9084be8..1659788 100644 --- a/src/commands/serve.rs +++ b/src/commands/serve.rs @@ -1,12 +1,12 @@ use std::sync::Arc; use anyhow::Result; -use axum::{Json, Router, extract::State, response::IntoResponse, routing::post, serve}; +use axum::{extract::State, response::IntoResponse, routing::post, serve, Json, Router}; use clap::Args; use paste::paste; use tokio::net::TcpListener; -use crate::{MinaMesh, MinaMeshConfig, util::Wrapper}; +use crate::{util::Wrapper, MinaMesh, MinaMeshConfig}; #[derive(Debug, Args)] #[command(about = "Start the Mina Mesh Server.")] diff --git a/src/config.rs b/src/config.rs index bfe69ce..4e3326c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,7 +3,7 @@ use clap::Args; use mesh::models::BlockIdentifier; use sqlx::PgPool; -use crate::{MinaMesh, graphql::GraphQLClient}; +use crate::{graphql::GraphQLClient, MinaMesh}; #[derive(Debug, Args)] pub struct MinaMeshConfig { diff --git a/tests/block.rs b/tests/block.rs index 421ec83..c154a2e 100644 --- a/tests/block.rs +++ b/tests/block.rs @@ -1,7 +1,7 @@ use std::sync::OnceLock; use anyhow::Result; -use futures::{StreamExt, stream::FuturesUnordered}; +use futures::{stream::FuturesUnordered, StreamExt}; use mina_mesh::{BlockMetadata, MinaMeshConfig, PartialBlockIdentifier}; #[tokio::test] From c66c2366fba0b91a0a0ad5ce3c40d5fbee682780 Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:21:09 -0400 Subject: [PATCH 13/24] remove emojis --- .github/workflows/checks.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 498ef9e..1b6232f 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -53,17 +53,14 @@ jobs: ~/.cargo/git target key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }} - - - name: โš™๏ธ Setup + - name: Setup run: | just get-mainnet-archive-db just pg just wait-for-pg - - - name: ๐Ÿงช Test + - name: Test run: just test - - - name: ๐Ÿ‘จโ€๐Ÿ”ง Tear down + - name: Tear down run: just pg-down rustfmt: From 76a9049ad043a35f57b37329ffa253e537f101de Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:28:31 -0400 Subject: [PATCH 14/24] configure sql-formatter --- .github/workflows/checks.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 1b6232f..978c826 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -75,6 +75,14 @@ jobs: 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/check@v2.2 From fb7441d8267c45ceb74600147c23ca2bffb927b0 Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:31:44 -0400 Subject: [PATCH 15/24] debugging cspell action --- cspell.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cspell.json b/cspell.json index 427442c..a299fc0 100644 --- a/cspell.json +++ b/cspell.json @@ -10,11 +10,12 @@ "enableGlobDot": true, "dictionaries": ["project-words", "rust"], "ignorePaths": [ - ".git", - ".sqlx", - "mesh-generated", + ".git/", + ".sqlx/", + "mesh-generated/", "src/graphql/schema/mina_schema.graphql", - "target" + "sql/", + "target/" ], "useGitignore": true } From edfae2f4bea358243225902444272f3427fdb7ae Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:33:47 -0400 Subject: [PATCH 16/24] debugging cspell action --- cspell.json | 10 +++++----- words.txt | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cspell.json b/cspell.json index a299fc0..73e16c3 100644 --- a/cspell.json +++ b/cspell.json @@ -10,12 +10,12 @@ "enableGlobDot": true, "dictionaries": ["project-words", "rust"], "ignorePaths": [ - ".git/", - ".sqlx/", - "mesh-generated/", + ".git/**", + ".sqlx/**", + "mesh-generated/**", "src/graphql/schema/mina_schema.graphql", - "sql/", - "target/" + "sql/**", + "target/**" ], "useGitignore": true } diff --git a/words.txt b/words.txt index 35f6245..2407eef 100644 --- a/words.txt +++ b/words.txt @@ -1,7 +1,12 @@ +MINAMESH +RUSTFLAGS codegen coinbases deamon's +dprint +dsherret dyntest +esbenp eventbus graphviz hardfork @@ -13,14 +18,15 @@ joaosreis johnmarcou microschemas mina -MINAMESH navroot +nocapture preprocess querygen reqwest retriable rustfmt snarked +sqltools sqlx thiserror walkdir From 3fd6238b96155c28eaee7c1d454e25e35e93430f Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:35:32 -0400 Subject: [PATCH 17/24] debugging cspell action --- cspell.json | 10 +++++----- scripts/wait_for_pg.sh | 4 ++-- words.txt | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cspell.json b/cspell.json index 73e16c3..254ba15 100644 --- a/cspell.json +++ b/cspell.json @@ -10,12 +10,12 @@ "enableGlobDot": true, "dictionaries": ["project-words", "rust"], "ignorePaths": [ - ".git/**", - ".sqlx/**", - "mesh-generated/**", + ".git/**/*", + ".sqlx/**/*", + "mesh-generated/**/*", "src/graphql/schema/mina_schema.graphql", - "sql/**", - "target/**" + "sql/**/*", + "target/**/*" ], "useGitignore": true } diff --git a/scripts/wait_for_pg.sh b/scripts/wait_for_pg.sh index edd8fff..96ac2d8 100755 --- a/scripts/wait_for_pg.sh +++ b/scripts/wait_for_pg.sh @@ -9,9 +9,9 @@ PG_HOST="${1:-localhost}" PG_PORT="${2:-5432}" # Wait for PostgreSQL to become available -until pg_isready -h "$PG_HOST" -p "$PG_PORT"; do +until pg_is_ready -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}" \ No newline at end of file +echo "PostgreSQL is available at ${PG_HOST}:${PG_PORT}" diff --git a/words.txt b/words.txt index 2407eef..92d3e71 100644 --- a/words.txt +++ b/words.txt @@ -2,7 +2,7 @@ MINAMESH RUSTFLAGS codegen coinbases -deamon's +deamon dprint dsherret dyntest @@ -16,6 +16,7 @@ initdb insta joaosreis johnmarcou +loopback microschemas mina navroot @@ -32,3 +33,4 @@ thiserror walkdir webroot zkapp +zkapps From 25c3e26b6b24b355e1077d38dc694c9985487e1e Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:38:16 -0400 Subject: [PATCH 18/24] debugging cspell action --- cspell.json | 10 +++++----- words.txt | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cspell.json b/cspell.json index 254ba15..73e16c3 100644 --- a/cspell.json +++ b/cspell.json @@ -10,12 +10,12 @@ "enableGlobDot": true, "dictionaries": ["project-words", "rust"], "ignorePaths": [ - ".git/**/*", - ".sqlx/**/*", - "mesh-generated/**/*", + ".git/**", + ".sqlx/**", + "mesh-generated/**", "src/graphql/schema/mina_schema.graphql", - "sql/**/*", - "target/**/*" + "sql/**", + "target/**" ], "useGitignore": true } diff --git a/words.txt b/words.txt index 92d3e71..f7dcad0 100644 --- a/words.txt +++ b/words.txt @@ -16,7 +16,8 @@ initdb insta joaosreis johnmarcou -loopback +keypair +lookback microschemas mina navroot @@ -26,10 +27,14 @@ querygen reqwest retriable rustfmt +schnorr +secp snarked sqltools sqlx thiserror +urlencode +utxo walkdir webroot zkapp From a8812ea13309ce23574b866ffecb0a856ef7b028 Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:42:45 -0400 Subject: [PATCH 19/24] fix ignore path in cspell --- cspell.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cspell.json b/cspell.json index 73e16c3..a470c20 100644 --- a/cspell.json +++ b/cspell.json @@ -12,7 +12,7 @@ "ignorePaths": [ ".git/**", ".sqlx/**", - "mesh-generated/**", + "mesh_generated/**", "src/graphql/schema/mina_schema.graphql", "sql/**", "target/**" From 9849af7689e58f12d1992203dca0f99dbd768932 Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:47:25 -0400 Subject: [PATCH 20/24] fix previous change that broke things --- scripts/wait_for_pg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/wait_for_pg.sh b/scripts/wait_for_pg.sh index 96ac2d8..8930d15 100755 --- a/scripts/wait_for_pg.sh +++ b/scripts/wait_for_pg.sh @@ -9,7 +9,7 @@ PG_HOST="${1:-localhost}" PG_PORT="${2:-5432}" # Wait for PostgreSQL to become available -until pg_is_ready -h "$PG_HOST" -p "$PG_PORT"; do +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 From b314fa994033899f28f8f1cbd46927002a5b4567 Mon Sep 17 00:00:00 2001 From: Harry Solovay Date: Thu, 26 Sep 2024 08:49:58 -0400 Subject: [PATCH 21/24] cspell fix --- words.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/words.txt b/words.txt index f7dcad0..6bf2c84 100644 --- a/words.txt +++ b/words.txt @@ -14,6 +14,7 @@ harrysolovay indoc initdb insta +isready joaosreis johnmarcou keypair From c2f90054077f145f2f8ef7957a254d2155a32ab5 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 26 Sep 2024 15:02:42 +0200 Subject: [PATCH 22/24] update readme --- README.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 87bfe73..7e481ce 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,59 @@ # 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. From 6503ec699e27ab6078f802ef1f94b1fa9567daf5 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 26 Sep 2024 15:02:56 +0200 Subject: [PATCH 23/24] 10 min timeout in test check --- .github/workflows/checks.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 978c826..731d913 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -42,6 +42,7 @@ jobs: test: runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 - uses: dsherret/rust-toolchain-file@v1 From 5b71ea741d77bdedcdca3faff4f6318a37139ad1 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 26 Sep 2024 15:16:50 +0200 Subject: [PATCH 24/24] satisfy dprint --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7e481ce..e65b187 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ ## 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/). +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 @@ -24,7 +26,8 @@ target/debug/mina_mesh ### Setup PostgreSQL with Latest Mainnet Archive DB -To set up the testing environment with a working PostgreSQL database, use the predefined `just` steps: +To set up the testing environment with a working PostgreSQL database, use the predefined `just` +steps: ```bash just get-mainnet-archive-db @@ -45,13 +48,14 @@ 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): - +- **Restart PostgreSQL**: To restart without reinitializing the database (useful if the database is + already set up): + ```bash just pg-up ```