f2091cc9d6
* rename nyxd-scraper to sqlite
wip: made storage mostly generic minus modules
changed error types to make modules dyn compatible
implemented traits for sqlite instance
using sqlite instance for rewarder and chain watcher
psql scaffolding
initial postgres support - missing some proto -> json parsing
use postgres in chain scraper
added message registry to block processor
message content parsing in psql
involved addresses
adding null value for logs
Revert "use postgres in chain scraper"
This reverts commit 83c84bfd2d.
using SignerInfo proto definitions for db serialisation
added ibc messages to MessageRegistry
* add the data observatory
* add the data observatory
* move message parsing and change webhook
* handle wasm messages in a module
* formatting and clippy
* copy shared migrations and add comments to ignore file to explain
* update offline queries
* change to clap args and use url::Url to parse args
* tidy up README, startup info, typos
* tidy up validator rewarder
* lock file
* change webhook module from msg to tx handler
* ignore profiler output
* add missing things and make clippy happy
* updated cosmrs version used by the nym wallet
* add glob to workspace dependencies
* rename migration files
* remove copying from shared migrations
* duplicate shared migrations to keep things simple
* add check for manual migration sync that will fail on `cargo build` in CI
* build.rs checks data observatory migrations have content of all shared scraper migrations and errors on changes or new files
* update runner
* add reset target to make file
* process events and logs
* migrations - remove unnecessary columns
* update offline queries
* chore: run cargo fmt
* fix up: inpsect_err instead of map_err
---------
Co-authored-by: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com>
Co-authored-by: Mark Sinclair <mmsinclair@users.noreply.github.com>
Co-authored-by: benedettadavico <benedetta.davico@gmail.com>
88 lines
2.8 KiB
Rust
88 lines
2.8 KiB
Rust
use std::collections::HashMap;
|
|
// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
use glob::glob;
|
|
use std::env;
|
|
use std::path::Path;
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
// check if migrations in "../common/nyxd-scraper-psql/sql_migrations/* are in "nym-data-observatory/migrations"
|
|
println!("Checking common migrations...");
|
|
let manifest_dir_string = env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
let common_migrations_path = Path::new(&manifest_dir_string)
|
|
.join("../common/nyxd-scraper-psql/sql_migrations/")
|
|
.canonicalize()?;
|
|
let output_path = Path::new(&manifest_dir_string)
|
|
.join("migrations")
|
|
.canonicalize()?;
|
|
println!(
|
|
"output_path: {:?} (exists = {})",
|
|
output_path,
|
|
output_path.exists()
|
|
);
|
|
let common_migrations_path = common_migrations_path.as_path();
|
|
println!(
|
|
"common_migrations_path: {:?} (exists = {})",
|
|
common_migrations_path,
|
|
common_migrations_path.exists()
|
|
);
|
|
|
|
// hash contents of files in common migrations
|
|
let mut common_migrations_hashes = HashMap::new();
|
|
for file in glob(&format!("{}/*", common_migrations_path.to_str().unwrap()))
|
|
.unwrap()
|
|
.flatten()
|
|
{
|
|
let hash = blake3::hash(std::fs::read(&file)?.as_slice());
|
|
common_migrations_hashes.insert(hash, file);
|
|
}
|
|
|
|
// hash contents of files in data observatory migrations
|
|
let mut data_observatory_migrations_hashes = HashMap::new();
|
|
for file in glob(&format!("{}/*", output_path.to_str().unwrap()))
|
|
.unwrap()
|
|
.flatten()
|
|
{
|
|
let hash = blake3::hash(std::fs::read(&file)?.as_slice());
|
|
data_observatory_migrations_hashes.insert(hash, file);
|
|
}
|
|
|
|
let mut errors = vec![];
|
|
|
|
for entry in common_migrations_hashes {
|
|
println!(
|
|
"- checking if {:?} exists in nym-data-observatory/migrations directory...",
|
|
entry.1
|
|
);
|
|
let res = data_observatory_migrations_hashes.get(&entry.0);
|
|
let res_path = res.and_then(|r| r.to_str()).unwrap_or("(not found)");
|
|
println!(
|
|
"- {} {} => {res_path} (content matches = {})",
|
|
if res.is_some() { "✅" } else { "❌" },
|
|
entry.1.as_path().to_str().unwrap(),
|
|
res.is_some()
|
|
);
|
|
|
|
if res.is_none() {
|
|
errors.push(format!("- {:?}", entry.1.as_path()));
|
|
}
|
|
}
|
|
|
|
// show all errors
|
|
if !errors.is_empty() {
|
|
anyhow::bail!(
|
|
"the following migrations have changed or do not exist in nym-data-observatory/migrations directory, please check and copy them:\n{}",
|
|
errors.join("\n")
|
|
);
|
|
}
|
|
|
|
// sqlx
|
|
if let Ok(database_url) = std::env::var("DATABASE_URL") {
|
|
println!("cargo:rustc-env=DATABASE_URL={database_url}");
|
|
}
|
|
|
|
println!("✅ done");
|
|
|
|
Ok(())
|
|
}
|