예제 #1
0
from evm.opcode import as_opcode

from evm.logic import (
    arithmetic,
    system,
    call,
)

from evm.vm.forks.eip150.opcodes import EIP150_OPCODES


UPDATED_OPCODES = {
    opcode_values.EXP: as_opcode(
        logic_fn=arithmetic.exp(gas_per_byte=constants.GAS_EXPBYTE_EIP160),
        mnemonic=mnemonics.EXP,
        gas_cost=constants.GAS_EXP_EIP160,
    ),
    opcode_values.SELFDESTRUCT: as_opcode(
        logic_fn=system.selfdestruct_eip161,
        mnemonic=mnemonics.SELFDESTRUCT,
        gas_cost=constants.GAS_SELFDESTRUCT_EIP150,
    ),
    opcode_values.CALL: call.CallEIP161.configure(
        name='opcode:CALL',
        mnemonic=mnemonics.CALL,
        gas_cost=constants.GAS_CALL_EIP150,
    )(),
}

예제 #2
0
파일: opcodes.py 프로젝트: zhengger/py-evm
from evm.opcode import as_opcode

from evm.logic import (
    call,
    context,
    storage,
    system,
)

from evm.vm.forks.homestead.opcodes import HOMESTEAD_OPCODES

UPDATED_OPCODES = {
    opcode_values.EXTCODESIZE:
    as_opcode(
        logic_fn=context.extcodesize,
        mnemonic=mnemonics.EXTCODESIZE,
        gas_cost=constants.GAS_EXTCODE_EIP150,
    ),
    opcode_values.EXTCODECOPY:
    as_opcode(
        logic_fn=context.extcodecopy,
        mnemonic=mnemonics.EXTCODECOPY,
        gas_cost=constants.GAS_EXTCODE_EIP150,
    ),
    opcode_values.BALANCE:
    as_opcode(
        logic_fn=context.balance,
        mnemonic=mnemonics.BALANCE,
        gas_cost=constants.GAS_BALANCE_EIP150,
    ),
    opcode_values.SLOAD:
예제 #3
0
    memory,
    sha3,
    stack,
    storage,
    swap,
    system,
)


