Skip to content

Spec

Documentation for tests/osaka/eip7939_count_leading_zeros/spec.py@cc5fc26a.

Defines EIP-7939 specification constants and functions.

Spec dataclass

Constants and helpers for the CLZ opcode.

Source code in tests/osaka/eip7939_count_leading_zeros/spec.py
17
18
19
20
21
22
23
24
25
26
27
28
@dataclass(frozen=True)
class Spec:
    """Constants and helpers for the CLZ opcode."""

    CLZ_GAS_COST = 3

    @classmethod
    def calculate_clz(cls, value: int) -> int:
        """Calculate the count of leading zeros for a 256-bit value."""
        if value == 0:
            return 256
        return 256 - value.bit_length()