mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Consensus updates for v0.12 (#1228)
* Update state processing for v0.12 * Fix EF test runners for v0.12 * Fix some tests * Fix broken attestation verification test * More test fixes * Fix typo found in review
This commit is contained in:
@@ -25,12 +25,17 @@ impl Case for BlsAggregateSigs {
|
||||
aggregate_signature.add(&sig);
|
||||
}
|
||||
|
||||
let output_bytes = Some(
|
||||
// Check for YAML null value, indicating invalid input. This is a bit of a hack,
|
||||
// as our mutating `aggregate_signature.add` API doesn't play nicely with aggregating 0
|
||||
// inputs.
|
||||
let output_bytes = if self.output == "~" {
|
||||
AggregateSignature::new().as_bytes().to_vec()
|
||||
} else {
|
||||
hex::decode(&self.output[2..])
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?,
|
||||
);
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?
|
||||
};
|
||||
let aggregate_signature = Ok(aggregate_signature.as_bytes().to_vec());
|
||||
|
||||
compare_result::<Vec<u8>, Vec<u8>>(&aggregate_signature, &output_bytes)
|
||||
compare_result::<Vec<u8>, Vec<u8>>(&aggregate_signature, &Some(output_bytes))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,10 @@ use crate::cases::common::BlsCase;
|
||||
use bls::{AggregateSignature, PublicKey};
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct BlsAggregatePair {
|
||||
pub pubkey: PublicKey,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct BlsAggregateVerifyInput {
|
||||
pub pairs: Vec<BlsAggregatePair>,
|
||||
pub pubkeys: Vec<PublicKey>,
|
||||
pub messages: Vec<String>,
|
||||
pub signature: String,
|
||||
}
|
||||
|
||||
@@ -28,11 +23,10 @@ impl Case for BlsAggregateVerify {
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let messages = self
|
||||
.input
|
||||
.pairs
|
||||
.messages
|
||||
.iter()
|
||||
.map(|pair| {
|
||||
hex::decode(&pair.message[2..])
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))
|
||||
.map(|message| {
|
||||
hex::decode(&message[2..]).map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))
|
||||
})
|
||||
.collect::<Result<Vec<Vec<_>>, _>>()?;
|
||||
|
||||
@@ -41,12 +35,7 @@ impl Case for BlsAggregateVerify {
|
||||
.map(|x| x.as_slice())
|
||||
.collect::<Vec<&[u8]>>();
|
||||
|
||||
let pubkey_refs = self
|
||||
.input
|
||||
.pairs
|
||||
.iter()
|
||||
.map(|p| &p.pubkey)
|
||||
.collect::<Vec<_>>();
|
||||
let pubkey_refs = self.input.pubkeys.iter().collect::<Vec<_>>();
|
||||
|
||||
let signature_ok = hex::decode(&self.input.signature[2..])
|
||||
.ok()
|
||||
|
||||
@@ -27,7 +27,7 @@ struct Metadata {
|
||||
pub struct Operations<E: EthSpec, O: Operation<E>> {
|
||||
metadata: Metadata,
|
||||
pub pre: BeaconState<E>,
|
||||
pub operation: O,
|
||||
pub operation: Option<O>,
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
@@ -135,8 +135,16 @@ impl<E: EthSpec, O: Operation<E>> LoadCase for Operations<E, O> {
|
||||
} else {
|
||||
Metadata::default()
|
||||
};
|
||||
|
||||
let pre = ssz_decode_file(&path.join("pre.ssz"))?;
|
||||
let operation = ssz_decode_file(&path.join(O::filename()))?;
|
||||
|
||||
// Check BLS setting here before SSZ deserialization, as most types require signatures
|
||||
// to be valid.
|
||||
let operation = if metadata.bls_setting.unwrap_or_default().check().is_ok() {
|
||||
Some(ssz_decode_file(&path.join(O::filename()))?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let post_filename = path.join("post.ssz");
|
||||
let post = if post_filename.is_file() {
|
||||
Some(ssz_decode_file(&post_filename)?)
|
||||
@@ -162,8 +170,6 @@ impl<E: EthSpec, O: Operation<E>> Case for Operations<E, O> {
|
||||
}
|
||||
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
self.metadata.bls_setting.unwrap_or_default().check()?;
|
||||
|
||||
let spec = &E::default_spec();
|
||||
let mut state = self.pre.clone();
|
||||
let mut expected = self.post.clone();
|
||||
@@ -173,7 +179,12 @@ impl<E: EthSpec, O: Operation<E>> Case for Operations<E, O> {
|
||||
.build_all_committee_caches(spec)
|
||||
.expect("committee caches OK");
|
||||
|
||||
let mut result = self.operation.apply_to(&mut state, spec).map(|()| state);
|
||||
let mut result = self
|
||||
.operation
|
||||
.as_ref()
|
||||
.ok_or(Error::SkippedBls)?
|
||||
.apply_to(&mut state, spec)
|
||||
.map(|()| state);
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user