FRONTIER_OPCODES = {
    #
    # Arithmetic
    #
    opcode_values.STOP: as_opcode(
        logic_fn=flow.stop,
        mnemonic=mnemonics.STOP,
        gas_cost=constants.GAS_ZERO,
    ),
    opcode_values.ADD: as_opcode(
        logic_fn=arithmetic.add,
        mnemonic=mnemonics.ADD,
        gas_cost=constants.GAS_VERYLOW,
    ),
    opcode_values.MUL: as_opcode(
        logic_fn=arithmetic.mul,
        mnemonic=mnemonics.MUL,
        gas_cost=constants.GAS_LOW,
    ),
    opcode_values.SUB: as_opcode(
        logic_fn=arithmetic.sub,
        mnemonic=mnemonics.SUB,
예제 #4
0
파일: opcodes.py 프로젝트: firefox0x/py-evm
    memory,
    sha3,
    stack,
    storage,
    swap,
    system,
)


FRONTIER_OPCODES = {
    #
    # Arithmetic
    #
    opcode_values.STOP: as_opcode(
        logic_fn=flow.stop,
        mnemonic=mnemonics.STOP,
        gas_cost=constants.GAS_ZERO,
    ),
    opcode_values.ADD: as_opcode(
        logic_fn=arithmetic.add,
        mnemonic=mnemonics.ADD,
        gas_cost=constants.GAS_VERYLOW,
    ),
    opcode_values.MUL: as_opcode(
        logic_fn=arithmetic.mul,
        mnemonic=mnemonics.MUL,
        gas_cost=constants.GAS_LOW,
    ),
    opcode_values.SUB: as_opcode(
        logic_fn=arithmetic.sub,
        mnemonic=mnemonics.SUB,
예제 #5
0
파일: opcodes.py 프로젝트: firefox0x/py-evm
from evm.vm.forks.spurious_dragon.opcodes import SPURIOUS_DRAGON_OPCODES


def ensure_no_static(opcode_fn):
    @functools.wraps(opcode_fn)
    def inner(computation):
        if computation.msg.is_static:
            raise WriteProtection("Cannot modify state while inside of a STATICCALL context")
        return opcode_fn(computation)
    return inner


UPDATED_OPCODES = {
    opcode_values.REVERT: as_opcode(
        logic_fn=system.revert,
        mnemonic=mnemonics.REVERT,
        gas_cost=constants.GAS_ZERO,
    ),
    #
    # Context
    #
    opcode_values.RETURNDATASIZE: as_opcode(
        logic_fn=context.returndatasize,
        mnemonic=mnemonics.RETURNDATASIZE,
        gas_cost=constants.GAS_BASE,
    ),
    opcode_values.RETURNDATACOPY: as_opcode(
        logic_fn=context.returndatacopy,
        mnemonic=mnemonics.RETURNDATACOPY,
        gas_cost=constants.GAS_VERYLOW,
    ),
예제 #6
0
from evm.opcode import as_opcode

from evm.logic import (
    call,
    context,
    storage,
    system,
)

from evm.vm.flavors.homestead.opcodes import HOMESTEAD_OPCODES

UPDATED_OPCODES = {
    opcode_values.EXTCODESIZE:
    as_opcode(
        logic_fn=context.extcodesize,
        mnemonic=mnemonics.EXTCODESIZE,
        gas_cost=constants.GAS_EXTCODE_EIP150,
    ),
    opcode_values.EXTCODECOPY:
    as_opcode(
        logic_fn=context.extcodecopy,
        mnemonic=mnemonics.EXTCODECOPY,
        gas_cost=constants.GAS_EXTCODE_EIP150,
    ),
    opcode_values.BALANCE:
    as_opcode(
        logic_fn=context.balance,
        mnemonic=mnemonics.BALANCE,
        gas_cost=constants.GAS_BALANCE_EIP150,
    ),
    opcode_values.SLOAD:
예제 #7
0
파일: opcodes.py 프로젝트: firefox0x/py-evm
from evm.opcode import as_opcode

from evm.logic import (
    call,
    context,
    storage,
    system,
)

from evm.vm.forks.homestead.opcodes import HOMESTEAD_OPCODES


UPDATED_OPCODES = {
    opcode_values.EXTCODESIZE: as_opcode(
        logic_fn=context.extcodesize,
        mnemonic=mnemonics.EXTCODESIZE,
        gas_cost=constants.GAS_EXTCODE_EIP150,
    ),
    opcode_values.EXTCODECOPY: as_opcode(
        logic_fn=context.extcodecopy,
        mnemonic=mnemonics.EXTCODECOPY,
        gas_cost=constants.GAS_EXTCODE_EIP150,
    ),
    opcode_values.BALANCE: as_opcode(
        logic_fn=context.balance,
        mnemonic=mnemonics.BALANCE,
        gas_cost=constants.GAS_BALANCE_EIP150,
    ),
    opcode_values.SLOAD: as_opcode(
        logic_fn=storage.sload,
        mnemonic=mnemonics.SLOAD,
예제 #8
0
파일: opcodes.py 프로젝트: firefox0x/py-evm
    system,
    call,
)

from evm.vm.forks.tangerine_whistle.opcodes import TANGERINE_WHISTLE_OPCODES

from .constants import (
    GAS_EXP_EIP160,
    GAS_EXPBYTE_EIP160
)


UPDATED_OPCODES = {
    opcode_values.EXP: as_opcode(
        logic_fn=arithmetic.exp(gas_per_byte=GAS_EXPBYTE_EIP160),
        mnemonic=mnemonics.EXP,
        gas_cost=GAS_EXP_EIP160,
    ),
    opcode_values.SELFDESTRUCT: as_opcode(
        logic_fn=system.selfdestruct_eip161,
        mnemonic=mnemonics.SELFDESTRUCT,
        gas_cost=GAS_SELFDESTRUCT_EIP150,
    ),
    opcode_values.CALL: call.CallEIP161.configure(
        name='opcode:CALL',
        mnemonic=mnemonics.CALL,
        gas_cost=GAS_CALL_EIP150,
    )(),
}

예제 #9
0
def ensure_no_static(opcode_fn):
    @functools.wraps(opcode_fn)
    def inner(computation):
        if computation.msg.is_static:
            raise WriteProtection(
                "Cannot modify state while inside of a STATICCALL context")
        return opcode_fn(computation)

    return inner


UPDATED_OPCODES = {
    opcode_values.REVERT:
    as_opcode(
        logic_fn=system.revert,
        mnemonic=mnemonics.REVERT,
        gas_cost=constants.GAS_ZERO,
    ),
    #
    # Context
    #
    opcode_values.RETURNDATASIZE:
    as_opcode(
        logic_fn=context.returndatasize,
        mnemonic=mnemonics.RETURNDATASIZE,
        gas_cost=constants.GAS_BASE,
    ),
    opcode_values.RETURNDATACOPY:
    as_opcode(
        logic_fn=context.returndatacopy,
        mnemonic=mnemonics.RETURNDATACOPY,
예제 #10
0
from evm import mnemonics

from evm.opcode import as_opcode
from evm.logic import (
    call,
    context,
    system,
)

from evm.vm.forks.byzantium.opcodes import BYZANTIUM_OPCODES

NEW_OPCODES = {
    opcode_values.SIGHASH:
    as_opcode(
        logic_fn=context.sighash,
        mnemonic=mnemonics.SIGHASH,
        gas_cost=constants.GAS_BASE,
    ),
    opcode_values.CREATE2:
    system.Create2.configure(
        __name__='opcode:CREATE2',
        mnemonic=mnemonics.CREATE2,
        gas_cost=constants.GAS_CREATE2,
    )(),
    opcode_values.PAYGAS:
    as_opcode(
        logic_fn=system.paygas,
        mnemonic=mnemonics.PAYGAS,
        gas_cost=constants.GAS_VERYLOW,
    ),
}