Skip to content
This repository was archived by the owner on Sep 18, 2020. It is now read-only.

refactor&more (feel free to review, still improving docs and tests) #159

Merged
merged 229 commits into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
229 commits
Select commit Hold shift + click to select a range
3a6834f
add bridge/src/log_stream.rs
snd Apr 11, 2018
1d8c918
add bridge/src/contract_connection.rs
snd Apr 11, 2018
5949012
add web3 dep to cli and deploy
snd Apr 11, 2018
4d49442
refactor
snd Apr 11, 2018
f3eb56d
cli/main: improve log message
snd Apr 11, 2018
b8ece04
deposit_relay.rs: finalize extracting code for indiviual relay
snd Apr 11, 2018
39a3232
log_stream.rs: LogStreamItem -> LogRange
snd Apr 11, 2018
aa1231e
remove unused `type CallResult`
snd Apr 11, 2018
75b6ce8
pluralize names of relay streams and init deposit relay correctly
snd Apr 11, 2018
e8d1d5b
improve log messages
snd Apr 11, 2018
7e106a2
extract RelayStream abstraction
snd Apr 12, 2018
830f23b
make deposit relay use RelayStream
snd Apr 12, 2018
cf3f6cd
cli/main: remove `target` from logging
snd Apr 12, 2018
f69652e
bridge/lib: pub use relay_stream
snd Apr 12, 2018
f0bf208
use RelayStream for all relays, rename, various improvements
snd Apr 13, 2018
e05a6e2
log message for every step of every relay
snd Apr 13, 2018
1dbad82
bind futures to vars as prep for adding error context
snd Apr 16, 2018
c36959b
decouple RelayStream from LogStream and Bridge from Database
snd Apr 16, 2018
2d24f94
chain_err to add context to errors and various other small improvements
snd Apr 18, 2018
572b743
use U256 for block number, refactor LogStream
snd Apr 18, 2018
f11f3df
fix infinite loop in bridge
snd Apr 18, 2018
ba3a112
distinguish timer and timeout errors
snd Apr 18, 2018
e895340
remove outcommented code
snd Apr 18, 2018
c063702
cli/main: don't use collect on stream which might keep growing memory…
snd Apr 18, 2018
bba6cd7
consume bridge stream without collecting values (growing memory)
snd Apr 19, 2018
090bb7c
move `.consume` into `StreamExt`
snd Apr 19, 2018
a663969
fetch signature from `side` not `main`. integration tests passing
snd Apr 19, 2018
fd60212
withdraw relay: log signature count
snd Apr 19, 2018
3492de9
deposit_relay > tests: remove unwrap that is no longer needed
snd Apr 19, 2018
11895dc
cargo fmt
snd Apr 19, 2018
2848872
deploy/main: cargo fmt
snd Apr 19, 2018
93e76ac
deposit relay: fix test
snd Apr 19, 2018
4549f49
IPC -> RPC (resolves #153)
snd Apr 19, 2018
eb46634
improve some exports and docs
snd Apr 20, 2018
bee3665
simplify/decomplect stream testing
snd Apr 23, 2018
dc6c058
replace `helpers.StreamExt.consume` by `last` which is more useful
snd Apr 23, 2018
3da8b51
add tests for helpers::StreamExt
snd Apr 23, 2018
f7029db
make cloned MockTransports refer to same storage
snd Apr 24, 2018
68d719b
add test for LogStream
snd Apr 24, 2018
6ca1633
add initial new rough test for deposit relay future
snd Apr 25, 2018
3803c4f
more descriptive test name
snd Apr 25, 2018
34487ae
remove commented out code
snd Apr 25, 2018
2da4ec3
improve docstring
snd Apr 25, 2018
43ac0f0
use non zero gas / gas_price in deposit relay test
snd Apr 25, 2018
192daeb
add todo
snd Apr 25, 2018
4d57cb7
assert yielded values in log stream test
snd Apr 25, 2018
c5ea9d3
add test test_log_stream_once_one_log
snd Apr 25, 2018
e13bfce
rustfmt
snd Apr 25, 2018
8fffc68
remove `tests/tests/deposit_relay.rs` which has been superseded
snd Apr 25, 2018
667e754
better error messages if `git` and `solc` in build.rs fail
snd Apr 26, 2018
2ac39d4
add side_contract.rs (highlevel interaction with side contract)
snd Apr 30, 2018
fa6c671
add `call` and `Transport` and log helper to helpers
snd Apr 30, 2018
dec8871
make deposits and signatures in side contract public so they can be c…
snd Apr 30, 2018
5192d7a
remove whitespace
snd May 2, 2018
5cfd9b6
message to mainnet -> message to main
snd May 3, 2018
fd34ebd
bridge.sol: make HomeBridge.withdraws public so we can check whether …
snd May 15, 2018
5bdbf84
bridge.sol: rename SignaturesCollection.signed to authorities
snd May 15, 2018
382f2e4
bridge.sol: make ForeignBridge.signatures private again
snd May 15, 2018
5df0fbb
bridge.sol: rename hash -> message_hash which is more descriptive
snd May 15, 2018
09a5581
add ForeignBridge.hasAuthoritySignedMessage
snd May 15, 2018
48c84a4
move contracts into subcrate to later move to parity-contracts
snd May 15, 2018
030aec1
flesh out side_contract.rs some more
snd May 15, 2018
e014f1f
add WIP version of main_contract.rs
snd May 15, 2018
ad2fc84
flesh out helpers.rs
snd May 15, 2018
a43e787
remove contracts from bridge and use external crate
snd May 15, 2018
2f3cf05
bridge/src/bridge/deposit_relay.rs -> bridge/src/main_to_side_sign.rs
snd May 15, 2018
01790fd
bridge/src/bridge/withdraw_confirm.rs -> bridge/src/side_to_main_sign.rs
snd May 15, 2018
143c5d9
bridge/src/bridge/withdraw_relay.rs -> bridge/src/side_to_main_signat…
snd May 15, 2018
684ec77
add first rough version of future_heap
snd May 16, 2018
9ac66b3
make relay_stream use future_heap
snd May 16, 2018
099f060
remove obsolete contract_connection
snd May 16, 2018
773ea0f
make future_heap.rs compile
snd May 17, 2018
0fd4498
message_to_main: side_transaction_hash -> side_tx_hash
snd May 17, 2018
1919853
make message_to_main.from_log take reference to log
snd May 17, 2018
5dcfbaf
log_stream: use u64 (instead U256) again for blocks and rename
snd May 17, 2018
d3efff2
make log_to_future take reference to log
snd May 17, 2018
66dd428
improve field names of state and use u64 for blocks again
snd May 17, 2018
b6811b9
make helpers.rs compile
snd May 17, 2018
f55462f
src/bridge/mod.rs -> src/bridge.rs (completion of flatter dir structure)
snd May 17, 2018
13e334b
cli/main: adapt to changes
snd May 17, 2018
57b564b
add MessageToMain::keccak256
snd May 28, 2018
e9b2da3
use u32 in config for confirmations
snd May 28, 2018
da7c145
src/bridge/deploy.rs -> src/deploy.rs
snd May 28, 2018
20e1972
add tiny-keccak to deps
snd May 28, 2018
c100416
use u32 for confirmations in LogStream
snd May 28, 2018
af78604
FutureHeap: make it compile
snd May 28, 2018
1461a65
extern crate tiny_keccak
snd May 28, 2018
52f921c
config: use U256 for gas and gas_price and make it non-optional
snd May 28, 2018
890045e
bridge.sol: make ForeignBridge.deposits private again
snd May 28, 2018
97f26dd
bridge.sol: add ForeignBridge.hasAuthoritySignedMainToSide and hasAut…
snd May 28, 2018
c384101
bridge.sol: snakecase -> camelcase
snd May 28, 2018
436deb5
RelayStream: fixes & fix usage of FutureHeap
snd May 28, 2018
3d15c5f
MainContract: fix compilation errors and flesh out constructor
snd May 28, 2018
c14c470
SideContract: fix many compilation errors
snd May 28, 2018
36b491b
lib.rs: update modules
snd May 28, 2018
f887966
return H256 from MessageToMain::keccac256
snd May 28, 2018
24bab41
make LogStream compile
snd May 28, 2018
da85608
fix all compilation errors except Timeouts and receipt
snd May 28, 2018
074f0c6
use ParseLog trait from soon to be released new version of ethabi
snd May 29, 2018
003793f
use ethabi branch with ContractFunction trait
snd May 29, 2018
b118f64
rename tests crate to parity-bridge-tests
snd May 29, 2018
001dc59
bump ethereum types (new version used by new ethabi)
snd May 29, 2018
a8bf20d
use web3 0.3 since bridge branch still is on ethereum-types 0.2
snd May 29, 2018
4dc844f
update Cargo.lock
snd May 29, 2018
85e399c
rough initial version of AsyncCall and AsyncTransaction futures
snd May 29, 2018
d19341f
remove examples (it's deprecated)
snd May 29, 2018
43910e6
bump ethereum-types to 0.3 for integration-tests
snd May 29, 2018
fefde77
throw out tons of futures boilerplate that is no longer necessary
snd May 29, 2018
50f1b06
replace contract function types by their WithInput types
snd May 29, 2018
2a42cd5
adapt to ethabi 6 and other fixes
snd May 29, 2018
57a2c7a
remove tests that were just testing whether ethabi works
snd Jun 4, 2018
ed07f05
future heap: add missing type annotation
snd Jun 4, 2018
c79957b
add timeouts again
snd Jun 4, 2018
0feae7e
make MessageToMain::from_bytes return Result
snd Jun 4, 2018
fdb643e
throw out waiting for receipt for now and make it compile
snd Jun 4, 2018
57d253c
use ethabi master and error_chain non rc
snd Jun 4, 2018
e80eebc
use ethabi master
snd Jun 4, 2018
59f1e7c
update Cargo.lock
snd Jun 4, 2018
b880c18
use get-logs branch of web3
snd Jun 5, 2018
c117ffe
log_stream: pass filter by reference as needed by get-logs branch
snd Jun 5, 2018
42ce467
make the borrow checker happy
snd Jun 5, 2018
9cf878b
fix imports
snd Jun 5, 2018
49b9d77
make integration tests compile again
snd Jun 5, 2018
464cf13
main_to_side_sign.rs: improve logging
snd Jun 6, 2018
001e220
integration tests config: gas units as strings (U256)
snd Jun 6, 2018
2479e33
precisely specify stable rust version used so format check doesn't ra…
snd Jun 12, 2018
e7d722f
run `rustfmt --version` on travis for troubleshooting
snd Jun 12, 2018
856eaf0
cargo fmt and more logging
snd Jun 18, 2018
b192755
cargo fmt
snd Jun 18, 2018
d125cc3
adapt Cargo.toml to branch removed upstream and cargo update
snd Jun 18, 2018
f50dbd2
disable withdraw relay test for now
snd Jun 19, 2018
e6a8ace
add jsonrpc_core to dev-deps
snd Jun 19, 2018
e4b48d8
make tests for config compile
snd Jun 19, 2018
b86a98b
web3::Log does not impl Default anymore. adapt
snd Jun 19, 2018
2137904
adapt to MessageToMain::from_slice returning Result
snd Jun 19, 2018
87dd203
adapt config test to changes
snd Jun 19, 2018
3e314ad
better error message for mock stream tests
snd Jun 19, 2018
e072fee
make log_stream tests pass again
snd Jun 19, 2018
6122fca
use rust_solc to compile solidity sources
snd Jun 19, 2018
02a40bf
comment out tests that need redoing
snd Jun 19, 2018
cf26e7e
remove unused imports
snd Jun 19, 2018
151fdd8
remove unused imports
snd Jun 19, 2018
549739e
LogStream: improve helpers that convert filters
snd Jun 19, 2018
7495e32
more correct info message
snd Jun 19, 2018
cd30d04
fix wrong error message - pinpointing integration test failure
snd Jun 19, 2018
374972a
update Cargo.lock
snd Jun 25, 2018
622fbc7
improve logging and error handling making it easier to pinpoint errors
snd Jun 25, 2018
6c8a84b
use rust stable-2018-06-21 on travis
snd Jun 25, 2018
f45292c
cargo fmt
snd Jun 25, 2018
30fa2bc
adapt to upstream changes to ethabi
snd Jul 2, 2018
136a534
switch back to tomusdrw/rust-web3
snd Jul 16, 2018
688efd8
switch to newest ethabi master
snd Jul 16, 2018
2702b02
remove outcommented code
snd Jul 16, 2018
27fff8e
add TODO
snd Jul 16, 2018
54f6f2f
integration tests: more verbose deploying of contracts
snd Jul 16, 2018
02c6ac7
integration test: check that `has_authority_signed_main_to_side` is c…
snd Jul 16, 2018
2c3b690
cargo fmt
snd Jul 16, 2018
4fc8d1a
checks and good error messages if main/side contract addresses are mi…
snd Jul 16, 2018
4611395
remove unused import
snd Jul 16, 2018
46d9abb
cli: fix that side_transport is passed into side_contract
snd Jul 16, 2018
c669a54
integration test: remove check that is no longer needed
snd Jul 16, 2018
a2b5a36
integration test: don't set gas price by accident
snd Jul 16, 2018
da64ce7
log_stream: better log message
snd Jul 16, 2018
06c6aac
side contract: fix gas and gas price handling for side to main signature
snd Jul 16, 2018
386a9e3
add license header to every file as add_license.sh that does just that
snd Jul 17, 2018
d117d74
rename more things from home/foreign -> main/side
snd Jul 17, 2018
1d042ef
add add_license.sh
snd Jul 17, 2018
55f863f
truffle: test side.hasAuthoritySignedMainToSide
snd Jul 17, 2018
9d72d06
add license_header.txt
snd Jul 17, 2018
54efe22
pass whole message into main.hasAuthoritySignedSideToMain
snd Jul 17, 2018
fa7c81a
truffle: better test description
snd Jul 17, 2018
b355923
truffle: test side.meta.hasAuthoritySignedSideToMain
snd Jul 17, 2018
1b6fb10
truffle: test main.isMainBridgeContract
snd Jul 17, 2018
da8f2dd
truffle: test side.isSideBridgeContract
snd Jul 17, 2018
8b3d057
truffle: test to hit branch missing for 100% coverage
snd Jul 17, 2018
bf5904a
FutureHeap -> OrderedStream & docs, doctest, nicer impl
snd Jul 20, 2018
bdea82e
cargo fmt
snd Jul 20, 2018
347fc73
add to OrderedStream docstring
snd Jul 20, 2018
6ff94c6
add OrderedStream.{ready_count, not_ready_count}
snd Jul 20, 2018
c197e14
add some tests for OrderedStream
snd Jul 20, 2018
59f8aee
.travis.yml: add comment
snd Jul 20, 2018
96d92e9
rust_solc has moved from snd to paritytech
snd Jul 20, 2018
1606ba8
helpers: add module docstring
snd Jul 23, 2018
10c2f8b
export bridge::MainContract and bridge::SideContract
snd Jul 23, 2018
ae3ffd3
ordered stream: add some docstrings
snd Jul 23, 2018
ad4ca7c
remove outcommented database test which no longer applies
snd Jul 23, 2018
de7713f
various documentation improvements
snd Jul 23, 2018
bcef534
documentation improvements
snd Jul 23, 2018
c5d248a
add docstring explaining the bridge impl in a nutshell
snd Jul 24, 2018
56b7305
doc improvements
snd Jul 24, 2018
3c9c423
doc improvements
snd Jul 24, 2018
9a0ce96
doc improvements
snd Jul 24, 2018
c01de52
doc improvements
snd Jul 24, 2018
3c32252
doc improvements
snd Jul 24, 2018
8714b64
Fixed side_contract address pointing to main_contract address
JosefJ Aug 6, 2018
07d7878
Merge pull request #188 from JosefJ/snd-refactor
snd Aug 6, 2018
0389cb5
RelayStream: improve docs and explain why OrderedStream is required
snd Aug 14, 2018
32ad0b9
RelayStream: simplify use of OrderedStream
snd Aug 14, 2018
2d5269a
OrderedStream: add 1 more test
snd Aug 14, 2018
8cab0e3
RelayStream: improve comments
snd Aug 14, 2018
15a7853
OrderedStream: improve test name
snd Aug 14, 2018
bfa2c7f
remove outcommented test which just tested ethabi functionality
snd Aug 14, 2018
4c6d222
main to side sign: adapt outcommented test to changes
snd Aug 14, 2018
a33292f
make test test_main_to_side_sign_relay_future pass
snd Aug 14, 2018
72838af
main_to_side_sign: add test for when already relayed
snd Aug 16, 2018
b1dc5d7
one less magic hex string
snd Aug 16, 2018
5c4ffd5
mock_transport!: better error message if more actual requests than ex…
snd Aug 16, 2018
4c16bd0
rename
snd Aug 16, 2018
88ef793
side to main sign: add transport test for when not relayed
snd Aug 16, 2018
8f6c6c8
side to main sign: add test for when already relayed
snd Aug 16, 2018
d09e188
remove tests/tests/withdraw_confirm.rs which is now covered by other …
snd Aug 16, 2018
a8219e0
add test for side_to_main_signatures if not relayed and responsible
snd Aug 18, 2018
cb0ce4f
side to main signatures: add test for when authority not responsible
snd Aug 18, 2018
2fff377
cargo fmt
snd Aug 18, 2018
8288329
side to main signatures: add test for when responsible but already re…
snd Aug 18, 2018
947315a
remove obsolete test
snd Aug 18, 2018
a49e082
remove obsolete log stream tests
snd Aug 21, 2018
3fc3b7e
remove now obsolete /tests folder
snd Aug 21, 2018
72540a0
clean up comment describing timeouts and errors
snd Aug 21, 2018
9a492b9
remove add_license.sh which is only useful once
snd Aug 21, 2018
0fedf38
travis: comment why we explicitely set rust version
snd Aug 21, 2018
b1439fe
remove unused import
snd Aug 21, 2018
7c850c6
remove unused import
snd Aug 21, 2018
12ad432
remove `tests` from workspace
snd Aug 21, 2018
878e9ae
remove unused imports
snd Aug 21, 2018
57b290e
Cargo.lock: update and remove use of nonofficial web3 repo
snd Aug 21, 2018
9f629b6
add macro_use which is not unused again
snd Aug 22, 2018
e30fd4c
remove unused imports
snd Aug 22, 2018
18781e5
error.rs: removed #![allow(unknown_lints)]
snd Aug 22, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ branches:
matrix:
include:
- language: rust
rust: stable
# using `rust: stable` below would be preferable but it randomly
# breaks the rustfmt check on travis (`cargo fmt --all -- --write-mode=diff`)
# sometimes when the rustfmt rules have changed
rust: stable-2018-06-21
sudo: required
dist: trusty
cache: cargo
Expand All @@ -18,6 +21,8 @@ matrix:
before_script:
- export PATH=/snap/bin:${PATH}
- rustup component add rustfmt-preview
# useful for troubleshooting
- rustfmt --version
script:
# using --write-mode=diff instructs rustfmt to exit with an error code if the input is not formatted correctly
- cargo fmt --all -- --write-mode=diff
Expand Down
1,288 changes: 966 additions & 322 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["tests", "cli", "bridge", "integration-tests", "deploy"]
members = ["cli", "bridge", "integration-tests", "deploy", "contracts"]
16 changes: 10 additions & 6 deletions bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@ version = "0.4.0"
authors = ["debris <[email protected]>", "snd <[email protected]>"]

[dependencies]
bridge-contracts = { path = "../contracts" }
futures = "0.1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tokio-core = "0.1.8"
tokio-timer = "0.1.2"
toml = "0.4.2"
web3 = { git = "https://github.com/tomusdrw/rust-web3", branch = "bridge" }
error-chain = "0.11.0-rc.2"
ethabi = "5.1"
ethabi-derive = "5.0"
ethabi-contract = "5.0"
web3 = { git = "https://github.com/tomusdrw/rust-web3" }
error-chain = "0.11.0"
ethabi = { git = "https://github.com/paritytech/ethabi" }
rustc-hex = "1.0"
log = "0.3"
ethereum-types = "0.2"
ethereum-types = "0.3"
pretty_assertions = "0.2.1"
tiny-keccak = "1.3"

[dev-dependencies]
tempdir = "0.3"
quickcheck = "0.6.1"
jsonrpc-core = "8.0"

[build-dependencies]
solc = { git = "https://github.com/paritytech/rust_solc" }
51 changes: 22 additions & 29 deletions bridge/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// Copyright 2017 Parity Technologies (UK) Ltd.
// This file is part of Parity-Bridge.

// Parity-Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity-Bridge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity-Bridge. If not, see <http://www.gnu.org/licenses/>.
extern crate solc;

use std::process::Command;

fn main() {
Expand All @@ -11,43 +28,19 @@ fn main() {
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
.unwrap();
.expect("`git rev-parse HEAD` failed to run. run it yourself to verify. file an issue if this persists");
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);

// make solc version used to compile contracts (`solc --version`)
// available via `env!("SOLC_VERSION")` in sources
let output = Command::new("solc").args(&["--version"]).output().unwrap();
let output = Command::new("solc").args(&["--version"]).output().expect(
"`solc --version` failed to run. run it yourself to verify. file an issue if this persists",
);
let output_string = String::from_utf8(output.stdout).unwrap();
let solc_version = output_string.lines().last().unwrap();
println!("cargo:rustc-env=SOLC_VERSION={}", solc_version);

// compile contracts for inclusion with ethabis `use_contract!`
match Command::new("solc")
.arg("--abi")
.arg("--bin")
.arg("--optimize")
.arg("--output-dir")
.arg("../compiled_contracts")
.arg("--overwrite")
.arg("../contracts/bridge.sol")
.status()
{
Ok(exit_status) => {
if !exit_status.success() {
if let Some(code) = exit_status.code() {
panic!("`solc` exited with error exit status code `{}`", code);
} else {
panic!("`solc` exited because it was terminated by a signal");
}
}
}
Err(err) => {
if let std::io::ErrorKind::NotFound = err.kind() {
panic!("`solc` executable not found in `$PATH`. `solc` is required to compile the bridge contracts. please install it: https://solidity.readthedocs.io/en/develop/installing-solidity.html");
} else {
panic!("an error occurred when trying to spawn `solc`: {}", err);
}
}
}
solc::compile_dir("../contracts", "../compiled_contracts").unwrap();
}
212 changes: 0 additions & 212 deletions bridge/src/api.rs

This file was deleted.

Loading