Replace ssz_encode with int_to_bytes32

Only in the relevant places I can think of.. I might have missed some.
This commit is contained in:
Paul Hauner 2019-02-15 12:21:19 +11:00
parent fc04286ae6
commit 210ec89b0b
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
4 changed files with 9 additions and 6 deletions

View File

@ -5,6 +5,7 @@ authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
[dependencies]
slot_clock = { path = "../../eth2/utils/slot_clock" }
ssz = { path = "../../eth2/utils/ssz" }
types = { path = "../../eth2/types" }
int_to_bytes = { path = "../utils/int_to_bytes" }
slot_clock = { path = "../utils/slot_clock" }
ssz = { path = "../utils/ssz" }
types = { path = "../types" }

View File

@ -1,8 +1,8 @@
pub mod test_utils;
mod traits;
use int_to_bytes::int_to_bytes32;
use slot_clock::SlotClock;
use ssz::ssz_encode;
use std::sync::Arc;
use types::{BeaconBlock, ChainSpec, Slot};
@ -132,7 +132,7 @@ impl<T: SlotClock, U: BeaconNode, V: DutiesReader, W: Signer> BlockProducer<T, U
fn produce_block(&mut self, slot: Slot) -> Result<PollOutcome, Error> {
let randao_reveal = {
// TODO: add domain, etc to this message. Also ensure result matches `into_to_bytes32`.
let message = ssz_encode(&slot.epoch(self.spec.epoch_length));
let message = int_to_bytes32(slot.epoch(self.spec.epoch_length).as_u64());
match self.signer.sign_randao_reveal(&message) {
None => return Ok(PollOutcome::SignerRejection(slot)),

View File

@ -6,6 +6,7 @@ edition = "2018"
[dependencies]
hashing = { path = "../utils/hashing" }
int_to_bytes = { path = "../utils/int_to_bytes" }
integer-sqrt = "0.1"
log = "0.4"
ssz = { path = "../utils/ssz" }

View File

@ -1,5 +1,6 @@
use crate::SlotProcessingError;
use hashing::hash;
use int_to_bytes::int_to_bytes32;
use log::debug;
use ssz::{ssz_encode, TreeHash};
use types::{
@ -110,7 +111,7 @@ fn per_block_processing_signature_optional(
ensure!(
bls_verify(
&block_proposer.pubkey,
&ssz_encode(&state.current_epoch(spec)),
&int_to_bytes32(state.current_epoch(spec).as_u64()),
&block.randao_reveal,
get_domain(&state.fork, state.current_epoch(spec), DOMAIN_RANDAO)
),