Pass additional data when reporting (#5527)
* pass additional data when reporting * checkout correct tests
This commit is contained in:
@@ -25,7 +25,7 @@ use native_contracts::ValidatorReport as Provider;
|
||||
|
||||
use client::{Client, BlockChainClient};
|
||||
use engines::Call;
|
||||
use header::Header;
|
||||
use header::{Header, BlockNumber};
|
||||
|
||||
use super::ValidatorSet;
|
||||
use super::safe_contract::ValidatorSafeContract;
|
||||
@@ -92,15 +92,15 @@ impl ValidatorSet for ValidatorContract {
|
||||
self.validators.count_with_caller(bh, caller)
|
||||
}
|
||||
|
||||
fn report_malicious(&self, address: &Address) {
|
||||
match self.provider.report_malicious(&*self.transact(), *address).wait() {
|
||||
fn report_malicious(&self, address: &Address, block: BlockNumber, proof: Bytes) {
|
||||
match self.provider.report_malicious(&*self.transact(), *address, block.into(), proof).wait() {
|
||||
Ok(_) => warn!(target: "engine", "Reported malicious validator {}", address),
|
||||
Err(s) => warn!(target: "engine", "Validator {} could not be reported {}", address, s),
|
||||
}
|
||||
}
|
||||
|
||||
fn report_benign(&self, address: &Address) {
|
||||
match self.provider.report_benign(&*self.transact(), *address).wait() {
|
||||
fn report_benign(&self, address: &Address, block: BlockNumber) {
|
||||
match self.provider.report_benign(&*self.transact(), *address, block.into()).wait() {
|
||||
Ok(_) => warn!(target: "engine", "Reported benign validator misbehaviour {}", address),
|
||||
Err(s) => warn!(target: "engine", "Validator {} could not be reported {}", address, s),
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ mod multi;
|
||||
|
||||
use std::sync::Weak;
|
||||
use ids::BlockId;
|
||||
use util::{Address, H256};
|
||||
use util::{Bytes, Address, H256};
|
||||
use ethjson::spec::ValidatorSet as ValidatorSpec;
|
||||
use client::Client;
|
||||
use header::Header;
|
||||
use header::{Header, BlockNumber};
|
||||
|
||||
pub use self::simple_list::SimpleList;
|
||||
use self::contract::ValidatorContract;
|
||||
@@ -111,9 +111,9 @@ pub trait ValidatorSet: Send + Sync {
|
||||
fn count_with_caller(&self, parent_block_hash: &H256, caller: &Call) -> usize;
|
||||
|
||||
/// Notifies about malicious behaviour.
|
||||
fn report_malicious(&self, _validator: &Address) {}
|
||||
fn report_malicious(&self, _validator: &Address, _block: BlockNumber, _proof: Bytes) {}
|
||||
/// Notifies about benign misbehaviour.
|
||||
fn report_benign(&self, _validator: &Address) {}
|
||||
fn report_benign(&self, _validator: &Address, _block: BlockNumber) {}
|
||||
/// Allows blockchain state access.
|
||||
fn register_contract(&self, _client: Weak<Client>) {}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::Weak;
|
||||
use engines::{Call, EpochChange};
|
||||
use util::{H256, Address, RwLock};
|
||||
use util::{Bytes, H256, Address, RwLock};
|
||||
use ids::BlockId;
|
||||
use header::{BlockNumber, Header};
|
||||
use client::{Client, BlockChainClient};
|
||||
@@ -110,16 +110,12 @@ impl ValidatorSet for Multi {
|
||||
.map_or_else(usize::max_value, |set| set.count_with_caller(bh, caller))
|
||||
}
|
||||
|
||||
fn report_malicious(&self, validator: &Address) {
|
||||
for set in self.sets.values() {
|
||||
set.report_malicious(validator);
|
||||
}
|
||||
fn report_malicious(&self, validator: &Address, block: BlockNumber, proof: Bytes) {
|
||||
self.correct_set_by_number(block).1.report_malicious(validator, block, proof);
|
||||
}
|
||||
|
||||
fn report_benign(&self, validator: &Address) {
|
||||
for set in self.sets.values() {
|
||||
set.report_benign(validator);
|
||||
}
|
||||
fn report_benign(&self, validator: &Address, block: BlockNumber) {
|
||||
self.correct_set_by_number(block).1.report_benign(validator, block);
|
||||
}
|
||||
|
||||
fn register_contract(&self, client: Weak<Client>) {
|
||||
|
||||
Reference in New Issue
Block a user