-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add POSDAO transition and malice report queue. #11245
Add POSDAO transition and malice report queue. #11245
Conversation
It looks like @afck signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
Those test failures seem to be problems with the CI setup again. |
762b8cd
to
95ada81
Compare
95ada81
to
733d1bb
Compare
ethcore/client-traits/src/lib.rs
Outdated
@@ -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 { |
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.
pub fn opt_gas_price(mut self, gas_price: Option<U256>) -> TransactionRequest { | |
pub fn set_gas_price(mut self, gas_price: Option<U256>) -> TransactionRequest { |
|
||
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) { |
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.
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) { |
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.
I'll try to leave a more meaning review in the coming days.
ethcore/client-traits/src/lib.rs
Outdated
@@ -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 { |
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.
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()) | ||
})?; |
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.
spaces
733d1bb
to
dbdd9c5
Compare
Sorry for the indentation confusion! (Trying with vim-IndentConsistencyCop now.) |
I can't reproduce those test failures locally. |
It's a flaky test, apologies. Restarted the job. |
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? |
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
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.
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.
f7c6325
to
07a392c
Compare
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). Happy to discuss this PR in a call (see Discord)! |
Yes, I will retest that |
That works 👌 |
Works for me as well. 👍 |
We made the changes we discussed yesterday. Please take a look at the two new commits. |
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, 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); |
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.
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); |
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.
Seems we already have the warning message inside the do_report_benign
function.
cc755bf
to
5443f2d
Compare
You're right, @varasev, we completely missed that yesterday! I reverted that part of the change. |
@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? |
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? |
Co-Authored-By: David <dvdplm@gmail.com>
Co-Authored-By: David <dvdplm@gmail.com>
Ok, thanks |
…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)
* 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 <dvdplm@gmail.com> * Update ethcore/res/validator_contract.sol Co-Authored-By: David <dvdplm@gmail.com> Co-authored-by: varasev <33550681+varasev@users.noreply.github.com> Co-authored-by: David <dvdplm@gmail.com>
This adds a
posdaoTransition
parameter to enable: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.
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.This is based on poanetwork#151, poanetwork#129, and poanetwork@424c593.
It shares some code with #10946.