-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4b046e
commit 08631db
Showing
5 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
STOP | ||
ADD | ||
MUL | ||
SUB | ||
DIV | ||
SDIV | ||
MOD | ||
SMOD | ||
ADDMOD | ||
MULMOD | ||
EXP | ||
SIGNEXTEND | ||
LT | ||
GT | ||
SLT | ||
SGT | ||
EQ | ||
ISZERO | ||
AND | ||
OR | ||
XOR | ||
NOT | ||
BYTE | ||
SHL | ||
SHR | ||
SAR | ||
SHA3 | ||
ADDRESS | ||
BALANCE | ||
ORIGIN | ||
CALLER | ||
CALLVALUE | ||
CODECOPY | ||
CALLDATALOAD | ||
CALLDATASIZE | ||
CALLDATACOPY | ||
CODESIZE | ||
GASPRICE | ||
EXTCODESIZE | ||
EXTCODECOPY | ||
RETURNDATASIZE | ||
RETURNDATACOPY | ||
EXTCODEHASH | ||
BLOCKHASH | ||
COINBASE | ||
TIMESTAMP | ||
NUMBER | ||
DIFFICULTY | ||
GASLIMIT | ||
CHAINID | ||
SELFBALANCE | ||
BASEFEE | ||
POP | ||
MLOAD | ||
MSTORE | ||
MSTORE8 | ||
SLOAD | ||
SSTORE | ||
JUMP | ||
JUMPI | ||
PC | ||
MSIZE | ||
GAS | ||
JUMPDEST | ||
DUP | ||
SWAP | ||
LOG | ||
JUMPTO | ||
JUMPIF | ||
JUMPSUB | ||
JUMPSUBV | ||
BEGINSUB | ||
BEGINDATA | ||
RETURNSUB | ||
PUTLOCAL | ||
GETLOCA | ||
SLOADBYTES | ||
SSTOREBYTES | ||
SSIZE | ||
CREATE | ||
CALL | ||
CALLCODE | ||
RETURN | ||
DELEGATECALL | ||
CALLBLACKBOX | ||
STATICCALL | ||
CREATE2 | ||
TXEXECGAS | ||
REVERT | ||
INVALID | ||
SELFDESTRUCT | ||
PUSH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
Questo script Python confronta due file di testo e stampa le righe presenti solo nel primo file. | ||
""" | ||
|
||
def file_difference(file1_path, file2_path): | ||
with open(file1_path, 'r', encoding='utf-8') as file1: | ||
content1 = set(file1.readlines()) | ||
|
||
with open(file2_path, 'r', encoding='utf-8') as file2: | ||
content2 = set(file2.readlines()) | ||
|
||
difference = content1 - content2 | ||
|
||
for line in difference: | ||
print(line.strip()) | ||
|
||
if __name__ == "__main__": | ||
file1_path = "all-opcodes.txt" | ||
file2_path = "results-opcodes-preceding-a-jump.txt" | ||
|
||
file_difference(file1_path, file2_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Questo script analizza i file presenti in una directory specificata e conta quante volte ciascuna riga precedente | ||
alla comparsa di "JUMP" o "JUMPI" appare nei file. Viene effettuato un conteggio separato per le istruzioni di tipo | ||
"PUSH", "LOG", "SWAP" e "DUP", escludendo quelle righe che contengono la parola "Unknown". Il risultato del conteggio | ||
viene stampato a schermo. | ||
""" | ||
|
||
import os | ||
|
||
def find_previous_jump_line(file_path, jump_line_counter): | ||
with open(file_path, 'r', encoding='utf-8') as file: | ||
lines = file.readlines() | ||
for i in range(1, len(lines)): | ||
if 'JUMP' in lines[i] or 'JUMPI' in lines[i]: | ||
previous_line = lines[i - 1].strip() | ||
if previous_line.startswith('PUSH'): | ||
previous_line = 'PUSH' | ||
if previous_line.startswith('LOG'): | ||
previous_line = 'LOG' | ||
if previous_line.startswith('SWAP'): | ||
previous_line = 'SWAP' | ||
if previous_line.startswith('DUP'): | ||
previous_line = 'DUP' | ||
if 'Unknown' in previous_line: | ||
continue | ||
if previous_line in jump_line_counter: | ||
jump_line_counter[previous_line] += 1 | ||
else: | ||
jump_line_counter[previous_line] = 1 | ||
|
||
if __name__ == "__main__": | ||
directory_path = "../evm-testcases/benchmark" | ||
output_file = "results-opcodes-preceding-a-jump.txt" | ||
|
||
# Conta quante volte ogni riga precedente a "JUMP" o "JUMPI" appare nei file | ||
jump_line_counter = {} | ||
for root, dirs, files in os.walk(directory_path): | ||
for file in files: | ||
if file.endswith('.sol'): # Controllo sull'estensione del file | ||
file_path = os.path.join(root, file) | ||
find_previous_jump_line(file_path, jump_line_counter) | ||
|
||
with open(output_file, 'w', encoding='utf-8') as output: | ||
print("Opcode precedenti a 'JUMP' o 'JUMPI':") | ||
for line, count in jump_line_counter.items(): | ||
print(f"{line}: {count}") | ||
output.write(line + '\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
PUSH | ||
REVERT | ||
STOP | ||
JUMP | ||
RETURN | ||
SLOAD | ||
SWAP | ||
AND | ||
DUP | ||
ISZERO | ||
ADD | ||
POP | ||
SSTORE | ||
LOG | ||
JUMPDEST | ||
GT | ||
LT | ||
MSTORE | ||
JUMPI | ||
INVALID | ||
CALLER | ||
EQ | ||
MLOAD | ||
SELFDESTRUCT | ||
NOT | ||
ADDRESS | ||
CALLDATALOAD | ||
DIV | ||
EXTCODESIZE | ||
OR | ||
RETURNDATACOPY | ||
SUB | ||
CALLDATACOPY | ||
SHR | ||
SGT | ||
SLT | ||
MSTORE8 | ||
XOR | ||
SHA3 | ||
SELFBALANCE | ||
GAS | ||
MUL | ||
MSIZE | ||
SHL | ||
CALLDATASIZE | ||
GASPRICE | ||
GASLIMIT | ||
BLOCKHASH | ||
TIMESTAMP | ||
BYTE | ||
NUMBER | ||
BALANCE | ||
PC | ||
ORIGIN | ||
COINBASE | ||
MOD | ||
SMOD | ||
BASEFEE | ||
CODECOPY | ||
CALLVALUE | ||
SIGNEXTEND | ||
CREATE2 | ||
SDIV | ||
CHAINID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Questo script esplora ricorsivamente una directory specificata dall'utente e | ||
analizza ogni file al suo interno. Per ogni file che soddisfa determinate condizioni | ||
(meno di 3000 righe e non contiene la parola "PUSH0"), salva il nome del file | ||
(senza estensione) in un file di output specificato. | ||
""" | ||
import os | ||
|
||
def analyze_file(file_path): | ||
try: | ||
with open(file_path, 'r', encoding='utf-8') as file: | ||
lines = file.readlines() | ||
if len(lines) < 3000 and "PUSH0" not in "".join(lines): | ||
return True | ||
else: | ||
return False | ||
except Exception as e: | ||
print(f"Error analyzing file {file_path}: {e}") | ||
return False | ||
|
||
def explore_directory(directory_path, output_file): | ||
with open(output_file, 'w', encoding='utf-8') as output: | ||
for root, dirs, files in os.walk(directory_path): | ||
for file in files: | ||
file_path = os.path.join(root, file) | ||
if analyze_file(file_path): | ||
output.write(os.path.splitext(file)[0] + '\n') | ||
|
||
if __name__ == "__main__": | ||
directory_path = "../evm-testcases/benchmark" | ||
output_file = "result.txt" | ||
|
||
explore_directory(directory_path, output_file) | ||
print("Exploration completed. Results saved in:", output_file) |