Skip to content

Commit 3094eee

Browse files
anvacarurv-auditor
andauthored
Eliminate complex KLabels from Python code (#2463)
* abi.md: refactor klabel and symbol attributes * kevm.py: change klabels used in Python to symbols * Set Version: 1.0.586 * apply review suggestions * Set Version: 1.0.587 --------- Co-authored-by: devops <[email protected]>
1 parent dc7fb85 commit 3094eee

File tree

11 files changed

+207
-208
lines changed

11 files changed

+207
-208
lines changed

kevm-pyk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "kevm-pyk"
7-
version = "1.0.586"
7+
version = "1.0.587"
88
description = ""
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",

kevm-pyk/src/kevm_pyk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
if TYPE_CHECKING:
66
from typing import Final
77

8-
VERSION: Final = '1.0.586'
8+
VERSION: Final = '1.0.587'

kevm-pyk/src/kevm_pyk/kevm.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,11 @@ def to_hex(kast: KInner) -> KInner:
387387

388388
@staticmethod
389389
def halt() -> KApply:
390-
return KApply('#halt_EVM_KItem')
390+
return KApply('halt')
391391

392392
@staticmethod
393393
def sharp_execute() -> KApply:
394-
return KApply('#execute_EVM_KItem')
394+
return KApply('execute')
395395

396396
@staticmethod
397397
def jumpi() -> KApply:
@@ -411,7 +411,7 @@ def jump_applied(pc: KInner) -> KApply:
411411

412412
@staticmethod
413413
def pc_applied(op: KInner) -> KApply:
414-
return KApply('#pc[_]_EVM_InternalOp_OpCode', [op])
414+
return KApply('pc', [op])
415415

416416
@staticmethod
417417
def pow128() -> KApply:
@@ -423,35 +423,35 @@ def pow256() -> KApply:
423423

424424
@staticmethod
425425
def range_uint(width: int, i: KInner) -> KApply:
426-
return KApply('#rangeUInt(_,_)_WORD_Bool_Int_Int', [intToken(width), i])
426+
return KApply('rangeUInt', [intToken(width), i])
427427

428428
@staticmethod
429429
def range_sint(width: int, i: KInner) -> KApply:
430-
return KApply('#rangeSInt(_,_)_WORD_Bool_Int_Int', [intToken(width), i])
430+
return KApply('rangeSInt', [intToken(width), i])
431431

432432
@staticmethod
433433
def range_address(i: KInner) -> KApply:
434-
return KApply('#rangeAddress(_)_WORD_Bool_Int', [i])
434+
return KApply('rangeAddress', [i])
435435

436436
@staticmethod
437437
def range_bool(i: KInner) -> KApply:
438-
return KApply('#rangeBool(_)_WORD_Bool_Int', [i])
438+
return KApply('rangeBool', [i])
439439

440440
@staticmethod
441441
def range_bytes(width: KInner, ba: KInner) -> KApply:
442-
return KApply('#rangeBytes(_,_)_WORD_Bool_Int_Int', [width, ba])
442+
return KApply('rangeBytes', [width, ba])
443443

444444
@staticmethod
445445
def range_nonce(i: KInner) -> KApply:
446-
return KApply('#rangeNonce(_)_WORD_Bool_Int', [i])
446+
return KApply('rangeNonce', [i])
447447

448448
@staticmethod
449449
def range_blocknum(ba: KInner) -> KApply:
450-
return KApply('#rangeBlockNum(_)_WORD_Bool_Int', [ba])
450+
return KApply('rangeBlockNum', [ba])
451451

452452
@staticmethod
453453
def bool_2_word(cond: KInner) -> KApply:
454-
return KApply('bool2Word(_)_EVM-TYPES_Int_Bool', [cond])
454+
return KApply('bool2Word', [cond])
455455

456456
@staticmethod
457457
def size_bytes(ba: KInner) -> KApply:
@@ -463,7 +463,7 @@ def inf_gas(g: KInner) -> KApply:
463463

464464
@staticmethod
465465
def compute_valid_jumpdests(p: KInner) -> KApply:
466-
return KApply('#computeValidJumpDests(_)_EVM_Set_Bytes', [p])
466+
return KApply('computeValidJumpDests', [p])
467467

468468
@staticmethod
469469
def bin_runtime(c: KInner) -> KApply:
@@ -475,13 +475,11 @@ def init_bytecode(c: KInner) -> KApply:
475475

476476
@staticmethod
477477
def is_precompiled_account(i: KInner, s: KInner) -> KApply:
478-
return KApply('#isPrecompiledAccount(_,_)_EVM_Bool_Int_Schedule', [i, s])
478+
return KApply('isPrecompiledAccount', [i, s])
479479

480480
@staticmethod
481481
def hashed_location(compiler: str, base: KInner, offset: KInner, member_offset: int = 0) -> KApply:
482-
location = KApply(
483-
'#hashedLocation(_,_,_)_HASHED-LOCATIONS_Int_String_Int_IntList', [stringToken(compiler), base, offset]
484-
)
482+
location = KApply('hashLoc', [stringToken(compiler), base, offset])
485483
if member_offset > 0:
486484
location = KApply('_+Int_', [location, intToken(member_offset)])
487485
return location
@@ -492,23 +490,23 @@ def loc(accessor: KInner) -> KApply:
492490

493491
@staticmethod
494492
def lookup(map: KInner, key: KInner) -> KApply:
495-
return KApply('#lookup(_,_)_EVM-TYPES_Int_Map_Int', [map, key])
493+
return KApply('lookup', [map, key])
496494

497495
@staticmethod
498496
def abi_calldata(name: str, args: list[KInner]) -> KApply:
499-
return KApply('#abiCallData(_,_)_EVM-ABI_Bytes_String_TypedArgs', [stringToken(name), KEVM.typed_args(args)])
497+
return KApply('abiCallData', [stringToken(name), KEVM.typed_args(args)])
500498

501499
@staticmethod
502500
def abi_selector(name: str) -> KApply:
503501
return KApply('abi_selector', [stringToken(name)])
504502

505503
@staticmethod
506504
def abi_address(a: KInner) -> KApply:
507-
return KApply('#address(_)_EVM-ABI_TypedArg_Int', [a])
505+
return KApply('abi_type_address', [a])
508506

509507
@staticmethod
510508
def abi_bool(b: KInner) -> KApply:
511-
return KApply('#bool(_)_EVM-ABI_TypedArg_Int', [b])
509+
return KApply('abi_type_bool', [b])
512510

513511
@staticmethod
514512
def abi_type(type: str, value: KInner) -> KApply:
@@ -524,7 +522,7 @@ def abi_array(elem_type: KInner, length: KInner, elems: list[KInner]) -> KApply:
524522

525523
@staticmethod
526524
def as_word(b: KInner) -> KApply:
527-
return KApply('#asWord(_)_EVM-TYPES_Int_Bytes', [b])
525+
return KApply('asWord', [b])
528526

529527
@staticmethod
530528
def empty_typedargs() -> KApply:
@@ -560,15 +558,15 @@ def wordstack_len(wordstack: KInner) -> int:
560558

561559
@staticmethod
562560
def parse_bytestack(s: KInner) -> KApply:
563-
return KApply('#parseByteStack(_)_SERIALIZATION_Bytes_String', [s])
561+
return KApply('parseByteStack', [s])
564562

565563
@staticmethod
566564
def bytes_empty() -> KApply:
567565
return KApply('.Bytes_BYTES-HOOKED_Bytes')
568566

569567
@staticmethod
570568
def buf(width: KInner, v: KInner) -> KApply:
571-
return KApply('#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int', [width, v])
569+
return KApply('buf', [width, v])
572570

573571
@staticmethod
574572
def intlist(ints: list[KInner]) -> KApply:
@@ -675,7 +673,7 @@ def compute_jumpdests(sections: list[KInner]) -> KInner:
675673
offset = 0
676674
jumpdests = []
677675
for s in sections:
678-
if type(s) is KApply and s.label == KLabel('#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int'):
676+
if type(s) is KApply and s.label == KLabel('buf'):
679677
width_token = s.args[0]
680678
assert type(width_token) is KToken
681679
offset += int(width_token.token)

0 commit comments

Comments
 (0)