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

Commit

Permalink
Merge pull request #44 from paritytech/fixes
Browse files Browse the repository at this point in the history
fixed loading .bin files, filter topics and example gas amounts
  • Loading branch information
debris authored Oct 2, 2017
2 parents 6b649b1 + 3fad3f4 commit f859c62
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 73 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ testnet_deploy = { gas = 500000 }
- `testnet.account` - authority address on the testnet (**required**)
- `testnet.ipc` - path to testnet parity ipc handle (**required**)
- `testnet.contract.bin` - path to the compiled bridge contract (**required**)
- `testnet.required_confirmations` - number of confirmation required to consider transaction final on testnte (default: **12**)
- `testnet.required_confirmations` - number of confirmation required to consider transaction final on testnet (default: **12**)
- `testnet.poll_interval` - specify how often mainnet node should be polled for changes (in seconds, default: **1**)
- `testnet.request_timeout` - specify request timeout (in seconds, default: **5**)

Expand Down
12 changes: 6 additions & 6 deletions bridge/src/bridge/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ impl<T: Transport + Clone> Future for Deploy<T> {
};

let main_future = api::send_transaction_with_confirmation(
self.app.connections.mainnet.clone(),
main_tx_request,
self.app.config.mainnet.poll_interval,
self.app.connections.mainnet.clone(),
main_tx_request,
self.app.config.mainnet.poll_interval,
self.app.config.mainnet.required_confirmations
);

let test_future = api::send_transaction_with_confirmation(
self.app.connections.testnet.clone(),
test_tx_request,
self.app.config.testnet.poll_interval,
self.app.connections.testnet.clone(),
test_tx_request,
self.app.config.testnet.poll_interval,
self.app.config.testnet.required_confirmations
);

