diff --git a/ethcore/engines/authority-round/src/lib.rs b/ethcore/engines/authority-round/src/lib.rs index d8b085dc7cc..7d4c6e86c0f 100644 --- a/ethcore/engines/authority-round/src/lib.rs +++ b/ethcore/engines/authority-round/src/lib.rs @@ -1145,7 +1145,7 @@ impl AuthorityRound { fn run_posdao(&self, block: &ExecutedBlock, nonce: Option) -> Result, Error> { // Skip the rest of the function unless there has been a transition to POSDAO AuRa. if self.posdao_transition.map_or(true, |posdao_block| block.header.number() < posdao_block) { - trace!(target: "engine", "Skipping calls to POSDAO randomness and validator set contracts"); + trace!(target: "engine", "Skipping POSDAO calls to validator set contracts"); return Ok(Vec::new()); } diff --git a/ethcore/engines/validator-set/res/validator_report.json b/ethcore/engines/validator-set/res/validator_report.json index c2877a0c49d..e0c01143269 100644 --- a/ethcore/engines/validator-set/res/validator_report.json +++ b/ethcore/engines/validator-set/res/validator_report.json @@ -1,5 +1,5 @@ [ {"constant":false,"inputs":[{"name":"validator","type":"address"},{"name":"blockNumber","type":"uint256"},{"name":"proof","type":"bytes"}],"name":"reportMalicious","outputs":[],"payable":false,"type":"function"}, {"constant":false,"inputs":[{"name":"validator","type":"address"},{"name":"blockNumber","type":"uint256"}],"name":"reportBenign","outputs":[],"payable":false,"type":"function"}, - { "constant": true, "inputs": [ { "name": "validator", "type": "address" }, { "name": "blockNum", "type": "uint256" } ], "name": "maliceReportedForBlock", "outputs": [ { "name": "", "type": "address[]" } ], "payable": false, "stateMutability": "view", "type": "function" } + {"constant": true, "inputs": [ { "name": "validator", "type": "address" }, { "name": "blockNum", "type": "uint256" } ], "name": "maliceReportedForBlock", "outputs": [ { "name": "", "type": "address[]" } ], "payable": false, "stateMutability": "view", "type": "function" } ] diff --git a/ethcore/engines/validator-set/src/contract.rs b/ethcore/engines/validator-set/src/contract.rs index bcc2fd176cb..fc79ab47c2a 100644 --- a/ethcore/engines/validator-set/src/contract.rs +++ b/ethcore/engines/validator-set/src/contract.rs @@ -22,7 +22,7 @@ use std::sync::Weak; use parity_bytes::Bytes; use ethabi_contract::use_contract; use ethereum_types::{H256, U256, Address}; -use log::{warn, trace}; +use log::{info, warn, trace}; use machine::Machine; use parking_lot::RwLock; use common_types::{ @@ -165,6 +165,8 @@ 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); } } @@ -172,6 +174,8 @@ impl ValidatorSet for ValidatorContract { 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); } } diff --git a/ethcore/engines/validator-set/src/safe_contract.rs b/ethcore/engines/validator-set/src/safe_contract.rs index b65b972ba91..06bdd0035a3 100644 --- a/ethcore/engines/validator-set/src/safe_contract.rs +++ b/ethcore/engines/validator-set/src/safe_contract.rs @@ -53,6 +53,8 @@ use_contract!(validator_set, "res/validator_set.json"); const MAX_QUEUED_REPORTS: usize = 10; /// The maximum number of malice reports to include when creating a new block. const MAX_REPORTS_PER_BLOCK: usize = 10; +/// Don't re-send malice reports every block. Skip this many before retrying. +const REPORTS_SKIP_BLOCKS: u64 = 1; const MEMOIZE_CAPACITY: usize = 500; @@ -233,6 +235,13 @@ impl ValidatorSafeContract { } } + /// Puts a malice report into the queue for later resending. + /// + /// # Arguments + /// + /// * `addr` - The address of the misbehaving validator. + /// * `block` - The block number at which the misbehavior occurred. + /// * `data` - The call data for the `reportMalicious` contract call. pub(crate) fn enqueue_report(&self, addr: Address, block: BlockNumber, data: Vec) { // 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 < block_num) { @@ -388,7 +397,7 @@ impl ValidatorSet for ValidatorSafeContract { let mut resent_reports_in_block = self.resent_reports_in_block.lock(); // Skip at least one block after sending malicious reports last time. - if header.number() > *resent_reports_in_block + 1 { + if header.number() > *resent_reports_in_block + REPORTS_SKIP_BLOCKS { *resent_reports_in_block = header.number(); let mut nonce = client.latest_nonce(our_address); for (address, block, data) in report_queue.iter() {