-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Version and notification for private contract wrapper added #9761
Conversation
please review @dvdplm @andresilva |
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.
Overall LGTM, some minor grumbles.
ethcore/private-tx/src/lib.rs
Outdated
@@ -350,6 +354,21 @@ impl Provider where { | |||
bail!(err); | |||
} | |||
} | |||
//Notify about state changes | |||
let contract = Self::contract_address_from_transaction(&desc.original_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.
Why not use ?
here?
ethcore/private-tx/src/lib.rs
Outdated
bail!("Incorrect type of action for the transaction"); | ||
} | ||
let contract = contract.expect("Error was checked before"); | ||
// TODO Usage of BlockId::Latest |
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.
What's the issue with using BlockId::Latest
?
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.
See for example @tomusdrw comment here: https://github.com/paritytech/parity-ethereum/blob/master/ethcore/private-tx/src/lib.rs#L209 We still use Latest in several modules, but I agree with him, that it's error-prone.
BTW I created a separate issue for addressing BlockId::Latest todo in private tx code (#9825)
ethcore/private-tx/src/lib.rs
Outdated
|
||
fn get_contract_version(&self, block: BlockId, address: &Address) -> Result<usize, Error> { | ||
let (data, decoder) = private_contract::functions::get_version::call(); | ||
let value = self.client.call_contract(block, *address, data)?; |
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.
Should we also fallback to INITIAL_PRIVATE_CONTRACT_VER
if this call fails? (this way this function would return usize
instead of Result
).
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.
My suggestion is that we may want to fail early when possible. If someone deploys a contract that has illegal interface, then stop early. It wouldn't crash the client anyway!
ethcore/private-tx/src/lib.rs
Outdated
trace!(target: "privatetx", "Sending signature for private transaction: {:?}", signed_private_transaction); | ||
self.broadcast_signed_private_transaction(signed_private_transaction.hash(), signed_private_transaction.rlp_bytes()); | ||
} else { | ||
let contract = Self::contract_address_from_transaction(&transaction.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.
Why not use ?
here?
ethcore/private-tx/src/lib.rs
Outdated
status_code: 0, | ||
}) | ||
} | ||
let contract = Self::contract_address_from_transaction(&signed_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.
Prefer .map_err
and ?
here, instead of using expect
below.
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.
LGTM (after @andresilva's grumbles are addressed!). Also a small grumble.
ethcore/private-tx/src/lib.rs
Outdated
@@ -350,6 +347,15 @@ impl Provider where { | |||
bail!(err); | |||
} | |||
} | |||
//Notify about state changes |
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.
nit: missing space after //
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.
A small grumble on TODO comments!
ethcore/private-tx/src/lib.rs
Outdated
let data = signed_transaction.rlp_bytes(); | ||
let encrypted_transaction = self.encrypt(&contract, &Self::iv_from_transaction(&signed_transaction), &data)?; | ||
let private = PrivateTransaction::new(encrypted_transaction, contract); | ||
// TODO [ToDr] Using BlockId::Latest is bad here, |
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.
// TODO [ToDr] Using BlockId::Latest is bad here, | |
// TODO #9825 [ToDr] Using BlockId::Latest is bad here, |
Please add issue number to help navigate!
ethcore/private-tx/src/lib.rs
Outdated
bail!("Incorrect type of action for the transaction"); | ||
let contract = Self::contract_address_from_transaction(&transaction.transaction) | ||
.map_err(|_| "Incorrect type of action for the transaction")?; | ||
// TODO [ToDr] Usage of BlockId::Latest |
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.
// TODO [ToDr] Usage of BlockId::Latest | |
// TODO #9825 [ToDr] Usage of BlockId::Latest |
* Version and notification for private contract wrapper added * Error handling improved * Style for comments in file fixed * TODO issue added into comments
…reum#9761) * Version and notification for private contract wrapper added * Error handling improved * Style for comments in file fixed * TODO issue added into comments
Special (Solidity) event is emitted, when changes in private contract state are approved and corresponding transaction sent to local miner.
The code of the contract wrapper is also updated, review can be found openethereum/private-tx#7
Closes #9719