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

ValidatorSet reporting #4208

Merged
merged 24 commits into from Jan 24, 2017
Merged

ValidatorSet reporting #4208

merged 24 commits into from Jan 24, 2017

Conversation

keorn
Copy link

@keorn keorn commented Jan 18, 2017

Adds report_malicious and report_benign to ValidatorSet. These can be called by validator Engines (ones using ValidatorSet) when they see misbehavior.
Separates ValidatorContract from ValidatorSafeContract, where the latter does not have an ability to send transactions. ValidatorContract is able to call reporting contract methods reportMalicious and reportBenign, then its up to the contract to do something with that info.

Test contract can be found here. Goes after #4189.

@keorn keorn added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Jan 18, 2017
@arkpar arkpar added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 20, 2017
@gavofyork
Copy link
Contributor

conflicts

@gavofyork gavofyork added A7-looksgoodcantmerge 🙄 Pull request is reviewed well, but cannot be merged due to conflicts. and removed A8-looksgood 🦄 Pull request is reviewed well. labels Jan 20, 2017
@keorn
Copy link
Author

keorn commented Jan 20, 2017

Commit squashing on merge is evil...

@keorn keorn added A8-looksgood 🦄 Pull request is reviewed well. and removed A7-looksgoodcantmerge 🙄 Pull request is reviewed well, but cannot be merged due to conflicts. labels Jan 20, 2017
@rphmeier
Copy link
Contributor

Makes backporting a hell of a lot easier. Many projects of this size actually expect PRs to be rebased/squashed down prior to merge.

@keorn
Copy link
Author

keorn commented Jan 20, 2017

just grumble about conflicts, appreciate the 👎 though 😄

@@ -275,15 +275,17 @@ impl Engine for AuthorityRound {
// Give one step slack if step is lagging, double vote is still not possible.
if header_step <= self.step.load(AtomicOrdering::SeqCst) + 1 {
let proposer_signature = header_signature(header)?;
let ok_sig = verify_address(&self.step_proposer(header_step), &proposer_signature, &header.bare_hash())?;
let correct_proposer = self.step_proposer(header_step);
let ok_sig = verify_address(&correct_proposer, &proposer_signature, &header.bare_hash())?;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe just

if verify_address(&correct_proposer, &proposer_signature, &header.bare_hash())? { 
    ...
}
else {
    ...
}

.ok_or("No client!".into())
.and_then(|c| c.transact_contract(a, d).map_err(|e| format!("Transaction import error: {}", e)))
.map(|_| Default::default());
*self.provider.write() = Some(provider::Contract::new(self.validators.address, transact));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this Default::default() contract really needs to be set as provider when there is no Client? Is this a part of some real logic? Maybe it should be left as None and return error or fail fast with other method?

Copy link
Author

Choose a reason for hiding this comment

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

Not sure what you mean, its there to conform with the Contract::new type signature (it will produce an empty Vec<u8> here). It means that transact results are discarded.

Copy link
Contributor

@NikVolf NikVolf Jan 23, 2017

Choose a reason for hiding this comment

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

Ok, so you upgrade Weak<Client> and modify the state of the &self with some data it returned. If you failed to acquire reference to the Client, self.provider becomes vec![]. How is this empty-vector state differs from this vector being None logically? If it does not, is there really should be 2 states?

Copy link
Author

Choose a reason for hiding this comment

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

nope, when I failed to get Client then Contract method calling the closure gets Err("No client!"). self.provider is Some(Contract) always after registration, never Vec.

@NikVolf NikVolf added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. and removed A8-looksgood 🦄 Pull request is reviewed well. labels Jan 23, 2017
@NikVolf NikVolf added A8-looksgood 🦄 Pull request is reviewed well. and removed A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. labels Jan 23, 2017
@NikVolf NikVolf merged commit ba02096 into master Jan 24, 2017
@NikVolf NikVolf deleted the report-contract branch January 24, 2017 09:04
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.

None yet

5 participants