-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
pub fn import(&self, transaction: UnverifiedTransaction, _peer_id: usize) -> Result<(), Error> { | ||
{ | ||
let mut transactions = self.transactions.write(); | ||
transactions.push(transaction.clone()); |
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.
why clone? also seems strange to put this in its own block.
|
||
pub fn get_list(&self) -> Vec<UnverifiedTransaction> { | ||
let transactions = self.transactions.read(); | ||
transactions.clone() |
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.
self.transactions().read().clone()
ethcore/src/service.rs
Outdated
NewMessage(Bytes) | ||
NewConsensusMessage(Bytes), | ||
/// New private transaction received | ||
NewPrivateTransaction(Bytes, usize) |
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.
missing trailing comma. what's the usize param?
sync/src/chain.rs
Outdated
|
||
pub const SNAPSHOT_SYNC_PACKET_COUNT: u8 = 0x16; | ||
pub const SNAPSHOT_SYNC_PACKET_COUNT: u8 = 0x17; |
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.
that requires a protocol upgrade, doesn't it? @arkpar
How are private transactions differentiated from regular transactions if they both serialize to the |
b4ed35c
to
cc7c5c2
Compare
ethcore/src/client/chain_notify.rs
Outdated
@@ -18,6 +18,12 @@ use ipc::IpcConfig; | |||
use bigint::hash::H256; | |||
use bytes::Bytes; | |||
|
|||
pub enum ChainMessageType { |
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.
missing documentation
ethcore/src/client/client.rs
Outdated
@@ -1215,6 +1218,10 @@ impl BlockChainClient for Client { | |||
Ok(results) | |||
} | |||
|
|||
fn get_private_transactions_provider(&self) -> Arc<PrivateTransactionsProvider> { |
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.
style: generally we don't prefix getters with get_
/// Storage for private transactions | ||
pub struct PrivateTransactions { | ||
transactions: RwLock<Vec<UnverifiedTransaction>>, | ||
signed_transactions: RwLock<Vec<UnverifiedTransaction>>, |
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'm a little confused why it needs locks here. Isn't it protected by a mutex within the Provider
?
} | ||
|
||
impl PrivateTransactions { | ||
pub fn new() -> Self { |
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.
documentation on methods
use SyncConfig; | ||
|
||
#[test] | ||
pub fn send_private_transaction() { |
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 don't think test functions need to be public
/// Add private transaction into the store | ||
pub fn import_private_transaction(&self, rlp: &[u8], peer_id: usize) -> Result<(), EthcoreError> { | ||
let tx: UnverifiedTransaction = UntrustedRlp::new(rlp).as_val()?; | ||
// TODO: notify engines about private transactions |
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.
why?
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.
Some grumbles addressed in #8249
ethcore/private-tx/src/lib.rs
Outdated
use ethcore::trace::{Tracer, VMTracer}; | ||
use rustc_hex::FromHex; | ||
|
||
// Source avaiable at https://github.com/paritytech/contracts/blob/master/contracts/PrivateContract.sol |
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.
Outdated, right?
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.
Replaced with the actual link
match validation_account { | ||
None => { | ||
// Not for verification, broadcast further to peers | ||
self.broadcast_private_transaction(rlp.into()); |
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 don't think it makes much sense. How is it supposed to work if we are blidnly forwarding all transactions?
If you send a bunch of incorrect private transactions they will be forever relayed by peers but never included.
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.
Good point. Some basic validation should be introduced. Is it okay to do that in the separate PR?
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.
Added an issue for that #8250
ethcore/private-tx/src/messages.rs
Outdated
private_transaction_hash: private_transaction_hash, | ||
r: sig.r().into(), | ||
s: sig.s().into(), | ||
v: sig.v() as u64 + if let Some(n) = chain_id { 35 + n * 2 } else { 27 }, |
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.
Seems duplicated with ethcore-transaction
? Could be re-used?
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.
Not sure. Only with some refactoring of Transaction struct (like creating of TransactionSignature trait and so on). Didn't want to touch so vital code for that.
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 specifically meant the chain-id encoding within v
I think the rest is fine.
/// 0 if `v` would have been 27 under "Electrum" notation, 1 if 28 or 4 if invalid. | ||
pub fn check_replay_protection(v: u64) -> u8 { | ||
match v { | ||
v if v == 27 => 0 as u8, |
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.
27 => 0 as u8
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.
removed
pub fn check_replay_protection(v: u64) -> u8 { | ||
match v { | ||
v if v == 27 => 0 as u8, | ||
v if v == 28 => 1 as u8, |
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.
28 => 1 as u8
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.
removed
* Tiny fixes part 1. * A bunch of additional comments and todos. * Fix ethsync tests.
…rity into PrivateTransactionsNetwork
* added cli option that enables private transactions * fixed failing test * fixed failing test
to simplify merge with master, I removed I made |
This pr is used for integrating all the changes in terms of building private transactions system.
We tried to review changes made on every step, but didn't request the merge into the main brunch till the functionality was ready and tested
So it's ready now. The documentation with detailed description of the solution is available on wiki: https://paritytech.github.io/wiki/Private-Transactions.html