From 13ea0a1c87335a512c1176ef31c1a4543f5974e8 Mon Sep 17 00:00:00 2001 From: antazoey Date: Thu, 18 Apr 2024 10:56:20 -0600 Subject: [PATCH] refactor!: rename geth to node (#1982) --- docs/userguides/config.md | 4 +- docs/userguides/contracts.md | 2 +- docs/userguides/networks.md | 36 +++++++-------- docs/userguides/testing.md | 5 ++- docs/userguides/transactions.md | 2 +- src/ape/__modules__.py | 2 +- src/ape/api/networks.py | 8 ++-- src/ape/api/providers.py | 8 +--- src/ape/managers/networks.py | 6 +-- src/ape/managers/project/manager.py | 6 +-- src/ape_ethereum/ecosystem.py | 8 +++- src/ape_ethereum/provider.py | 2 +- src/ape_networks/__init__.py | 2 +- src/ape_networks/_cli.py | 2 +- src/{ape_geth => ape_node}/__init__.py | 9 ++-- src/{ape_geth => ape_node}/provider.py | 25 ++++++----- src/{ape_geth => ape_node}/py.typed | 0 src/{ape_geth => ape_node}/query.py | 0 tests/conftest.py | 4 +- tests/functional/geth/conftest.py | 8 ++-- tests/functional/geth/test_provider.py | 45 ++++++++++++------- tests/functional/test_cli.py | 6 +-- tests/functional/test_config.py | 10 ++--- tests/functional/test_network_api.py | 4 +- tests/functional/test_network_manager.py | 24 +++++----- .../cli/projects/geth/ape-config.yaml | 4 +- .../geth/tests/test_using_local_geth.py | 2 +- tests/integration/cli/test_misc.py | 2 +- tests/integration/cli/test_networks.py | 32 ++++++------- tests/integration/cli/test_plugins.py | 2 +- tests/integration/cli/test_test.py | 26 +++++------ 31 files changed, 154 insertions(+), 142 deletions(-) rename src/{ape_geth => ape_node}/__init__.py (65%) rename src/{ape_geth => ape_node}/provider.py (96%) rename src/{ape_geth => ape_node}/py.typed (100%) rename src/{ape_geth => ape_node}/query.py (100%) diff --git a/docs/userguides/config.md b/docs/userguides/config.md index f922246c0f..716012b0a5 100644 --- a/docs/userguides/config.md +++ b/docs/userguides/config.md @@ -99,9 +99,9 @@ geth: uri: http://localhost:5030 ``` -Now, the `ape-geth` core plugin will use the URL `http://localhost:5030` to connect and make requests. +Now, the `ape-node` core plugin will use the URL `http://localhost:5030` to connect and make requests. -**WARN**: Instead of using `ape-geth` to connect to an Infura or Alchemy node, use the [ape-infura](https://github.com/ApeWorX/ape-infura) or [ape-alchemy](https://github.com/ApeWorX/ape-alchemy) provider plugins instead, which have their own way of managing API keys via environment variables. +**WARN**: Instead of using `ape-node` to connect to an Infura or Alchemy node, use the [ape-infura](https://github.com/ApeWorX/ape-infura) or [ape-alchemy](https://github.com/ApeWorX/ape-alchemy) provider plugins instead, which have their own way of managing API keys via environment variables. For more information on networking as a whole, see [this guide](./networks.html). diff --git a/docs/userguides/contracts.md b/docs/userguides/contracts.md index f6f5876f01..f868670b59 100644 --- a/docs/userguides/contracts.md +++ b/docs/userguides/contracts.md @@ -219,7 +219,7 @@ print(receipt.gas_used) Notice that transacting returns a [ReceiptAPI](../methoddocs/api.html#ape.api.transactions.ReceiptAPI) object which contains all the receipt data, such as `gas_used`. -**NOTE**: If you need the `return_value` from a transaction, you have to either treat transaction as a call (see the section below!) or use a provider with tracing-features enabled (such as `ape-foundry` or `ape-geth`) and access the [return_value](../methoddocs/api.html#ape.api.transactions.ReceiptAPI.return_value) property on the receipt. +**NOTE**: If you need the `return_value` from a transaction, you have to either treat transaction as a call (see the section below!) or use a provider with tracing-features enabled (such as `ape-foundry` or `ape-node`) and access the [return_value](../methoddocs/api.html#ape.api.transactions.ReceiptAPI.return_value) property on the receipt. ```python assert receipt.return_value == 123 diff --git a/docs/userguides/networks.md b/docs/userguides/networks.md index a303607037..04c34b54c1 100644 --- a/docs/userguides/networks.md +++ b/docs/userguides/networks.md @@ -1,6 +1,6 @@ # Networks -When interacting with a blockchain, you will have to select an ecosystem (e.g. Ethereum, Arbitrum, or Fantom), a network (e.g. Mainnet or Sepolia) and a provider (e.g. Eth-Tester, Geth, or Alchemy). +When interacting with a blockchain, you will have to select an ecosystem (e.g. Ethereum, Arbitrum, or Fantom), a network (e.g. Mainnet or Sepolia) and a provider (e.g. Eth-Tester, Node (Geth), or Alchemy). Networks are part of ecosystems and typically defined in plugins. For example, the `ape-ethereum` plugin comes with Ape and can be used for handling EVM-like behavior. @@ -15,7 +15,7 @@ No matter what type of network you are using in Ape, you specify the network usi Where `ecosystem-name` refers to the ecosystem, e.g. `ethereum`, `polygon`, `fantom`, or any valid ecosystem plugin name. The `network-name` refers to a network such as `mainnet`, `local`, or something else defined by your ecosystem or custom network config. -And `provider-name` refers to the provider plugin in Ape, such as `geth` for a generic node or `foundry` if the network is more Anvil-based, or a different plugin altogether. +And `provider-name` refers to the provider plugin in Ape, such as `node` for a generic node or `foundry` if the network is more Anvil-based, or a different plugin altogether. Commonly, the network triplet value is specified via the `--network` option in Ape CLI commands. The following is a list of common Ape commands that can use the `--network` option: @@ -79,10 +79,10 @@ Here is a list of all L2 network plugins supported by Ape: **NOTE**: If you are connecting an L2 network or any other network that does not have a plugin, you can use the custom network support, which is described in the [next section](#custom-network-connection). -Once you have the L2 network plugin installed, you can configure its node's URI by setting the values in the `geth` (default node) core plugin via your `ape-config.yaml` file: +Once you have the L2 network plugin installed, you can configure its node's URI by setting the values in the `node` core plugin via your `ape-config.yaml` file: ```yaml -geth: +node: : : uri: https://path.to.node.example.com @@ -120,7 +120,7 @@ networks: chain_id: 109 # Required ecosystem: shibarium # The ecosystem name, can either be new or an existing base_ecosystem_plugin: polygon # The ecosystem base-class, defaults to the default ecosystem - default_provider: geth # Default is the generic node provider + default_provider: node # Default is the generic node provider ``` The following paragraphs explain the different parameters of the custom network config. @@ -168,13 +168,13 @@ networks: base_ecosystem_plugin: polygon # Closest base class. chain_id: 109 # This must be correct or txns will fail. -geth: +node: shibarium: mainnet: uri: https://www.shibrpc.com ``` -Now, when using `ethereum:apenet:geth`, it will connect to the RPC URL `https://apenet.example.com/rpc`. +Now, when using `ethereum:apenet:node`, it will connect to the RPC URL `https://apenet.example.com/rpc`. #### Explorer URL @@ -186,7 +186,7 @@ networks: custom: - name: customnetwork chain_id: 31337 - default_provider: geth + default_provider: node ``` To add a corresponding entry in `ape-etherscan` (assuming you are using `ape-etherscan` as your explorer plugin), add the following to your `ape-config.yaml` file: @@ -314,24 +314,24 @@ It is meant for running tests and debugging contracts. Out-of-the-box, Ape ships with two development providers you can use for the `local` network: - [EthTester](https://github.com/ethereum/eth-tester) -- An Ephemeral Geth process +- An Ephemeral Node (defaults to Geth) process ```bash ape test --network ::test -ape test --network ::geth # Launch a local development geth process +ape test --network ::node # Launch a local development node (geth) process ``` To learn more about testing in ape, follow [this guide](./testing.html). ## Live Networks -Use the core plugin `ape-geth` to connect to local or remote nodes via URI. -The geth plugin is abstract in that it represents any node, not just geth nodes. +Use the core plugin `ape-node` to connect to local or remote nodes via URI. +The node plugin is abstract in that it represents any node. However, it will work best when connected to a geth node. -To configure network URIs in geth, you can use the `ape-config.yaml` file: +To configure network URIs in `node`, you can use the `ape-config.yaml` file: ```yaml -geth: +node: ethereum: mainnet: uri: https://foo.node.bar @@ -391,7 +391,7 @@ To run a network with a process, use the `ape networks run` command: ape networks run ``` -By default, `ape networks run` runs a development Geth process. +By default, `ape networks run` runs a development Node (geth) process. To use a different network, such as `hardhat` or Anvil nodes, use the `--network` flag: ```shell @@ -423,7 +423,7 @@ from ape import chain, networks def main(): start_provider = chain.provider.name - with networks.ethereum.mainnet.use_provider("geth") as provider: + with networks.ethereum.mainnet.use_provider("node") as provider: # We are using a different provider than the one we started with. assert start_provider != provider.name ``` @@ -436,9 +436,9 @@ from ape import networks @click.command() def cli(): - with networks.polygon.mainnet.use_provider("geth"): + with networks.polygon.mainnet.use_provider("node"): ... - with networks.ethereum.mainnet.use_provider("geth"): + with networks.ethereum.mainnet.use_provider("node"): ... ``` diff --git a/docs/userguides/testing.md b/docs/userguides/testing.md index 71eb42f7f4..93aac64122 100644 --- a/docs/userguides/testing.md +++ b/docs/userguides/testing.md @@ -235,10 +235,11 @@ ape test test_my_contract -I -s ## Test Providers -Out-of-the-box, your tests run using the `eth-tester` provider, which comes bundled with ape. If you have `geth` installed, you can use the `ape-geth` plugin that also comes with ape. +Out-of-the-box, your tests run using the `eth-tester` provider, which comes bundled with ape. +If you have Ethereum node software installed, you can use the `ape-node` plugin that also comes with ape. ```bash -ape test --network ethereum:local:geth +ape test --network ethereum:local:node ``` Each testing plugin should work the same way. You will have access to the same test accounts. diff --git a/docs/userguides/transactions.md b/docs/userguides/transactions.md index 3c3371bfe1..d625ab9764 100644 --- a/docs/userguides/transactions.md +++ b/docs/userguides/transactions.md @@ -265,7 +265,7 @@ Use the `show_trace=` kwarg on a contract call and Ape will display the trace be token.balanceOf(account, show_trace=True) ``` -**NOTE**: This may not work on all providers, but it should work on common ones such as `ape-hardhat` or `ape-geth`. +**NOTE**: This may not work on all providers, but it should work on common ones such as `ape-hardhat` or `ape-node`. ## Gas Reports diff --git a/src/ape/__modules__.py b/src/ape/__modules__.py index 8bcaa95a0c..57a8ce6358 100644 --- a/src/ape/__modules__.py +++ b/src/ape/__modules__.py @@ -5,9 +5,9 @@ "ape_compile", "ape_console", "ape_ethereum", - "ape_geth", "ape_init", "ape_networks", + "ape_node", "ape_plugins", "ape_run", "ape_test", diff --git a/src/ape/api/networks.py b/src/ape/api/networks.py index e5f275da4f..778063f424 100644 --- a/src/ape/api/networks.py +++ b/src/ape/api/networks.py @@ -124,7 +124,7 @@ def custom_network(self) -> "NetworkAPI": ecosystem=ethereum, data_folder=self.data_folder / "custom", request_header=request_header, - _default_provider="geth", + _default_provider="node", _is_custom=True, ) @@ -958,7 +958,7 @@ def is_adhoc(self) -> bool: @cached_property def providers(self): # -> Dict[str, Partial[ProviderAPI]] """ - The providers of the network, such as Infura, Alchemy, or Geth. + The providers of the network, such as Infura, Alchemy, or Node. Returns: Dict[str, partial[:class:`~ape.api.providers.ProviderAPI`]] @@ -1023,11 +1023,11 @@ def get_provider( if ":" in provider_name: # NOTE: Shortcut that allows `--network ecosystem:network:http://...` to work provider_settings["uri"] = provider_name - provider_name = "geth" + provider_name = "node" elif provider_name.endswith(".ipc"): provider_settings["ipc_path"] = provider_name - provider_name = "geth" + provider_name = "node" if provider_name in self.providers: provider = self.providers[provider_name](provider_settings=provider_settings) diff --git a/src/ape/api/providers.py b/src/ape/api/providers.py index 51c3e6c428..5d86547626 100644 --- a/src/ape/api/providers.py +++ b/src/ape/api/providers.py @@ -645,13 +645,7 @@ def set_balance(self, address: AddressType, amount: int): @log_instead_of_fail(default="") def __repr__(self) -> str: - try: - chain_id = self.chain_id - except Exception as err: - logger.error(str(err)) - chain_id = None - - return f"<{self.name} chain_id={self.chain_id}>" if chain_id else f"<{self.name}>" + return f"<{self.name.capitalize()} chain_id={self.chain_id}>" @raises_not_implemented def set_code( # type: ignore[empty-body] diff --git a/src/ape/managers/networks.py b/src/ape/managers/networks.py index c4828412d7..e4d750f25f 100644 --- a/src/ape/managers/networks.py +++ b/src/ape/managers/networks.py @@ -26,7 +26,7 @@ class NetworkManager(BaseManager): from ape import networks # "networks" is the NetworkManager singleton - with networks.ethereum.mainnet.use_provider("geth"): + with networks.ethereum.mainnet.use_provider("node"): ... """ @@ -230,7 +230,7 @@ def create_custom_provider( if provider_name is None: if issubclass(provider_cls, EthereumNodeProvider): - name = "geth" + name = "node" elif cls_name := getattr(provider_cls, "name", None): name = cls_name @@ -323,7 +323,7 @@ def get_network_choices( e.g. ``--network [ECOSYSTEM:NETWORK:PROVIDER]``. Each value is in the form ``ecosystem:network:provider`` and shortened options also - appear in the list. For example, ``::geth`` would default to ``:ethereum:local:geth`` + appear in the list. For example, ``::node`` would default to ``:ethereum:local:node`` and both will be in the returned list. The values come from each :class:`~ape.api.providers.ProviderAPI` that is installed. diff --git a/src/ape/managers/project/manager.py b/src/ape/managers/project/manager.py index b8eecf878d..c4021bdb43 100644 --- a/src/ape/managers/project/manager.py +++ b/src/ape/managers/project/manager.py @@ -468,10 +468,10 @@ def contracts(self) -> Dict[str, ContractType]: Returns: Dict[str, ``ContractType``] """ - if self.local_project.cached_manifest is None: - return self.load_contracts() + if contracts := self.local_project.contracts: + return contracts - return self.local_project.contracts + return self.load_contracts() def __getattr__(self, attr_name: str) -> Any: """ diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index 547ff9accf..c2bdf4b548 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -81,7 +81,7 @@ class NetworkConfig(PluginConfig): required_confirmations: int = 0 - default_provider: Optional[str] = "geth" + default_provider: Optional[str] = "node" """ The default provider to use. If set to ``None``, ape will rely on an external plugin supplying the provider implementation, such as @@ -324,9 +324,13 @@ def size(self) -> int: # (normal). return self._size + number = self.number + if number is None: + raise APINotImplementedError() + # Try to get it from the provider. if provider := self.network_manager.active_provider: - block = provider.get_block(self.number) + block = provider.get_block(number) size = block._size if size is not None and size > -1: self._size = size diff --git a/src/ape_ethereum/provider.py b/src/ape_ethereum/provider.py index 0b31d9a86f..2f84a67b01 100644 --- a/src/ape_ethereum/provider.py +++ b/src/ape_ethereum/provider.py @@ -1225,7 +1225,7 @@ class EthereumNodeProvider(Web3Provider, ABC): block_page_size: int = 5000 concurrency: int = 16 - name: str = "geth" + name: str = "node" """Is ``None`` until known.""" can_use_parity_traces: Optional[bool] = None diff --git a/src/ape_networks/__init__.py b/src/ape_networks/__init__.py index 7f60876edd..96a2ae5ee3 100644 --- a/src/ape_networks/__init__.py +++ b/src/ape_networks/__init__.py @@ -22,7 +22,7 @@ class CustomNetwork(PluginConfig): base_ecosystem_plugin: Optional[str] = None """The default provider plugin to use. Default is the default node provider.""" - default_provider: str = "geth" + default_provider: str = "node" """The HTTP request header.""" request_header: Dict = {} diff --git a/src/ape_networks/_cli.py b/src/ape_networks/_cli.py index 9e3419a7c0..b8558ff183 100644 --- a/src/ape_networks/_cli.py +++ b/src/ape_networks/_cli.py @@ -107,7 +107,7 @@ def make_sub_tree(data: Dict, create_tree: Callable) -> Tree: @cli.command(short_help="Start a node process") @ape_cli_context() -@network_option(default="ethereum:local:geth") +@network_option(default="ethereum:local:node") def run(cli_ctx, provider): """ Start a subprocess node as if running independently diff --git a/src/ape_geth/__init__.py b/src/ape_node/__init__.py similarity index 65% rename from src/ape_geth/__init__.py rename to src/ape_node/__init__.py index 9b150e9cd8..bec9023f6f 100644 --- a/src/ape_geth/__init__.py +++ b/src/ape_node/__init__.py @@ -1,22 +1,21 @@ from ape import plugins from ape.api.networks import LOCAL_NETWORK_NAME -from .provider import Geth as GethProvider -from .provider import GethConfig, GethDev, GethNetworkConfig +from .provider import EthereumNetworkConfig, EthereumNodeConfig, GethDev, Node from .query import OTSQueryEngine @plugins.register(plugins.Config) def config_class(): - return GethConfig + return EthereumNodeConfig @plugins.register(plugins.ProviderPlugin) def providers(): - networks_dict = GethNetworkConfig().model_dump() + networks_dict = EthereumNetworkConfig().model_dump() networks_dict.pop(LOCAL_NETWORK_NAME) for network_name in networks_dict: - yield "ethereum", network_name, GethProvider + yield "ethereum", network_name, Node yield "ethereum", LOCAL_NETWORK_NAME, GethDev diff --git a/src/ape_geth/provider.py b/src/ape_node/provider.py similarity index 96% rename from src/ape_geth/provider.py rename to src/ape_node/provider.py index 8018e5246b..59a9abfa50 100644 --- a/src/ape_geth/provider.py +++ b/src/ape_node/provider.py @@ -63,7 +63,7 @@ def __init__( ): executable = executable or "geth" if not shutil.which(executable): - raise GethNotInstalledError() + raise NodeSoftwareNotInstalledError() self.data_dir = data_dir self._hostname = hostname @@ -195,7 +195,7 @@ def wait(self, *args, **kwargs): self.proc.wait(*args, **kwargs) -class GethNetworkConfig(PluginConfig): +class EthereumNetworkConfig(PluginConfig): # Make sure you are running the right networks when you try for these mainnet: Dict = {"uri": get_random_rpc("ethereum", "mainnet")} sepolia: Dict = {"uri": get_random_rpc("ethereum", "sepolia")} @@ -205,8 +205,8 @@ class GethNetworkConfig(PluginConfig): model_config = SettingsConfigDict(extra="allow") -class GethConfig(PluginConfig): - ethereum: GethNetworkConfig = GethNetworkConfig() +class EthereumNodeConfig(PluginConfig): + ethereum: EthereumNetworkConfig = EthereumNetworkConfig() executable: Optional[str] = None ipc_path: Optional[Path] = None data_dir: Optional[Path] = None @@ -214,11 +214,10 @@ class GethConfig(PluginConfig): model_config = SettingsConfigDict(extra="allow") -# TODO: 0.8 rename exception. -class GethNotInstalledError(ConnectionError): +class NodeSoftwareNotInstalledError(ConnectionError): def __init__(self): super().__init__( - "No node found and 'ape-geth' is unable to start one.\n" + "No node found and 'ape-node' is unable to start one.\n" "Things you can do:\n" "\t1. Check your connection URL, if trying to connect remotely.\n" "\t2. Install node software (geth), if trying to run a local node.\n" @@ -229,7 +228,7 @@ def __init__(self): # NOTE: Using EthereumNodeProvider because of it's geth-derived default behavior. class GethDev(EthereumNodeProvider, TestProviderAPI, SubprocessProvider): _process: Optional[GethDevProcess] = None - name: str = "geth" + name: str = "node" can_use_parity_traces: Optional[bool] = False @property @@ -242,12 +241,14 @@ def chain_id(self) -> int: @property def data_dir(self) -> Path: - # Overridden from BaseGeth class for placing debug logs in ape data folder. + # Overridden from base class for placing debug logs in ape data folder. return self.settings.data_dir or self.data_folder / self.name - @log_instead_of_fail(default="") + @log_instead_of_fail(default="") def __repr__(self) -> str: - return f"" + client_version = self.client_version + client_version_str = f" ({client_version}) " if client_version else " " + return f"" @property def auto_mine(self) -> bool: @@ -469,7 +470,7 @@ def build_command(self) -> List[str]: # NOTE: The default behavior of EthereumNodeBehavior assumes geth. -class Geth(EthereumNodeProvider): +class Node(EthereumNodeProvider): @property def uri(self) -> str: if "uri" in self.provider_settings: diff --git a/src/ape_geth/py.typed b/src/ape_node/py.typed similarity index 100% rename from src/ape_geth/py.typed rename to src/ape_node/py.typed diff --git a/src/ape_geth/query.py b/src/ape_node/query.py similarity index 100% rename from src/ape_geth/query.py rename to src/ape_node/query.py diff --git a/tests/conftest.py b/tests/conftest.py index 8c2dc735cc..1cbc175f24 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -241,13 +241,13 @@ def networks_connected_to_tester(eth_tester_provider): def geth_provider(networks): if ( not networks.active_provider - or networks.provider.name != "geth" + or networks.provider.name != "node" or not networks.provider.is_connected or getattr(networks.provider, "uri", "") != GETH_URI ): test_acct_100 = "0x63c7f11162dBFC374DC6f5C0B3Aa26C618846a85" with networks.ethereum.local.use_provider( - "geth", provider_settings={"uri": GETH_URI, "extra_funded_accounts": [test_acct_100]} + "node", provider_settings={"uri": GETH_URI, "extra_funded_accounts": [test_acct_100]} ) as provider: yield provider else: diff --git a/tests/functional/geth/conftest.py b/tests/functional/geth/conftest.py index 68c8948d80..afeaf9edf6 100644 --- a/tests/functional/geth/conftest.py +++ b/tests/functional/geth/conftest.py @@ -4,7 +4,7 @@ import pytest from ape.contracts import ContractContainer -from ape_geth.provider import Geth +from ape_node.provider import Node from tests.functional.data.python import TRACE_RESPONSE @@ -62,8 +62,8 @@ def middle_contract_geth(geth_provider, owner, leaf_contract_geth, get_contract_ @pytest.fixture def mock_geth(geth_provider, mock_web3): - provider = Geth( - name="geth", + provider = Node( + name="node", network=geth_provider.network, provider_settings={}, data_folder=Path("."), @@ -105,7 +105,7 @@ def custom_network_connection( with temp_config(config): geth_provider.network = ethereum.apenet try: - with networks.ethereum.apenet.use_provider("geth"): + with networks.ethereum.apenet.use_provider("node"): yield finally: diff --git a/tests/functional/geth/test_provider.py b/tests/functional/geth/test_provider.py index 818850510f..9418bda823 100644 --- a/tests/functional/geth/test_provider.py +++ b/tests/functional/geth/test_provider.py @@ -25,7 +25,7 @@ TransactionStatusEnum, TransactionType, ) -from ape_geth.provider import GethDevProcess, GethNotInstalledError +from ape_node.provider import GethDevProcess, NodeSoftwareNotInstalledError from tests.conftest import GETH_URI, geth_process_test @@ -43,9 +43,9 @@ def test_uri(geth_provider): @geth_process_test def test_uri_localhost_not_running_uses_random_default(config): - cfg = config.get_config("geth").ethereum.mainnet + cfg = config.get_config("node").ethereum.mainnet assert cfg["uri"] in PUBLIC_CHAIN_META["ethereum"]["mainnet"]["rpc"] - cfg = config.get_config("geth").ethereum.sepolia + cfg = config.get_config("node").ethereum.sepolia assert cfg["uri"] in PUBLIC_CHAIN_META["ethereum"]["sepolia"]["rpc"] @@ -54,7 +54,7 @@ def test_uri_when_configured(geth_provider, temp_config, ethereum): settings = geth_provider.provider_settings geth_provider.provider_settings = {} value = "https://value/from/config" - config = {"geth": {"ethereum": {"local": {"uri": value}, "mainnet": {"uri": value}}}} + config = {"node": {"ethereum": {"local": {"uri": value}, "mainnet": {"uri": value}}}} expected = DEFAULT_SETTINGS["uri"] network = ethereum.get_network("mainnet") @@ -63,7 +63,7 @@ def test_uri_when_configured(geth_provider, temp_config, ethereum): # Assert we use the config value. actual_local_uri = geth_provider.uri # Assert provider settings takes precedence. - provider = network.get_provider("geth", provider_settings={"uri": expected}) + provider = network.get_provider("node", provider_settings={"uri": expected}) actual_mainnet_uri = provider.uri finally: @@ -75,19 +75,32 @@ def test_uri_when_configured(geth_provider, temp_config, ethereum): @geth_process_test def test_repr_connected(geth_provider): - assert repr(geth_provider) == "" + actual = repr(geth_provider) + expected = f"" + assert actual == expected @geth_process_test def test_repr_on_local_network_and_disconnected(networks): - geth = networks.get_provider_from_choice("ethereum:local:geth") - assert repr(geth) == "" + node = networks.get_provider_from_choice("ethereum:local:node") + # Ensure disconnected. + if w3 := node._web3: + node._web3 = None + + actual = repr(node) + expected = "" + assert actual == expected + + if w3: + node._web3 = w3 @geth_process_test def test_repr_on_live_network_and_disconnected(networks): - geth = networks.get_provider_from_choice("ethereum:sepolia:geth") - assert repr(geth) == "" + node = networks.get_provider_from_choice("ethereum:sepolia:node") + actual = repr(node) + expected = "" + assert actual == expected @geth_process_test @@ -106,8 +119,8 @@ def test_chain_id_when_connected(geth_provider): @geth_process_test def test_chain_id_live_network_not_connected(networks): - geth = networks.get_provider_from_choice("ethereum:sepolia:geth") - assert geth.chain_id == 11155111 + node = networks.get_provider_from_choice("ethereum:sepolia:node") + assert node.chain_id == 11155111 @geth_process_test @@ -159,7 +172,7 @@ def test_connect_to_chain_that_started_poa(mock_web3, web3_factory, ethereum): mock_web3.eth.get_block.side_effect = ExtraDataLengthError mock_web3.eth.chain_id = ethereum.sepolia.chain_id web3_factory.return_value = mock_web3 - provider = ethereum.sepolia.get_provider("geth") + provider = ethereum.sepolia.get_provider("node") provider.provider_settings = {"uri": "http://node.example.com"} # fake provider.connect() @@ -351,7 +364,7 @@ def test_send_transaction_when_no_error_and_receipt_fails( @geth_process_test def test_network_choice(geth_provider): actual = geth_provider.network_choice - expected = "ethereum:local:geth" + expected = "ethereum:local:node" assert actual == expected @@ -378,7 +391,7 @@ def test_make_request_not_exists(geth_provider): def test_geth_not_found(): bin_name = "__NOT_A_REAL_EXECUTABLE_HOPEFULLY__" - with pytest.raises(GethNotInstalledError): + with pytest.raises(NodeSoftwareNotInstalledError): _ = GethDevProcess(Path.cwd(), executable=bin_name) @@ -470,7 +483,7 @@ def test_create_access_list(geth_provider, geth_contract, geth_account): def test_send_call_base_class_block_id(networks, ethereum, mocker): """ Testing a case where was a bug in the base class for most providers. - Note: can't use ape-geth as-is, as it overrides `send_call()`. + Note: can't use ape-node as-is, as it overrides `send_call()`. """ provider = mocker.MagicMock() diff --git a/tests/functional/test_cli.py b/tests/functional/test_cli.py index fd71708161..7c7896e8c7 100644 --- a/tests/functional/test_cli.py +++ b/tests/functional/test_cli.py @@ -281,7 +281,7 @@ def cmd(network): @pytest.mark.parametrize("network_name", ("apenet", "apenet1")) def test_network_option_specify_custom_network(runner, custom_networks_config, network_name): - network_part = ("--network", f"ethereum:{network_name}:geth") + network_part = ("--network", f"ethereum:{network_name}:node") # NOTE: Also testing network filter with a custom network # But this is also required to work around LRU cache @@ -582,10 +582,10 @@ def cmd(provider): click.echo(provider.name) # NOTE: Must use a network that is not the default. - spec = ("--network", "ethereum:local:geth") + spec = ("--network", "ethereum:local:node") res = runner.invoke(cmd, spec, catch_exceptions=False) assert res.exit_code == 0, res.output - assert "geth" in res.output + assert "node" in res.output def test_connected_provider_command_none_network(runner): diff --git a/tests/functional/test_config.py b/tests/functional/test_config.py index b7efe2c1b6..25de0bf786 100644 --- a/tests/functional/test_config.py +++ b/tests/functional/test_config.py @@ -173,7 +173,7 @@ def test_config_access(): config.default_provider == config["default_provider"] == getattr(config, "default-provider") - == "geth" + == "node" ) @@ -222,13 +222,13 @@ def test_merge_configs(): """ global_config = { "ethereum": { - "mainnet": {"default_provider": "geth"}, + "mainnet": {"default_provider": "node"}, "local": {"default_provider": "test", "required_confirmations": 5}, } } project_config = { "ethereum": { - "local": {"default_provider": "geth"}, + "local": {"default_provider": "node"}, "sepolia": {"default_provider": "alchemy"}, }, "test": "foo", @@ -242,8 +242,8 @@ def test_merge_configs(): # Expected case `add missing project keys`: `test` is added, so is `sepolia` (nested-example). expected = { "ethereum": { - "local": {"default_provider": "geth", "required_confirmations": 5}, - "mainnet": {"default_provider": "geth"}, + "local": {"default_provider": "node", "required_confirmations": 5}, + "mainnet": {"default_provider": "node"}, "sepolia": {"default_provider": "alchemy"}, }, "test": "foo", diff --git a/tests/functional/test_network_api.py b/tests/functional/test_network_api.py index 37deaab08d..121e599969 100644 --- a/tests/functional/test_network_api.py +++ b/tests/functional/test_network_api.py @@ -35,9 +35,9 @@ def test_get_provider_ipc(ethereum): def test_get_provider_custom_network(custom_networks_config, ethereum): network = ethereum.apenet - actual = network.get_provider("geth") + actual = network.get_provider("node") assert isinstance(actual, ProviderAPI) - assert actual.name == "geth" + assert actual.name == "node" def test_block_times(ethereum): diff --git a/tests/functional/test_network_manager.py b/tests/functional/test_network_manager.py index 9850f1f4e7..067e00195c 100644 --- a/tests/functional/test_network_manager.py +++ b/tests/functional/test_network_manager.py @@ -19,23 +19,23 @@ def __call__(self, *args, **kwargs) -> int: chain_id_factory = NewChainID() DEFAULT_CHOICES = { - "::geth", + "::node", "::test", ":sepolia", - ":sepolia:geth", + ":sepolia:node", ":local", ":mainnet", - ":mainnet:geth", + ":mainnet:node", "ethereum", "ethereum::test", - "ethereum::geth", + "ethereum::node", "ethereum:sepolia", - "ethereum:sepolia:geth", + "ethereum:sepolia:node", "ethereum:local", - "ethereum:local:geth", + "ethereum:local:node", "ethereum:local:test", "ethereum:mainnet", - "ethereum:mainnet:geth", + "ethereum:mainnet:node", } @@ -107,10 +107,10 @@ def test_get_network_choices_filter_network(networks): actual = {c for c in networks.get_network_choices(network_filter="mainnet")} mainnet_choices = { ":mainnet", - ":mainnet:geth", + ":mainnet:node", "ethereum", "ethereum:mainnet", - "ethereum:mainnet:geth", + "ethereum:mainnet:node", } assert mainnet_choices.issubset(actual) @@ -131,7 +131,7 @@ def test_get_provider_when_no_default(network_with_no_providers): def test_repr_connected_to_local(networks_connected_to_tester): actual = repr(networks_connected_to_tester) - expected = f">" + expected = f">" assert actual == expected # Check individual network @@ -151,7 +151,7 @@ def test_get_provider_from_choice_custom_provider(networks_connected_to_tester): uri = "https://geth:1234567890abcdef@geth.foo.bar/" provider = networks_connected_to_tester.get_provider_from_choice(f"ethereum:local:{uri}") assert uri in provider.connection_id - assert provider.name == "geth" + assert provider.name == "node" assert provider.uri == uri assert provider.network.name == "local" # Network was specified to be local! assert provider.network.ecosystem.name == "ethereum" @@ -160,7 +160,7 @@ def test_get_provider_from_choice_custom_provider(networks_connected_to_tester): def test_get_provider_from_choice_custom_adhoc_ecosystem(networks_connected_to_tester): uri = "https://geth:1234567890abcdef@geth.foo.bar/" provider = networks_connected_to_tester.get_provider_from_choice(uri) - assert provider.name == "geth" + assert provider.name == "node" assert provider.uri == uri assert provider.network.name == "custom" assert provider.network.ecosystem.name == "ethereum" diff --git a/tests/integration/cli/projects/geth/ape-config.yaml b/tests/integration/cli/projects/geth/ape-config.yaml index 31300467cd..ba78d21673 100644 --- a/tests/integration/cli/projects/geth/ape-config.yaml +++ b/tests/integration/cli/projects/geth/ape-config.yaml @@ -1,11 +1,11 @@ ethereum: local: - default_provider: geth + default_provider: node # Change the default URI for one of the networks to # ensure that the default values of the other networks # remain unchanged. -geth: +node: ethereum: mainnet: uri: http://localhost:5000 diff --git a/tests/integration/cli/projects/geth/tests/test_using_local_geth.py b/tests/integration/cli/projects/geth/tests/test_using_local_geth.py index 8366b0f247..2164735d7d 100644 --- a/tests/integration/cli/projects/geth/tests/test_using_local_geth.py +++ b/tests/integration/cli/projects/geth/tests/test_using_local_geth.py @@ -5,7 +5,7 @@ def test_provider(project, networks): """ Tests that the network gets set from ape-config.yaml. """ - assert networks.provider.name == "geth" + assert networks.provider.name == "node" assert networks.provider.is_connected diff --git a/tests/integration/cli/test_misc.py b/tests/integration/cli/test_misc.py index 6514100734..88005173b5 100644 --- a/tests/integration/cli/test_misc.py +++ b/tests/integration/cli/test_misc.py @@ -23,7 +23,7 @@ def test_invocation(ape_cli, runner, args): def test_help(ape_cli, runner): result = runner.invoke(ape_cli, "--help") assert result.exit_code == 0, result.output - anything = r"[.\n\s\w`/\-,\)\(:\]\[]*" + anything = r"[.\n\s\w`/\-,\)\(:\]\[']*" expected = ( rf"{anything}Core Commands:\n accounts " rf"Manage local accounts{anything} " diff --git a/tests/integration/cli/test_networks.py b/tests/integration/cli/test_networks.py index 4f8c7c3cc3..43741e5a4f 100644 --- a/tests/integration/cli/test_networks.py +++ b/tests/integration/cli/test_networks.py @@ -6,12 +6,12 @@ _DEFAULT_NETWORKS_TREE = """ ethereum (default) ├── local (default) -│ ├── geth +│ ├── node │ └── test (default) ├── mainnet │ └── test (default) └── sepolia - └── geth (default) + └── node (default) """ _DEFAULT_NETWORKS_YAML = """ ecosystems: @@ -21,28 +21,28 @@ - isDefault: true name: local providers: - - name: geth + - name: node - isDefault: true name: test - name: mainnet providers: - isDefault: true - name: geth + name: node - name: mainnet-fork providers: [] - name: sepolia providers: - isDefault: true - name: geth + name: node - name: sepolia-fork providers: [] """ -_GETH_NETWORKS_TREE = """ +_NODE_NETWORKS_TREE = """ ethereum (default) ├── local (default) -│ └── geth (default) +│ └── node (default) └── mainnet - └── geth (default) + └── node (default) """ _TEST_PROVIDER_TREE_OUTPUT = """ ethereum (default) @@ -52,18 +52,18 @@ _SEPOLIA_NETWORK_TREE_OUTPUT = """ ethereum (default) └── sepolia - └── geth (default) + └── node (default) """ _CUSTOM_NETWORKS_TREE = """ ethereum (default) ├── apenet -│ └── geth (default) +│ └── node (default) ├── apenet1 -│ └── geth (default) +│ └── node (default) ├── local (default) -│ └── geth (default) +│ └── node (default) └── mainnet - └── geth (default) + └── node (default) """ @@ -128,11 +128,11 @@ def test_list_geth(ape_cli, runner, networks, project): # Grab ethereum actual = "ethereum (default)\n" + "".join(result.output.split("ethereum (default)\n")[-1]) - assert_rich_text(actual, _GETH_NETWORKS_TREE) + assert_rich_text(actual, _NODE_NETWORKS_TREE) # Assert that URI still exists for local network # (was bug where one network's URI disappeared when setting different network's URI) - geth_provider = networks.get_provider_from_choice(f"ethereum:{LOCAL_NETWORK_NAME}:geth") + geth_provider = networks.get_provider_from_choice(f"ethereum:{LOCAL_NETWORK_NAME}:node") actual_uri = geth_provider.uri assert actual_uri == GETH_URI @@ -189,7 +189,7 @@ def test_run_custom_network(ape_cli, runner): @geth_process_test @skip_projects_except("geth") def test_run_already_running(ape_cli, runner, geth_provider): - cmd = ("networks", "run", "--network", f"ethereum:{LOCAL_NETWORK_NAME}:geth") + cmd = ("networks", "run", "--network", f"ethereum:{LOCAL_NETWORK_NAME}:node") result = runner.invoke(ape_cli, cmd) assert result.exit_code != 0 assert "ERROR: Process already running." in result.output diff --git a/tests/integration/cli/test_plugins.py b/tests/integration/cli/test_plugins.py index 5d04d645cd..4f406b44e8 100644 --- a/tests/integration/cli/test_plugins.py +++ b/tests/integration/cli/test_plugins.py @@ -112,7 +112,7 @@ def test_list_excludes_core_plugins(ape_plugins_runner): assert not result.available_plugins assert "console" not in result.installed_plugins, message("console") assert "networks" not in result.installed_plugins, message("networks") - assert "geth" not in result.installed_plugins, message("geth") + assert "node" not in result.installed_plugins, message("node") @github_xfail() diff --git a/tests/integration/cli/test_test.py b/tests/integration/cli/test_test.py index 753f7ca29b..22a3d8ac9e 100644 --- a/tests/integration/cli/test_test.py +++ b/tests/integration/cli/test_test.py @@ -40,7 +40,7 @@ {TOKEN_B_GAS_REPORT} """ GETH_LOCAL_CONFIG = f""" -geth: +node: ethereum: local: uri: {GETH_URI} @@ -220,7 +220,7 @@ def test_gas_flag_when_not_supported(setup_pytester, project, pytester, eth_test def test_gas_flag_in_tests(geth_provider, setup_pytester, project, pytester, owner): owner.transfer(owner, "1 wei") # Do this to force a clean slate. passed, failed = setup_pytester(project.path.name) - result = pytester.runpytest("--gas", "--network", "ethereum:local:geth") + result = pytester.runpytest("--gas", "--network", "ethereum:local:node") run_gas_test(result, passed, failed) @@ -232,14 +232,14 @@ def test_gas_flag_set_in_config( geth_account.transfer(geth_account, "1 wei") # Force a clean block. passed, failed = setup_pytester(project.path.name) config_content = f""" - geth: + node: ethereum: local: uri: {GETH_URI} ethereum: local: - default_provider: geth + default_provider: node test: disconnect_providers_after: false @@ -249,7 +249,7 @@ def test_gas_flag_set_in_config( """ with switch_config(project, config_content): - result = pytester.runpytest("--network", "ethereum:local:geth") + result = pytester.runpytest("--network", "ethereum:local:node") run_gas_test(result, passed, failed) @@ -263,14 +263,14 @@ def test_gas_when_estimating( """ passed, failed = setup_pytester(project.path.name) config_content = f""" - geth: + node: ethereum: local: uri: {GETH_URI} ethereum: local: - default_provider: geth + default_provider: node gas_limit: auto test: @@ -302,7 +302,7 @@ def test_gas_flag_exclude_using_cli_option( "--gas-exclude", "*:fooAndBar,*:myNumber,tokenB:*", "--network", - "ethereum:local:geth", + "ethereum:local:node", ) run_gas_test(result, passed, failed, expected_report=expected) @@ -319,14 +319,14 @@ def test_gas_flag_exclusions_set_in_config( # Also ensure can filter out whole class expected = expected.replace(TOKEN_B_GAS_REPORT, "") config_content = rf""" - geth: + node: ethereum: local: uri: {GETH_URI} ethereum: local: - default_provider: geth + default_provider: node test: disconnect_providers_after: false @@ -337,7 +337,7 @@ def test_gas_flag_exclusions_set_in_config( - contract_name: TokenB """ with switch_config(project, config_content): - result = pytester.runpytest("--gas", "--network", "ethereum:local:geth") + result = pytester.runpytest("--gas", "--network", "ethereum:local:node") run_gas_test(result, passed, failed, expected_report=expected) @@ -349,7 +349,7 @@ def test_gas_flag_excluding_contracts( geth_account.transfer(geth_account, "1 wei") # Force a clean block. passed, failed = setup_pytester(project.path.name) result = pytester.runpytest( - "--gas", "--gas-exclude", "VyperContract,TokenA", "--network", "ethereum:local:geth" + "--gas", "--gas-exclude", "VyperContract,TokenA", "--network", "ethereum:local:node" ) run_gas_test(result, passed, failed, expected_report=TOKEN_B_GAS_REPORT) @@ -365,7 +365,7 @@ def test_coverage(geth_provider, setup_pytester, project, pytester, geth_account """ geth_account.transfer(geth_account, "1 wei") # Force a clean block. passed, failed = setup_pytester(project.path.name) - result = pytester.runpytest("--coverage", "--show-internal", "--network", "ethereum:local:geth") + result = pytester.runpytest("--coverage", "--show-internal", "--network", "ethereum:local:node") result.assert_outcomes(passed=passed, failed=failed)