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

Commit

Permalink
cameltoe
Browse files Browse the repository at this point in the history
  • Loading branch information
keorn committed Dec 22, 2016
1 parent 9d68740 commit b7996fa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ethcore/res/validator_contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
"0000000000000000000000000000000000000005": {
"balance": "1",
"constructor": "0x60a06040819052737d577a597b2742b498cb5cf0c26cdcd726d39e6e60609081527382a978b3f5962a5b0957d9ee9eef472ee55b42f1608052600080546002825581805290927f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5639182019291905b828111156100a25782518254600160a060020a031916600160a060020a0390911617825560209092019160019091019061006d565b5b506100cd9291505b808211156100c9578054600160a060020a03191681556001016100ab565b5090565b505034610000575b610332806100e46000396000f300606060405263ffffffff60e060020a60003504166335aa2e44811461004557806380a02a41146100715780639112f55c1461008c578063ea0564861461009e575b610000565b3461000057610055600435610106565b60408051600160a060020a039092168252519081900360200190f35b346100005761008a600160a060020a0360043516610136565b005b346100005761008a6004356101ad565b005b34610000576100ab61029c565b60408051602080825283518183015283519192839290830191858101910280838382156100f3575b8051825260208311156100f357601f1990920191602091820191016100d3565b5050509050019250505060405180910390f35b600081815481101561000057906000526020600020900160005b915054906101000a9004600160a060020a031681565b60008054806001018281815481835581811511610178576000838152602090206101789181019083015b808211156101745760008155600101610160565b5090565b5b505050916000526020600020900160005b8154600160a060020a038086166101009390930a92830292021916179055505b50565b6000805460001981019081101561000057906000526020600020900160005b9054906101000a9004600160a060020a0316600082815481101561000057906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a031602179055506000600160008054905003815481101561000057906000526020600020900160005b6101000a815490600160a060020a0302191690556000805480919060019003815481835581811511610293576000838152602090206102939181019083015b808211156101745760008155600101610160565b5090565b5b505050505b50565b60408051602081810183526000808352805484518184028101840190955280855292939290918301828280156102fb57602002820191906000526020600020905b8154600160a060020a031681526001909101906020018083116102dd575b505050505090505b905600a165627a7a723058200c52661ec16b59726ce62645c05e4e40ece30b50946af735411313f10637403e0029"
"constructor": "0x60a06040819052737d577a597b2742b498cb5cf0c26cdcd726d39e6e60609081527382a978b3f5962a5b0957d9ee9eef472ee55b42f1608052600080546002825581805290927f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5639182019291905b828111156100a25782518254600160a060020a031916600160a060020a0390911617825560209092019160019091019061006d565b5b506100cd9291505b808211156100c9578054600160a060020a03191681556001016100ab565b5090565b505034610000575b610332806100e46000396000f300606060405263ffffffff60e060020a60003504166335aa2e4481146100455780634d238c8e14610071578063b7ab4db51461008c578063f94e1867146100f4575b610000565b3461000057610055600435610106565b60408051600160a060020a039092168252519081900360200190f35b346100005761008a600160a060020a0360043516610136565b005b34610000576100996101ad565b60408051602080825283518183015283519192839290830191858101910280838382156100e1575b8051825260208311156100e157601f1990920191602091820191016100c1565b5050509050019250505060405180910390f35b346100005761008a600435610217565b005b600081815481101561000057906000526020600020900160005b915054906101000a9004600160a060020a031681565b60008054806001018281815481835581811511610178576000838152602090206101789181019083015b808211156101745760008155600101610160565b5090565b5b505050916000526020600020900160005b8154600160a060020a038086166101009390930a92830292021916179055505b50565b604080516020818101835260008083528054845181840281018401909552808552929392909183018282801561020c57602002820191906000526020600020905b8154600160a060020a031681526001909101906020018083116101ee575b505050505090505b90565b6000805460001981019081101561000057906000526020600020900160005b9054906101000a9004600160a060020a0316600082815481101561000057906000526020600020900160005b6101000a815481600160a060020a030219169083600160a060020a031602179055506000600160008054905003815481101561000057906000526020600020900160005b6101000a815490600160a060020a03021916905560008054809190600190038154818355818115116102fd576000838152602090206102fd9181019083015b808211156101745760008155600101610160565b5090565b5b505050505b505600a165627a7a72305820d742dd391941c1c255f0e1187ffa5b1e783219264fb10196018aefa379f5638b0029"
},
"9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376" }
}
Expand Down
14 changes: 6 additions & 8 deletions ethcore/src/engines/validator_set/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use super::ValidatorSet;
use super::simple_list::SimpleList;

