Skip to content

Commit a2ee3e7

Browse files
nhtyyratankaliani
andauthored
fix(operator): chunk header requests (#48)
* fix: chunk header requests * fix: exponential backoff on failed requests * fix: comment * fix: add log for failures * chore: add catch unwind on Operator::run * add errs to tendermint utils * fix: better worst case handling * fix: dont max out rate limit in loop * fix: retry faster on errors * fix: cleanup more unwraps, debug print err * feat: multi-chain operators (#49) * chore: cleanup api / util seperation * chore: add retries to some tendermint routes * fix: dont need option on sleep duration * feat: multi-chain operator * log -> tracing * fix: cleanup * separate logs * feat: batch proofs * fix: log chain id on fail * temp: prints * cleanup * comments, default env filter * fix: use old env setup for one chain * update example env * Update script/src/util/retry.rs Co-authored-by: Ratan Kaliani <[email protected]> * fix: move consensus checks of target block to `run_inner` * Update script/bin/operator.rs Co-authored-by: Ratan Kaliani <[email protected]> * fix: remove `we` from comments * fix: new fn for vkey/data commit max checks * add section headings in operator, use_kms -> signer mode * missed `we` * fix: use_kms_relayer -> signer_mode * run -> loop Co-authored-by: Ratan Kaliani <[email protected]> * Revert "run -> loop" This reverts commit c4eacbf. * chore: simplify operator loop, renaming, better comments (#50) * chore: help refactor * add * add * chore: arc networkprover * chore: docs * docs * chore: fmt * rm unused clones & arc --------- Co-authored-by: Ratan Kaliani <[email protected]> * fix: network prover run -> run_async * fix: clippy --------- Co-authored-by: Ratan Kaliani <[email protected]>
1 parent 0acabee commit a2ee3e7

File tree

15 files changed

+1210
-556
lines changed

15 files changed

+1210
-556
lines changed

.env.example

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
# Example configuration for Sepolia + Celestia Mocha.
22
TENDERMINT_RPC_URL=https://rpc.celestia-mocha.com/
3-
CHAIN_ID=11155111
4-
RPC_URL=https://ethereum-sepolia.publicnode.com/
5-
CONTRACT_ADDRESS=
6-
# Key for relaying to the contract.
3+
4+
# Optional: Key for relaying to the contract.
75
PRIVATE_KEY=
86

9-
NETWORK_PRIVATE_KEY=
107
# Optional: Set if you're using a custom RPC URL.
11-
NETWORK_RPC_URL=
8+
NETWORK_RPC_URL=
9+
NETWORK_PRIVATE_KEY=
10+
11+
BLOCK_UPDATE_INTERVAL=
12+
LOOP_INTERVAL_MINS=
13+
14+
# Optional: Set if you're using the KMS relayer.
15+
SECURE_RELAYER_API_KEY=
16+
SECURE_RELAYER_ENDPOINT=
17+
USE_KMS_RELAYER=
18+
19+
# Optional: Set if you're using `ChainConfig::from_env`.
20+
# Only provide one of each.
21+
CONTRACT_ADDRESS=
22+
RPC_URL=
23+
24+
# Optional: Path to the `chains.json` file.
25+
CHAINS_PATH=

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ pgo-data.profdata
1919
.idea
2020

2121
filtered_transactions/**.csv
22-
filtered_transactions
22+
filtered_transactions
23+
24+
chains.json
25+
chains*.json
26+
!chains.example.json

Cargo.lock

Lines changed: 5 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ dotenv = "0.15.0"
2020
subtle-encoding = "0.5.1"
2121
anyhow = "1.0.82"
2222
clap = { version = "4.0", features = ["derive", "env"] }
23-
log = "0.4.21"
2423
hex = "0.4.3"
2524
futures = "0.3.30"
26-
env_logger = "0.11.3"
2725
serde_json = "1"
2826
chrono = "0.4.38"
2927
csv = "1.3.1"

chains.example.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"name": "chain",
4+
"rpc_url": "https://rpc.chain.com",
5+
"blobstream_address": "0xA83ca7775Bc2889825BcDeDfFa5b758cf69e8794"
6+
}
7+
]

script/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ serde = { workspace = true }
3737
serde_cbor = { workspace = true }
3838
dotenv = { workspace = true }
3939
subtle-encoding = { workspace = true }
40-
anyhow = { workspace = true }
40+
anyhow.workspace = true
4141
clap = { workspace = true }
42-
log = { workspace = true }
4342
hex = { workspace = true }
4443
futures = { workspace = true }
45-
env_logger = { workspace = true }
4644
serde_json = { workspace = true }
4745
chrono = { workspace = true }
4846
csv = { workspace = true }
47+
async-trait = "0.1.86"
48+
tracing = "0.1.41"
49+
tracing-subscriber = "0.3.19"
4950

5051
[build-dependencies]
5152
sp1-build = "4.0.0-rc.8"

script/bin/costs.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use clap::Parser;
1515
use futures::StreamExt;
1616
use reqwest::Url;
1717
use std::{cmp::Ordering, collections::HashMap, env, fs, str::FromStr};
18+
use tracing_subscriber::EnvFilter;
1819

1920
#[derive(Parser, Debug, Clone)]
2021
#[command(about = "Get transaction costs for an address in a given month")]
@@ -153,7 +154,11 @@ async fn get_receipts_for_chain(
153154
async fn main() -> Result<()> {
154155
env::set_var("RUST_LOG", "info");
155156
dotenv::dotenv().ok();
156-
env_logger::init();
157+
158+
// Set up tracing.
159+
tracing_subscriber::fmt::fmt()
160+
.with_env_filter(EnvFilter::from_default_env())
161+
.init();
157162

158163
let args = CostScriptArgs::parse();
159164

script/bin/genesis.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
//!
99
1010
use clap::Parser;
11-
use log::info;
12-
use sp1_blobstream_script::util::TendermintRPCClient;
11+
use sp1_blobstream_script::util::*;
12+
use sp1_blobstream_script::TendermintRPCClient;
1313
use sp1_sdk::{HashableKey, Prover, ProverClient};
1414
use std::env;
15+
use tracing::info;
16+
use tracing_subscriber::EnvFilter;
1517
const BLOBSTREAMX_ELF: &[u8] = include_bytes!("../../elf/blobstream-elf");
1618

1719
#[derive(Parser, Debug, Clone)]
@@ -25,24 +27,37 @@ pub struct GenesisArgs {
2527
pub async fn main() {
2628
env::set_var("RUST_LOG", "info");
2729
dotenv::dotenv().ok();
28-
env_logger::init();
30+
31+
// Set up tracing.
32+
tracing_subscriber::fmt::fmt()
33+
.with_env_filter(EnvFilter::from_default_env())
34+
.init();
35+
2936
let data_fetcher = TendermintRPCClient::default();
3037
let args = GenesisArgs::parse();
3138

3239
let client = ProverClient::builder().mock().build();
3340
let (_pk, vk) = client.setup(BLOBSTREAMX_ELF);
3441

3542
if let Some(block) = args.block {
36-
let header_hash = data_fetcher.fetch_header_hash(block).await;
43+
let header_hash = fetch_header_hash(&data_fetcher, block)
44+
.await
45+
.expect("Failed to fetch genesis header hash");
46+
3747
info!(
3848
"\nGENESIS_HEIGHT={:?}\nGENESIS_HEADER={}\nSP1_BLOBSTREAM_PROGRAM_VKEY={}\n",
3949
block,
4050
header_hash.to_string(),
4151
vk.bytes32(),
4252
);
4353
} else {
44-
let latest_block_height = data_fetcher.get_latest_block_height().await;
45-
let header_hash = data_fetcher.fetch_header_hash(latest_block_height).await;
54+
let latest_block_height = get_latest_block_height(&data_fetcher)
55+
.await
56+
.expect("Can get latest block hash");
57+
58+
let header_hash = fetch_header_hash(&data_fetcher, latest_block_height)
59+
.await
60+
.expect("Failed to fetch latest block header hash");
4661

4762
info!(
4863
"\nGENESIS_HEIGHT={:?}\nGENESIS_HEADER={}\nSP1_BLOBSTREAM_PROGRAM_VKEY={}\n",

0 commit comments

Comments
 (0)