ethereum / ethereum/execution-specs
Strict types needed
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 505
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 116
Description
I see many places in code rely on Any. thats very unclear what properties I can expect in this `Any` types.
But here I want to point out this problem that I had too:
```
def read_randao(self, data: Any, t8n: Any) -> None:
"""
Read the randao from the data.
"""
self.prev_randao = None
if t8n.is_after_fork("ethereum.paris"):
# tf tool might not always provide an
# even number of nibbles in the randao
# This could create issues in the
# hex_to_bytes function
current_random = data["currentRandom"]
if current_random.startswith("0x"):
current_random = current_random[2:]
if len(current_random) % 2 == 1:
current_random = "0" + current_random
self.prev_randao = Bytes32(
left_pad_zero_bytes(hex_to_bytes(current_random), 32)
)
```
this is because there is no type representing hex value. at some point it will make a mess reading and converting this to accurate 0x00 values. you need to store all hex values in prefixed hex string type. that will guarantee that the value is following schema
```
0x
0x00
0x01
0x0112
```
this type class can read from int, string and output the formatted representation
Contributor guide
Assessment
This issue has not been assessed yet.