Get arbitrary check passing (2.0) (#2710)

## Issue Addressed

NA

## Proposed Changes

This is a wholesale rip-off of #2708, see that PR for more of a description.

I've made this PR since @realbigsean is offline and I can't merge his PR due to Github's frustrating `target-branch-check` bug. I also changed the branch to `unstable`, since I'm trying to minimize the diff between `merge-f2f`/`unstable`. I'll just rebase `merge-f2f` onto `unstable` after this PR merges.

When running `make lint` I noticed the following warning:

```
warning: patch for `fixed-hash` uses the features mechanism. default-features and features will not take effect because the patch dependency does not support this mechanism
```

So, I removed the `features` section from the patch.

## Additional Info

NA


Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
Paul Hauner
2021-10-14 02:58:11 +00:00
parent e2d09bb8ac
commit 18340d1fb6
25 changed files with 93 additions and 68 deletions

View File

@@ -5,7 +5,7 @@ authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
[dependencies]
ethereum-types = "0.11.0"
ethereum-types = "0.12.1"
eth2_ssz_types = "0.2.1"
eth2_hashing = "0.2.0"
eth2_ssz_derive = "0.3.0"

View File

@@ -5,7 +5,7 @@ authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2018"
[dependencies]
ethereum-types = "0.11.0"
ethereum-types = "0.12.1"
eth2_hashing = "0.2.0"
lazy_static = "1.4.0"
safe_arith = { path = "../safe_arith" }

View File

@@ -13,7 +13,7 @@ name = "ssz"
eth2_ssz_derive = "0.3.0"
[dependencies]
ethereum-types = "0.11.0"
ethereum-types = "0.12.1"
smallvec = "1.6.1"
[features]

View File

@@ -16,7 +16,7 @@ serde_derive = "1.0.116"
eth2_serde_utils = "0.1.0"
eth2_ssz = "0.4.0"
typenum = "1.12.0"
arbitrary = { version = "0.4.6", features = ["derive"], optional = true }
arbitrary = { version = "1.0", features = ["derive"], optional = true }
[dev-dependencies]
serde_json = "1.0.58"

View File

@@ -644,7 +644,7 @@ impl<N: Unsigned + Clone> tree_hash::TreeHash for Bitfield<Fixed<N>> {
}
#[cfg(feature = "arbitrary")]
impl<N: 'static + Unsigned> arbitrary::Arbitrary for Bitfield<Fixed<N>> {
impl<N: 'static + Unsigned> arbitrary::Arbitrary<'_> for Bitfield<Fixed<N>> {
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
let size = N::to_usize();
let mut vec: Vec<u8> = vec![0u8; size];
@@ -654,7 +654,7 @@ impl<N: 'static + Unsigned> arbitrary::Arbitrary for Bitfield<Fixed<N>> {
}
#[cfg(feature = "arbitrary")]
impl<N: 'static + Unsigned> arbitrary::Arbitrary for Bitfield<Variable<N>> {
impl<N: 'static + Unsigned> arbitrary::Arbitrary<'_> for Bitfield<Variable<N>> {
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
let max_size = N::to_usize();
let rand = usize::arbitrary(u)?;

View File

@@ -280,8 +280,10 @@ where
}
#[cfg(feature = "arbitrary")]
impl<T: arbitrary::Arbitrary, N: 'static + Unsigned> arbitrary::Arbitrary for FixedVector<T, N> {
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
impl<'a, T: arbitrary::Arbitrary<'a>, N: 'static + Unsigned> arbitrary::Arbitrary<'a>
for FixedVector<T, N>
{
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
let size = N::to_usize();
let mut vec: Vec<T> = Vec::with_capacity(size);
for _ in 0..size {

View File

@@ -259,8 +259,10 @@ where
}
#[cfg(feature = "arbitrary")]
impl<T: arbitrary::Arbitrary, N: 'static + Unsigned> arbitrary::Arbitrary for VariableList<T, N> {
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
impl<'a, T: arbitrary::Arbitrary<'a>, N: 'static + Unsigned> arbitrary::Arbitrary<'a>
for VariableList<T, N>
{
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
let max_size = N::to_usize();
let rand = usize::arbitrary(u)?;
let size = std::cmp::min(rand, max_size);

View File

@@ -22,7 +22,7 @@ rayon = "1.4.1"
eth2_hashing = "0.2.0"
int_to_bytes = { path = "../int_to_bytes" }
smallvec = "1.6.1"
arbitrary = { version = "0.4.6", features = ["derive"], optional = true }
arbitrary = { version = "1.0", features = ["derive"], optional = true }
lighthouse_metrics = { path = "../../common/lighthouse_metrics", optional = true }
lazy_static = { version = "1.4.0", optional = true }

View File

@@ -13,7 +13,7 @@ criterion = "0.3.3"
[dependencies]
eth2_hashing = "0.2.0"
ethereum-types = "0.11.0"
ethereum-types = "0.12.1"
[features]
arbitrary = ["ethereum-types/arbitrary"]

View File

@@ -15,7 +15,7 @@ eth2_ssz = "0.4.0"
eth2_ssz_derive = "0.3.0"
[dependencies]
ethereum-types = "0.11.0"
ethereum-types = "0.12.1"
eth2_hashing = "0.2.0"
smallvec = "1.6.1"

View File

@@ -13,7 +13,7 @@ bls = { path = "../../crypto/bls" }
compare_fields = { path = "../../common/compare_fields" }
compare_fields_derive = { path = "../../common/compare_fields_derive" }
eth2_interop_keypairs = { path = "../../common/eth2_interop_keypairs" }
ethereum-types = "0.11.0"
ethereum-types = "0.12.1"
eth2_hashing = "0.2.0"
hex = "0.4.2"
int_to_bytes = { path = "../int_to_bytes" }
@@ -37,7 +37,7 @@ serde_yaml = "0.8.13"
tempfile = "3.1.0"
derivative = "2.1.1"
rusqlite = { version = "0.25.3", features = ["bundled"], optional = true }
arbitrary = { version = "0.4.6", features = ["derive"], optional = true }
arbitrary = { version = "1.0", features = ["derive"], optional = true }
eth2_serde_utils = "0.1.0"
regex = "1.3.9"
lazy_static = "1.4.0"

View File

@@ -327,7 +327,7 @@ pub fn get_active_validator_indices(validators: &[Validator], epoch: Epoch) -> V
}
#[cfg(feature = "arbitrary-fuzz")]
impl arbitrary::Arbitrary for CommitteeCache {
impl arbitrary::Arbitrary<'_> for CommitteeCache {
fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self::default())
}

View File

@@ -62,7 +62,7 @@ impl ExitCache {
}
#[cfg(feature = "arbitrary-fuzz")]
impl arbitrary::Arbitrary for ExitCache {
impl arbitrary::Arbitrary<'_> for ExitCache {
fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self::default())
}

View File

@@ -43,7 +43,7 @@ impl PubkeyCache {
}
#[cfg(feature = "arbitrary-fuzz")]
impl arbitrary::Arbitrary for PubkeyCache {
impl arbitrary::Arbitrary<'_> for PubkeyCache {
fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self::default())
}

View File

@@ -589,7 +589,7 @@ impl OptionalTreeHashCacheInner {
}
#[cfg(feature = "arbitrary-fuzz")]
impl<T: EthSpec> arbitrary::Arbitrary for BeaconTreeHashCache<T> {
impl<T: EthSpec> arbitrary::Arbitrary<'_> for BeaconTreeHashCache<T> {
fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self::default())
}

View File

@@ -20,7 +20,7 @@ pub struct PendingAttestation<T: EthSpec> {
}
#[cfg(feature = "arbitrary-fuzz")]
impl<T: EthSpec> arbitrary::Arbitrary for PendingAttestation<T> {
impl<T: EthSpec> arbitrary::Arbitrary<'_> for PendingAttestation<T> {
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self {
aggregation_bits: <BitList<T::MaxValidatorsPerCommittee>>::arbitrary(u)?,