Add randomness contract support to AuthorityRound. (#10946)

* Add randomness contract support to Authority Round.

Changes have been cherry-picked from poanetwork's aura-pos branch.
Most of the work has been done by @mbr.

* Address review comments for randomness contract.

Co-Authored-By: David <dvdplm@gmail.com>

* Rename revealSecret to revealNumber

* Update Randomness contract bytecode

* Use H256, rename secret to random number.

* Use get_commit_and_cipher

* Clean up Miner::prepare_block.

* Remove is_reveal_phase call.

* Add more comments, require randomness contract map.

* Simplify run_randomness_phase

* Address review comments.

* Remove Client::transact_contract.
This commit is contained in:
Andreas Fackler
2019-12-17 11:34:14 +01:00
committed by David
parent f6909d8243
commit 2b1d148ceb
26 changed files with 1293 additions and 69 deletions

View File

@@ -18,7 +18,7 @@ use std::sync::Arc;
use accounts::AccountProvider;
use ethkey::Password;
use crypto::publickey::{Address, Message, Signature, Error};
use crypto::publickey::{Address, Message, Public, Signature, Error};
/// An implementation of EngineSigner using internal account management.
pub struct EngineSigner {
@@ -42,8 +42,19 @@ impl engine::signer::EngineSigner for EngineSigner {
}
}
fn decrypt(&self, auth_data: &[u8], cipher: &[u8]) -> Result<Vec<u8>, Error> {
self.accounts.decrypt(self.address, None, auth_data, cipher).map_err(|e| {
warn!("Unable to decrypt message: {:?}", e);
Error::InvalidMessage
})
}
fn address(&self) -> Address {
self.address
}
fn public(&self) -> Option<Public> {
self.accounts.account_public(self.address, &self.password).ok()
}
}