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

Version and notification for private contract wrapper added #9761

Merged
merged 4 commits into from
Dec 3, 2018

Conversation

grbIzl
Copy link
Collaborator

@grbIzl grbIzl commented Oct 16, 2018

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

@grbIzl grbIzl added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Oct 16, 2018
@5chdn 5chdn added this to the 2.2 milestone Oct 17, 2018
@5chdn 5chdn requested review from dvdplm and andresilva October 26, 2018 11:46
@5chdn
Copy link
Contributor

5chdn commented Oct 26, 2018

please review @dvdplm @andresilva

@5chdn 5chdn modified the milestones: 2.2, 2.3 Oct 29, 2018
Copy link
Contributor

@andresilva andresilva left a 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.

@@ -350,6 +354,21 @@ impl Provider where {
bail!(err);
}
}
//Notify about state changes
let contract = Self::contract_address_from_transaction(&desc.original_transaction);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use ? here?

bail!("Incorrect type of action for the transaction");
}
let contract = contract.expect("Error was checked before");
// TODO Usage of BlockId::Latest
Copy link
Contributor

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?

Copy link
Collaborator Author

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)


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

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).

Copy link
Collaborator

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!

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

Choose a reason for hiding this comment

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

Why not use ? here?

status_code: 0,
})
}
let contract = Self::contract_address_from_transaction(&signed_transaction);
Copy link
Contributor

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.

Copy link
Collaborator

@sorpaas sorpaas left a 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.

@@ -350,6 +347,15 @@ impl Provider where {
bail!(err);
}
}
//Notify about state changes
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: missing space after //

@sorpaas sorpaas added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Nov 25, 2018
@grbIzl grbIzl added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Nov 28, 2018
Copy link
Collaborator

@sorpaas sorpaas left a 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!

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

Choose a reason for hiding this comment

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

Suggested change
// TODO [ToDr] Using BlockId::Latest is bad here,
// TODO #9825 [ToDr] Using BlockId::Latest is bad here,

Please add issue number to help navigate!

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

Choose a reason for hiding this comment

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

Suggested change
// TODO [ToDr] Usage of BlockId::Latest
// TODO #9825 [ToDr] Usage of BlockId::Latest

@sorpaas sorpaas added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Nov 28, 2018
@grbIzl grbIzl added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Nov 28, 2018
@sorpaas sorpaas added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Dec 3, 2018
@andresilva andresilva merged commit 4ded418 into master Dec 3, 2018
@ordian ordian deleted the PrivateNotificationUponChanges branch December 4, 2018 10:38
niklasad1 pushed a commit that referenced this pull request Dec 16, 2018
* Version and notification for private contract wrapper added

* Error handling improved

* Style for comments in file fixed

* TODO issue added into comments
insipx pushed a commit to insipx/parity-ethereum that referenced this pull request Dec 17, 2018
…reum#9761)

* Version and notification for private contract wrapper added

* Error handling improved

* Style for comments in file fixed

* TODO issue added into comments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants