Merge branch 'unstable' into fix-daily

This commit is contained in:
diegomrsantos 2024-09-05 15:07:17 +02:00 committed by GitHub
commit c7d6513c83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 536 additions and 42 deletions

View File

@ -320,7 +320,7 @@ jobs:
ref: unstable
- name: Download artefacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.7
- name: Create release notes
run: |

View File

@ -349,7 +349,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download artefacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.7
- name: Create release notes
run: |
cat > release_notes.md <<EOF

View File

@ -175,6 +175,19 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ Tail block only in common OK
```
OK: 2/2 Fail: 0/2 Skip: 0/2
## EF - EIP7594 - Networking [Preset: mainnet]
```diff
+ Networking - Get Custody Columns - mainnet/eip7594/networking/get_custody_columns/pyspec_t OK
+ Networking - Get Custody Columns - mainnet/eip7594/networking/get_custody_columns/pyspec_t OK
+ Networking - Get Custody Columns - mainnet/eip7594/networking/get_custody_columns/pyspec_t OK
+ Networking - Get Custody Columns - mainnet/eip7594/networking/get_custody_columns/pyspec_t OK
+ Networking - Get Custody Columns - mainnet/eip7594/networking/get_custody_columns/pyspec_t OK
+ Networking - Get Custody Columns - mainnet/eip7594/networking/get_custody_columns/pyspec_t OK
+ Networking - Get Custody Columns - mainnet/eip7594/networking/get_custody_columns/pyspec_t OK
+ Networking - Get Custody Columns - mainnet/eip7594/networking/get_custody_columns/pyspec_t OK
+ Networking - Get Custody Columns - mainnet/eip7594/networking/get_custody_columns/pyspec_t OK
```
OK: 9/9 Fail: 0/9 Skip: 0/9
## EF - KZG
```diff
+ KZG - Blob to KZG commitment - blob_to_kzg_commitment_case_invalid_blob_59d64ff6b4648fad OK
@ -432,6 +445,66 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
+ KZG - Verify blob KZG proof batch - verify_blob_kzg_proof_batch_case_proof_length_differen OK
```
OK: 253/253 Fail: 0/253 Skip: 0/253
## EF - KZG - EIP7594
```diff
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_invalid_blob_26555bdcbf OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_invalid_blob_79fb3cb1ef OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_invalid_blob_7e99dea889 OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_invalid_blob_9d88c33852 OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_valid_419245fbfe69f145 OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_valid_4aedd1a2a3933c3e OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_valid_6e773f256383918c OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_valid_b0731ef77b166ca8 OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_valid_b81d309b22788820 OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_valid_ed8b5001151417d5 OK
+ KZG - Compute Cells And Proofs - compute_cells_and_kzg_proofs_case_valid_edeb8500a6507818 OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_all_cells_a OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_cell_047ee7 OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_cell_76ab46 OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_cell_77b669 OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_cell_c8e2ca OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_cell_index_ OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_duplicate_c OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_more_cell_i OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_more_cells_ OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_more_cells_ OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_invalid_more_than_h OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_valid_half_missing_ OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_valid_half_missing_ OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_valid_half_missing_ OK
+ KZG - Recover Cells And Kzg Proofs - recover_cells_and_kzg_proofs_case_valid_no_missing_a1 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_incorrect_cell_48bcbf OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_incorrect_commitment_ OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_incorrect_proof_ba29f OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_cell_bcb1b35c OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_cell_d89304ce OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_cell_d939faf6 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_cell_ef6ac828 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_cell_index_5d OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_commitment_4b OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_commitment_53 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_commitment_68 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_commitment_d3 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_missing_cell_ OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_missing_cell_ OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_missing_commi OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_missing_proof OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_proof_0424858 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_proof_48fa9d1 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_proof_8feaf47 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_invalid_proof_a9d14f0 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_0cfba0f22152206 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_3073caf43016db4 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_5211d9e9ff34c00 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_92c0b5242fa34ae OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_9fb9bff6fe1fb6b OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_d3f60d6d484ddb6 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_fd341ee5517e590 OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_multiple_blobs_ OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_same_cell_multi OK
+ KZG - Verify Cell Kzg Proof Batch - verify_cell_kzg_proof_batch_case_valid_zero_cells_fbbd OK
```
OK: 56/56 Fail: 0/56 Skip: 0/56
## EF - SSZ generic types
```diff
Testing basic_vector inputs - invalid Skip
@ -1040,4 +1113,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 9/9 Fail: 0/9 Skip: 0/9
---TOTAL---
OK: 693/698 Fail: 0/698 Skip: 5/698
OK: 758/763 Fail: 0/763 Skip: 5/763

View File

@ -1,3 +1,36 @@
2024-08-29 v24.8.0
==================
Nimbus `v24.8.0` is a `low-urgency` release with beacon API improvements and fixes.
### Improvements
* Increase speed of processing blocks with deposits by 25%:
https://github.com/status-im/nimbus-eth2/pull/6469
* Avoid running light client sync in background when node is synced:
https://github.com/status-im/nimbus-eth2/pull/6505
* Add additional Sepolia bootnode:
https://github.com/status-im/nimbus-eth2/pull/6490
### Fixes
* Add timeouts to failed execution layer requests:
https://github.com/status-im/nimbus-eth2/pull/6441
* Use correct fork digest when broadcasting blob sidecars, sync committee, and sync contribution messages:
https://github.com/status-im/nimbus-eth2/pull/6440
* Fix Holesky genesis state being downloaded multiple times:
https://github.com/status-im/nimbus-eth2/pull/6452
* Check blob versioned hashes when optimistic syncing:
https://github.com/status-im/nimbus-eth2/pull/6501
* Increase trusted node sync state downloading timeout to 120 seconds:
https://github.com/status-im/nimbus-eth2/pull/6487
2024-07-29 v24.7.0
==================

View File

@ -22,7 +22,7 @@ import
eth/p2p/discoveryv5/enr,
json_serialization, web3/[primitives, confutils_defs],
chronos/transports/common,
kzg4844/kzg_ex,
kzg4844/kzg,
./spec/[engine_authentication, keystore, network, crypto],
./spec/datatypes/base,
./networking/network_metadata,
@ -1500,11 +1500,11 @@ proc loadKzgTrustedSetup*(): Result[void, string] =
vendorDir & "/nim-kzg4844/kzg4844/csources/src/trusted_setup.txt")
static: doAssert const_preset in ["mainnet", "gnosis", "minimal"]
Kzg.loadTrustedSetupFromString(trustedSetup)
loadTrustedSetupFromString(trustedSetup, 0)
proc loadKzgTrustedSetup*(trustedSetupPath: string): Result[void, string] =
try:
Kzg.loadTrustedSetupFromString(readFile(trustedSetupPath))
loadTrustedSetupFromString(readFile(trustedSetupPath), 0)
except IOError as err:
err(err.msg)

View File

@ -15,6 +15,7 @@ import
web3, web3/[engine_api, primitives, conversions],
eth/common/eth_types,
results,
kzg4844/[kzg_abi, kzg],
stew/[assign2, byteutils, objects],
# Local modules:
../spec/[eth2_merkleization, forks],

View File

@ -8,6 +8,7 @@
{.push raises: [].}
import
kzg4844/[kzg_abi, kzg],
../spec/datatypes/[bellatrix, capella, deneb, electra],
web3/[engine_api, engine_api_types]

View File

@ -11,6 +11,7 @@ import
# Status
chronicles, chronos, metrics,
results,
kzg4844/[kzg, kzg_abi],
stew/byteutils,
# Internals
../spec/[
@ -458,7 +459,7 @@ proc validateBlobSidecar*(
# [REJECT] The sidecar's blob is valid as verified by `verify_blob_kzg_proof(
# blob_sidecar.blob, blob_sidecar.kzg_commitment, blob_sidecar.kzg_proof)`.
block:
let ok = verifyProof(
let ok = verifyBlobKzgProof(
KzgBlob(bytes: blob_sidecar.blob),
blob_sidecar.kzg_commitment,
blob_sidecar.kzg_proof).valueOr:

View File

@ -0,0 +1,110 @@
# beacon_chain
# Copyright (c) 2022-2024 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [].}
import
std/[sequtils],
"."/[altair, base, deneb],
kzg4844/[kzg, kzg_abi]
from std/strutils import join
export base
const
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/polynomial-commitments-sampling.md#cells
FIELD_ELEMENTS_PER_EXT_BLOB* = 2 * kzg_abi.FIELD_ELEMENTS_PER_BLOB
# Number of field elements in a Reed-Solomon extended blob |
FIELD_ELEMENTS_PER_CELL* = 64 # Number of field elements in a cell |
BYTES_PER_CELL* = FIELD_ELEMENTS_PER_CELL * kzg_abi.BYTES_PER_FIELD_ELEMENT
# The number of bytes in a cell |
CELLS_PER_EXT_BLOB* = FIELD_ELEMENTS_PER_EXT_BLOB div FIELD_ELEMENTS_PER_CELL
# The number of cells in an extended blob |
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/p2p-interface.md#preset
KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH* = 4
type
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/polynomial-commitments-sampling.md#custom-types
BLSFieldElement* = KzgBytes32
G2Point* = array[96, byte]
PolynomialCoeff* = List[BLSFieldElement, FIELD_ELEMENTS_PER_EXT_BLOB]
Coset* = array[FIELD_ELEMENTS_PER_CELL, BLSFieldElement]
CosetEvals* = array[FIELD_ELEMENTS_PER_CELL, BLSFieldElement]
Cell* = KzgCell
Cells* = KzgCells
CellsAndProofs* = KzgCellsAndKzgProofs
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/das-core.md#custom-types
RowIndex* = uint64
ColumnIndex* = uint64
CellIndex* = uint64
const
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/das-core.md#data-size
NUMBER_OF_COLUMNS* = 128
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/das-core.md#networking
DATA_COLUMN_SIDECAR_SUBNET_COUNT* = 128
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/das-core.md#custody-setting
SAMPLES_PER_SLOT* = 8
CUSTODY_REQUIREMENT* = 4
type
DataColumn* = List[KzgCell, Limit(MAX_BLOB_COMMITMENTS_PER_BLOCK)]
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/das-core.md#datacolumnsidecar
DataColumnSidecar* = object
index*: ColumnIndex # Index of column in extended matrix
column*: DataColumn
kzg_commitments*: KzgCommitments
kzg_proofs*: KzgProofs
signed_block_header*: SignedBeaconBlockHeader
kzg_commitments_inclusion_proof*:
array[KZG_COMMITMENTS_INCLUSION_PROOF_DEPTH, Eth2Digest]
DataColumnSidecars* = seq[ref DataColumnSidecar]
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/p2p-interface.md#datacolumnidentifier
DataColumnIdentifier* = object
block_root*: Eth2Digest
index*: ColumnIndex
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/das-core.md#matrixentry
MatrixEntry* = object
cell*: Cell
kzg_proof*: KzgProof
column_index*: ColumnIndex
row_index*: RowIndex
# Not in spec, defined in order to compute custody subnets
CscBits* = BitArray[DATA_COLUMN_SIDECAR_SUBNET_COUNT]
CscCount* = uint8
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/p2p-interface.md#metadata
MetaData* = object
seq_number*: uint64
attnets*: AttnetBits
syncnets*: SyncnetBits
custody_subnet_count*: CscCount
func shortLog*(v: DataColumnSidecar): auto =
(
index: v.index,
kzg_commitments: v.kzg_commitments.len,
kzg_proofs: v.kzg_proofs.len,
block_header: shortLog(v.signed_block_header.message),
)
func shortLog*(v: seq[DataColumnSidecar]): auto =
"[" & v.mapIt(shortLog(it)).join(", ") & "]"
func shortLog*(x: seq[DataColumnIdentifier]): string =
"[" & x.mapIt(shortLog(it.block_root) & "/" & $it.index).join(", ") & "]"

View File

@ -0,0 +1,105 @@
# beacon_chain
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [].}
# Uncategorized helper functions from the spec
import
std/[algorithm, hashes],
results,
eth/p2p/discoveryv5/[node],
./[helpers, digest],
./datatypes/[eip7594]
proc sortedColumnIndices*(columnsPerSubnet: ColumnIndex,
subnetIds: HashSet[uint64]):
seq[ColumnIndex] =
var res: seq[ColumnIndex] = @[]
for i in 0'u64 ..< columnsPerSubnet:
for subnetId in subnetIds:
let index = DATA_COLUMN_SIDECAR_SUBNET_COUNT * i + subnetId
res.add(ColumnIndex(index))
res.sort
res
proc sortedColumnIndexList*(columnsPerSubnet: ColumnIndex,
subnetIds: HashSet[uint64]):
List[ColumnIndex, NUMBER_OF_COLUMNS] =
var
res: seq[ColumnIndex]
for i in 0'u64 ..< columnsPerSubnet:
for subnetId in subnetIds:
let index = DATA_COLUMN_SIDECAR_SUBNET_COUNT * i + subnetId
res.add(ColumnIndex(index))
res.sort()
let list = List[ColumnIndex, NUMBER_OF_COLUMNS].init(res)
list
proc get_custody_column_subnets*(node_id: NodeId,
custody_subnet_count: uint64):
Result[HashSet[uint64], cstring] =
# Decouples the custody subnet computation part from
# `get_custody_columns`, in order to later use this subnet list
# in order to maintain subscription to specific column subnets.
if not (custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT):
return err("Eip7594: Custody subnet count exceeds the DATA_COLUMN_SIDECAR_SUBNET_COUNT")
var
subnet_ids: HashSet[uint64]
current_id = node_id
while subnet_ids.lenu64 < custody_subnet_count:
var
hashed_bytes: array[8, byte]
let
current_id_bytes = current_id.toBytesLE()
hashed_current_id = eth2digest(current_id_bytes)
hashed_bytes[0..7] = hashed_current_id.data.toOpenArray(0,7)
let subnet_id = bytes_to_uint64(hashed_bytes) mod
DATA_COLUMN_SIDECAR_SUBNET_COUNT
subnet_ids.incl(subnet_id)
if current_id == UInt256.high.NodeId:
# Overflow prevention
current_id = NodeId(StUint[256].zero)
current_id += NodeId(StUint[256].one)
ok(subnet_ids)
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/das-core.md#get_custody_columns
proc get_custody_columns*(node_id: NodeId,
custody_subnet_count: uint64):
seq[ColumnIndex] =
let
subnet_ids =
get_custody_column_subnets(node_id, custody_subnet_count).get
const
columns_per_subnet =
NUMBER_OF_COLUMNS div DATA_COLUMN_SIDECAR_SUBNET_COUNT
sortedColumnIndices(ColumnIndex(columns_per_subnet), subnet_ids)
proc get_custody_column_list*(node_id: NodeId,
custody_subnet_count: uint64):
List[ColumnIndex, NUMBER_OF_COLUMNS] =
# Not in spec in the exact format, but it is useful in sorting custody columns
# before sending, data_column_sidecars_by_range requests
let
subnet_ids =
get_custody_column_subnets(node_id, custody_subnet_count).get
const
columns_per_subnet =
NUMBER_OF_COLUMNS div DATA_COLUMN_SIDECAR_SUBNET_COUNT
sortedColumnIndexList(ColumnIndex(columns_per_subnet), subnet_ids)

View File

@ -14,13 +14,8 @@ import
func readExecutionTransaction(
txBytes: bellatrix.Transaction): Result[ExecutionTransaction, string] =
# Nim 2.0.8: `rlp.decode(distinctBase(txBytes), ExecutionTransaction)`
# uses the generic `read` from `rlp.nim` instead of the specific `read`
# from `eth_types_rlp.nim`, leading to compilation error.
# Doing this in two steps works around this resolution order issue.
var rlp = rlpFromBytes(distinctBase(txBytes))
try:
ok rlp.read(ExecutionTransaction)
ok rlp.decode(distinctBase(txBytes), ExecutionTransaction)
except RlpError as exc:
err("Invalid transaction: " & exc.msg)

View File

@ -29,7 +29,7 @@ import
../extras,
./datatypes/[phase0, altair, bellatrix, deneb],
"."/[beaconstate, eth2_merkleization, helpers, validator, signatures],
kzg4844/kzg_abi, kzg4844/kzg_ex
kzg4844/kzg_abi, kzg4844/kzg
from std/algorithm import fill, sorted
from std/sequtils import count, filterIt, mapIt
@ -1083,7 +1083,7 @@ func kzg_commitment_to_versioned_hash*(
proc validate_blobs*(
expected_kzg_commitments: seq[KzgCommitment], blobs: seq[KzgBlob],
proofs: seq[KzgProof]): Result[void, string] =
let res = verifyProofs(blobs, expected_kzg_commitments, proofs).valueOr:
let res = verifyBlobKzgProofBatch(blobs, expected_kzg_commitments, proofs).valueOr:
return err("validate_blobs proof verification error: " & error())
if not res:

View File

@ -128,7 +128,7 @@ proc unblindAndRouteBlockMEV*(
if blindedBlock.message.body.blob_kzg_commitments !=
bundle.data.blobs_bundle.commitments:
return err("unblinded blobs bundle has unexpected commitments")
let ok = verifyProofs(
let ok = verifyBlobKzgProofBatch(
blobs_bundle.blobs.mapIt(KzgBlob(bytes: it)),
asSeq blobs_bundle.commitments,
asSeq blobs_bundle.proofs).valueOr:

View File

@ -18,7 +18,7 @@ const
"Copyright (c) 2019-" & compileYear & " Status Research & Development GmbH"
versionMajor* = 24
versionMinor* = 7
versionMinor* = 8
versionBuild* = 0
versionBlob* = "stateofus" # Single word - ends up in the default graffiti

View File

@ -32,7 +32,7 @@ When building from source, you will need additional build dependencies to be ins
dnf install @development-tools cmake
# Arch Linux, using an AUR manager
yourAURmanager -S base-devel cmake
yourAURmanager -S base-devel git-lfs cmake
```
=== "macOS"

5
funding.json Normal file
View File

@ -0,0 +1,5 @@
{
"opRetro": {
"projectId": "0xe346264e87202b47f1057eb0b0fcaa0ea7f83e14507ca4585a91a5d94e0e92c0"
}
}

View File

@ -15,4 +15,5 @@
import
./test_fixture_kzg,
./test_fixture_networking,
./test_fixture_ssz_generic_types

View File

@ -11,7 +11,7 @@
import
std/json,
yaml/tojson,
kzg4844/kzg_ex,
kzg4844/[kzg, kzg_abi],
stew/byteutils,
../testutil,
./fixtures_utils, ./os_ops
@ -19,6 +19,14 @@ import
from std/sequtils import anyIt, mapIt, toSeq
from std/strutils import rsplit
func toUInt64(s: int): Opt[uint64] =
if s < 0:
return Opt.none uint64
try:
Opt.some uint64(s)
except ValueError:
Opt.none uint64
func fromHex[N: static int](s: string): Opt[array[N, byte]] =
if s.len != 2*(N+1):
# 0x prefix
@ -31,9 +39,9 @@ func fromHex[N: static int](s: string): Opt[array[N, byte]] =
block:
template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0]
doAssert Kzg.loadTrustedSetup(
doAssert loadTrustedSetup(
sourceDir &
"/../../vendor/nim-kzg4844/kzg4844/csources/src/trusted_setup.txt").isOk
"/../../vendor/nim-kzg4844/kzg4844/csources/src/trusted_setup.txt", 0).isOk
proc runBlobToKzgCommitmentTest(suiteName, suitePath, path: string) =
let relativePathComponent = path.relativeTestPathComponent(suitePath)
@ -75,7 +83,7 @@ proc runVerifyKzgProofTest(suiteName, suitePath, path: string) =
if commitment.isNone or z.isNone or y.isNone or proof.isNone:
check output.kind == JNull
else:
let v = verifyProof(
let v = verifyKzgProof(
KzgCommitment(bytes: commitment.get),
KzgBytes32(bytes: z.get), KzgBytes32(bytes: y.get),
KzgBytes48(bytes: proof.get))
@ -193,9 +201,93 @@ proc runComputeBlobKzgProofTest(suiteName, suitePath, path: string) =
else:
check p.get.bytes == fromHex[48](output.getStr).get
proc runComputeCellsAndKzgProofsTest(suiteName, suitePath, path: string) =
let relativePathComponent = path.relativeTestPathComponent(suitePath)
test "KZG - Compute Cells And Proofs - " & relativePathComponent:
let
data = loadToJson(os_ops.readFile(path/"data.yaml"))[0]
output = data["output"]
blob = fromHex[131072](data["input"]["blob"].getStr)
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/tests/formats/kzg_7594/verify_cell_kzg_proof.md#condition
# If the blob is invalid (e.g. incorrect length or one of the 32-byte
# blocks does not represent a BLS field element) it should error, i.e. the
# the output should be `null`.
if blob.isNone:
check output.kind == JNull
else:
let p = newClone computeCellsAndKzgProofs(KzgBlob(bytes: blob.get))
if p[].isErr:
check output.kind == JNull
else:
let p_val = p[].get
for i in 0..<CELLS_PER_EXT_BLOB:
check p_val.cells[i].bytes == fromHex[2048](output[0][i].getStr).get
check p_val.proofs[i].bytes == fromHex[48](output[1][i].getStr).get
proc runVerifyCellKzgProofBatchTest(suiteName, suitePath, path: string) =
let relativePathCompnent = path.relativeTestPathComponent(suitePath)
test "KZG - Verify Cell Kzg Proof Batch - " & relativePathCompnent:
let
data = loadToJson(os_ops.readFile(path/"data.yaml"))[0]
output = data["output"]
commitments = data["input"]["commitments"].mapIt(fromHex[48](it.getStr))
cell_indices = data["input"]["cell_indices"].mapIt(toUInt64(it.getInt))
cells = data["input"]["cells"].mapIt(fromHex[2048](it.getStr))
proofs = data["input"]["proofs"].mapIt(fromHex[48](it.getStr))
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/tests/formats/kzg_7594/verify_cell_kzg_proof_batch.md#condition
# If the blob is invalid (e.g. incorrect length or one of the 32-byte
# blocks does not represent a BLS field element) it should error, i.e. the
# the output should be `null`.
if commitments.anyIt(it.isNone) or
cell_indices.anyIt(it.isNone) or
proofs.anyIt(it.isNone) or
cells.anyIt(it.isNone):
check output.kind == JNull
else:
let v = newClone verifyCellKzgProofBatch(
commitments.mapIt(KzgCommitment(bytes: it.get)),
cell_indices.mapIt(it.get),
cells.mapIt(KzgCell(bytes: it.get)),
proofs.mapIt(KzgBytes48(bytes: it.get))
)
check:
if v[].isErr:
output.kind == JNull
else:
v[].get == output.getBool
proc runRecoverCellsAndKzgProofsTest(suiteName, suitePath, path: string) =
let relativePathComponent = path.relativeTestPathComponent(suitePath)
test "KZG - Recover Cells And Kzg Proofs - " & relativePathComponent:
let
data = loadToJson(os_ops.readFile(path/"data.yaml"))[0]
output = data["output"]
cell_ids = data["input"]["cell_indices"].mapIt(toUInt64(it.getInt))
cells = data["input"]["cells"].mapIt(fromHex[2048](it.getStr))
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5 /tests/formats/kzg_7594/recover_all_cells.md#condition
# If the blob is invalid (e.g. incorrect length or one of the 32-byte
# blocks does not represent a BLS field element) it should error, i.e. the
# the output should be `null`.
if cell_ids.anyIt(it.isNone) or
cells.anyIt(it.isNone):
check output.kind == JNull
else:
let v = newClone recoverCellsAndKzgProofs(
cell_ids.mapIt(it.get),
cells.mapIt(KzgCell(bytes: it.get)))
if v[].isErr:
check output.kind == JNull
else:
let val = v[].get
for i in 0..<CELLS_PER_EXT_BLOB:
check val.cells[i].bytes == fromHex[2048](output[0][i].getStr).get
check val.proofs[i].bytes == fromHex[48](output[1][i].getStr).get
from std/algorithm import sorted
const suiteName = "EF - KZG"
var suiteName = "EF - KZG"
suite suiteName:
const suitePath = SszTestsDir/"general"/"deneb"/"kzg"
@ -237,4 +329,30 @@ suite suiteName:
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
runComputeBlobKzgProofTest(suiteName, testsDir, testsDir / path)
doAssert Kzg.freeTrustedSetup().isOk
suiteName = "EF - KZG - EIP7594"
suite suiteName:
const suitePath = SszTestsDir/"general"/"eip7594"/"kzg"
# TODO also check that the only direct subdirectory of each is kzg-mainnet
doAssert sorted(mapIt(
toSeq(walkDir(suitePath, relative = true, checkDir = true)), it.path)) ==
["compute_cells_and_kzg_proofs", "recover_cells_and_kzg_proofs",
"verify_cell_kzg_proof_batch"]
block:
let testsDir = suitePath/"compute_cells_and_kzg_proofs"/"kzg-mainnet"
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
runComputeCellsAndKzgProofsTest(suiteName, testsDir, testsDir/path)
block:
let testsDir = suitePath/"recover_cells_and_kzg_proofs"/"kzg-mainnet"
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
runRecoverCellsAndKzgProofsTest(suiteName, testsDir, testsDir/path)
block:
let testsDir = suitePath/"verify_cell_kzg_proof_batch"/"kzg-mainnet"
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
runVerifyCellKzgProofBatchTest(suiteName, testsDir, testsDir/path)
doAssert freeTrustedSetup().isOk

View File

@ -0,0 +1,51 @@
# beacon_chain
# Copyright (c) 2024 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [].}
{.used.}
import
std/[json, streams],
yaml,
kzg4844/[kzg, kzg_abi],
stint,
eth/p2p/discoveryv5/[node],
../../beacon_chain/spec/eip7594_helpers,
../testutil,
./fixtures_utils, ./os_ops
from std/sequtils import mapIt
proc runGetCustodyColumns(suiteName, path: string) =
let relativePathComponent = path.relativeTestPathComponent()
test "Networking - Get Custody Columns - " & relativePathComponent:
type TestMetaYaml = object
node_id: string
custody_subnet_count: uint64
result: seq[uint64]
let
meta = block:
var s = openFileStream(path/"meta.yaml")
defer: close(s)
var res: TestMetaYaml
yaml.load(s, res)
res
node_id = UInt256.fromDecimal(meta.node_id)
custody_subnet_count = meta.custody_subnet_count
reslt = (meta.result).mapIt(it)
let columns = get_custody_columns(node_id, custody_subnet_count)
for i in 0..<columns.lenu64:
check columns[i] == reslt[i]
suite "EF - EIP7594 - Networking" & preset():
const presetPath = SszTestsDir/const_preset
let basePath =
presetPath/"eip7594"/"networking"/"get_custody_columns"/"pyspec_tests"
for kind, path in walkDir(basePath, relative = true, checkDir = true):
runGetCustodyColumns(suiteName, basePath/path)

2
vendor/holesky vendored

@ -1 +1 @@
Subproject commit 874c199423ccd180607320c38cbaca05d9a1573a
Subproject commit e7fdf62fc0e59434d9d3155d8ad6ed06bcfa0dde

2
vendor/nim-blscurve vendored

@ -1 +1 @@
Subproject commit d5d595a59ca906898c51af7f9511a01082435393
Subproject commit 72d1980c8770ed2e6fb30c7f297b835d43aa925d

@ -1 +1 @@
Subproject commit 33761a5f77610d3f87f774244490eae43a9ac5a1
Subproject commit a28bb9781ce74e725796c307ad05083e646872be

2
vendor/nim-chronos vendored

@ -1 +1 @@
Subproject commit dc3847e4d6733dfc3811454c2a9c384b87343e26
Subproject commit c04576d829b8a0a1b12baaa8bc92037501b3a4a0

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit cc6d88962e4a22170361b576534246bd57974d80
Subproject commit f2568a64c0933c3a0bf959568df400cb1d16c2bf

@ -1 +1 @@
Subproject commit 98496aa24d9364d1652e531f5f346de9b7cb3e15
Subproject commit 8b88ad6dd9a6326c29f82067800c483d9410d873

@ -1 +1 @@
Subproject commit 89f7be1783b2f828a95dea1496fdac3510532997
Subproject commit 8a4ed98bbd0a9479df15af2fa31da38a586ea6d5

2
vendor/nim-kzg4844 vendored

@ -1 +1 @@
Subproject commit 7bd7f115db8983be2549ce1a55891355c404fdc0
Subproject commit 76ffb3b39610adde23f0c70faba3553272c9791d

@ -1 +1 @@
Subproject commit 55780313446b618cd226025cd0383c4c9da4a18a
Subproject commit b6e26f03c091a8e3bba6adc06198fc3055bacc66

2
vendor/nim-libp2p vendored

@ -1 +1 @@
Subproject commit b5fb7b3a97d8977d969d786633f70c4094cd0eaf
Subproject commit 18a2e79ce209d2f21d8c5db7a41659cc39dbe0b4

2
vendor/nim-metrics vendored

@ -1 +1 @@
Subproject commit 4337ccd62c0b7d57492402dd4cb838ddc0c78a84
Subproject commit 29bb7ba63cd884770169891687595348a70cf166

@ -1 +1 @@
Subproject commit 9c7dc8c58ff9c3dfb11c2d333171b47659ed824c
Subproject commit a3aa0c5f9d2a2870f1fd0f7a613d4fe025c84ab7

@ -1 +1 @@
Subproject commit 331d1a252f309f5d0813f7cdbabafc15606369a2
Subproject commit e9ece052e0e4c6e003994e5c3e826d9ed0d8db29

2
vendor/nim-results vendored

@ -1 +1 @@
Subproject commit 410afe8acdda0b746582883e951243b6652dee3c
Subproject commit 71d404b314479a6205bfd050f4fe5fe49cdafc69

@ -1 +1 @@
Subproject commit 6f831b79df24af00c10e73e717cbe40d7d0e2439
Subproject commit b5aa78cae197cc97277be050ba69ef9c5d33aad1

2
vendor/nim-stew vendored

@ -1 +1 @@
Subproject commit af07b0a70dbd5528cbca9d944b0aa8b7bea92963
Subproject commit d4634c5405ac188e7050d348332edb6c3b09a527

@ -1 +1 @@
Subproject commit e96f3215030cbfa13abc2f5827069b6f8ba87e38
Subproject commit 36c714fb3ddcf9e63b8772296dede80a788d81b7

2
vendor/sepolia vendored

@ -1 +1 @@
Subproject commit b97e62eee42362d7f85f7167ddfa19fe3635562d
Subproject commit 0f71ae1b5ca38c565358f5251bc1a2314ba5edc7