Skip to content

Commit

Permalink
Merge pull request #7 from graphprotocol/tmigone/remove-oracle-opt
Browse files Browse the repository at this point in the history
fix: derive oracle address from private key
  • Loading branch information
tmigone committed Feb 6, 2024
2 parents e44d409 + b16bad0 commit 127e9b7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

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

5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The Subgraph Oracle verifies the availability of the subgraph files and does oth

```
USAGE:
availability-oracle [FLAGS] [OPTIONS] --contracts <contracts> --ipfs <ipfs> --oracle <oracle> --signing-key <signing-key> --subgraph <subgraph>
availability-oracle [FLAGS] [OPTIONS] --contracts <contracts> --ipfs <ipfs> --signing-key <signing-key> --subgraph <subgraph>
FLAGS:
--dry-run log the results but not send a transaction to the rewards manager
Expand All @@ -30,9 +30,6 @@ OPTIONS:
--min-signal <min-signal>
Minimum signal for a subgraph to be checked [env: ORACLE_MIN_SIGNAL=] [default: 100]
-o, --oracle <oracle>
The address used by by the oracle to sign transactions [env: ORACLE_ADDRESS=]
--period <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]
Expand Down
1 change: 1 addition & 0 deletions availability-oracle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
15 changes: 4 additions & 11 deletions availability-oracle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ mod util;

use common::prelude::*;
use common::prometheus;
use common::web3::signing::Key;
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};
Expand Down Expand Up @@ -94,15 +96,6 @@ struct Config {
)]
contracts: Option<common::contracts::ContractConfig>,

#[structopt(
short,
long,
env = "ORACLE_ADDRESS",
required_unless("dry-run"),
help = "The address used by by the oracle to sign transactions"
)]
oracle: Option<Address>,

#[structopt(
long,
env = "ORACLE_SIGNING_KEY",
Expand Down Expand Up @@ -151,10 +144,10 @@ async fn run(logger: Logger, config: Config) -> Result<()> {
let subgraph = NetworkSubgraphImpl::new(logger.clone(), config.subgraph);
let contract: Box<dyn RewardsManager> = 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))
}
Expand Down

0 comments on commit 127e9b7

Please sign in to comment.