Upgrade to c-kzg 2.1.0 and alloy-primitives 1.0 (#7271)

Update `c-kzg` from `v1` to `v2`. My motivation here is that `alloy-consensus` now uses `c-kzg` in `v2` and this results in a conflict when using lighthouse in combination with latest alloy. I tried also to disable the `czkg` feature in alloy, but the conflict persisted.

See here for the alloy update to `c-kzg v2`:  https://github.com/alloy-rs/alloy/pull/2240

Error:
```
error: failed to select a version for `c-kzg`.
...
versions that meet the requirements `^1` are: 1.0.3, 1.0.2, 1.0.0

the package `c-kzg` links to the native library `ckzg`, but it conflicts with a previous package which links to `ckzg` as well:
package `c-kzg v2.1.0`
... which satisfies dependency `c-kzg = "^2.1"` of package `alloy-consensus v0.13.0`
... which satisfies dependency `alloy-consensus = "^0.13.0"` of package ...
...
```


  - Upgrade `alloy-consensus` to `0.14.0` and disable all default features
- Upgrade `c-kzg` to `v2.1.0`
- Upgrade `alloy-primitives` to `1.0.0`
- Adapt the code to the new API `c-kzg`
- There is now `NO_PRECOMPUTE` as my understand from https://github.com/ethereum/c-kzg-4844/pull/545/files we should use `0` here as `new_from_trusted_setup_no_precomp` does not precomp. But maybe it is misleading. For all other places I used `RECOMMENDED_PRECOMP_WIDTH` because `8` is matching the recommendation.
- `BYTES_PER_G1_POINT` and `BYTES_PER_G2_POINT` are no longer public in `c-kzg`
- I adapted two tests that checking for the `Attestation`  bitfield size. But I could not pinpoint to what has changed and why now 8 bytes less. I would be happy about any hint, and if this is correct. I found related a PR here: https://github.com/sigp/lighthouse/pull/6915
- Use same fields names, in json, as well as `c-kzg` and `rust_eth_kzg` for `g1_monomial`, `g1_lagrange`, and `g2_monomial`
This commit is contained in:
cakevm
2025-07-09 07:02:41 +02:00
committed by GitHub
parent b9c1a2b0c0
commit 734ad90dd8
8 changed files with 650 additions and 520 deletions

View File

@@ -98,8 +98,8 @@ edition = "2021"
[workspace.dependencies]
account_utils = { path = "common/account_utils" }
alloy-consensus = "0.3.0"
alloy-primitives = { version = "0.8", features = ["rlp", "getrandom"] }
alloy-consensus = { version = "0.14.0", default-features = false }
alloy-primitives = { version = "1.0", features = ["rlp", "getrandom"] }
alloy-rlp = "0.3.4"
anyhow = "1"
arbitrary = { version = "1", features = ["derive"] }
@@ -116,7 +116,7 @@ byteorder = "1"
bytes = "1"
# Turn off c-kzg's default features which include `blst/portable`. We can turn on blst's portable
# feature ourselves when desired.
c-kzg = { version = "1", default-features = false }
c-kzg = { version = "2.1.0", default-features = false }
cargo_metadata = "0.19"
clap = { version = "4.5.4", features = ["derive", "cargo", "wrap_help"] }
clap_utils = { path = "common/clap_utils" }
@@ -143,9 +143,9 @@ eth2_keystore = { path = "crypto/eth2_keystore" }
eth2_network_config = { path = "common/eth2_network_config" }
eth2_wallet = { path = "crypto/eth2_wallet" }
ethereum_hashing = "0.7.0"
ethereum_serde_utils = "0.7"
ethereum_ssz = "0.8.2"
ethereum_ssz_derive = "0.8.2"
ethereum_serde_utils = "0.8.0"
ethereum_ssz = "0.9.0"
ethereum_ssz_derive = "0.9.0"
ethers-core = "1"
ethers-middleware = { version = "1", default-features = false }
ethers-providers = { version = "1", default-features = false }
@@ -184,7 +184,7 @@ malloc_utils = { path = "common/malloc_utils" }
maplit = "1"
merkle_proof = { path = "consensus/merkle_proof" }
metrics = { path = "common/metrics" }
milhouse = "0.5"
milhouse = "0.6"
mockall = "0.13"
mockall_double = "0.3"
mockito = "1.5.0"
@@ -230,7 +230,7 @@ slashing_protection = { path = "validator_client/slashing_protection" }
slot_clock = { path = "common/slot_clock" }
smallvec = { version = "1.11.2", features = ["arbitrary"] }
snap = "1"
ssz_types = "0.10"
ssz_types = "0.11.0"
state_processing = { path = "consensus/state_processing" }
store = { path = "beacon_node/store" }
strum = { version = "0.24", features = ["derive"] }
@@ -254,8 +254,8 @@ tracing-appender = "0.2"
tracing-core = "0.1"
tracing-log = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
tree_hash = "0.9"
tree_hash_derive = "0.9"
tree_hash = "0.10.0"
tree_hash_derive = "0.10.0"
types = { path = "consensus/types" }
unused_port = { path = "common/unused_port" }
url = "2"