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

Add POSDAO transition and malice report queue. #11245

Merged
merged 12 commits into from
Jan 29, 2020

Conversation

afck
Copy link
Contributor

@afck afck commented Nov 6, 2019

This adds a posdaoTransition parameter to enable:

  • Calling the emitInitiateChange function of the validator set contract.
    The POSDAO network needs one of the validators to call this, so that a log event is added to a block when the validator set changes.
  • A malice report queue.
    Misbehaving validators can be reported to the validator set contract, by making a transaction with a call to reportMalicious. However, transactions may fail to get included and may even become obsolete, if some other transaction was made with their nonce. The queue keeps track of malice reports, and retries them with updated nonces until they succeed.
  • Setting the gas price for malice reports to zero: Validator nodes shouldn't need to have positive balance in their signing accounts.

This is based on poanetwork#151, poanetwork#129, and poanetwork@424c593.

It shares some code with #10946.

@parity-cla-bot
Copy link

It looks like @afck signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

@afck
Copy link
Contributor Author

afck commented Nov 6, 2019

Those test failures seem to be problems with the CI setup again.

@@ -450,6 +450,12 @@ impl TransactionRequest {
self
}

/// Sets a gas price, or clears it. If this is `None`, a sensible default is used.
pub fn opt_gas_price(mut self, gas_price: Option<U256>) -> TransactionRequest {
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
pub fn opt_gas_price(mut self, gas_price: Option<U256>) -> TransactionRequest {
pub fn set_gas_price(mut self, gas_price: Option<U256>) -> TransactionRequest {

ethcore/engines/authority-round/src/lib.rs Outdated Show resolved Hide resolved

fn run_posdao(&self, block: &ExecutedBlock, nonce: Option<U256>) -> Result<Vec<SignedTransaction>, Error> {
// Skip the rest of the function unless there has been a transition to POSDAO AuRa.
if self.posdao_transition.map_or(true, |block_num| block.header.number() < block_num) {
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
if self.posdao_transition.map_or(true, |block_num| block.header.number() < block_num) {
if self.posdao_transition.map_or(true, |posdao_block| block.header.number() < posdao_block) {

ethcore/engines/authority-round/src/lib.rs Outdated Show resolved Hide resolved
ethcore/engines/validator-set/src/safe_contract.rs Outdated Show resolved Hide resolved
ethcore/engines/validator-set/src/safe_contract.rs Outdated Show resolved Hide resolved
ethcore/engines/validator-set/src/safe_contract.rs Outdated Show resolved Hide resolved
ethcore/engines/validator-set/src/safe_contract.rs Outdated Show resolved Hide resolved
ethcore/engines/validator-set/src/contract.rs Outdated Show resolved Hide resolved
ethcore/engines/validator-set/src/contract.rs Show resolved Hide resolved
Copy link
Collaborator

@ordian ordian left a comment

Choose a reason for hiding this comment

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

I'll try to leave a more meaning review in the coming days.

@@ -450,6 +450,12 @@ impl TransactionRequest {
self
}

/// Sets a gas price, or clears it. If this is `None`, a sensible default is used.
pub fn opt_gas_price(mut self, gas_price: Option<U256>) -> TransactionRequest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need both gas_price and opt_gas_price? I would just change the gas_price method.

})?;
let full_client = client.as_full_client().ok_or_else(|| {
EngineError::FailedSystemCall("Failed to upgrade to BlockchainClient.".to_string())
})?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

spaces

ethcore/engines/validator-set/src/contract.rs Outdated Show resolved Hide resolved
@afck afck force-pushed the poanetwork-posdao-transition branch from 733d1bb to dbdd9c5 Compare January 14, 2020 14:40
@afck
Copy link
Contributor Author

afck commented Jan 14, 2020

Sorry for the indentation confusion! (Trying with vim-IndentConsistencyCop now.)
I tried to address all comments so far.

@afck
Copy link
Contributor Author

afck commented Jan 14, 2020

I can't reproduce those test failures locally.

@dvdplm
Copy link
Collaborator

dvdplm commented Jan 14, 2020

I can't reproduce those test failures locally.

It's a flaky test, apologies. Restarted the job.

@varasev
Copy link
Contributor

varasev commented Jan 21, 2020

Hi all - It seems all suggestions have been addressed. Are there any other proposals we could take into account here? Or this PR could be approved?

Copy link
Collaborator

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

lgtm

ethcore/engines/validator-set/src/safe_contract.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@ordian ordian left a comment

Choose a reason for hiding this comment

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

I must admit that I don't fully understand the logic here, but don't want to block merging the PR either. Would appreciate though if you could walk me through the code in a call or a meetup.

Left a few suggestions.

ethcore/engines/authority-round/src/lib.rs Outdated Show resolved Hide resolved
ethcore/engines/validator-set/src/safe_contract.rs Outdated Show resolved Hide resolved
ethcore/engines/validator-set/src/contract.rs Outdated Show resolved Hide resolved
@afck afck force-pushed the poanetwork-posdao-transition branch from f7c6325 to 07a392c Compare January 28, 2020 09:47
@afck
Copy link
Contributor Author

afck commented Jan 28, 2020

I addressed the comments, rebased, and fixed the bug @varasev found: The nonce was not incremented between the randomness and the POSDAO calls after the refactoring (moving the transaction generation into separate methods).
Let's run posdao-test-setup as well before merging, to make sure.

Happy to discuss this PR in a call (see Discord)!

@varasev
Copy link
Contributor

varasev commented Jan 28, 2020

Let's run posdao-test-setup as well before merging, to make sure.

Yes, I will retest that

@varasev
Copy link
Contributor

varasev commented Jan 28, 2020

The nonce was not incremented between the randomness and the POSDAO calls after the refactoring (moving the transaction generation into separate methods). Let's run posdao-test-setup as well before merging, to make sure.

That works 👌

@afck
Copy link
Contributor Author

afck commented Jan 28, 2020

Works for me as well. 👍

@afck
Copy link
Contributor Author

afck commented Jan 29, 2020

We made the changes we discussed yesterday. Please take a look at the two new commits.

Copy link
Collaborator

@ordian ordian left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@@ -165,13 +165,17 @@ impl ValidatorSet for ValidatorContract {
fn report_malicious(&self, address: &Address, _set_block: BlockNumber, block: BlockNumber, proof: Bytes) {
if let Err(s) = self.do_report_malicious(address, block, proof) {
warn!(target: "engine", "Validator {} could not be reported ({}) on block {}", address, s, block);
} else {
info!(target: "engine", "Reporting malicious validator {} on block {}", address, block);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems we already have the warning message inside the do_report_malicious function.

}
}

fn report_benign(&self, address: &Address, _set_block: BlockNumber, block: BlockNumber) {
trace!(target: "engine", "validator set recording benign misbehaviour at block #{} by {:#x}", block, address);
if let Err(s) = self.do_report_benign(address, block) {
warn!(target: "engine", "Validator {} could not be reported ({}) on block {}", address, s, block);
} else {
info!(target: "engine", "Reporting validator {} on block {} (benign fault)", address, block);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems we already have the warning message inside the do_report_benign function.

@afck afck force-pushed the poanetwork-posdao-transition branch from cc755bf to 5443f2d Compare January 29, 2020 10:39
@afck
Copy link
Contributor Author

afck commented Jan 29, 2020

You're right, @varasev, we completely missed that yesterday! I reverted that part of the change.

@varasev
Copy link
Contributor

varasev commented Jan 29, 2020

@dvdplm Will it be correct to contribute to Parity docs through https://github.com/paritytech/wiki repository after our changes are released? Or there are other places we should add the docs to?

@dvdplm
Copy link
Collaborator

dvdplm commented Jan 29, 2020

Will it be correct to contribute to Parity docs through https://github.com/paritytech/wiki repository after our changes are released? Or there are other places we should add the docs to?

That is a great question. I don't think we have a comprehensive plan for the client docs once we migrate away from the Parity org, so until we do I'd say the parity wiki is the least worst option?

ethcore/res/validator_contract.sol Outdated Show resolved Hide resolved
@varasev
Copy link
Contributor

varasev commented Jan 29, 2020

I'd say the parity wiki is the least worst option?

Ok, thanks

@ordian ordian merged commit bf44f02 into openethereum:master Jan 29, 2020
@afck afck deleted the poanetwork-posdao-transition branch January 29, 2020 14:21
dvdplm added a commit that referenced this pull request Jan 29, 2020
…pstream

* master:
  Add POSDAO transition and malice report queue. (#11245)
  update master/nightly version: v2.8.0 (#11419)
  ethcore/res: remove morden testnet (#11392)
  fix: export hardcoded sync format (#11416)
  update hardcoded headers: mainnet and ropsten (#11414)
  AuthorityEngine: Minor cleanups. (#11408)
  Update POA bootnodes (#11411)
  Add EtherCore support (#11402)
  verification: fix race same block + misc (#11400)
  Update ProgPoW to 0.9.3 (#11407)
  update classic testnet bootnodes (#11398)
  dependencies: bump `derive_more v0.99` (#11405)
  engine error: remove faulty/unused `From` (#11404)
  Switching to stable-track (#11377)
  ethcore/res: fix ethereum classic chainspec blake2_f activation block num (#11391)
  Update copyright notice 2020 (#11386)
afck added a commit to poanetwork/parity-ethereum that referenced this pull request Feb 26, 2020
* Add POSDAO transition; call emitInitiateChange.

* Retry failed malice reports.

* Make malice reports with zero gas price.

* Address review comments.

* Extract ReportQueue from ValidatorSafeContract.

* Add shouldValidatorReport to validator set contract.

* Rename queue_report to enqueue_report

* Increment nonce between randomness and POSDAO transactions.

* Refactor the test ValidatorSet contract

* Address review comments, docs

* Update ethcore/res/validator_contract.sol

Co-Authored-By: David <[email protected]>

* Update ethcore/res/validator_contract.sol

Co-Authored-By: David <[email protected]>

Co-authored-by: varasev <[email protected]>
Co-authored-by: David <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants