Skip to content

Commit

Permalink
fix: update tendermint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiserKarel committed Aug 31, 2023
1 parent bd9a1be commit 74db14a
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 23 deletions.
101 changes: 97 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,4 @@ zedxv
zerolog
zkps
λpxrx
omnichain
3 changes: 2 additions & 1 deletion hubble/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "^0.11", features = ["json", "blocking"] }
serde_json = { version = "1.0" }
color-eyre = "0.6.2"
clap = { version = "4.4.0", features = ["derive"] }
clap = { version = "4.4.0", features = ["derive", "env"] }
url = { version = "2.4.1", features = ["serde"] }
tracing = "0.1.37"
tracing-subscriber = "0.3.17"
futures = "0.3.28"
4 changes: 4 additions & 0 deletions hubble/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Hubble is an omnichain indexer.

> **Warning**
> This is not ready for public usage. It can index tendermint chains, but the schema is not public yet.
14 changes: 5 additions & 9 deletions hubble/hubble.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@
};
in
{
inherit (hubble) checks ;
inherit (hubble) checks;
packages = {
hubble = hubble.packages.hubble;

hubble-image = pkgs.dockerTools.buildImage {
hubble-image = pkgs.dockerTools.buildLayeredImage {
name = "hubble";

copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [ pkgs.coreutils-full hubble ];
pathsToLink = [ "/bin" ];
};
contents = [ pkgs.coreutils-full pkgs.cacert self'.packages.hubble ];
config = {
Entrypoint = [ (pkgs.lib.getExe self'.packages.uniond) ];
Entrypoint = [ (pkgs.lib.getExe self'.packages.hubble) ];
Env = [ "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
};
};
};
Expand Down
7 changes: 4 additions & 3 deletions hubble/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ use url::Url;
#[command(author, version, about, long_about = None)]
pub struct Args {
/// The url to the hasura graphql endpoint.
#[arg(short, long)]
pub hasura: Url,
#[arg(short, long, env = "HUBBLE_URL")]
pub url: Url,
/// The admin secret used to authenticate with hasura.
#[arg(short, long)]
#[arg(short, long, env = "HUBBLE_SECRET")]
pub secret: String,
/// Indexer configurations to start.
#[arg(short, long, env = "HUBBLE_INDEXERS")]
pub indexers: Vec<IndexerConfig>,
}

Expand Down
18 changes: 14 additions & 4 deletions hubble/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
use clap::Parser;
use tracing::info;
use tracing::{error, info};
mod cli;
mod hasura;
mod tm;

#[tokio::main(flavor = "current_thread")]
#[tokio::main]
async fn main() {
color_eyre::install().unwrap();

let args = crate::cli::Args::parse();
tracing_subscriber::fmt::init();

let mut handles = vec![];

for indexer in args.indexers.into_iter() {
info!("starting indexer {:?}", indexer);
let url = args.hasura.clone();
let url = args.url.clone();
let secret = args.secret.clone();
tokio::task::spawn_local(async move { indexer.index(&url, &secret).await.unwrap() });
handles.push(tokio::task::spawn(async move {
// indexer should never return with Ok, thus we log the error.
let result = indexer.index(&url, &secret).await;
error!("indexer {:?} exited with: {:?}", &indexer, result);
}));
}

futures::future::join_all(handles).await;
}
5 changes: 3 additions & 2 deletions hubble/src/tm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ impl Config {
let mut height: u32 = if data.blocks.is_empty() {
0
} else {
TryInto::<u32>::try_into(data.blocks[0].height).unwrap() + 1_u32
TryInto::<u32>::try_into(data.blocks[0].height).unwrap()
};
debug!("latest stored block height is: {}", &height);

let chain_db_id = data.chains[0].id;

loop {
height += 1;

info!("indexing block {}", &height);
// if we're caught up indexing to the latest height, this will error. In that case,
// we retry until we obtain the next header.
Expand Down Expand Up @@ -140,7 +142,6 @@ impl Config {
};

do_post::<InsertBlock>(secret, &url, &db, v).await?;
height += 1;
}
}
}

0 comments on commit 74db14a

Please sign in to comment.