Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuRa randomness #52

Merged
merged 22 commits into from
Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
77b9ecb
Added `randomness_contract` field.
mbr Dec 27, 2018
6fb927f
Added initial `engines::authority_round::randomness` module.
mbr Dec 27, 2018
ff80715
Added `authority_round_random.json`, based on `pos-contracts@8d10a85a…
mbr Dec 30, 2018
3df2d0f
Added phase skeleton for determination through constant contract calls.
mbr Dec 30, 2018
b18a9a0
Run `rustfmt` on `randomness` module.
mbr Dec 31, 2018
74a118b
Fixed path for `authority_round_random.json`.
mbr Dec 31, 2018
b087410
Fixed indentation in `randomness.rs`.
mbr Dec 31, 2018
cb80ccc
Updated docs for `randomness.rs`.
mbr Dec 31, 2018
bdde183
Factor out utility functions into `util` module.
mbr Dec 31, 2018
9afb509
Added capabilities to `BoundContract` to call non-constant functions …
mbr Dec 31, 2018
35c4f55
Implemented remainder of high-level logic for `randomness` module.
mbr Dec 31, 2018
c1a6d61
Actually hash secrets before transferring them.
mbr Dec 31, 2018
f71f1ab
Remove an outdated `NOTE` in `util.rs`.
mbr Dec 31, 2018
3fbd11d
Improved docs for `randomness.rs` module.
mbr Dec 31, 2018
31ccaf1
Replace spaces with tabs.
afck Jan 7, 2019
fe37342
Implement signing.
afck Jan 8, 2019
59a19ce
Make calls service transactions i.e. zero gas price.
afck Jan 9, 2019
adcf4a2
Update randomness contract.
afck Jan 9, 2019
d6c0e95
Address review comments: Extend docs.
afck Jan 9, 2019
3b677d4
Add randomness option to spec params.
afck Jan 10, 2019
8ce962c
Reformat ABI file according to editorconfig.
afck Jan 10, 2019
9f0afa7
Add comments about adding txns to current block.
afck Jan 10, 2019
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
328 changes: 328 additions & 0 deletions ethcore/res/authority_round_random.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
[
{
"constant": true,
"inputs": [],
"name": "COMMIT_PHASE_LENGTH",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "currentRandom",
"outputs": [
{
"name": "",
"type": "uint256[]"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "VALIDATOR_SET_CONTRACT",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "COLLECT_ROUND_LENGTH",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_secretHash",
"type": "bytes32"
}
],
"name": "commitHash",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_secret",
"type": "uint256"
}
],
"name": "revealSecret",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_currentValidator",
"type": "address"
}
],
"name": "onBlockClose",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_collectRound",
"type": "uint256"
}
],
"name": "blocksProducers",
"outputs": [
{
"name": "",
"type": "address[]"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_collectRound",
"type": "uint256"
}
],
"name": "committedValidators",
"outputs": [
{
"name": "",
"type": "address[]"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_collectRound",
"type": "uint256"
},
{
"name": "_validator",
"type": "address"
}
],
"name": "createdBlockOnCommitsPhase",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_collectRound",
"type": "uint256"
},
{
"name": "_validator",
"type": "address"
}
],
"name": "createdBlockOnRevealsPhase",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "currentCollectRound",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_collectRound",
"type": "uint256"
},
{
"name": "_validator",
"type": "address"
}
],
"name": "getCommit",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getCurrentSecret",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_collectRound",
"type": "uint256"
},
{
"name": "_validator",
"type": "address"
}
],
"name": "isCommitted",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isCommitPhase",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "isRevealPhase",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_collectRound",
"type": "uint256"
}
],
"name": "revealsCount",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_collectRound",
"type": "uint256"
},
{
"name": "_validator",
"type": "address"
}
],
"name": "sentReveal",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
12 changes: 7 additions & 5 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2110,15 +2110,17 @@ impl BlockChainClient for Client {
}
}

fn transact_contract(&self, address: Address, data: Bytes) -> Result<(), transaction::Error> {
fn transact(&self, action: Action, data: Bytes, gas: Option<U256>, gas_price: Option<U256>)
-> Result<(), transaction::Error>
{
let authoring_params = self.importer.miner.authoring_params();
let transaction = Transaction {
nonce: self.latest_nonce(&authoring_params.author),
action: Action::Call(address),
gas: self.importer.miner.sensible_gas_limit(),
gas_price: self.importer.miner.sensible_gas_price(),
action,
gas: gas.unwrap_or_else(|| self.importer.miner.sensible_gas_limit()),
gas_price: gas_price.unwrap_or_else(|| self.importer.miner.sensible_gas_price()),
value: U256::zero(),
data: data,
data,
};
let chain_id = self.engine.signing_chain_id(&self.latest_env_info());
let signature = self.engine.sign(transaction.hash(chain_id))
Expand Down
10 changes: 6 additions & 4 deletions ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,14 @@ impl BlockChainClient for TestBlockChainClient {
}
}

fn transact_contract(&self, address: Address, data: Bytes) -> Result<(), transaction::Error> {
fn transact(&self, action: Action, data: Bytes, gas: Option<U256>, gas_price: Option<U256>)
-> Result<(), transaction::Error>
{
let transaction = Transaction {
nonce: self.latest_nonce(&self.miner.authoring_params().author),
action: Action::Call(address),
gas: self.spec.gas_limit,
gas_price: U256::zero(),
action,
gas: gas.unwrap_or(self.spec.gas_limit),
gas_price: gas_price.unwrap_or(U256::zero()),
value: U256::default(),
data: data,
};
Expand Down
12 changes: 10 additions & 2 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use header::{BlockNumber};
use log_entry::LocalizedLogEntry;
use receipt::LocalizedReceipt;
use trace::LocalizedTrace;
use transaction::{self, LocalizedTransaction, SignedTransaction};
use transaction::{self, LocalizedTransaction, SignedTransaction, Action};
use verification::queue::QueueInfo as BlockQueueInfo;
use verification::queue::kind::blocks::Unverified;
use state::StateInfo;
Expand Down Expand Up @@ -388,7 +388,15 @@ pub trait BlockChainClient : Sync + Send + AccountData + BlockChain + CallContra
fn pruning_info(&self) -> PruningInfo;

/// Schedule state-altering transaction to be executed on the next pending block.
fn transact_contract(&self, address: Address, data: Bytes) -> Result<(), transaction::Error>;
fn transact_contract(&self, address: Address, data: Bytes) -> Result<(), transaction::Error> {
self.transact(Action::Call(address), data, None, None)
}

/// Schedule state-altering transaction to be executed on the next pending block with the given gas parameters.
///
/// If they are `None`, sensible values are selected automatically.
fn transact(&self, action: Action, data: Bytes, gas: Option<U256>, gas_price: Option<U256>)
-> Result<(), transaction::Error>;

/// Get the address of the registry itself.
fn registrar_address(&self) -> Option<Address>;
Expand Down
Loading