program

package
v0.0.0-...-a6ff567 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: GPL-3.0 Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunProgram

func RunProgram(testFn func() error) error

RunProgram parses flags (for profiling), and executes teh testFn

Types

type Program

type Program struct {
	// contains filtered or unexported fields
}

func NewProgram

func NewProgram() *Program

func (*Program) AddAll

func (p *Program) AddAll(data []byte)

AddAll adds the data to the Program

func (*Program) Bytecode

func (p *Program) Bytecode() []byte

Bytecode returns the Program bytecode

func (*Program) Call

func (p *Program) Call(gas *big.Int, address, value, inOffset, inSize, outOffset, outSize interface{})

Call is a convenience function to make a call

func (*Program) CallCode

func (p *Program) CallCode(gas *big.Int, address, value, inOffset, inSize, outOffset, outSize interface{})

func (*Program) CallF

func (p *Program) CallF(i uint16)

CallF implements CALLF (0xb0) - call a function

func (*Program) CreateAndCall

func (p *Program) CreateAndCall(code []byte, isCreate2 bool, callOp ops.OpCode)

CreateAndCall calls create/create2 with the given bytecode and then checks if the returnvalue is non-zero. If so, it calls into the newly created contract with all available gas

func (*Program) DelegateCall

func (p *Program) DelegateCall(gas *big.Int, address, inOffset, inSize, outOffset, outSize interface{})

DelegateCall is a convenience function to make a delegatecall

func (*Program) ExtcodeCopy

func (p *Program) ExtcodeCopy(address, memOffset, codeOffset, length interface{})

func (*Program) Hex

func (p *Program) Hex() string

Bytecode returns the Program bytecode

func (*Program) InputAddressToStack

func (p *Program) InputAddressToStack(inputOffset uint32)

InputToMemory stores the input (calldata) to memory as address (20 bytes).

func (*Program) Jump

func (p *Program) Jump(loc interface{})

Jump pushes the destination and adds a JUMP

func (*Program) JumpIf

func (p *Program) JumpIf(loc interface{}, condition interface{})

Jump pushes the destination and adds a JUMP

func (*Program) Jumpdest

func (p *Program) Jumpdest() uint64

Jumpdest adds a JUMPDEST op, and returns the PC of that instruction

func (*Program) Label

func (p *Program) Label() uint64

Label returns the PC (of the next instruction)

func (*Program) MemToStorage

func (p *Program) MemToStorage(memStart, memSize, startSlot int)

MemToStorage copies the given memory area into SSTORE slots, It expects data to be aligned to 32 byte, and does not zero out remainders if some data is not I.e, if given a 1-byte area, it will still copy the full 32 bytes to storage

func (*Program) Mstore

func (p *Program) Mstore(data []byte, memStart uint32)

MStore stores the provided data (into the memory area starting at memStart)

func (*Program) Op

func (p *Program) Op(op ops.OpCode)

Op appends the given opcode

func (*Program) Push

func (p *Program) Push(val interface{}) *Program

Push creates a PUSHX instruction with the data provided

func (*Program) Push0

func (p *Program) Push0() *Program

Push0 implements PUSH0 (0x5f)

func (*Program) RJump

func (p *Program) RJump(relOffset uint16)

RJump implements RJUMP (0x5c) - relative jump

func (*Program) RJumpI

func (p *Program) RJumpI(relOffset uint16, condition interface{})

RJumpI implements RJUMPI (0x5d) - conditional relative jump

func (*Program) RJumpV

func (p *Program) RJumpV(relOffsets []uint16)

RJumpV implements RJUMPV (0x5e) - relative jump via jump table

func (*Program) RetF

func (p *Program) RetF()

RetF implements RETF (0xb1) - return from a function

func (*Program) Return

func (p *Program) Return(offset, len uint32)

func (*Program) ReturnData

func (p *Program) ReturnData(data []byte)

ReturnData loads the given data into memory, and does a return with it

func (*Program) Size

func (p *Program) Size() int

func (*Program) Sstore

func (p *Program) Sstore(slot interface{}, value interface{})

Sstore stores the given byte array to the given slot. OBS! Does not verify that the value indeed fits into 32 bytes If it does not, it will panic later on via pushBig

func (*Program) StaticCall

func (p *Program) StaticCall(gas *big.Int, address, inOffset, inSize, outOffset, outSize interface{})

StaticCall is a convenience function to make a staticcall

func (*Program) Tstore

func (p *Program) Tstore(slot interface{}, value interface{})

Tstore stores the given byte array to the given t-slot. OBS! Does not verify that the value indeed fits into 32 bytes If it does not, it will panic later on via pushBig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL