Migrate derivative to educe (#8125)

Fixes #7001.


  Mostly mechanical replacement of `derivative` attributes with `educe` ones.

### **Attribute Syntax Changes**

```rust
// Bounds: = "..." → (...)
#[derivative(Hash(bound = "E: EthSpec"))]
#[educe(Hash(bound(E: EthSpec)))]

// Ignore: = "ignore" → (ignore)
#[derivative(PartialEq = "ignore")]
#[educe(PartialEq(ignore))]

// Default values: value = "..." → expression = ...
#[derivative(Default(value = "ForkName::Base"))]
#[educe(Default(expression = ForkName::Base))]

// Methods: format_with/compare_with = "..." → method(...)
#[derivative(Debug(format_with = "fmt_peer_set_as_len"))]
#[educe(Debug(method(fmt_peer_set_as_len)))]

// Empty bounds: removed entirely, educe can infer appropriate bounds
#[derivative(Default(bound = ""))]
#[educe(Default)]

// Transparent debug: manual implementation (educe doesn't support it)
#[derivative(Debug = "transparent")]
// Replaced with manual Debug impl that delegates to inner field
```

**Note**: Some bounds use strings (`bound("E: EthSpec")`) for superstruct compatibility (`expected ','` errors).


Co-Authored-By: Javier Chávarri <javier.chavarri@gmail.com>

Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
Javier Chávarri
2025-11-06 15:13:57 +01:00
committed by GitHub
parent 0090b35ee0
commit 2c1f1c1605
56 changed files with 277 additions and 287 deletions

View File

@@ -1,4 +1,4 @@
use derivative::Derivative;
use educe::Educe;
use smallvec::{SmallVec, smallvec};
use state_processing::{SigVerifiedOp, TransformPersist, VerifyOperation, VerifyOperationAt};
use std::collections::HashSet;
@@ -14,8 +14,8 @@ pub const SMALL_VEC_SIZE: usize = 8;
/// Stateful tracker for exit/slashing operations seen on the network.
///
/// Implements the conditions for gossip verification of exits and slashings from the P2P spec.
#[derive(Debug, Derivative)]
#[derivative(Default(bound = "T: ObservableOperation<E>, E: EthSpec"))]
#[derive(Debug, Educe)]
#[educe(Default(bound(T: ObservableOperation<E>, E: EthSpec)))]
pub struct ObservedOperations<T: ObservableOperation<E>, E: EthSpec> {
/// Indices of validators for whom we have already seen an instance of an operation `T`.
///
@@ -26,7 +26,7 @@ pub struct ObservedOperations<T: ObservableOperation<E>, E: EthSpec> {
/// `attestation_1.attester_indices` and `attestation_2.attester_indices`.
observed_validator_indices: HashSet<u64>,
/// The name of the current fork. The default will be overwritten on first use.
#[derivative(Default(value = "ForkName::Base"))]
#[educe(Default(expression = ForkName::Base))]
current_fork: ForkName,
_phantom: PhantomData<(T, E)>,
}