ethereum.vm.stack
¶
Ethereum Virtual Machine (EVM) Stack¶
Table of Contents
Introduction¶
Implementation of the stack operators for the EVM.
Module Contents¶
Functions¶
Pops the top item off of stack. |
|
Pushes value onto stack. |
Module Details¶
pop¶
- ethereum.vm.stack.pop(stack: List[ethereum.base_types.U256]) → ethereum.base_types.U256¶
Pops the top item off of stack.
- Parameters
stack – EVM stack.
- Returns
value – The top element on the stack.
- Return type
U256
- Raises
StackUnderflowError – If stack is empty.
def pop(stack: List[U256]) -> U256:
if len(stack) == 0:
raise StackUnderflowError
return stack.pop()
push¶
- ethereum.vm.stack.push(stack: List[ethereum.base_types.U256], value: ethereum.base_types.U256) → None¶
Pushes value onto stack.
- Parameters
stack – EVM stack.
value – Item to be pushed onto stack.
- Raises
StackOverflowError – If len(stack) is 1024.
def push(stack: List[U256], value: U256) -> None:
if len(stack) == 1024:
raise StackOverflowError
return stack.append(value)