Skip to content

Commit

Permalink
Update EIP-7495: Remove redundant is_active_field helper
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
etan-status authored Jun 13, 2024
1 parent ec89dd6 commit 83e11f0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions EIPS/eip-7495.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,9 @@ Serialization of `StableContainer[N]` is defined similarly to the [existing logi
- If variable-length fields are serialized, their offsets are relative to the start of serialized active fields, after the `Bitvector[N]`

```python
def is_active_field(element):
return not is_optional(element) or element is not None

# Determine active fields
active_fields = Bitvector[N](([is_active_field(element) for element in value] + [False] * N)[:N])
active_values = [element for element in value if is_active_field(element)]
active_fields = Bitvector[N](([element is not None for element in value] + [False] * N)[:N])
active_values = [element for element in value if element is not None]

# Recursively serialize
fixed_parts = [serialize(element) if not is_variable_size(element) else None for element in active_values]
Expand Down Expand Up @@ -120,7 +117,7 @@ To merkleize a `StableContainer[N]`, a `Bitvector[N]` is constructed, indicating

Merkleization `hash_tree_root(value)` of an object `value` is extended with:

- `mix_in_aux(merkleize(([hash_tree_root(element) if is_active_field(element) else Bytes32() for element in value.data] + [Bytes32()] * N)[:N]), hash_tree_root(value.active_fields))` if `value` is a `StableContainer[N]`.
- `mix_in_aux(merkleize(([hash_tree_root(element) if element is not None else Bytes32() for element in value.data] + [Bytes32()] * N)[:N]), hash_tree_root(value.active_fields))` if `value` is a `StableContainer[N]`.

### `Profile[B]`

Expand Down

0 comments on commit 83e11f0

Please sign in to comment.