Skip to content

Commit

Permalink
Merge branch 'dev' into kw/add-eip7594-to-pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed Apr 29, 2024
2 parents cac9ebc + 186c943 commit 1cd63df
Show file tree
Hide file tree
Showing 31 changed files with 717 additions and 372 deletions.
9 changes: 4 additions & 5 deletions configs/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ DENEB_FORK_VERSION: 0x04000000
DENEB_FORK_EPOCH: 269568 # March 13, 2024, 01:55:35pm UTC
# Electra
ELECTRA_FORK_VERSION: 0x05000000
ELECTRA_FORK_EPOCH: 18446744073709551615
ELECTRA_FORK_EPOCH: 18446744073709551615 # temporary stub
# EIP7594
EIP7594_FORK_VERSION: 0x06000000 # temporary stub
EIP7594_FORK_EPOCH: 18446744073709551615
# WHISK
WHISK_FORK_VERSION: 0x08000000 # temporary stub
WHISK_FORK_EPOCH: 18446744073709551615
# EIP7594
EIP7594_FORK_VERSION: 0x06000001
EIP7594_FORK_EPOCH: 18446744073709551615


# Time parameters
# ---------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions configs/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ DENEB_FORK_EPOCH: 18446744073709551615
# Electra
ELECTRA_FORK_VERSION: 0x05000001
ELECTRA_FORK_EPOCH: 18446744073709551615
# WHISK
WHISK_FORK_VERSION: 0x08000001
WHISK_FORK_EPOCH: 18446744073709551615
# EIP7594
EIP7594_FORK_VERSION: 0x06000001
EIP7594_FORK_EPOCH: 18446744073709551615
# WHISK
WHISK_FORK_VERSION: 0x08000001
WHISK_FORK_EPOCH: 18446744073709551615

# Time parameters
# ---------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion specs/_features/eip7594/das-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def get_data_column_sidecars(signed_block: SignedBeaconBlock,
block.body,
get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'),
)
cells_and_proofs = [compute_cells_and_proofs(blob) for blob in blobs]
cells_and_proofs = [compute_cells_and_kzg_proofs(blob) for blob in blobs]
blob_count = len(blobs)
cells = [cells_and_proofs[i][0] for i in range(blob_count)]
proofs = [cells_and_proofs[i][1] for i in range(blob_count)]
Expand Down
2 changes: 1 addition & 1 deletion specs/_features/eip7594/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Warning: this configuration is not definitive.

| Name | Value |
| - | - |
| `EIP7594_FORK_VERSION` | `Version('0x05000000')` |
| `EIP7594_FORK_VERSION` | `Version('0x06000000')` |
| `EIP7594_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** |

## Helper functions
Expand Down
4 changes: 2 additions & 2 deletions specs/_features/eip7594/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def verify_data_column_sidecar_kzg_proofs(sidecar: DataColumnSidecar) -> bool:
row_ids = [RowIndex(i) for i in range(len(sidecar.column))]

# KZG batch verifies that the cells match the corresponding commitments and proofs
return verify_cell_proof_batch(
row_commitments_bytes=sidecar.kzg_commitments,
return verify_cell_kzg_proof_batch(
row_commitments=sidecar.kzg_commitments,
row_indices=row_ids, # all rows
column_indices=[sidecar.index],
cells=sidecar.column,
Expand Down
32 changes: 16 additions & 16 deletions specs/_features/eip7594/polynomial-commitments-sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
- [`coset_for_cell`](#coset_for_cell)
- [Cells](#cells-1)
- [Cell computation](#cell-computation)
- [`compute_cells_and_proofs`](#compute_cells_and_proofs)
- [`compute_cells_and_kzg_proofs`](#compute_cells_and_kzg_proofs)
- [`compute_cells`](#compute_cells)
- [Cell verification](#cell-verification)
- [`verify_cell_proof`](#verify_cell_proof)
- [`verify_cell_proof_batch`](#verify_cell_proof_batch)
- [`verify_cell_kzg_proof`](#verify_cell_kzg_proof)
- [`verify_cell_kzg_proof_batch`](#verify_cell_kzg_proof_batch)
- [Reconstruction](#reconstruction)
- [`construct_vanishing_polynomial`](#construct_vanishing_polynomial)
- [`recover_shifted_data`](#recover_shifted_data)
Expand Down Expand Up @@ -423,10 +423,10 @@ def coset_for_cell(cell_id: CellID) -> Coset:

### Cell computation

#### `compute_cells_and_proofs`
#### `compute_cells_and_kzg_proofs`

```python
def compute_cells_and_proofs(blob: Blob) -> Tuple[
def compute_cells_and_kzg_proofs(blob: Blob) -> Tuple[
Vector[Cell, CELLS_PER_EXT_BLOB],
Vector[KZGProof, CELLS_PER_EXT_BLOB]]:
"""
Expand Down Expand Up @@ -481,13 +481,13 @@ def compute_cells(blob: Blob) -> Vector[Cell, CELLS_PER_EXT_BLOB]:

### Cell verification

#### `verify_cell_proof`
#### `verify_cell_kzg_proof`

```python
def verify_cell_proof(commitment_bytes: Bytes48,
cell_id: CellID,
cell: Cell,
proof_bytes: Bytes48) -> bool:
def verify_cell_kzg_proof(commitment_bytes: Bytes48,
cell_id: CellID,
cell: Cell,
proof_bytes: Bytes48) -> bool:
"""
Check a cell proof
Expand All @@ -507,14 +507,14 @@ def verify_cell_proof(commitment_bytes: Bytes48,
bytes_to_kzg_proof(proof_bytes))
```

#### `verify_cell_proof_batch`
#### `verify_cell_kzg_proof_batch`

```python
def verify_cell_proof_batch(row_commitments_bytes: Sequence[Bytes48],
row_indices: Sequence[RowIndex],
column_indices: Sequence[ColumnIndex],
cells: Sequence[Cell],
proofs_bytes: Sequence[Bytes48]) -> bool:
def verify_cell_kzg_proof_batch(row_commitments_bytes: Sequence[Bytes48],
row_indices: Sequence[RowIndex],
column_indices: Sequence[ColumnIndex],
cells: Sequence[Cell],
proofs_bytes: Sequence[Bytes48]) -> bool:
"""
Verify a set of cells, given their corresponding proofs and their coordinates (row_id, column_id) in the blob
matrix. The list of all commitments is also provided in row_commitments_bytes.
Expand Down
2 changes: 1 addition & 1 deletion specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class PendingPartialWithdrawal(Container):
```
#### `ExecutionLayerWithdrawalRequest`

*Note*: The container is new in EIP7251.
*Note*: The container is new in EIP7251:EIP7002.

```python
class ExecutionLayerWithdrawalRequest(Container):
Expand Down
2 changes: 1 addition & 1 deletion tests/core/pyspec/eth2spec/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0-alpha.0
1.5.0-alpha.1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_provider(create_provider_fn: Callable[[SpecForkName, PresetBaseName, str

def get_create_provider_fn(runner_name: str) -> Callable[[SpecForkName, str, str, PresetBaseName], TestProvider]:
def prepare_fn() -> None:
bls.use_milagro()
bls.use_fastest()
return

def create_provider(fork_name: SpecForkName, preset_name: PresetBaseName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,26 +338,30 @@ def run_randomized_non_validated_execution_fields_test(spec, state, execution_va
@with_bellatrix_and_later
@spec_state_test
def test_randomized_non_validated_execution_fields_first_payload__execution_valid(spec, state):
rng = Random(1111)
state = build_state_with_incomplete_transition(spec, state)
yield from run_randomized_non_validated_execution_fields_test(spec, state)
yield from run_randomized_non_validated_execution_fields_test(spec, state, rng=rng)


@with_bellatrix_and_later
@spec_state_test
def test_randomized_non_validated_execution_fields_regular_payload__execution_valid(spec, state):
rng = Random(2222)
state = build_state_with_complete_transition(spec, state)
yield from run_randomized_non_validated_execution_fields_test(spec, state)
yield from run_randomized_non_validated_execution_fields_test(spec, state, rng=rng)


@with_bellatrix_and_later
@spec_state_test
def test_invalid_randomized_non_validated_execution_fields_first_payload__execution_invalid(spec, state):
rng = Random(3333)
state = build_state_with_incomplete_transition(spec, state)
yield from run_randomized_non_validated_execution_fields_test(spec, state, execution_valid=False)
yield from run_randomized_non_validated_execution_fields_test(spec, state, execution_valid=False, rng=rng)


@with_bellatrix_and_later
@spec_state_test
def test_invalid_randomized_non_validated_execution_fields_regular_payload__execution_invalid(spec, state):
rng = Random(4444)
state = build_state_with_complete_transition(spec, state)
yield from run_randomized_non_validated_execution_fields_test(spec, state, execution_valid=False)
yield from run_randomized_non_validated_execution_fields_test(spec, state, execution_valid=False, rng=rng)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


def _run_blob_kzg_commitments_merkle_proof_test(spec, state, rng=None):
opaque_tx, blobs, blob_kzg_commitments, proofs = get_sample_opaque_tx(spec, blob_count=1)
opaque_tx, blobs, blob_kzg_commitments, _ = get_sample_opaque_tx(spec, blob_count=1)
if rng is None:
block = build_empty_block_for_next_slot(spec, state)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ def test_fft(spec):
@with_eip7594_and_later
@spec_test
@single_phase
def test_verify_cell_proof(spec):
def test_verify_cell_kzg_proof(spec):
blob = get_sample_blob(spec)
commitment = spec.blob_to_kzg_commitment(blob)
cells, proofs = spec.compute_cells_and_proofs(blob)
cells, proofs = spec.compute_cells_and_kzg_proofs(blob)

cell_id = 0
assert spec.verify_cell_proof(commitment, cell_id, cells[cell_id], proofs[cell_id])
assert spec.verify_cell_kzg_proof(commitment, cell_id, cells[cell_id], proofs[cell_id])
cell_id = 1
assert spec.verify_cell_proof(commitment, cell_id, cells[cell_id], proofs[cell_id])
assert spec.verify_cell_kzg_proof(commitment, cell_id, cells[cell_id], proofs[cell_id])


@with_eip7594_and_later
@spec_test
@single_phase
def test_verify_cell_proof_batch(spec):
def test_verify_cell_kzg_proof_batch(spec):
blob = get_sample_blob(spec)
commitment = spec.blob_to_kzg_commitment(blob)
cells, proofs = spec.compute_cells_and_proofs(blob)
cells, proofs = spec.compute_cells_and_kzg_proofs(blob)

assert len(cells) == len(proofs)

assert spec.verify_cell_proof_batch(
assert spec.verify_cell_kzg_proof_batch(
row_commitments_bytes=[commitment],
row_indices=[0, 0],
column_indices=[0, 4],
Expand Down

0 comments on commit 1cd63df

Please sign in to comment.