mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 19:02:42 +00:00
Arbitrary trait for eth2/types (#1040)
* Add the arbitrary type to eth2/types and their deps Signed-off-by: Kirk Baird <baird.k@outlook.com> * Wrap arbitrary in a feature flag Signed-off-by: Kirk Baird <baird.k@outlook.com> * Fix feature for types Signed-off-by: Kirk Baird <baird.k@outlook.com> * Fix comment Signed-off-by: Kirk Baird <baird.k@outlook.com> * Patch versioning Signed-off-by: Kirk Baird <baird.k@outlook.com> * Allow expanded crate reference for arbitrary 0.4.3 Signed-off-by: Kirk Baird <baird.k@outlook.com> * Add arbitrary to remaining types Signed-off-by: Kirk Baird <baird.k@outlook.com> * use cmp::min Signed-off-by: Kirk Baird <baird.k@outlook.com> * Derive Arbitrary trait for ValidatorStatus, TotalBalances and InclusionInfo * Add CI check for state processing arbitrary faetures Signed-off-by: Kirk Baird <baird.k@outlook.com> * Fix indentation Signed-off-by: Kirk Baird <baird.k@outlook.com> Co-authored-by: Mehdi Zerouali <mehdi@sigmaprime.io>
This commit is contained in:
@@ -33,7 +33,11 @@ mod verify_deposit;
|
||||
mod verify_exit;
|
||||
mod verify_proposer_slashing;
|
||||
|
||||
#[cfg(feature = "arbitrary-fuzz")]
|
||||
use arbitrary::Arbitrary;
|
||||
|
||||
/// The strategy to be used when validating the block's signatures.
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))]
|
||||
#[derive(PartialEq, Clone, Copy)]
|
||||
pub enum BlockSignatureStrategy {
|
||||
/// Do not validate any signature. Use with caution.
|
||||
@@ -45,6 +49,7 @@ pub enum BlockSignatureStrategy {
|
||||
}
|
||||
|
||||
/// The strategy to be used when validating the block's signatures.
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))]
|
||||
#[derive(PartialEq, Clone, Copy)]
|
||||
pub enum VerifySignatures {
|
||||
/// Validate all signatures encountered.
|
||||
|
||||
@@ -2,6 +2,9 @@ use crate::common::get_attesting_indices;
|
||||
use safe_arith::SafeArith;
|
||||
use types::*;
|
||||
|
||||
#[cfg(feature = "arbitrary-fuzz")]
|
||||
use arbitrary::Arbitrary;
|
||||
|
||||
/// Sets the boolean `var` on `self` to be true if it is true on `other`. Otherwise leaves `self`
|
||||
/// as is.
|
||||
macro_rules! set_self_if_other_is_true {
|
||||
@@ -13,6 +16,7 @@ macro_rules! set_self_if_other_is_true {
|
||||
}
|
||||
|
||||
/// The information required to reward a block producer for including an attestation in a block.
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct InclusionInfo {
|
||||
/// The distance between the attestation slot and the slot that attestation was included in a
|
||||
@@ -44,6 +48,7 @@ impl InclusionInfo {
|
||||
}
|
||||
|
||||
/// Information required to reward some validator during the current and previous epoch.
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))]
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct ValidatorStatus {
|
||||
/// True if the validator has been slashed, ever.
|
||||
@@ -108,7 +113,9 @@ impl ValidatorStatus {
|
||||
|
||||
/// The total effective balances for different sets of validators during the previous and current
|
||||
/// epochs.
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))]
|
||||
pub struct TotalBalances {
|
||||
/// The effective balance increment from the spec.
|
||||
effective_balance_increment: u64,
|
||||
@@ -165,6 +172,7 @@ impl TotalBalances {
|
||||
|
||||
/// Summarised information about validator participation in the _previous and _current_ epochs of
|
||||
/// some `BeaconState`.
|
||||
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ValidatorStatuses {
|
||||
/// Information about each individual validator from the state's validator registry.
|
||||
|
||||
Reference in New Issue
Block a user