Fix typing and delete the `signed_sidecar`

This commit is contained in:
Hsiao-Wei Wang 2023-10-30 18:24:19 +08:00
parent a12441486c
commit 51343f54fe
No known key found for this signature in database
GPG Key ID: AE3D6B174F971DE4
3 changed files with 6 additions and 6 deletions

View File

@ -27,7 +27,7 @@ GeneralizedIndex = NewType('GeneralizedIndex', int)
@classmethod
def sundry_functions(cls) -> str:
return '''
def get_generalized_index(ssz_class: Any, *path: Sequence[PyUnion[int, SSZVariableName]]) -> GeneralizedIndex:
def get_generalized_index(ssz_class: Any, *path: PyUnion[int, SSZVariableName]) -> GeneralizedIndex:
ssz_path = Path(ssz_class)
for item in path:
ssz_path = ssz_path / item

View File

@ -163,18 +163,18 @@ def get_blob_sidecars(signed_block: SignedBeaconBlock,
blob=blob,
kzg_commitment=block.body.blob_kzg_commitments[index],
kzg_proof=blob_kzg_proofs[index],
signed_block_header=signed_block_header,
commitment_inclusion_proof=compute_merkle_proof(
block.body,
get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments', index), # type: ignore
get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments', index),
),
signed_block_header=signed_block_header,
)
for index, blob in enumerate(blobs)
]
```
The `subnet_id` for the `signed_sidecar` is calculated with:
- Let `blob_index = signed_sidecar.message.index`.
The `subnet_id` for the `blob_sidecar` is calculated with:
- Let `blob_index = blob_sidecar.index`.
- Let `subnet_id = compute_subnet_for_blob_sidecar(blob_index)`.
```python

View File

@ -167,7 +167,7 @@ def get_item_position(typ: SSZType, index_or_variable_name: Union[int, SSZVariab
```
```python
def get_generalized_index(typ: SSZType, path: Sequence[Union[int, SSZVariableName]]) -> GeneralizedIndex:
def get_generalized_index(typ: SSZType, *path: PyUnion[int, SSZVariableName]) -> GeneralizedIndex:
"""
Converts a path (eg. `[7, "foo", 3]` for `x[7].foo[3]`, `[12, "bar", "__len__"]` for
`len(x[12].bar)`) into the generalized index representing its position in the Merkle tree.