-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the groundwork for failover RPC support #110
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,13 +100,21 @@ impl<T: Transport + Clone> Future for Deploy<T> { | |
data: test_data.into(), | ||
}; | ||
|
||
let main_future = api::send_transaction_with_nonce(self.app.connections.home.clone(), self.app.clone(), | ||
self.app.config.home.clone(), main_tx, self.home_chain_id, | ||
TransactionWithConfirmation(self.app.connections.home.clone(), self.app.config.home.poll_interval, self.app.config.home.required_confirmations)); | ||
let main_future = api::send_transaction_with_nonce( | ||
self.app.connections.home.clone(), self.app.connections.home_url.clone(), | ||
self.app.clone(), self.app.config.home.clone(), main_tx, self.home_chain_id, | ||
TransactionWithConfirmation(self.app.connections.home.clone(), | ||
self.app.config.home.poll_interval, | ||
self.app.config.home.required_confirmations) | ||
); | ||
|
||
let test_future = api::send_transaction_with_nonce(self.app.connections.foreign.clone(), self.app.clone(), | ||
self.app.config.foreign.clone(), test_tx, self.foreign_chain_id, | ||
TransactionWithConfirmation(self.app.connections.foreign.clone(), self.app.config.foreign.poll_interval, self.app.config.foreign.required_confirmations)); | ||
let test_future = api::send_transaction_with_nonce( | ||
self.app.connections.foreign.clone(), self.app.connections.foreign_url.clone(), | ||
self.app.clone(), self.app.config.foreign.clone(), test_tx, self.foreign_chain_id, | ||
TransactionWithConfirmation(self.app.connections.foreign.clone(), | ||
self.app.config.foreign.poll_interval, | ||
self.app.config.foreign.required_confirmations) | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like these are formatting changes unrelated to the actual change. They obscure the substance of the change, making it harder to understand what's important and what's not. |
||
DeployState::Deploying(main_future.join(test_future)) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,7 @@ impl<T: Transport> Stream for DepositRelay<T> { | |
let gas = U256::from(self.app.config.txs.deposit_relay.gas); | ||
let gas_price = U256::from(*self.foreign_gas_price.read().unwrap()); | ||
let balance_required = gas * gas_price * U256::from(item.logs.len()); | ||
|
||
if balance_required > *foreign_balance.as_ref().unwrap() { | ||
return Err(ErrorKind::InsufficientFunds.into()) | ||
} | ||
|
@@ -110,8 +110,10 @@ impl<T: Transport> Stream for DepositRelay<T> { | |
nonce: U256::zero(), | ||
action: Action::Call(self.foreign_contract.clone()), | ||
}; | ||
api::send_transaction_with_nonce(self.app.connections.foreign.clone(), self.app.clone(), self.app.config.foreign.clone(), | ||
tx, self.foreign_chain_id, SendRawTransaction(self.app.connections.foreign.clone())) | ||
api::send_transaction_with_nonce(self.app.connections.foreign.clone(), | ||
self.app.connections.foreign_url.clone(), self.app.clone(), | ||
self.app.config.foreign.clone(), tx, self.foreign_chain_id, | ||
SendRawTransaction(self.app.connections.foreign.clone())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like these are formatting changes unrelated to the actual change. They make sense, but they would have been a lot easier to process as a part of separate "formatting" patch, both for review and later reading. |
||
}).collect_vec(); | ||
|
||
info!("relaying {} deposits", len); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,8 +134,10 @@ impl<T: Transport> Stream for WithdrawConfirm<T> { | |
nonce: U256::zero(), | ||
action: Action::Call(contract), | ||
}; | ||
api::send_transaction_with_nonce(self.app.connections.foreign.clone(), self.app.clone(), self.app.config.foreign.clone(), | ||
tx, self.foreign_chain_id, SendRawTransaction(self.app.connections.foreign.clone())) | ||
api::send_transaction_with_nonce(self.app.connections.foreign.clone(), | ||
self.app.connections.foreign_url.clone(), self.app.clone(), | ||
self.app.config.foreign.clone(), tx, self.foreign_chain_id, | ||
SendRawTransaction(self.app.connections.foreign.clone())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like these are formatting changes unrelated to the actual change. |
||
}).collect_vec(); | ||
|
||
info!("submitting {} signatures", len); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,7 @@ impl<T: Transport> Stream for WithdrawRelay<T> { | |
let contract = self.home_contract.clone(); | ||
let home = &self.app.config.home; | ||
let t = &self.app.connections.home; | ||
let t_url = &self.app.connections.home_url; | ||
let chain_id = self.home_chain_id; | ||
|
||
loop { | ||
|
@@ -232,7 +233,8 @@ impl<T: Transport> Stream for WithdrawRelay<T> { | |
nonce: U256::zero(), | ||
action: Action::Call(contract), | ||
}; | ||
api::send_transaction_with_nonce(t.clone(), app.clone(), home.clone(), tx, chain_id, SendRawTransaction(t.clone())) | ||
api::send_transaction_with_nonce(t.clone(), t_url.clone(), app.clone(), | ||
home.clone(), tx, chain_id, SendRawTransaction(t.clone())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this is a formatting change unrelated to the actual change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I made these formatting changes to make the code more readable (and to adhere more closely to the Rust style guidelines. I'll put them all in a separate PR. |
||
}).collect_vec(); | ||
|
||
info!("relaying {} withdraws", len); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the most important part of my review. My reading of https://github.com/tomusdrw/rust-web3/blob/master/src/transports/http.rs#L78 suggests that this call will never fail if primary is not available as it doesn't attempt the connection, meaning bridge will always try primary, then fail, restart and try it again to no avail.
Would love to be proven wrong, though -- if I misread any part or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right which is why I wanted to make clear that this PR doesn't properly address the issue. It looks like the connection errors are passed up through the spawned future. I'll need to dig around and look into how those are currently handled (see below).