diff --git a/ethervm.py b/ethervm.py index b7713ee..67da5e5 100644 --- a/ethervm.py +++ b/ethervm.py @@ -1,14 +1,13 @@ from flask import Flask -from flask_table import Table, Col # type: ignore - -from evm_asm import disassemble, evm_opcodes, LATEST_VERSION -from evm_asm.typing import Bytecode - +from flask_table import Col, Table # type: ignore +from web3.auto.infura.goerli import w3 as goerli_w3 +from web3.auto.infura.kovan import w3 as kovan_w3 from web3.auto.infura.mainnet import w3 as mainnet_w3 -from web3.auto.infura.ropsten import w3 as ropsten_w3 from web3.auto.infura.rinkeby import w3 as rinkeby_w3 -from web3.auto.infura.kovan import w3 as kovan_w3 -from web3.auto.infura.goerli import w3 as goerli_w3 +from web3.auto.infura.ropsten import w3 as ropsten_w3 + +from evm_asm import LATEST_VERSION, disassemble, evm_opcodes +from evm_asm.typing import Bytecode AVAILABLE_WEB3 = { "mainnet": mainnet_w3, diff --git a/evm_asm/assembler.py b/evm_asm/assembler.py index 006fdbf..07ec28b 100644 --- a/evm_asm/assembler.py +++ b/evm_asm/assembler.py @@ -1,18 +1,8 @@ from typing import Dict, Optional, Tuple -from evm_asm.errors import ( - InvalidOpcodeInput, - UnsupportedOpcode, -) -from evm_asm.typing import ( - Assembly, - Bytecode, - Metadata, - Opcode, - OpcodeValue, -) +from evm_asm.errors import InvalidOpcodeInput, UnsupportedOpcode from evm_asm.forks import Fork - +from evm_asm.typing import Assembly, Bytecode, Metadata, Opcode, OpcodeValue END_OPCODES = ( 0x00, # STOP diff --git a/evm_asm/forks/__init__.py b/evm_asm/forks/__init__.py index 6a8fdc7..f7ca996 100755 --- a/evm_asm/forks/__init__.py +++ b/evm_asm/forks/__init__.py @@ -1,16 +1,15 @@ from typing import Iterator from .base import Fork - -from .frontier import Frontier -from .homestead import Homestead -from .tangerine_whistle import TangerineWhistle -from .spurious_dragon import SpuriousDragon from .byzantium import Byzantium from .constantinople import Constantinople -from .petersburg import Petersburg +from .frontier import Frontier +from .homestead import Homestead from .istanbul import Istanbul from .muir_glacier import MuirGlacier +from .petersburg import Petersburg +from .spurious_dragon import SpuriousDragon +from .tangerine_whistle import TangerineWhistle class EvmForks: diff --git a/evm_asm/forks/base.py b/evm_asm/forks/base.py index 4bedcd5..f4d4ed0 100644 --- a/evm_asm/forks/base.py +++ b/evm_asm/forks/base.py @@ -1,17 +1,9 @@ -from typing import Dict, Iterator, Tuple - import re from collections import OrderedDict +from typing import Dict, Iterator, Tuple -from evm_asm.errors import ( - UnsupportedOpcode, -) -from evm_asm.typing import ( - Mnemonic, - Opcode, - OpcodeLike, - OpcodeValue, -) +from evm_asm.errors import UnsupportedOpcode +from evm_asm.typing import Mnemonic, Opcode, OpcodeLike, OpcodeValue class Fork: diff --git a/evm_asm/forks/byzantium.py b/evm_asm/forks/byzantium.py index 5c85c46..f0330a2 100644 --- a/evm_asm/forks/byzantium.py +++ b/evm_asm/forks/byzantium.py @@ -1,6 +1,7 @@ -from .spurious_dragon import SpuriousDragon from evm_asm.typing import Opcode +from .spurious_dragon import SpuriousDragon + class Byzantium(SpuriousDragon): REVERT = Opcode("REVERT", 0, 0xFD) diff --git a/evm_asm/forks/constantinople.py b/evm_asm/forks/constantinople.py index 823fd7a..378808c 100644 --- a/evm_asm/forks/constantinople.py +++ b/evm_asm/forks/constantinople.py @@ -1,6 +1,7 @@ -from .byzantium import Byzantium from evm_asm.typing import Opcode +from .byzantium import Byzantium + class Constantinople(Byzantium): SHL = Opcode("SHL", 3, 0x1B) diff --git a/evm_asm/forks/frontier.py b/evm_asm/forks/frontier.py index 129ed93..95de30f 100644 --- a/evm_asm/forks/frontier.py +++ b/evm_asm/forks/frontier.py @@ -1,6 +1,7 @@ -from .base import Fork from evm_asm.typing import Opcode +from .base import Fork + class Frontier(Fork): STOP = Opcode("STOP", 0, 0x00) diff --git a/evm_asm/forks/homestead.py b/evm_asm/forks/homestead.py index a325aa1..38898d8 100644 --- a/evm_asm/forks/homestead.py +++ b/evm_asm/forks/homestead.py @@ -1,6 +1,7 @@ -from .frontier import Frontier from evm_asm.typing import Opcode +from .frontier import Frontier + class Homestead(Frontier): DELEGATECALL = Opcode("DELEGATECALL", 40, 0xF4) diff --git a/evm_asm/forks/istanbul.py b/evm_asm/forks/istanbul.py index 3e784f9..2cc60c7 100644 --- a/evm_asm/forks/istanbul.py +++ b/evm_asm/forks/istanbul.py @@ -1,6 +1,7 @@ -from .petersburg import Petersburg from evm_asm.typing import Opcode +from .petersburg import Petersburg + class Istanbul(Petersburg): BALANCE = Opcode("BALANCE", 700, 0x31) diff --git a/evm_asm/forks/petersburg.py b/evm_asm/forks/petersburg.py index e3c0e89..583dab2 100644 --- a/evm_asm/forks/petersburg.py +++ b/evm_asm/forks/petersburg.py @@ -1,6 +1,7 @@ -from .byzantium import Byzantium from evm_asm.typing import Opcode +from .byzantium import Byzantium + class Petersburg(Byzantium): SHL = Opcode("SHL", 3, 0x1B) diff --git a/evm_asm/forks/tangerine_whistle.py b/evm_asm/forks/tangerine_whistle.py index 30baf5a..539c00a 100644 --- a/evm_asm/forks/tangerine_whistle.py +++ b/evm_asm/forks/tangerine_whistle.py @@ -1,6 +1,7 @@ -from .homestead import Homestead from evm_asm.typing import Opcode +from .homestead import Homestead + class TangerineWhistle(Homestead): BALANCE = Opcode("BALANCE", 400, 0x31) diff --git a/evm_asm/typing.py b/evm_asm/typing.py index 64f3d0e..861421c 100644 --- a/evm_asm/typing.py +++ b/evm_asm/typing.py @@ -1,6 +1,5 @@ from dataclasses import dataclass -from typing import Iterable, Optional, NewType, Union - +from typing import Iterable, NewType, Optional, Union # TODO https://ethervm.io/ diff --git a/tests/conftest.py b/tests/conftest.py index 16bd868..e61e78d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,6 @@ import pytest - from eth.vm import forks as pyevm_forks + from evm_asm import evm_opcodes diff --git a/tools/fork_gen.py b/tools/fork_gen.py index d7c3151..b27f488 100644 --- a/tools/fork_gen.py +++ b/tools/fork_gen.py @@ -1,18 +1,18 @@ -import sys import pathlib +import sys path = str(pathlib.Path(__file__).absolute().parent.parent) sys.path.insert(0, path) -from eth.vm.forks.frontier.opcodes import FRONTIER_OPCODES -from eth.vm.forks.homestead.opcodes import HOMESTEAD_OPCODES -from eth.vm.forks.tangerine_whistle.opcodes import TANGERINE_WHISTLE_OPCODES -from eth.vm.forks.spurious_dragon.opcodes import SPURIOUS_DRAGON_OPCODES from eth.vm.forks.byzantium.opcodes import BYZANTIUM_OPCODES from eth.vm.forks.constantinople.opcodes import CONSTANTINOPLE_OPCODES -from eth.vm.forks.petersburg.opcodes import PETERSBURG_OPCODES +from eth.vm.forks.frontier.opcodes import FRONTIER_OPCODES +from eth.vm.forks.homestead.opcodes import HOMESTEAD_OPCODES from eth.vm.forks.istanbul.opcodes import ISTANBUL_OPCODES from eth.vm.forks.muir_glacier.opcodes import MUIR_GLACIER_OPCODES +from eth.vm.forks.petersburg.opcodes import PETERSBURG_OPCODES +from eth.vm.forks.spurious_dragon.opcodes import SPURIOUS_DRAGON_OPCODES +from eth.vm.forks.tangerine_whistle.opcodes import TANGERINE_WHISTLE_OPCODES PY_EVM_FORKS = { "frontier": FRONTIER_OPCODES,