Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ethcore/light/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,12 @@ impl<T: ChainDataFetcher> ::ethcore::client::ChainInfo for Client<T> {
}
}

impl<T: ChainDataFetcher> ::ethcore::client::Nonce for Client<T> {
fn nonce(&self, _address: &ethereum_types::H160, _blockid: ethcore::client::BlockId) -> std::option::Option<ethereum_types::U256> {
panic!("we never call this function on a light client, so this is unreachable; qed")
}
}

impl<T: ChainDataFetcher> ::ethcore::client::EngineClient for Client<T> {
fn update_sealing(&self) { }
fn submit_seal(&self, _block_hash: H256, _seal: Vec<Vec<u8>>) { }
Expand Down
5 changes: 3 additions & 2 deletions ethcore/res/contracts/validator_report.json
Original file line number Diff line number Diff line change
@@ -1,4 +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": false, "inputs": [ { "name": "validator", "type": "address" }, { "name": "blockNum", "type": "uint256" }, { "name": "", "type": "bytes" } ], "name": "reportMalicious", "outputs": [], "payable": false, "stateMutability": "nonpayable", "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" }
]
42 changes: 42 additions & 0 deletions ethcore/res/contracts/validator_set_aura.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,47 @@
],
"name": "InitiateChange",
"type": "event"
},
{
"constant": true,
"inputs": [
{
"name": "_miningAddress",
"type": "address"
}
],
"name": "isValidatorBanned",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_maliciousMiningAddress",
"type": "address"
},
{
"name": "_blockNumber",
"type": "uint256"
}
],
"name": "maliceReportedForBlock",
"outputs": [
{
"name": "",
"type": "address[]"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
7 changes: 7 additions & 0 deletions ethcore/res/contracts/validator_set_aura.json.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
getValidators
initiateChange
emitInitiateChangeCallable
emitInitiateChange
maliceReportedForBlock
finalizeChange
InitiateChange
2 changes: 1 addition & 1 deletion ethcore/res/validator_contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
"0000000000000000000000000000000000000005": {
"balance": "1",
"constructor": "60806040526040805190810160405280737d577a597b2742b498cb5cf0c26cdcd726d39e6e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020017382a978b3f5962a5b0957d9ee9eef472ee55b42f173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681525060009060026100a9929190610159565b503480156100b657600080fd5b5060008090505b60008054905081101561015357806001600080848154811015156100dd57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080806001019150506100bd565b50610226565b8280548282559060005260206000209081019282156101d2579160200282015b828111156101d15782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610179565b5b5090506101df91906101e3565b5090565b61022391905b8082111561021f57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016101e9565b5090565b90565b610618806102356000396000f3fe608060405260043610610088576000357c01000000000000000000000000000000000000000000000000000000009004806335aa2e441461008d5780633d3b54581461010857806368ffa02d14610137578063752862111461019257806393b4e25e146101a9578063b7ab4db5146101c0578063d69f13bb1461022c578063d8f2e0bf14610287575b600080fd5b34801561009957600080fd5b506100c6600480360360208110156100b057600080fd5b81019080803590602001909291905050506102de565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561011457600080fd5b5061011d61031c565b604051808215151515815260200191505060405180910390f35b34801561014357600080fd5b506101906004803603604081101561015a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610325565b005b34801561019e57600080fd5b506101a761049e565b005b3480156101b557600080fd5b506101be6104a0565b005b3480156101cc57600080fd5b506101d56104a2565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156102185780820151818401526020810190506101fd565b505050509050019250505060405180910390f35b34801561023857600080fd5b506102856004803603604081101561024f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610530565b005b34801561029357600080fd5b5061029c610575565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000818154811015156102ed57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006001905090565b600060016000805490500381548110151561033c57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548154811015156103b557fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600060016000805490500381548110151561045757fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000805480919060019003610499919061059b565b505050565b565b565b6060600080548060200260200160405190810160405280929190818152602001828054801561052657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116104dc575b5050505050905090565b81600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b8154818355818111156105c2578183600052602060002091820191016105c191906105c7565b5b505050565b6105e991905b808211156105e55760008160009055506001016105cd565b5090565b9056fea165627a7a723058209ddf89214270830c0be6b514c27eb8eedf1bb989eb9b46867d20749faef133490029"
"constructor": "60806040526040805190810160405280737d577a597b2742b498cb5cf0c26cdcd726d39e6e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020017382a978b3f5962a5b0957d9ee9eef472ee55b42f173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681525060009060026100a9929190610159565b503480156100b657600080fd5b5060008090505b60008054905081101561015357806001600080848154811015156100dd57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080806001019150506100bd565b50610226565b8280548282559060005260206000209081019282156101d2579160200282015b828111156101d15782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610179565b5b5090506101df91906101e3565b5090565b61022391905b8082111561021f57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016101e9565b5090565b90565b610de3806102356000396000f3fe6080604052600436106100a9576000357c01000000000000000000000000000000000000000000000000000000009004806335aa2e44146100ae5780633d3b54581461012957806375286211146101585780639300c9261461016f57806393b4e25e14610234578063a92252ae1461024b578063b56b366b146102b4578063b7ab4db514610364578063c476dd40146103d0578063d69f13bb14610480578063d8f2e0bf146104db575b600080fd5b3480156100ba57600080fd5b506100e7600480360360208110156100d157600080fd5b8101908080359060200190929190505050610532565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013557600080fd5b5061013e610570565b604051808215151515815260200191505060405180910390f35b34801561016457600080fd5b5061016d61057a565b005b34801561017b57600080fd5b506102326004803603602081101561019257600080fd5b81019080803590602001906401000000008111156101af57600080fd5b8201836020820111156101c157600080fd5b803590602001918460208302840111640100000000831117156101e357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929050505061057c565b005b34801561024057600080fd5b50610249610647565b005b34801561025757600080fd5b5061029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106fa565b604051808215151515815260200191505060405180910390f35b3480156102c057600080fd5b5061030d600480360360408110156102d757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107ab565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610350578082015181840152602081019050610335565b505050509050019250505060405180910390f35b34801561037057600080fd5b506103796108a7565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156103bc5780820151818401526020810190506103a1565b505050509050019250505060405180910390f35b3480156103dc57600080fd5b5061047e600480360360608110156103f357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561043a57600080fd5b82018360208201111561044c57600080fd5b8035906020019184600183028401116401000000008311171561046e57600080fd5b9091929391929390505050610935565b005b34801561048c57600080fd5b506104d9600480360360408110156104a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c2e565b005b3480156104e757600080fd5b506104f0610c73565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008181548110151561054157fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000804311905090565b565b8060009080519060200190610592929190610c99565b5060014303407f55252fa6eee4741b4e24a74a70e9c11fd2c2281df8d6ea13126ff845f7825c8960006040518080602001828103825283818154815260200191508054801561063657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116105ec575b50509250505060405180910390a250565b60014303407f55252fa6eee4741b4e24a74a70e9c11fd2c2281df8d6ea13126ff845f7825c896000604051808060200182810382528381815481526020019150805480156106ea57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116106a0575b50509250505060405180910390a2565b60008173ffffffffffffffffffffffffffffffffffffffff166000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481548110151561076157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b6060600260008484604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405160208183030381529060405280519060200120815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561089a57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610850575b5050505050905092915050565b6060600080548060200260200160405190810160405280929190818152602001828054801561092b57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116108e1575b5050505050905090565b600260008585604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001925050506040516020818303038152906040528051906020012081526020019081526020016000203390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550508373ffffffffffffffffffffffffffffffffffffffff166000600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054815481101515610a6b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610c28576000600160008054905003815481101515610ac957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054815481101515610b4257fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600090556000600160008054905003815481101515610be457fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556000805480919060019003610c269190610d23565b505b50505050565b81600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b828054828255906000526020600020908101928215610d12579160200282015b82811115610d115782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610cb9565b5b509050610d1f9190610d4f565b5090565b815481835581811115610d4a57818360005260206000209182019101610d499190610d92565b5b505050565b610d8f91905b80821115610d8b57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550600101610d55565b5090565b90565b610db491905b80821115610db0576000816000905550600101610d98565b5090565b9056fea165627a7a7230582034f862f72c47fac1ba2693934a579f7a71d54a90c302cfe8660c741c821b55c00029"
},
"0x7d577a597b2742b498cb5cf0c26cdcd726d39e6e": { "balance": "1606938044258990275541962092341162602522202993782792835301376" },
"0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1": { "balance": "1606938044258990275541962092341162602522202993782792835301376" }
Expand Down
43 changes: 32 additions & 11 deletions ethcore/res/validator_contract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract TestList {
];

mapping(address => uint) indices;
// Should remain 0 because `reportBenign` is no longer used.
mapping(bytes32 => address[]) maliceReported;
address public disliked;

event InitiateChange(bytes32 indexed parentHash, address[] newSet);
Expand All @@ -28,27 +28,48 @@ contract TestList {
return validators;
}

function setValidators(address[] memory _validators) public {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really need this function here? Seems it is not called anywhere.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's called here, in the test.

validators = _validators;
emit InitiateChange(blockhash(block.number - 1), validators);
}

// Removes a validator from the list.
function reportMalicious(address validator) public {
validators[indices[validator]] = validators[validators.length-1];
delete indices[validator];
delete validators[validators.length-1];
validators.length--;
function reportMalicious(address validator, uint256 blockNum, bytes calldata) external {
maliceReported[keccak256(abi.encode(validator, blockNum))].push(msg.sender);
if (validators[indices[validator]] == validator) {
validators[indices[validator]] = validators[validators.length-1];
delete indices[validator];
delete validators[validators.length-1];
validators.length--;
}
}

// Returns the list of all validators that reported the given validator as malicious for the given block.
function maliceReportedForBlock(address validator, uint256 blockNum) public view returns(address[] memory) {
return maliceReported[keccak256(abi.encode(validator, blockNum))];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indentation: spaces should be replaced with tabs.

}

// Benign validator behaviour report. Kept here for regression testing.
function reportBenign(address validator) public {
function reportBenign(address validator, uint256) public {
disliked = validator;
}

// Checks if `emitInitiateChange` can be called.
function emitInitiateChangeCallable() pure public returns (bool) {
return true;
function emitInitiateChangeCallable() view public returns (bool) {
return block.number > 0;
}

// Emits an `InitiateChange` event in production code. Does nothing in the test.
function emitInitiateChange() pure public {}
// Checks if a validator has been removed.
function isValidatorBanned(address validator) view public returns (bool) {
return validators[indices[validator]] != validator;
}

// Emits an `InitiateChange` event.
function emitInitiateChange() public {
emit InitiateChange(blockhash(block.number - 1), validators);
}

// Applies a validator set change in production code. Does nothing in the test.
function finalizeChange() pure public {}
}

4 changes: 2 additions & 2 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2187,10 +2187,10 @@ impl BlockChainClient for Client {
Ok(SignedTransaction::new(transaction.with_signature(signature, chain_id))?)
}

fn transact(&self, action: Action, data: Bytes, gas: Option<U256>, gas_price: Option<U256>)
fn transact(&self, action: Action, data: Bytes, gas: Option<U256>, gas_price: Option<U256>, nonce: Option<U256>)
-> Result<(), transaction::Error>
{
let signed = self.create_transaction(action, data, gas, gas_price, None)?;
let signed = self.create_transaction(action, data, gas, gas_price, nonce)?;
self.importer.miner.import_own_transaction(self, signed.into())
}

Expand Down
10 changes: 8 additions & 2 deletions ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,14 @@ impl BlockChainClient for TestBlockChainClient {
Ok(SignedTransaction::new(transaction.with_signature(sig, chain_id)).unwrap())
}

fn transact(&self, action: Action, data: Bytes, gas: Option<U256>, gas_price: Option<U256>)
-> Result<(), transaction::Error>
fn transact(
&self,
action: Action,
data: Bytes,
gas: Option<U256>,
gas_price: Option<U256>,
_nonce: Option<U256>,
) -> Result<(), transaction::Error>
{
let signed = self.create_transaction(action, data, gas, gas_price, None)?;
self.miner.import_own_transaction(self, signed.into())
Expand Down
Loading