8000 Add pop/push size per instruction by montyly · Pull Request #116 · crytic/tealer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add pop/push size per instruction #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 20, 2022
Merged

Add pop/push size per instruction #116

merged 8 commits into from
Dec 20, 2022

Conversation

montyly
Copy link
Contributor
@montyly montyly commented Dec 13, 2022

No description provided.

@montyly montyly requested a review from S3v3ru5 December 13, 2022 09:54
@CLAassistant
Copy link
CLAassistant commented Dec 13, 2022

CLA assistant check
All committers have signed the CLA.

@montyly
Copy link
Contributor Author
montyly commented Dec 13, 2022

TODO: improve testing coverage so that we cover the new code

@property
def stack_push_size(self) -> int:
return 1


class Txn(Instruction):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add stack_push_size = 1 for Txn instruction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch

@property
def stack_push_size(self) -> int:
return 2


class Global(Instruction):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add stack_push_size = 1 for Global Instruction

@property
def stack_push_size(self) -> int:
return 1


class Cover(Instruction):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add stack_pop_size = 1 + self._idx and stack_push_size = 1 + self._idx to cover instruction (?)

@@ -1444,6 +1736,10 @@ def __init__(self) -> None:
def __str__(self) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add stack_push_size = 1 for AppGlobalGet (app_global_get) instruction.

10000
@property
def stack_push_size(self) -> int:
return 1


class Addr(Instruction):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add stack_push_size = 1 for Addr instruction.

@@ -2678,6 +3346,14 @@ def cost(self) -> int:
return 4
return 0

@property
def stack_pop_size(self) -> int:
return 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to stack_pop_size = 1 for BBitwiseInvert (b~) instruction

@property
def stack_push_size(self) -> int:
return 1


class Intc3(Instruction):
Copy link
Contributor
@S3v3ru5 S3v3ru5 Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add stack_push_size = 1 for Intc3

@property
def stack_push_size(self) -> int:
return 1


class Substring3(Instruction):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add stack_push_size = 1 and stack_pop_size = 3 to Substring3 Instruction

@@ -3760,6 +4676,10 @@ def field(self) -> TransactionField:
"""Array transaction field being accessed."""
return self._field

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add stack_pop_size = 1 to Itxnas instruction

@@ -3903,6 +4847,14 @@ def start_position(self) -> int:
raise TealerException("replace instruction does not have any immediates")
return self._idx

@property
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Number of values popped depends on the immediate argument s. If there's no immediate argument then, replace is replace3 and stack_pop_size = 3. If there is a immediate argument then replace s is equivalent to replace2 s and stack_pop_size = 2.

@@ -4142,6 +5142,14 @@ def __init__(self, index: int):
self._index: int = index
self._version: int = 8

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bury n: should we set the pop size to n + 1 and push size to n? I don't know if the stack depth n includes A value or not.

@@ -4164,6 +5172,10 @@ def __init__(self, n: int):
self._nelements: int = n
self._version: int = 8

@property
Copy link
Contributor
@S3v3ru5 S3v3ru5 Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add stack_pop_size = n and update stack_push_size to 0 for Popn instruction

@@ -4183,6 +5195,10 @@ def __init__(self, count: int):
self._count: int = count
self._version: int = 8

@property
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update stack_push_size = n + 1 and stack_pop_size = 1 for Dupn instruction

@@ -4204,6 +5220,10 @@ def __init__(self, bytes_list: List[str]):
self._bytes_list = bytes_list
self._version: int = 8

@property
def stack_push_size(self) -> int:
return 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update stack_push_size = len(self._bytes_list) for PushBytess instruction.

@@ -4225,6 +5245,10 @@ def __init__(self, int_list: List[int]):
self._int_list = int_list
self._version: int = 8

@property
def stack_push_size(self) -> int:
return 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update stack_push_size = len(self._int_list) for PushInts instruction.

@montyly montyly merged commit 76e3d2f into dev Dec 20, 2022
@montyly montyly deleted the dev-instruction-pop-push branch December 20, 2022 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0