Skip to content

Commit

Permalink
Compare field order in Profile compatibility check
Browse files Browse the repository at this point in the history
  • Loading branch information
etan-status committed Jun 4, 2024
1 parent b833f77 commit f0ffb49
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions remerkleable/stable_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ def has_compatible_merkleization(ftyp, ftyp_base) -> bool:
fields_base = ftyp_base.fields()
if len(fields) != len(fields_base):
return False
for fkey, t in fields.items():
if fkey not in fields_base:
for (fkey, t), (fkey_b, t_b) in zip(fields.items(), fields_base.items()):
if fkey != fkey_b:
return False
if not has_compatible_merkleization(t, fields_base[fkey]):
if not has_compatible_merkleization(t, t_b):
return False
return True
if issubclass(ftyp, StableContainer):
Expand All @@ -428,10 +428,10 @@ def has_compatible_merkleization(ftyp, ftyp_base) -> bool:
fields_base = ftyp_base.fields()
if len(fields) != len(fields_base):
return False
for fkey, t in fields.items():
if fkey not in fields_base:
for (fkey, t), (fkey_b, t_b) in zip(fields.items(), fields_base.items()):
if fkey != fkey_b:
return False
if not has_compatible_merkleization(t, fields_base[fkey]):
if not has_compatible_merkleization(t, t_b):
return False
return True
if issubclass(ftyp, Profile):
Expand All @@ -445,11 +445,10 @@ def has_compatible_merkleization(ftyp, ftyp_base) -> bool:
fields_base = ftyp_base.fields()
if len(fields) != len(fields_base):
return False
for fkey, (t, _) in fields.items():
if fkey not in fields_base:
for (fkey, (t, _)), (fkey_b, (t_b, _)) in zip(fields.items(), fields_base.items()):
if fkey != fkey_b:
return False
(t_base, _) = fields_base[fkey]
if not has_compatible_merkleization(t, t_base):
if not has_compatible_merkleization(t, t_b):
return False
return True
return False
Expand Down

0 comments on commit f0ffb49

Please sign in to comment.