Expand Down
17 changes: 12 additions & 5 deletions bridge/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::path::{PathBuf, Path};
use std::fs;
use std::io::Read;
use std::time::Duration;
use rustc_hex::FromHex;
use web3::types::{Address, Bytes};
use error::{ResultExt, Error};
use {toml};
Expand Down Expand Up @@ -62,7 +63,12 @@ impl Node {
let result = Node {
account: node.account,
contract: ContractConfig {
bin: Bytes(fs::File::open(node.contract.bin)?.bytes().collect::<Result<_, _>>()?),
bin: {
let mut read = String::new();
let mut file = fs::File::open(node.contract.bin)?;
file.read_to_string(&mut read)?;
Bytes(read.from_hex()?)
}
},
ipc: node.ipc,
request_timeout: Duration::from_secs(node.request_timeout.unwrap_or(DEFAULT_TIMEOUT)),
Expand Down Expand Up @@ -182,6 +188,7 @@ mod load {
#[cfg(test)]
mod tests {
use std::time::Duration;
use rustc_hex::FromHex;
use super::{Config, Node, ContractConfig, Transactions, Authorities, TransactionConfig};

#[test]
Expand Down Expand Up @@ -221,7 +228,7 @@ mainnet_deploy = { gas = 20 }
account: "0x1B68Cb0B50181FC4006Ce572cF346e596E51818b".parse().unwrap(),
ipc: "/mainnet.ipc".into(),
contract: ContractConfig {
bin: include_bytes!("../../contracts/EthereumBridge.bin").to_vec().into(),
bin: include_str!("../../contracts/EthereumBridge.bin").from_hex().unwrap().into(),
},
poll_interval: Duration::from_secs(2),
request_timeout: Duration::from_secs(5),
Expand All @@ -230,7 +237,7 @@ mainnet_deploy = { gas = 20 }
testnet: Node {
account: "0x0000000000000000000000000000000000000001".parse().unwrap(),
contract: ContractConfig {
bin: include_bytes!("../../contracts/KovanBridge.bin").to_vec().into(),
bin: include_str!("../../contracts/KovanBridge.bin").from_hex().unwrap().into(),
},
ipc: "/testnet.ipc".into(),
poll_interval: Duration::from_secs(1),
Expand Down Expand Up @@ -287,7 +294,7 @@ required_signatures = 2
account: "0x1B68Cb0B50181FC4006Ce572cF346e596E51818b".parse().unwrap(),
ipc: "".into(),
contract: ContractConfig {
bin: include_bytes!("../../contracts/EthereumBridge.bin").to_vec().into(),
bin: include_str!("../../contracts/EthereumBridge.bin").from_hex().unwrap().into(),
},
poll_interval: Duration::from_secs(1),
request_timeout: Duration::from_secs(5),
Expand All @@ -297,7 +304,7 @@ required_signatures = 2
account: "0x0000000000000000000000000000000000000001".parse().unwrap(),
ipc: "".into(),
contract: ContractConfig {
bin: include_bytes!("../../contracts/KovanBridge.bin").to_vec().into(),
bin: include_str!("../../contracts/KovanBridge.bin").from_hex().unwrap().into(),
},
poll_interval: Duration::from_secs(1),
request_timeout: Duration::from_secs(5),
Expand Down
3 changes: 2 additions & 1 deletion bridge/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::io;
use api::ApiCall;
use tokio_timer::{TimerError, TimeoutError};
use {web3, toml, ethabi};
use {web3, toml, ethabi, rustc_hex};

error_chain! {
types {
Expand All @@ -15,6 +15,7 @@ error_chain! {
Toml(toml::de::Error);
Ethabi(ethabi::Error);
Timer(TimerError);
Hex(rustc_hex::FromHexError);
}

errors {
Expand Down
7 changes: 6 additions & 1 deletion bridge/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ use ethabi;

fn web3_topic(topic: ethabi::Topic<ethabi::Hash>) -> Option<Vec<H256>> {
let t: Vec<ethabi::Hash> = topic.into();
Some(t.into_iter().map(|x| H256(x)).collect())
// parity does not conform to an ethereum spec
if t.is_empty() {
None
} else {
Some(t.into_iter().map(|x| H256(x)).collect())
}
}

pub fn web3_filter(filter: ethabi::TopicFilter, address: Address) -> FilterBuilder {
Expand Down
2 changes: 1 addition & 1 deletion contracts/Authorities.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60606040523415600e57600080fd5b5b603680601c6000396000f30060606040525b600080fd00a165627a7a72305820e26a7229ad87867b62326d8eecc9599e42fc23cf06ad9f6bb05c5c945b8e7f940029
60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00a165627a7a72305820c733ecef2aa1d616125ac7e6e57619bb9be23be96002392497d6de20de2eb7520029
26 changes: 0 additions & 26 deletions contracts/EthereumBridge.abi
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,6 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "v",
"type": "uint8[]"
},
{
"name": "r",
"type": "bytes32[]"
},
{
"name": "s",
"type": "bytes32[]"
},
{
"name": "message",
"type": "bytes"
}
],
"name": "reelect",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
2 changes: 1 addition & 1 deletion contracts/EthereumBridge.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6060604052341561000f57600080fd5b604051610cae380380610cae833981016040528080519190602001805190910190505b81151561003e57600080fd5b805182111561004c57600080fd5b6000829055600181805161006492916020019061006d565b505b5050610100565b8280548282559060005260206000209081019282156100c4579160200282015b828111156100c45782518254600160a060020a031916600160a060020a03919091161782556020929092019160019091019061008d565b5b506100d19291506100d5565b5090565b6100fd91905b808211156100d1578054600160a060020a03191681556001016100db565b5090565b90565b610b9f8061010f6000396000f3006060604052361561005f5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663494503d481146100a75780638d068043146100d95780639ce318f6146100fe578063c3371af414610211575b5b7fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c3334604051600160a060020a03909216825260208201526040908101905180910390a15b005b34156100b257600080fd5b6100bd600435610324565b604051600160a060020a03909116815260200160405180910390f35b34156100e457600080fd5b6100ec610356565b60405190815260200160405180910390f35b341561010957600080fd5b6100a56004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080601f01602080910402602001604051908101604052818152929190602084018383808284375094965061035c95505050505050565b005b341561021c57600080fd5b6100a56004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080601f0160208091040260200160405190810160405281815292919060208401838380828437509496506106ef95505050505050565b005b600180548290811061033257fe5b906000526020600020900160005b915054906101000a9004600160a060020a031681565b60005481565b60008060008686868661036d610b04565b6000610377610b04565b60008060408051908101604052601a81527f19457468657265756d205369676e6564204d6573736167653a0a00000000000060208201529450848651876040518084805190602001908083835b602083106103e457805182525b601f1990920191602091820191016103c4565b6001836020036101000a038019825116818451161790925250505091909101848152602001905082805190602001908083835b6020831061043757805182525b601f199092019160209182019101610417565b6001836020036101000a03801982511681845116179092525050509190910194506040935050505051809103902093506000546040518059106104775750595b908082528060200260200182016040525b5092508851600054111561049b57600080fd5b600091505b60005482101561061b576001848a84815181106104b957fe5b906020019060200201518a85815181106104cf57fe5b906020019060200201518a86815181106104e557fe5b906020019060200201516040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f1151561054e57600080fd5b50506020604051035190506105c68160018054806020026020016040519081016040528092919081815260200182805480156105b357602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610595575b5050505050610a5490919063ffffffff16565b15156105d157600080fd5b6105e1838263ffffffff610a5416565b156105eb57600080fd5b808383815181106105f857fe5b600160a060020a039092166020928302909101909101525b6001909101906104a0565b8c519b5060328d01519a5060648d0151600081815260026020526040902054909a5060ff161561064a57600080fd5b60008a81526002602052604090819020805460ff19166001179055600160a060020a038d16908c156108fc02908d9051600060405180830381858888f19350505050151561069757600080fd5b7f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243648c8c604051600160a060020a03909216825260208201526040908101905180910390a15b5b50505050505050505050505050505050565b60008060008087878787610701610b04565b600061070b610b04565b60008060408051908101604052601a81527f19457468657265756d205369676e6564204d6573736167653a0a00000000000060208201529450848651876040518084805190602001908083835b6020831061077857805182525b601f199092019160209182019101610758565b6001836020036101000a038019825116818451161790925250505091909101848152602001905082805190602001908083835b602083106107cb57805182525b601f1990920191602091820191016107ab565b6001836020036101000a038019825116818451161790925250505091909101945060409350505050518091039020935060005460405180591061080b5750595b908082528060200260200182016040525b5092508851600054111561082f57600080fd5b600091505b6000548210156109af576001848a848151811061084d57fe5b906020019060200201518a858151811061086357fe5b906020019060200201518a868151811061087957fe5b906020019060200201516040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f115156108e257600080fd5b505060206040510351905061095a8160018054806020026020016040519081016040528092919081815260200182805480156105b357602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610595575b5050505050610a5490919063ffffffff16565b151561096557600080fd5b610975838263ffffffff610a5416565b1561097f57600080fd5b8083838151811061098c57fe5b600160a060020a039092166020928302909101909101525b600190910190610834565b8d519c5060328e01519b508b8d11156109c757600080fd5b6109d860018d63ffffffff610aae16565b600099505b8b8a1015610a3f5789603202606401808f01519b50508a60018b815481101515610a0357fe5b906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a031602179055505b6001909901986109dd565b5b5b5050505050505050505050505050505050565b6000805b8351811015610aa25782600160a060020a0316848281518110610a7757fe5b90602001906020020151600160a060020a03161415610a995760019150610aa7565b5b600101610a58565b600091505b5092915050565b805b8254811015610af2578281815481101515610ac757fe5b906000526020600020900160005b6101000a815490600160a060020a0302191690555b600101610ab0565b81610afd8482610b28565b505b505050565b60206040519081016040526000815290565b60206040519081016040526000815290565b815481835581811511610aff57600083815260209020610aff918101908301610b52565b5b505050565b610b7091905b80821115610b6c5760008155600101610b58565b5090565b905600a165627a7a72305820a60dd57d592610f297deee331e56aa0bb71d6a42dae188060a71d89c94b99e5d0029
6060604052341561000f57600080fd5b604051610b92380380610b92833981016040528080519060200190919080518201919050506000821415151561004457600080fd5b8051821115151561005457600080fd5b816000819055508060019080519060200190610071929190610079565b505050610146565b8280548282559060005260206000209081019282156100f2579160200282015b828111156100f15782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610099565b5b5090506100ff9190610103565b5090565b61014391905b8082111561013f57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550600101610109565b5090565b90565b610a3d806101556000396000f30060606040523615610055576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063494503d4146100c25780638d068043146101255780639ce318f61461014e575b7fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c3334604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1005b34156100cd57600080fd5b6100e3600480803590602001909190505061026b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561013057600080fd5b6101386102aa565b6040518082815260200191505060405180910390f35b341561015957600080fd5b610269600480803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506102b0565b005b60018181548110151561027a57fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60008060008686868660006102c36109d5565b6000806102cf85610638565b93506000546040518059106102e15750595b9080825280602002602001820160405250925087516000541115151561030657600080fd5b600091505b6000548210156104fe57600184898481518110151561032657fe5b90602001906020020151898581518110151561033e57fe5b90602001906020020151898681518110151561035657fe5b90602001906020020151604051600081526020016040526000604051602001526040518085600019166000191681526020018460ff1660ff16815260200183600019166000191681526020018260001916600019168152602001945050505050602060405160208103908084039060008661646e5a03f115156103d857600080fd5b505060206040510351905061047c81600180548060200260200160405190810160405280929190818152602001828054801561046957602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001906001019080831161041f575b505050505061079890919063ffffffff16565b151561048757600080fd5b61049a818461079890919063ffffffff16565b1515156104a657600080fd5b8083838151811015156104b557fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050818060010192505061030b565b60208c01519a5060408c0151995060608c01519850600260008a6000191660001916815260200190815260200160002060009054906101000a900460ff1615151561054857600080fd5b6001600260008b6000191660001916815260200190815260200160002060006101000a81548160ff0219169083151502179055508a73ffffffffffffffffffffffffffffffffffffffff166108fc8b9081150290604051600060405180830381858888f1935050505015156105bc57600080fd5b7f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243648b8b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505050505050505050505050505050565b60006106426109e9565b6040805190810160405280601a81526020017f19457468657265756d205369676e6564204d6573736167653a0a0000000000008152509050806106858451610816565b846040518084805190602001908083835b6020831015156106bb5780518252602082019150602081019050602083039250610696565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b60208310151561070e57805182526020820191506020810190506020830392506106e9565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083101515610761578051825260208201915060208101905060208303925061073c565b6001836020036101000a03801982511681845116808217855250505050505090500193505050506040518091039020915050919050565b600080600090505b835181101561080a578273ffffffffffffffffffffffffffffffffffffffff1684828151811015156107ce57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1614156107fd576001915061080f565b80806001019150506107a0565b600091505b5092915050565b61081e6109fd565b6108266109e9565b6000806108316109e9565b600060086040518059106108425750595b90808252806020026020018201604052509450600093505b6000871415156108f157600a8781151561087057fe5b069250600a8781151561087f57fe5b049650826030017f01000000000000000000000000000000000000000000000000000000000000000285858060010196508151811015156108bc57fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535061085a565b836040518059106108ff5750595b90808252806020026020018201604052509150600090505b838110156109c8578460018286030381518110151561093257fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002828281518110151561098b57fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050610917565b8195505050505050919050565b602060405190810160405280600081525090565b602060405190810160405280600081525090565b6020604051908101604052806000815250905600a165627a7a7230582007d92199ccc35aa317b49b6eb0592a2469aabe3c420daa3e73db6e5ac4a38b860029
Loading

0 comments on commit f859c62

Please sign in to comment.