refactor: simplify dependencies

buddies-main-deployment
James Prestwich 4 years ago committed by James Prestwich
parent aa4e7272f4
commit ca7e773db8
No known key found for this signature in database
GPG Key ID: 7CC174C250AD83AD
  1. 11
      rust/Cargo.lock
  2. 1
      rust/README.md
  3. 15
      rust/optics-base/Cargo.toml
  4. 20
      rust/optics-base/src/abis/mod.rs
  5. 4
      rust/optics-base/src/main.rs
  6. 12
      rust/optics-base/src/settings/ethereum.rs
  7. 5
      rust/optics-core/Cargo.toml
  8. 4
      rust/optics-core/bin/toy.rs
  9. 2
      rust/optics-core/src/accumulator/incremental.rs
  10. 2
      rust/optics-core/src/accumulator/merkle.rs
  11. 5
      rust/optics-core/src/accumulator/mod.rs
  12. 2
      rust/optics-core/src/accumulator/prover.rs
  13. 14
      rust/optics-core/src/lib.rs
  14. 2
      rust/optics-core/src/models/home.rs
  15. 2
      rust/optics-core/src/models/replica.rs
  16. 2
      rust/optics-core/src/traits/home.rs
  17. 2
      rust/optics-core/src/traits/mod.rs
  18. 2
      rust/optics-core/src/traits/replica.rs
  19. 2
      rust/optics-core/src/utils.rs

11
rust/Cargo.lock generated

