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

@@ -20,7 +20,7 @@ portable = ["bls/supranational-portable"]
[dependencies]
arbitrary = { workspace = true }
bls = { workspace = true }
derivative = { workspace = true }
educe = { workspace = true }
ethereum_hashing = { workspace = true }
ethereum_ssz = { workspace = true }
ethereum_ssz_derive = { workspace = true }

View File

@@ -8,7 +8,7 @@ use crate::per_block_processing::{
verify_proposer_slashing,
};
use arbitrary::Arbitrary;
use derivative::Derivative;
use educe::Educe;
use smallvec::{SmallVec, smallvec};
use ssz::{Decode, Encode};
use ssz_derive::{Decode, Encode};
@@ -39,11 +39,11 @@ pub trait TransformPersist {
///
/// The inner `op` field is private, meaning instances of this type can only be constructed
/// by calling `validate`.
#[derive(Derivative, Debug, Clone, Arbitrary)]
#[derivative(
#[derive(Educe, Debug, Clone, Arbitrary)]
#[educe(
PartialEq,
Eq,
Hash(bound = "T: TransformPersist + std::hash::Hash, E: EthSpec")
Hash(bound(T: TransformPersist + std::hash::Hash, E: EthSpec))
)]
#[arbitrary(bound = "T: TransformPersist + Arbitrary<'arbitrary>, E: EthSpec")]
pub struct SigVerifiedOp<T: TransformPersist, E: EthSpec> {