Skip to content

Commit

Permalink
Problem: can't merge "required_signatures is static"
Browse files Browse the repository at this point in the history
This is because other changes on master are in conflict.

Solution: merge and resolve conflicts

Merge remote-tracking branch 'origin/master' into required-signatures
  • Loading branch information
yrashk committed Jun 4, 2018
2 parents fac38d7 + 036e83e commit d4de1c8
Show file tree
Hide file tree
Showing 17 changed files with 543 additions and 259 deletions.
18 changes: 13 additions & 5 deletions Cargo.lock

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

24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ rpc_host = "http://localhost"
rpc_port = 8545
required_confirmations = 0
password = "home_password.txt"
gas_price_oracle_url = "https://gasprice.poa.network"
gas_price_speed = "instant"
default_gas_price = 10_000_000_000 # 10 GWEI

[foreign]
account = "0x006e27b6a72e1f34c626762f3c4761547aff1421"
Expand All @@ -91,16 +94,12 @@ required_confirmations = 0
password = "foreign_password.txt"

[authorities]
accounts = [
"0x006e27b6a72e1f34c626762f3c4761547aff1421",
"0x006e27b6a72e1f34c626762f3c4761547aff1421",
"0x006e27b6a72e1f34c626762f3c4761547aff1421"
]
required_signatures = 2