@ -1226,11 +1226,6 @@ dependencies = [
"color-eyre",
"config",
"ethers",
"ethers-contract",
"ethers-core",
"ethers-middleware",
"ethers-providers",
"ethers-signers",
"futures-util",
"log",
"optics-core",
@ -1238,7 +1233,6 @@ dependencies = [
"serde_json",
"thiserror",
"tokio",
"url",
]
[[package]]
@ -1246,10 +1240,7 @@ name = "optics-core"
version = "0.1.0"
dependencies = [
"async-trait",
"ethers-contract",
"ethers-core",
"ethers-providers",
"ethers-signers",
"ethers",
"lazy_static",
"sha3",
"thiserror",

@ -72,6 +72,7 @@ We use the tokio async runtime environment. Please see the docs
- `mkdir $AGENT_NAME && cd $AGENT_NAME`
- `cargo init`
- add dependencies to the new `Cargo.toml`
- copy most of the dependencies from `optics-base`
- create a new module in `src/$AGENT_NAME.rs`
- add a new struct
- implement `optics_base::agent::OpticsAgent` for your struct

@ -4,28 +4,17 @@ version = "0.1.0"
authors = ["James Prestwich <prestwich@clabs.co>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
# Main block
tokio = { version = "1.0.1", features = ["rt", "macros"] }
optics-core = { path = "../optics-core" }
config = "0.10"
serde = "1.0.120"
serde_json = { version = "1.0.61", default-features = false }
log = "0.4.13"
ethers = { git = "https://github.com/gakonst/ethers-rs" }
ethers-signers = { git = "https://github.com/gakonst/ethers-rs" }
ethers-middleware = { git = "https://github.com/gakonst/ethers-rs" }
ethers-core = { git = "https://github.com/gakonst/ethers-rs" }
ethers-providers = { git = "https://github.com/gakonst/ethers-rs" }
ethers-contract = { git = "https://github.com/gakonst/ethers-rs", features = ["abigen"] }
ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["abigen"] }
thiserror = { version = "1.0.22", default-features = false }
async-trait = { version = "0.1.42", default-features = false }
url = { version = "2.2.0", default-features = false }
futures-util = "0.3.12"
color-eyre = "0.5.0"

@ -1,5 +1,5 @@
use async_trait::async_trait;
use ethers_core::types::{Address, H256, U256};
use ethers::core::types::{Address, H256, U256};
use std::sync::Arc;
use optics_core::{
@ -9,7 +9,7 @@ use optics_core::{
#[allow(missing_docs)]
mod contracts {
use ethers_contract::abigen;
use ethers::contract::abigen;
abigen!(
ReplicaContractInternal,
"optics-base/src/abis/ProcessingReplica.abi.json"
@ -22,7 +22,7 @@ mod contracts {
#[derive(Debug)]
pub struct ReplicaContract<M>
where
M: ethers_providers::Middleware,
M: ethers::providers::Middleware,
{
contract: contracts::ReplicaContractInternal<M>,
slip44: u32,
@ -31,7 +31,7 @@ where
impl<M> ReplicaContract<M>
where
M: ethers_providers::Middleware,
M: ethers::providers::Middleware,
{
/// Create a reference to a Replica at a specific Ethereum address on some
/// chain
@ -47,7 +47,7 @@ where
#[async_trait]
impl<M> Common for ReplicaContract<M>
where
M: ethers_providers::Middleware + 'static,
M: ethers::providers::Middleware + 'static,
{
fn name(&self) -> &str {
&self.name
@ -124,7 +124,7 @@ where
#[async_trait]
impl<M> Replica for ReplicaContract<M>
where
M: ethers_providers::Middleware + 'static,
M: ethers::providers::Middleware + 'static,
{
fn destination_slip44(&self) -> u32 {
self.slip44
@ -184,7 +184,7 @@ where
#[derive(Debug)]
pub struct HomeContract<M>
where
M: ethers_providers::Middleware,
M: ethers::providers::Middleware,
{
contract: contracts::HomeContractInternal<M>,
slip44: u32,
@ -193,7 +193,7 @@ where
impl<M> HomeContract<M>
where
M: ethers_providers::Middleware,
M: ethers::providers::Middleware,
{
/// Create a reference to a Home at a specific Ethereum address on some
/// chain
@ -209,7 +209,7 @@ where
#[async_trait]
impl<M> Common for HomeContract<M>
where
M: ethers_providers::Middleware + 'static,
M: ethers::providers::Middleware + 'static,
{
fn name(&self) -> &str {
&self.name
@ -286,7 +286,7 @@ where
#[async_trait]
impl<M> Home for HomeContract<M>
where
M: ethers_providers::Middleware + 'static,
M: ethers::providers::Middleware + 'static,
{
fn origin_slip44(&self) -> u32 {
self.slip44

@ -24,6 +24,7 @@ use color_eyre::Result;
use crate::{agent::OpticsAgent, settings::Settings};
/// An example main function for any agent that implemented Default
async fn _example_main<OA>(settings: Settings) -> Result<()>
where
OA: OpticsAgent + Default,
@ -34,7 +35,8 @@ where
oa.run_from_settings(&settings).await
}
/// Read settings from the
/// Read settings from the config file and set up reporting and logging based
/// on the settings
fn setup() -> Result<Settings> {
color_eyre::install()?;

@ -1,7 +1,7 @@
use std::convert::TryFrom;
use color_eyre::Report;
use ethers_core::types::Address;
use ethers::core::types::Address;
use optics_core::traits::{Home, Replica};
@ -26,7 +26,7 @@ pub enum EthereumConnection {
macro_rules! construct_box_contract {
($contract:ident, $name:expr, $slip44:expr, $address:expr, $provider:expr, $signer:expr) => {{
if let Some(signer) = $signer {
let provider = ethers_middleware::SignerMiddleware::new($provider, signer);
let provider = ethers::middleware::SignerMiddleware::new($provider, signer);
Box::new(crate::abis::$contract::new(
$name,
$slip44,
@ -46,8 +46,8 @@ macro_rules! construct_box_contract {
macro_rules! construct_ws_box_contract {
($contract:ident, $name:expr, $slip44:expr, $address:expr, $url:expr, $signer:expr) => {{
let ws = ethers_providers::Ws::connect($url).await?;
let provider = ethers_providers::Provider::new(ws);
let ws = ethers::providers::Ws::connect($url).await?;
let provider = ethers::providers::Provider::new(ws);
construct_box_contract!($contract, $name, $slip44, $address, provider, $signer)
}};
}
@ -55,7 +55,7 @@ macro_rules! construct_ws_box_contract {
macro_rules! construct_http_box_contract {
($contract:ident, $name:expr, $slip44:expr, $address:expr, $url:expr, $signer:expr) => {{
let provider =
ethers_providers::Provider::<ethers_providers::Http>::try_from($url.as_ref())?;
ethers::providers::Provider::<ethers::providers::Http>::try_from($url.as_ref())?;
construct_box_contract!($contract, $name, $slip44, $address, provider, $signer)
}};
@ -69,7 +69,7 @@ pub struct EthereumConf {
}
impl EthereumConf {
fn signer(&self) -> Option<ethers_signers::LocalWallet> {
fn signer(&self) -> Option<ethers::signers::LocalWallet> {
self.signer.clone().map(|s| s.parse().expect("!valid key"))
}

@ -7,10 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ethers-core = { git = "https://github.com/gakonst/ethers-rs" }
ethers-signers = { git = "https://github.com/gakonst/ethers-rs" }
ethers-contract = { git = "https://github.com/gakonst/ethers-rs" }
ethers-providers = { git = "https://github.com/gakonst/ethers-rs" }
ethers = { git = "https://github.com/gakonst/ethers-rs" }
sha3 = "0.9.1"
lazy_static = "*"
thiserror = "*"

@ -1,5 +1,5 @@
use ethers_core::types::{H256, U256};
use ethers_signers::LocalWallet;
use ethers::core::types::{H256, U256};
use ethers::signers::LocalWallet;
use std::time::Duration;
use tokio::time::interval;

@ -1,4 +1,4 @@
use ethers_core::types::H256;
use ethers::core::types::H256;
use crate::accumulator::{hash_concat, TREE_DEPTH, ZERO_HASHES};

@ -1,4 +1,4 @@
use ethers_core::types::H256;
use ethers::core::types::H256;
use lazy_static::lazy_static;
use thiserror::Error;

@ -10,11 +10,12 @@ pub mod prover;
/// Use the prover where possible :)
pub use prover::Prover;
use ethers_core::types::H256;
use ethers::core::types::H256;
use lazy_static::lazy_static;
use sha3::{Digest, Keccak256};
const TREE_DEPTH: usize = 32;
const EMPTY_SLICE: &[ethers_core::types::H256] = &[];
const EMPTY_SLICE: &[H256] = &[];
pub(super) fn hash(preimage: impl AsRef<[u8]>) -> H256 {
H256::from_slice(Keccak256::digest(preimage.as_ref()).as_slice())

@ -3,7 +3,7 @@ use crate::accumulator::{
TREE_DEPTH,
};
use ethers_core::types::H256;
use ethers::core::types::H256;
/// A merkle proof object. The leaf, its path to the root, and its index in the
/// tree.

@ -19,11 +19,13 @@ pub mod traits;
mod utils;
use ethers_core::{
types::{Address, Signature, SignatureError, H256},
utils::hash_message,
use ethers::{
core::{
types::{Address, Signature, SignatureError, H256},
utils::hash_message,
},
signers::Signer,
};
use ethers_signers::Signer;
use sha3::{Digest, Keccak256};
use std::convert::TryFrom;
@ -34,7 +36,7 @@ use crate::{traits::ChainCommunicationError, utils::*};
pub enum OpticsError {
/// Signature Error pasthrough
#[error(transparent)]
SignatureError(#[from] ethers_core::types::SignatureError),
SignatureError(#[from] SignatureError),
/// Update does not build off the current root
#[error("Update has wrong current root. Expected: {expected}. Got: {actual}.")]
WrongCurrentRoot {
@ -275,7 +277,7 @@ mod test {
#[test]
fn it_sign() {
let t = async {
let signer: ethers_signers::LocalWallet =
let signer: ethers::signers::LocalWallet =
"1111111111111111111111111111111111111111111111111111111111111111"
.parse()
.unwrap();

@ -1,4 +1,4 @@
use ethers_core::types::{Address, H256};
use ethers::core::types::{Address, H256};
use std::{collections::VecDeque, io::Write};
use crate::{

@ -1,5 +1,5 @@
use crate::{OpticsError, SignedUpdate};
use ethers_core::types::{Address, H256, U256};
use ethers::core::types::{Address, H256, U256};
/// Waiting state
#[derive(Debug, Clone, Copy, Default)]

@ -1,6 +1,6 @@
use async_trait::async_trait;
use ethers_core::types::H256;
use ethers::core::types::H256;
use crate::{
traits::{ChainCommunicationError, Common, TxOutcome},

@ -5,7 +5,7 @@ pub mod home;
pub mod replica;
use async_trait::async_trait;
use ethers_core::types::{TransactionReceipt, H256};
use ethers::core::types::{TransactionReceipt, H256};
use crate::SignedUpdate;

@ -1,5 +1,5 @@
use async_trait::async_trait;
use ethers_core::types::{H256, U256};
use ethers::core::types::{H256, U256};
use crate::{
traits::{ChainCommunicationError, Common, TxOutcome},

@ -1,4 +1,4 @@
use ethers_core::types::H256;
use ethers::core::types::H256;
use sha3::{Digest, Keccak256};
pub(crate) fn domain_hash(origin_slip44_id: u32) -> H256 {

Loading…
Cancel
Save