From 4c20560a79a58787ab14ac7ef9820500f555c4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 6 Feb 2024 11:37:32 -0300 Subject: [PATCH 1/3] fix: derive oracle address from private key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- Cargo.lock | 3 ++- availability-oracle/Cargo.toml | 1 + availability-oracle/src/main.rs | 15 ++++----------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 598ea77..570bb45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,7 +120,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "availability-oracle" -version = "0.3.0" +version = "0.3.4" dependencies = [ "async-trait", "bytes 1.3.0", @@ -132,6 +132,7 @@ dependencies = [ "moka", "multibase", "reqwest", + "secp256k1", "serde", "serde_derive", "serde_json", diff --git a/availability-oracle/Cargo.toml b/availability-oracle/Cargo.toml index 17943fe..924225b 100644 --- a/availability-oracle/Cargo.toml +++ b/availability-oracle/Cargo.toml @@ -26,3 +26,4 @@ wasmparser = "0.74.0" multibase = "0.8.0" moka = { version = "0.8", features = ["future"] } graphql-parser = "0.4.0" +secp256k1 = "0.20.3" diff --git a/availability-oracle/src/main.rs b/availability-oracle/src/main.rs index e89ceca..85d6619 100644 --- a/availability-oracle/src/main.rs +++ b/availability-oracle/src/main.rs @@ -7,6 +7,7 @@ mod util; use common::prelude::*; use common::prometheus; +use common::web3::signing::Key; use contract::*; use ipfs::*; use manifest::{Abi, DataSource, Manifest, Mapping}; @@ -18,6 +19,7 @@ use structopt::StructOpt; use tiny_cid::Cid; use tokio::time::MissedTickBehavior; use util::bytes32_to_cid_v0; +use secp256k1::key::SecretKey; fn parse_secs(secs: &str) -> Result { Ok(Duration::from_secs(u64::from_str(secs)?)) @@ -94,15 +96,6 @@ struct Config { )] contracts: Option, - #[structopt( - short, - long, - env = "ORACLE_ADDRESS", - required_unless("dry-run"), - help = "The address used by by the oracle to sign transactions" - )] - oracle: Option
, - #[structopt( long, env = "ORACLE_SIGNING_KEY", @@ -151,10 +144,10 @@ async fn run(logger: Logger, config: Config) -> Result<()> { let subgraph = NetworkSubgraphImpl::new(logger.clone(), config.subgraph); let contract: Box = match config.dry_run { false => { - let signing_key = &config.signing_key.unwrap().parse()?; + let signing_key: &SecretKey = &config.signing_key.unwrap().parse()?; let contracts_config = config.contracts.unwrap(); let web3_context = - Web3Context::new(&contracts_config.url, config.oracle.unwrap(), signing_key)?; + Web3Context::new(&contracts_config.url, signing_key.address(), signing_key)?; let contracts = Contracts::new(contracts_config, web3_context); Box::new(RewardsManagerContract::new(contracts)) } From ed3dd7fc5b4d40d4f094ed5b7053f1196ca9cf9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 6 Feb 2024 11:39:33 -0300 Subject: [PATCH 2/3] chore: fix formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- availability-oracle/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/availability-oracle/src/main.rs b/availability-oracle/src/main.rs index 85d6619..8034aac 100644 --- a/availability-oracle/src/main.rs +++ b/availability-oracle/src/main.rs @@ -12,6 +12,7 @@ use contract::*; use ipfs::*; use manifest::{Abi, DataSource, Manifest, Mapping}; use network_subgraph::*; +use secp256k1::key::SecretKey; use std::sync::Arc; use std::time::{Duration, Instant}; use std::{fmt::Display, str::FromStr}; @@ -19,7 +20,6 @@ use structopt::StructOpt; use tiny_cid::Cid; use tokio::time::MissedTickBehavior; use util::bytes32_to_cid_v0; -use secp256k1::key::SecretKey; fn parse_secs(secs: &str) -> Result { Ok(Duration::from_secs(u64::from_str(secs)?)) From b16bad0d810fad09afc9a8d988cf960b67f607fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 6 Feb 2024 11:46:55 -0300 Subject: [PATCH 3/3] chore: update readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index af3481d..4b5912f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ The Subgraph Oracle verifies the availability of the subgraph files and does oth ``` USAGE: - availability-oracle [FLAGS] [OPTIONS] --contracts --ipfs --oracle --signing-key --subgraph + availability-oracle [FLAGS] [OPTIONS] --contracts --ipfs --signing-key --subgraph FLAGS: --dry-run log the results but not send a transaction to the rewards manager @@ -30,9 +30,6 @@ OPTIONS: --min-signal Minimum signal for a subgraph to be checked [env: ORACLE_MIN_SIGNAL=] [default: 100] - -o, --oracle - The address used by by the oracle to sign transactions [env: ORACLE_ADDRESS=] - --period How often the oracle should check the subgraphs. With the default value of 0, the oracle will run once and terminate [env: ORACLE_PERIOD_SECS=] [default: 0]