/// The validator contract should have the following interface:
/// [{"constant":true,"inputs":[],"name":"get_validators","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"}]
/// [{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"}]
pub struct ValidatorContract {
address: Address,
validators: RwLock<SimpleList>,
Expand Down Expand Up @@ -97,14 +97,12 @@ impl ValidatorSet for Arc<ValidatorContract> {

mod provider {
// Autogenerated from JSON contract definition using Rust contract convertor.

#![allow(unused_imports)]
use std::string::String;
use std::result::Result;
use std::fmt;
use {util, ethabi};
use util::{FixedHash, Uint};
use util::ToPretty;

pub struct Contract {
contract: ethabi::Contract,
Expand All @@ -114,17 +112,17 @@ mod provider {
impl Contract {
pub fn new<F>(address: util::Address, do_call: F) -> Self where F: Fn(util::Address, Vec<u8>) -> Result<Vec<u8>, String> + Send + Sync + 'static {
Contract {
contract: ethabi::Contract::new(ethabi::Interface::load(b"[{\"constant\":true,\"inputs\":[],\"name\":\"get_validators\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"type\":\"function\"}]").expect("JSON is autogenerated; qed")),
contract: ethabi::Contract::new(ethabi::Interface::load(b"[{\"constant\":true,\"inputs\":[],\"name\":\"getValidators\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"type\":\"function\"}]").expect("JSON is autogenerated; qed")),
address: address,
do_call: Box::new(do_call),
}
}
fn as_string<T: fmt::Debug>(e: T) -> String { format!("{:?}", e) }

/// Auto-generated from: `{"constant":true,"inputs":[],"name":"get_validators","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"}`
/// Auto-generated from: `{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"}`
#[allow(dead_code)]
pub fn get_validators(&self) -> Result<Vec<util::Address>, String> {
let call = self.contract.function("get_validators".into()).map_err(Self::as_string)?;
let call = self.contract.function("getValidators".into()).map_err(Self::as_string)?;
let data = call.encode_call(
vec![]
).map_err(Self::as_string)?;
Expand Down Expand Up @@ -179,7 +177,7 @@ mod tests {
gas: 500_000.into(),
action: Action::Call(validator_contract),
value: 0.into(),
data: "9112f55c0000000000000000000000000000000000000000000000000000000000000001".from_hex().unwrap(),
data: "f94e18670000000000000000000000000000000000000000000000000000000000000001".from_hex().unwrap(),
}.sign(&"1".sha3(), None);
client.miner().import_own_transaction(client.as_ref(), tx.into()).unwrap();
client.update_sealing();
Expand All @@ -191,7 +189,7 @@ mod tests {
gas: 500_000.into(),
action: Action::Call(validator_contract),
value: 0.into(),
data: "80a02a4100000000000000000000000082a978b3f5962a5b0957d9ee9eef472ee55b42f1".from_hex().unwrap(),
data: "4d238c8e00000000000000000000000082a978b3f5962a5b0957d9ee9eef472ee55b42f1".from_hex().unwrap(),
}.sign(&"1".sha3(), None);
client.miner().import_own_transaction(client.as_ref(), tx.into()).unwrap();
client.update_sealing();
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl Spec {

/// Create a new Spec with BasicAuthority which uses a contract at address 5 to determine the current validators.
/// Accounts with secrets "0".sha3() and "1".sha3() are initially the validators.
/// Second validator can be removed with "0x9112f55c0000000000000000000000000000000000000000000000000000000000000001" and added back in using "0x80a02a4100000000000000000000000082a978b3f5962a5b0957d9ee9eef472ee55b42f1".
/// Second validator can be removed with "0xf94e18670000000000000000000000000000000000000000000000000000000000000001" and added back in using "0x4d238c8e00000000000000000000000082a978b3f5962a5b0957d9ee9eef472ee55b42f1".
pub fn new_validator_contract() -> Self { load_bundled!("validator_contract") }

/// Create a new Spec with Tendermint consensus which does internal sealing (not requiring work).
Expand Down
2 changes: 1 addition & 1 deletion scripts/contractABI.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function convertFunction(json, _prefs) {
}`;
}

let jsonabi = [{"constant":true,"inputs":[],"name":"get_validators","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"}];
let jsonabi = [{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"}];

let out = makeContractFile("Contract", jsonabi, {"_pub": true, "_": {"_client": {"string": true}, "_platform": {"string": true}}, "_sync": true});
console.log(`${out}`);

0 comments on commit b7996fa

Please sign in to comment.