[transactions]
deposit_relay = { gas = 3000000, gas_price = 1000000000 }
withdraw_relay = { gas = 3000000, gas_price = 1000000000 }
withdraw_confirm = { gas = 3000000, gas_price = 1000000000 }
deposit_relay = { gas = 3000000 }
withdraw_relay = { gas = 3000000 }
withdraw_confirm = { gas = 3000000 }
```

#### Options
Expand All @@ -118,8 +117,9 @@ withdraw_confirm = { gas = 3000000, gas_price = 1000000000 }
- `home/foreign.password` - path to the file containing a password for the validator's account (to decrypt the key from the keystore)
- `home/foreign.gas_price_oracle_url` - the URL used to query the current gas-price for the home and foreign nodes, this service is known as the gas-price Oracle. This config option defaults to `None` if not supplied in the User's config TOML file. If this config value is `None`, no Oracle gas-price querying will occur, resulting in the config value for `home/foreign.default_gas_price` being used for all gas-prices.
- `home/foreign.gas_price_timeout` - the number of seconds to wait for an HTTP response from the gas price oracle before using the default gas price. Defaults to `10 seconds`.
- `home/foreign.gas_price_speed_type` - retrieve the gas-price corresponding to this speed when querying from an Oracle. Defaults to `fast`. The available values are: "instant", "fast", "standard", and "slow".
- `home/foreign.gas_price_speed` - retrieve the gas-price corresponding to this speed when querying from an Oracle. Defaults to `fast`. The available values are: "instant", "fast", "standard", and "slow".
- `home/foreign.default_gas_price` - the default gas price (in WEI) used in transactions with the home or foreign nodes. The `default_gas_price` is used when the Oracle cannot be reached. The default value is `15_000_000_000` WEI (ie. 15 GWEI).
- `home/foreign.concurrent_http_requests` - the number of concurrent HTTP requests allowed in-flight (default: **64**)

#### authorities options

Expand All @@ -128,14 +128,8 @@ withdraw_confirm = { gas = 3000000, gas_price = 1000000000 }
#### transaction options

- `transaction.deposit_relay.gas` - specify how much gas should be consumed by deposit relay
- `transaction.deposit_relay.gas_price` - specify gas price for deposit relay
- `transaction.deposit_relay.concurrency` - how many concurrent transactions can be sent (default: **100**)
- `transaction.withdraw_confirm.gas` - specify how much gas should be consumed by withdraw confirm
- `transaction.withdraw_confirm.gas_price` - specify gas price for withdraw confirm
- `transaction.withdraw_confirm.concurrency` - how many concurrent transactions can be sent (default: **100**)
- `transaction.withdraw_relay.gas` - specify how much gas should be consumed by withdraw relay
- `transaction.withdraw_relay.gas_price` - specify gas price for withdraw relay
- `transaction.withdraw_relay.concurrency` - how many concurrent transactions can be sent (default: **100**)

### Database file format

Expand Down
20 changes: 20 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 0.2.1

This release contains a number of bugfixes and a change in handling gas price.
It is no longer set statically but rather dynamically using an external oracle
(see [config example](examples/config.toml))

# 0.2.0

This release, most notably, fixes a condition in which not all logs might be
retrieved from an RPC endpoint, resulting in the bridge not being able to
see all relevant events.

It also improves the performance by introducing concurrent transaction batching.

On the operations side, it'll now print the context of an occurring error
before exiting to help investigating that error.

# 0.1.0

Initial release
5 changes: 4 additions & 1 deletion bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bridge"
version = "0.2.0"
version = "0.3.0"

[dependencies]
futures = "0.1"
Expand Down Expand Up @@ -32,6 +32,9 @@ hyper-tls = "0.1.3"
tempdir = "0.3"
quickcheck = "0.6.1"

[build-dependencies]
rustc_version = "0.2.2"

[features]
default = []
deploy = []
21 changes: 21 additions & 0 deletions bridge/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
extern crate rustc_version;

use std::process::Command;

use rustc_version::{version as get_rustc_version, Version};

fn check_rustc_version() {
let minimum_required_version = Version::new(1, 26, 0);

if let Ok(version) = get_rustc_version() {
if version < minimum_required_version {
panic!(
"Invalid rustc version, `poa-bridge` requires \
rustc >= {}, found version: {}",
minimum_required_version,
version
);
}
}
}

fn main() {
check_rustc_version();

// rerun build script if bridge contract has changed.
// without this cargo doesn't since the bridge contract
// is outside the crate directories
Expand Down
8 changes: 4 additions & 4 deletions bridge/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ pub struct Connections<T> where T: Transport {
}

impl Connections<Http> {
pub fn new_http(handle: &Handle, home: &str, foreign: &str) -> Result<Self, Error> {
pub fn new_http(handle: &Handle, home: &str, home_concurrent_connections: usize, foreign: &str, foreign_concurrent_connections: usize) -> Result<Self, Error> {

let home = Http::with_event_loop(home, handle,1)
let home = Http::with_event_loop(home, handle,home_concurrent_connections)
.map_err(ErrorKind::Web3)
.map_err(Error::from)
.chain_err(||"Cannot connect to home node rpc")?;
let foreign = Http::with_event_loop(foreign, handle, 1)
let foreign = Http::with_event_loop(foreign, handle, foreign_concurrent_connections)
.map_err(ErrorKind::Web3)
.map_err(Error::from)
.chain_err(||"Cannot connect to foreign node rpc")?;
Expand All @@ -64,7 +64,7 @@ impl App<Http> {
let home_url:String = format!("{}:{}", config.home.rpc_host, config.home.rpc_port);
let foreign_url:String = format!("{}:{}", config.foreign.rpc_host, config.foreign.rpc_port);

let connections = Connections::new_http(handle, home_url.as_ref(), foreign_url.as_ref())?;
let connections = Connections::new_http(handle, home_url.as_ref(), config.home.concurrent_http_requests, foreign_url.as_ref(), config.foreign.concurrent_http_requests)?;
let keystore = EthStore::open(Box::new(RootDiskDirectory::at(&config.keystore))).map_err(|e| ErrorKind::KeyStore(e))?;

let keystore = AccountProvider::new(Box::new(keystore), AccountProviderSettings {
Expand Down
11 changes: 6 additions & 5 deletions bridge/src/bridge/deposit_relay.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::sync::{Arc, RwLock};
use futures::{self, Future, Stream, stream::{Collect, iter_ok, IterOk, Buffered}, Poll};
use futures::{self, Future, Stream, stream::{Collect, FuturesUnordered, futures_unordered}, Poll};
use web3::Transport;
use web3::types::{U256, Address, Bytes, Log, FilterBuilder};
use ethabi::RawLog;
Expand All @@ -11,6 +11,7 @@ use util::web3_filter;
use app::App;
use ethcore_transaction::{Transaction, Action};
use super::nonce::{NonceCheck, SendRawTransaction};
use super::BridgeChecked;
use itertools::Itertools;

fn deposits_filter(home: &home::HomeBridge, address: Address) -> FilterBuilder {
Expand All @@ -35,7 +36,7 @@ enum DepositRelayState<T: Transport> {
Wait,
/// Relaying deposits in progress.
RelayDeposits {
future: Collect<Buffered<IterOk<::std::vec::IntoIter<NonceCheck<T, SendRawTransaction<T>>>, Error>>>,
future: Collect<FuturesUnordered<NonceCheck<T, SendRawTransaction<T>>>>,
block: u64,
},
/// All deposits till given block has been relayed.
Expand Down Expand Up @@ -72,7 +73,7 @@ pub struct DepositRelay<T: Transport> {
}

impl<T: Transport> Stream for DepositRelay<T> {
type Item = u64;
type Item = BridgeChecked;
type Error = Error;

fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
Expand Down Expand Up @@ -115,7 +116,7 @@ impl<T: Transport> Stream for DepositRelay<T> {

info!("relaying {} deposits", len);
DepositRelayState::RelayDeposits {
future: iter_ok(deposits).buffered(self.app.config.txs.deposit_relay.concurrency).collect(),
future: futures_unordered(deposits).collect(),
block: item.to,
}
},
Expand All @@ -126,7 +127,7 @@ impl<T: Transport> Stream for DepositRelay<T> {
},
DepositRelayState::Yield(ref mut block) => match block.take() {
None => DepositRelayState::Wait,
some => return Ok(some.into()),
Some(v) => return Ok(Some(BridgeChecked::DepositRelay(v)).into()),
}
};
self.state = next_state;
Expand Down
Loading

0 comments on commit d4de1c8

Please sign in to comment.