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

Private transactions integration pr #6422

Merged
merged 96 commits into from
Apr 9, 2018
Merged

Conversation

grbIzl
Copy link
Collaborator

@grbIzl grbIzl commented Aug 30, 2017

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

@grbIzl grbIzl added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Aug 30, 2017
@grbIzl grbIzl requested a review from arkpar August 30, 2017 15:47
@grbIzl grbIzl added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. and removed A0-pleasereview 🤓 Pull request needs code review. labels Aug 30, 2017
pub fn import(&self, transaction: UnverifiedTransaction, _peer_id: usize) -> Result<(), Error> {
{
let mut transactions = self.transactions.write();
transactions.push(transaction.clone());
Copy link
Contributor

@rphmeier rphmeier Aug 30, 2017

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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.transactions().read().clone()

NewMessage(Bytes)
NewConsensusMessage(Bytes),
/// New private transaction received
NewPrivateTransaction(Bytes, usize)
Copy link
Contributor

@rphmeier rphmeier Aug 30, 2017

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?


pub const SNAPSHOT_SYNC_PACKET_COUNT: u8 = 0x16;
pub const SNAPSHOT_SYNC_PACKET_COUNT: u8 = 0x17;
Copy link
Contributor

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

@rphmeier
Copy link
Contributor

rphmeier commented Aug 30, 2017

How are private transactions differentiated from regular transactions if they both serialize to the UnverifiedTransaction type? I don't really see why this requires custom messages. It will also need light client protocol support as well.

@grbIzl grbIzl force-pushed the PrivateTransactionsNetwork branch from b4ed35c to cc7c5c2 Compare September 15, 2017 12:57
@@ -18,6 +18,12 @@ use ipc::IpcConfig;
use bigint::hash::H256;
use bytes::Bytes;

pub enum ChainMessageType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing documentation

@@ -1215,6 +1218,10 @@ impl BlockChainClient for Client {
Ok(results)
}

fn get_private_transactions_provider(&self) -> Arc<PrivateTransactionsProvider> {
Copy link
Contributor

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>>,
Copy link
Contributor

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 {
Copy link
Contributor

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() {
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

@5chdn 5chdn added this to the 1.9 milestone Oct 11, 2017
@5chdn 5chdn added A1-onice 🌨 Pull request is reviewed well, but should not yet be merged. and removed A1-onice 🌨 Pull request is reviewed well, but should not yet be merged. labels Oct 11, 2017
@5chdn 5chdn added A0-pleasereview 🤓 Pull request needs code review. and removed A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. labels Mar 28, 2018
Copy link
Collaborator

@tomusdrw tomusdrw left a 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

use ethcore::trace::{Tracer, VMTracer};
use rustc_hex::FromHex;

// Source avaiable at https://github.com/paritytech/contracts/blob/master/contracts/PrivateContract.sol
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outdated, right?

Copy link
Collaborator Author

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());
Copy link
Collaborator

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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

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 },
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

27 => 0 as u8

Copy link
Collaborator Author

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

28 => 1 as u8

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@5chdn 5chdn added the P2-asap 🌊 No need to stop dead in your tracks, however issue should be addressed as soon as possible. label Apr 9, 2018
@debris
Copy link
Collaborator

debris commented Apr 9, 2018

to simplify merge with master, I removed I made ethcore depend on kvdb_rocksb again... cc #8320

@debris debris merged commit e6f75bc into master Apr 9, 2018
@debris debris deleted the PrivateTransactionsNetwork branch April 9, 2018 14:15
@5chdn 5chdn added A9-buythatmanabeer 🍻 Pull request is reviewed well and worth buying the author a beer. and removed A0-pleasereview 🤓 Pull request needs code review. labels Apr 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A9-buythatmanabeer 🍻 Pull request is reviewed well and worth buying the author a beer. B7-releasenotes 📜 Changes should be mentioned in the release notes of the next minor version release. M4-core ⛓ Core client code / Rust. M6-rpcapi 📣 RPC API. P2-asap 🌊 No need to stop dead in your tracks, however issue should be addressed as soon as possible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants