Skip to content

Implement reportDoubleVote custom action #1640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 30, 2019

Conversation

HoOngEe
Copy link
Contributor

@HoOngEe HoOngEe commented Jun 18, 2019

No description provided.

@HoOngEe HoOngEe force-pushed the feature/report-double-vote branch 3 times, most recently from 6e77495 to 2ac4e10 Compare June 20, 2019 05:32
@HoOngEe HoOngEe changed the title [WIP] Implement report_double_vote custom action Implement report_double_vote custom action Jun 20, 2019
@HoOngEe HoOngEe changed the title Implement report_double_vote custom action Implement reportDoubleVote custom action Jun 20, 2019
@majecty
Copy link
Contributor

majecty commented Jul 2, 2019

@HoOngEe What is the current status of this PR?
Do you need someone to review it? Or something is not done yet?

@HoOngEe
Copy link
Contributor Author

HoOngEe commented Jul 2, 2019

@majecty I need someone to review it.

@majecty majecty requested review from foriequal0 and majecty July 2, 2019 02:47
@majecty
Copy link
Contributor

majecty commented Jul 2, 2019

@HoOngEe Please fix the conflicts.
After fixing it, @foriequal0 and I will review this PR.

@HoOngEe HoOngEe force-pushed the feature/report-double-vote branch 2 times, most recently from 9ec2703 to e375c1a Compare July 2, 2019 04:59
@HoOngEe
Copy link
Contributor Author

HoOngEe commented Jul 2, 2019

@majecty I resolved the conflicts

Copy link
Contributor

@majecty majecty left a comment

Choose a reason for hiding this comment

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

What happened to the delegated CCS of the banned validator.

))
})?;
let signer1 = signers
.get(signer_idx1)
Copy link
Contributor

Choose a reason for hiding this comment

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

The signer may be different from the message's signer. We should get the prev term's signers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

if let Some(criminal_info) = candidates.get_candidate(&criminal).map(Clone::clone) {
candidates.remove(&criminal);
if let Some(informant_info) = candidates.get_candidate(&public_to_address(informant)).map(Clone::clone) {
candidates.add_deposit(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why give CCC as a deposit?
Any reason for this? How about give CCC directly to the informant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right, I misread the spec

@HoOngEe HoOngEe force-pushed the feature/report-double-vote branch 2 times, most recently from 2f4e11e to 73fae8f Compare July 5, 2019 10:51
@HoOngEe
Copy link
Contributor Author

HoOngEe commented Jul 5, 2019

@foriequal0 I remember you mentioned about the expected compile error

^^^^^^ expected trait cstate::ActionHandler, found struct `consensus::stake::Stake`

at the line
But I could not recall the solution.

@HoOngEe
Copy link
Contributor Author

HoOngEe commented Jul 5, 2019

I have almost done. But I would better to change the error handling policy on "Cannot get validators from the parent state" part.

@HoOngEe HoOngEe force-pushed the feature/report-double-vote branch 3 times, most recently from 906d18e to 1ae58ea Compare July 8, 2019 07:28
@HoOngEe
Copy link
Contributor Author

HoOngEe commented Jul 8, 2019

Now I'll change the error types which would be returned by the ActionHandler::verify method.

majecty
majecty previously approved these changes Jul 9, 2019
Copy link
Contributor

@majecty majecty left a comment

Choose a reason for hiding this comment

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

LGTM

majecty
majecty previously approved these changes Jul 16, 2019
@majecty
Copy link
Contributor

majecty commented Jul 16, 2019

@foriequal0 Could you check this PR again?

@CodeChain-io CodeChain-io deleted a comment from foriequal0 Jul 16, 2019
@HoOngEe HoOngEe force-pushed the feature/report-double-vote branch from d0fface to 5ccd56f Compare July 23, 2019 05:38
parent_block_hash,
})?;

if signer1 != signer2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

(Question) Do we have a chance to have the same signer with two different signer indexes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So sharp. I'll change the code like this:
First compare signer_idx1 and signer_idx2. If they are different, invoke an error.
Then, I'll get signer public key without collecting all pubkeys in vector.

@HoOngEe HoOngEe force-pushed the feature/report-double-vote branch 7 times, most recently from 34085c5 to b319f60 Compare July 24, 2019 12:09
@HoOngEe
Copy link
Contributor Author

HoOngEe commented Jul 25, 2019

I now need to reject reportDoubleVote for already banned account.

@HoOngEe HoOngEe force-pushed the feature/report-double-vote branch 2 times, most recently from 16eb793 to d6492aa Compare July 25, 2019 10:10
@@ -414,12 +443,13 @@ pub fn jail(state: &mut TopLevelState, addresses: &[Address], custody_until: u64
}

#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove #[allow(dead_code)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it.

@HoOngEe HoOngEe force-pushed the feature/report-double-vote branch 4 times, most recently from a62db10 to cadfeea Compare July 26, 2019 07:55
majecty
majecty previously approved these changes Jul 29, 2019
Copy link
Contributor

@majecty majecty left a comment

Choose a reason for hiding this comment

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

LGTM

@HoOngEe HoOngEe force-pushed the feature/report-double-vote branch from 3a34328 to 848fa8a Compare July 29, 2019 08:19
pub fn verify(
&self,
current_params: &CommonParams,
client: Option<Arc<ConsensusClient>>,
Copy link
Contributor

@foriequal0 foriequal0 Jul 29, 2019

Choose a reason for hiding this comment

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

You could've accepted just &ConsensusClient. Anyway, We'll ship it now and fix it later.

@majecty majecty merged commit 9a88541 into CodeChain-io:master Jul 30, 2019
@HoOngEe HoOngEe deleted the feature/report-double-vote branch July 30, 2019 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants