ethereum.forks.constantinople.vm.stackethereum.forks.istanbul.vm.stack
Ethereum Virtual Machine (EVM) Stack.
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Implementation of the stack operators for the EVM.
pop
Pops the top item off of stack.
Parameters
stack : EVM stack.
Returns
value : U256
The top element on the stack.
def pop(stack: List[U256]) -> U256:
| 22 | """ |
|---|---|
| 23 | Pops the top item off of `stack`. |
| 24 | |
| 25 | Parameters |
| 26 | ---------- |
| 27 | stack : |
| 28 | EVM stack. |
| 29 | |
| 30 | Returns |
| 31 | ------- |
| 32 | value : `U256` |
| 33 | The top element on the stack. |
| 34 | |
| 35 | """ |
| 36 | if len(stack) == 0: |
| 37 | raise StackUnderflowError |
| 38 | |
| 39 | return stack.pop() |
push
Pushes value onto stack.
Parameters
stack : EVM stack.
value :
Item to be pushed onto stack.
def push(stack: List[U256], value: U256) -> None:
| 43 | """ |
|---|---|
| 44 | Pushes `value` onto `stack`. |
| 45 | |
| 46 | Parameters |
| 47 | ---------- |
| 48 | stack : |
| 49 | EVM stack. |
| 50 | |
| 51 | value : |
| 52 | Item to be pushed onto `stack`. |
| 53 | |
| 54 | """ |
| 55 | if len(stack) == 1024: |
| 56 | raise StackOverflowError |
| 57 | |
| 58 | return stack.append(value) |