@@ -407,60 +407,80 @@ def _transform_dash_aux(inner: KInner) -> KInner:
407407 return top_down (_transform_dash_aux , inner )
408408
409409
410- def _transform_rule_id (proof_id : str , requires : KInner ) -> str :
411- flag = 'USEGAS'
412- noberlin = False
413- le0 = False
414- le_length_bytes = False
410+ def _is_usegas_rule (inner : KInner ) -> bool :
411+ usegas = True
415412
416- def _transform_rule_id_nogas (_inner : KInner ) -> KInner :
417- nonlocal flag
418- if (
419- isinstance (_inner , KApply )
420- and _inner .label .name == 'notBool_'
421- and _inner .args [0 ] == KVariable ('USEGAS_CELL' , 'Bool' )
422- ):
423- flag = 'NOGAS'
413+ def _is_usegas_aux (_inner : KInner ) -> KInner :
414+ nonlocal usegas
415+ if _inner == KApply ('notBool_' , [KVariable ('USEGAS_CELL' , 'Bool' )]):
416+ usegas = False
424417 return _inner
425418
426- def _transform_rule_id_no_ghasaccesslist (_inner : KInner ) -> KInner :
427- nonlocal noberlin
428- if (
429- isinstance (_inner , KApply )
430- and _inner .label .name == 'notBool_'
431- and isinstance (_inner .args [0 ], KApply )
432- and _inner .args [0 ].label .name == '_<<_>>_SCHEDULE_Bool_ScheduleFlag_Schedule'
433- and _inner .args [0 ].args [0 ] == KApply ('Ghasaccesslist_SCHEDULE_ScheduleFlag' , [])
419+ top_down (_is_usegas_aux , inner )
420+ return usegas
421+
422+
423+ def _is_berlin_rule (inner : KInner ) -> bool :
424+ berlin = True
425+
426+ def _is_berlin_aux (_inner : KInner ) -> KInner :
427+ nonlocal berlin
428+ if _inner == KApply (
429+ 'notBool_' ,
430+ [
431+ KApply (
432+ '_<<_>>_SCHEDULE_Bool_ScheduleFlag_Schedule' ,
433+ [KApply ('Ghasaccesslist_SCHEDULE_ScheduleFlag' ), KVariable ('SCHEDULE_CELL' , 'Schedule' )],
434+ )
435+ ],
434436 ):
435- noberlin = True
437+ berlin = False
436438 return _inner
437439
438- def _transform_rule_id_le0 (_inner : KInner ) -> KInner :
440+ top_down (_is_berlin_aux , inner )
441+ return berlin
442+
443+
444+ def _is_le0 (inner : KInner ) -> bool :
445+ le0 = False
446+
447+ def _is_le0_aux (_inner : KInner ) -> KInner :
439448 nonlocal le0
440449 if _inner == KApply ('_<=Int_' , [KVariable ('W1' , 'Int' ), KToken ('0' , 'Int' )]):
441450 le0 = True
442451 return _inner
443452
444- def _transform_rule_id_le_length_bytes (_inner : KInner ) -> KInner :
445- nonlocal le_length_bytes
446- if (
447- isinstance (_inner , KApply )
448- and _inner .label .name == '_<=Int_'
449- and _inner .args [1 ] == KApply ('lengthBytes(_)_BYTES-HOOKED_Int_Bytes' , [KVariable ('OUTPUT_CELL' , 'Bytes' )])
453+ top_down (_is_le0_aux , inner )
454+ return le0
455+
456+
457+ def _is_invalid (inner : KInner ) -> bool :
458+ invalid = False
459+
460+ def _is_invalid_aux (_inner : KInner ) -> KInner :
461+ nonlocal invalid
462+ if _inner == KApply (
463+ '_<Int_' ,
464+ [
465+ KApply ('lengthBytes(_)_BYTES-HOOKED_Int_Bytes' , [KVariable ('OUTPUT_CELL' , 'Bytes' )]),
466+ KApply ('_+Int_' , [KVariable ('W1' , 'Int' ), KVariable ('W2' , 'Int' )]),
467+ ],
450468 ):
451- le_length_bytes = True
469+ invalid = True
452470 return _inner
453471
454- top_down (_transform_rule_id_nogas , requires )
455- top_down (_transform_rule_id_no_ghasaccesslist , requires )
456- top_down (_transform_rule_id_le0 , requires )
457- top_down (_transform_rule_id_le_length_bytes , requires )
458- if proof_id in ['BALANCE_NORMAL' , 'BALANCE_OWISE' , 'SLOAD' , 'SSTORE' ]:
459- flag += '-BERLIN' if not noberlin else ''
460- if proof_id == 'EXP' :
461- flag += '-LE0' if le0 else ''
462- if proof_id == 'RETURNDATACOPY' :
463- flag += '-INVALID' if not le_length_bytes else ''
472+ top_down (_is_invalid_aux , inner )
473+ return invalid
474+
475+
476+ def _transform_rule_id (proof_id : str , requires : KInner ) -> str :
477+ flag = 'USEGAS' if _is_usegas_rule (requires ) else 'NOGAS'
478+ if proof_id in ['BALANCE_NORMAL' , 'BALANCE_OWISE' , 'SLOAD' , 'SSTORE' ] and _is_berlin_rule (requires ):
479+ flag += '-BERLIN'
480+ if proof_id == 'EXP' and _is_le0 (requires ):
481+ flag += '-LE0'
482+ if proof_id == 'RETURNDATACOPY' and _is_invalid (requires ):
483+ flag += '-INVALID'
464484 return f'{ proof_id .replace ("_" , "-" )} -SUMMARY-{ flag } '
465485
466486
0 commit comments