mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-09 03:17:55 +00:00
Update to spec v1.0.0-rc.0 and BLSv4 (#1765)
## Issue Addressed Closes #1504 Closes #1505 Replaces #1703 Closes #1707 ## Proposed Changes * Update BLST and Milagro to versions compatible with BLSv4 spec * Update Lighthouse to spec v1.0.0-rc.0, and update EF test vectors * Use the v1.0.0 constants for `MainnetEthSpec`. * Rename `InteropEthSpec` -> `V012LegacyEthSpec` * Change all constants to suit the mainnet `v0.12.3` specification (i.e., Medalla). * Deprecate the `--spec` flag for the `lighthouse` binary * This value is now obtained from the `config_name` field of the `YamlConfig`. * Built in testnet YAML files have been updated. * Ignore the `--spec` value, if supplied, log a warning that it will be deprecated * `lcli` still has the spec flag, that's fine because it's dev tooling. * Remove the `E: EthSpec` from `YamlConfig` * This means we need to deser the genesis `BeaconState` on-demand, but this is fine. * Swap the old "minimal", "mainnet" strings over to the new `EthSpecId` enum. * Always require a `CONFIG_NAME` field in `YamlConfig` (it used to have a default). ## Additional Info Lots of breaking changes, do not merge! ~~We will likely need a Lighthouse v0.4.0 branch, and possibly a long-term v0.3.0 branch to keep Medalla alive~~. Co-authored-by: Kirk Baird <baird.k@outlook.com> Co-authored-by: Paul Hauner <paul@paulhauner.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use bls::{Hash256, INFINITY_PUBLIC_KEY, INFINITY_SIGNATURE};
|
||||
use bls::{Hash256, INFINITY_SIGNATURE, SECRET_KEY_BYTES_LEN};
|
||||
use ssz::{Decode, Encode};
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::Debug;
|
||||
@@ -19,6 +19,11 @@ macro_rules! test_suite {
|
||||
SecretKey::deserialize(&secret_bytes).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_zero_secret_key() {
|
||||
assert!(SecretKey::deserialize(&[0; SECRET_KEY_BYTES_LEN]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infinity_agg_sig() {
|
||||
assert_eq!(
|
||||
@@ -131,11 +136,6 @@ macro_rules! test_suite {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn infinity_pubkey(mut self) -> Self {
|
||||
self.pubkey = PublicKey::deserialize(&INFINITY_PUBLIC_KEY[..]).unwrap();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn assert_verify(self, is_valid: bool) {
|
||||
assert_eq!(self.sig.verify(&self.pubkey, self.msg), is_valid);
|
||||
|
||||
@@ -153,14 +153,6 @@ macro_rules! test_suite {
|
||||
SignatureTester::default().assert_verify(true)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infinity_signature_is_valid_with_infinity_pubkey() {
|
||||
SignatureTester::default()
|
||||
.infinity_sig()
|
||||
.infinity_pubkey()
|
||||
.assert_verify(true)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infinity_signature_is_invalid_with_standard_pubkey() {
|
||||
SignatureTester::default()
|
||||
@@ -168,13 +160,6 @@ macro_rules! test_suite {
|
||||
.assert_verify(false)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn standard_signature_is_invalid_with_infinity_pubkey() {
|
||||
SignatureTester::default()
|
||||
.infinity_pubkey()
|
||||
.assert_verify(false)
|
||||
}
|
||||
|
||||
/// A helper struct for composing tests via the builder pattern.
|
||||
struct AggregateSignatureTester {
|
||||
sig: AggregateSignature,
|
||||
@@ -234,17 +219,6 @@ macro_rules! test_suite {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn single_infinity_pubkey(mut self) -> Self {
|
||||
self.pubkeys = vec![PublicKey::deserialize(&INFINITY_PUBLIC_KEY[..]).unwrap()];
|
||||
self
|
||||
}
|
||||
|
||||
pub fn push_infinity_pubkey(mut self) -> Self {
|
||||
self.pubkeys
|
||||
.push(PublicKey::deserialize(&INFINITY_PUBLIC_KEY[..]).unwrap());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn assert_single_message_verify(self, is_valid: bool) {
|
||||
assert!(self.msgs.len() == 1);
|
||||
let msg = self.msgs.first().unwrap();
|
||||
@@ -304,15 +278,6 @@ macro_rules! test_suite {
|
||||
.assert_single_message_verify(false)
|
||||
}
|
||||
|
||||
/// The infinity signature and one infinity pubkey should verify.
|
||||
#[test]
|
||||
fn fast_aggregate_verify_infinity_signature_with_one_infinity_pubkey() {
|
||||
AggregateSignatureTester::new_with_single_msg(1)
|
||||
.infinity_sig()
|
||||
.single_infinity_pubkey()
|
||||
.assert_single_message_verify(true)
|
||||
}
|
||||
|
||||
/// Adding a infinity signature (without an infinity pubkey) should verify.
|
||||
#[test]
|
||||
fn fast_aggregate_verify_with_one_aggregated_infinity_sig() {
|
||||
@@ -332,34 +297,6 @@ macro_rules! test_suite {
|
||||
.assert_single_message_verify(true)
|
||||
}
|
||||
|
||||
/// Adding a infinity pubkey and an infinity signature should verify.
|
||||
#[test]
|
||||
fn fast_aggregate_verify_with_one_additional_infinity_pubkey_and_matching_sig() {
|
||||
AggregateSignatureTester::new_with_single_msg(1)
|
||||
.aggregate_infinity_sig()
|
||||
.push_infinity_pubkey()
|
||||
.assert_single_message_verify(true)
|
||||
}
|
||||
|
||||
/// Adding a single infinity pubkey **without** updating the signature **should verify**.
|
||||
#[test]
|
||||
fn fast_aggregate_verify_with_one_additional_infinity_pubkey() {
|
||||
AggregateSignatureTester::new_with_single_msg(1)
|
||||
.push_infinity_pubkey()
|
||||
.assert_single_message_verify(true)
|
||||
}
|
||||
|
||||
/// Adding multiple infinity pubkeys **without** updating the signature **should verify**.
|
||||
#[test]
|
||||
fn fast_aggregate_verify_with_four_additional_infinity_pubkeys() {
|
||||
AggregateSignatureTester::new_with_single_msg(1)
|
||||
.push_infinity_pubkey()
|
||||
.push_infinity_pubkey()
|
||||
.push_infinity_pubkey()
|
||||
.push_infinity_pubkey()
|
||||
.assert_single_message_verify(true)
|
||||
}
|
||||
|
||||
/// The wrong signature should not verify.
|
||||
#[test]
|
||||
fn fast_aggregate_verify_wrong_signature() {
|
||||
@@ -463,18 +400,6 @@ macro_rules! test_suite {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn push_invalid_sig_infinity_set(mut self) -> Self {
|
||||
let mut signature = AggregateSignature::infinity();
|
||||
signature.add_assign(&secret_from_u64(42).sign(Hash256::zero()));
|
||||
self.owned_sets.push(OwnedSignatureSet {
|
||||
signature,
|
||||
signing_keys: vec![PublicKey::deserialize(&INFINITY_PUBLIC_KEY).unwrap()],
|
||||
message: Hash256::zero(),
|
||||
should_be_valid: false,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
pub fn push_invalid_pubkey_infinity_set(mut self) -> Self {
|
||||
self.owned_sets.push(OwnedSignatureSet {
|
||||
signature: AggregateSignature::deserialize(&INFINITY_SIGNATURE).unwrap(),
|
||||
@@ -485,16 +410,6 @@ macro_rules! test_suite {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn push_valid_infinity_set(mut self) -> Self {
|
||||
self.owned_sets.push(OwnedSignatureSet {
|
||||
signature: AggregateSignature::deserialize(&INFINITY_SIGNATURE).unwrap(),
|
||||
signing_keys: vec![PublicKey::deserialize(&INFINITY_PUBLIC_KEY).unwrap()],
|
||||
message: Hash256::zero(),
|
||||
should_be_valid: true,
|
||||
});
|
||||
self
|
||||
}
|
||||
|
||||
pub fn run_checks(self) {
|
||||
assert!(!self.owned_sets.is_empty(), "empty test is meaningless");
|
||||
|
||||
@@ -568,22 +483,6 @@ macro_rules! test_suite {
|
||||
.run_checks()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signature_set_1_valid_set_with_1_infinity_set() {
|
||||
SignatureSetTester::default()
|
||||
.push_valid_infinity_set()
|
||||
.run_checks()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signature_set_3_sets_with_one_valid_infinity_set() {
|
||||
SignatureSetTester::default()
|
||||
.push_valid_set(2)
|
||||
.push_valid_infinity_set()
|
||||
.push_valid_set(2)
|
||||
.run_checks()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signature_set_3_sets_with_one_invalid_pubkey_infinity_set() {
|
||||
SignatureSetTester::default()
|
||||
@@ -592,15 +491,6 @@ macro_rules! test_suite {
|
||||
.push_valid_set(2)
|
||||
.run_checks()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signature_set_3_sets_with_one_invalid_sig_infinity_set() {
|
||||
SignatureSetTester::default()
|
||||
.push_valid_set(2)
|
||||
.push_invalid_sig_infinity_set()
|
||||
.push_valid_set(2)
|
||||
.run_checks()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user