fix linting issues + make spec builder remove comments in container re-initialization part
This commit is contained in:
parent
b4ef672f87
commit
2d67717079
|
@ -106,6 +106,18 @@ def apply_constants_preset(preset: Dict[str, Any]) -> None:
|
|||
'''
|
||||
|
||||
|
||||
def strip_comments(raw: str) -> str:
|
||||
comment_line_regex = re.compile('^\s+# ')
|
||||
lines = raw.split('\n')
|
||||
out = []
|
||||
for line in lines:
|
||||
if not comment_line_regex.match(line):
|
||||
if ' #' in line:
|
||||
line = line[:line.index(' #')]
|
||||
out.append(line)
|
||||
return '\n'.join(out)
|
||||
|
||||
|
||||
def objects_to_spec(functions: Dict[str, str],
|
||||
custom_types: Dict[str, str],
|
||||
constants: Dict[str, str],
|
||||
|
@ -133,7 +145,8 @@ def objects_to_spec(functions: Dict[str, str],
|
|||
ssz_objects_instantiation_spec = '\n\n'.join(ssz_objects.values())
|
||||
ssz_objects_reinitialization_spec = (
|
||||
'def init_SSZ_types() -> None:\n global_vars = globals()\n\n '
|
||||
+ '\n\n '.join([re.sub(r'(?!\n\n)\n', r'\n ', value[:-1]) for value in ssz_objects.values()])
|
||||
+ '\n\n '.join([strip_comments(re.sub(r'(?!\n\n)\n', r'\n ', value[:-1]))
|
||||
for value in ssz_objects.values()])
|
||||
+ '\n\n'
|
||||
+ '\n'.join(map(lambda x: ' global_vars[\'%s\'] = %s' % (x, x), ssz_objects.keys()))
|
||||
)
|
||||
|
|
|
@ -533,7 +533,7 @@ class BeaconState(Container):
|
|||
randao_mixes: Vector[Hash, EPOCHS_PER_HISTORICAL_VECTOR]
|
||||
active_index_roots: Vector[Hash, EPOCHS_PER_HISTORICAL_VECTOR] # Digests of the active registry, for light clients
|
||||
# Slashings
|
||||
slashed_balances: Vector[Gwei, EPOCHS_PER_SLASHED_BALANCES_VECTOR] # Sums of the effective balances of slashed validators
|
||||
slashed_balances: Vector[Gwei, EPOCHS_PER_SLASHED_BALANCES_VECTOR] # Sums of the slashed effective balances
|
||||
# Attestations
|
||||
previous_epoch_attestations: List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH]
|
||||
current_epoch_attestations: List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH]
|
||||
|
@ -1525,7 +1525,8 @@ def process_slashings(state: BeaconState) -> None:
|
|||
total_penalties = total_at_end - total_at_start
|
||||
|
||||
for index, validator in enumerate(state.validators):
|
||||
if validator.slashed and current_epoch == validator.withdrawable_epoch - EPOCHS_PER_SLASHED_BALANCES_VECTOR // 2:
|
||||
if validator.slashed and current_epoch == (
|
||||
validator.withdrawable_epoch - EPOCHS_PER_SLASHED_BALANCES_VECTOR // 2):
|
||||
penalty = max(
|
||||
validator.effective_balance * min(total_penalties * 3, total_balance) // total_balance,
|
||||
validator.effective_balance // MIN_SLASHING_PENALTY_QUOTIENT
|
||||
|
|
|
@ -319,7 +319,7 @@ class BaseList(list, Elements):
|
|||
|
||||
def last(self):
|
||||
# be explict about getting the last item, for the non-python readers, and negative-index safety
|
||||
return self[len(self)-1]
|
||||
return self[len(self) - 1]
|
||||
|
||||
|
||||
class List(BaseList):
|
||||
|
|
Loading…
Reference in New Issue