evm-opcodes-0.1.0: Opcode types for Ethereum Virtual Machine (EVM)

EVM.Opcode.Labelled

Description

This module exposes the LabelledOpcode type for expressing Ethereum VM opcodes with labelled jumps. Plain Ethereum VM Opcodes are not so ergonomic because one has to know the exact byte offset of the target JUMPDEST.

With Opcode the byte offset is pushed to the stack via PUSH, but the offset to the JUMPDEST depends on all occurrences of PUSH prior to the label, including the PUSH to the label itself.

Synopsis

# Documentation

type Label = Text Source #

For now, all labels are Text.

LabelledOpcodes use Label to represent jumps.

In particular, JUMP "name", JUMPI "name" and JUMPDEST "name".

All other opcodes remain the same.

Translation of LabelledOpcodes into PositionalOpcodes may fail if a jump is made to a non-occurring JUMPDEST or a JUMPDEST occurs twice.

Constructors

 TranslateError Fields

#### Instances

Instances details
 Source # Instance detailsDefined in EVM.Opcode.Labelled Methods Source # Instance detailsDefined in EVM.Opcode.Labelled MethodsshowList :: [TranslateError] -> ShowS #

Replace all labels with absolute positions.

Positions are calculated by fixed-point iteration to account for variable sizes of jumps. Labelled jumps don't have a size defined, the size of a positional jump depends on the address being jumped to.

For example, if jumping to the JUMPDEST on the 256th position in a [LabelledOpcode], this requires a PUSH2 instruction which uses an additional byte, which pushes the JUMPDEST one byte ahead.

Extract a Map Label Position that describes where each JUMPDEST is located, taking into account the sizes of all prior opcodes.