Skip to content

Commit

Permalink
chore: remove goerli network (#2085)
Browse files Browse the repository at this point in the history
Co-authored-by: NotPeopling2day <32708219+NotPeopling2day@users.noreply.github.com>
  • Loading branch information
antazoey and NotPeopling2day committed May 13, 2024
1 parent 5b0bd21 commit 5c96ee7
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 79 deletions.
2 changes: 1 addition & 1 deletion docs/userguides/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ deployments:
mainnet:
- contract_type: MyContract
address: 0x5FbDB2315678afecb367f032d93F642f64180aa3
goerli:
sepolia:
- contract_type: MyContract
address: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
```
Expand Down
2 changes: 1 addition & 1 deletion docs/userguides/networks.md
Original file line number Diff line number Diff line change
@@ -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 Goerli) 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, 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.

Expand Down
2 changes: 1 addition & 1 deletion docs/userguides/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ from ape.cli import ape_cli_context
def cli(cli_ctx):
# There is no connection yet at this point.
testnets = {
"ethereum": ["sepolia", "goerli"],
"ethereum": ["sepolia"],
"polygon": ["mumbai"]
}
nm = cli_ctx.network_manager
Expand Down
2 changes: 1 addition & 1 deletion docs/userguides/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ assert receipt.sender == dev
Deploying from [ape console](./console.html) allows you to interact with a contract in real time. You can also use the `--network` flag to connect a live network.

```bash
ape console --network ethereum:goerli:alchemy
ape console --network ethereum:sepolia:alchemy
```

This will launch an IPython shell:
Expand Down
2 changes: 0 additions & 2 deletions src/ape_ethereum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
NETWORKS = {
# chain_id, network_id
"mainnet": (1, 1),
"goerli": (5, 5),
"sepolia": (11155111, 11155111),
}
BLUEPRINT_HEADER = HexBytes("0xfe71")
Expand Down Expand Up @@ -311,7 +310,6 @@ def _get_custom_network(self, name: str) -> NetworkConfig:

class EthereumConfig(BaseEthereumConfig):
mainnet: NetworkConfig = create_network_config(block_time=13)
goerli: NetworkConfig = create_network_config(block_time=15)
sepolia: NetworkConfig = create_network_config(block_time=15)


Expand Down
1 change: 0 additions & 1 deletion src/ape_geth/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ def wait(self, *args, **kwargs):
class GethNetworkConfig(PluginConfig):
# Make sure you are running the right networks when you try for these
mainnet: Dict = {"uri": get_random_rpc("ethereum", "mainnet")}
goerli: Dict = {"uri": get_random_rpc("ethereum", "goerli")}
sepolia: Dict = {"uri": get_random_rpc("ethereum", "sepolia")}
# Make sure to run via `geth --dev` (or similar)
local: Dict = {**DEFAULT_SETTINGS.copy(), "chain_id": DEFAULT_TEST_CHAIN_ID}
Expand Down
12 changes: 8 additions & 4 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def use_debug(logger):
@pytest.fixture
def dummy_live_network(chain):
original_network = chain.provider.network.name
chain.provider.network.name = "goerli"
chain.provider.network.name = "sepolia"
yield chain.provider.network
chain.provider.network.name = original_network

Expand Down Expand Up @@ -742,7 +742,8 @@ def mock_fork_provider(mocker, ethereum):
A fake provider representing something like ape-foundry
that can fork networks (only uses sepolia-fork).
"""
actual = ethereum.sepolia_fork.__dict__.pop("providers", {})
initial_providers = ethereum.sepolia_fork.__dict__.pop("providers", {})
initial_default = ethereum.sepolia_fork._default_provider
mock_provider = mocker.MagicMock()
mock_provider.name = "mock"
mock_provider.network = ethereum.sepolia_fork
Expand All @@ -752,12 +753,15 @@ def fake_partial(*args, **kwargs):
mock_provider.partial_call = (args, kwargs)
return mock_provider

ethereum.sepolia_fork._default_provider = "mock"
ethereum.sepolia_fork.__dict__["providers"] = {"mock": fake_partial}

yield mock_provider

if actual:
ethereum.sepolia_fork.__dict__["providers"] = actual
if initial_providers:
ethereum.sepolia_fork.__dict__["providers"] = initial_providers
if initial_default:
ethereum.sepolia_fork._default_provider = initial_default


@pytest.fixture
Expand Down
20 changes: 10 additions & 10 deletions tests/functional/geth/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def test_repr_on_local_network_and_disconnected(networks):

@geth_process_test
def test_repr_on_live_network_and_disconnected(networks):
geth = networks.get_provider_from_choice("ethereum:goerli:geth")
assert repr(geth) == "<geth chain_id=5>"
geth = networks.get_provider_from_choice("ethereum:sepolia:geth")
assert repr(geth) == "<geth chain_id=11155111>"


@geth_process_test
Expand All @@ -106,8 +106,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:goerli:geth")
assert geth.chain_id == 5
geth = networks.get_provider_from_choice("ethereum:sepolia:geth")
assert geth.chain_id == 11155111


@geth_process_test
Expand All @@ -132,12 +132,12 @@ def test_connect_wrong_chain_id(ethereum, geth_provider, web3_factory):
start_network = geth_provider.network
expected_error_message = (
f"Provider connected to chain ID '{geth_provider._web3.eth.chain_id}', "
"which does not match network chain ID '5'. "
"Are you connected to 'goerli'?"
"which does not match network chain ID '11155111'. "
"Are you connected to 'sepolia'?"
)

try:
geth_provider.network = ethereum.get_network("goerli")
geth_provider.network = ethereum.get_network("sepolia")

# Ensure when reconnecting, it does not use HTTP
web3_factory.return_value = geth_provider._web3
Expand All @@ -151,15 +151,15 @@ def test_connect_wrong_chain_id(ethereum, geth_provider, web3_factory):
def test_connect_to_chain_that_started_poa(mock_web3, web3_factory, ethereum):
"""
Ensure that when connecting to a chain that
started out as PoA, such as Goerli, we include
started out as PoA, such as Sepolia, we include
the right middleware. Note: even if the chain
is no longer PoA, we still need the middleware
to fetch blocks during the PoA portion of the chain.
"""
mock_web3.eth.get_block.side_effect = ExtraDataLengthError
mock_web3.eth.chain_id = ethereum.goerli.chain_id
mock_web3.eth.chain_id = ethereum.sepolia.chain_id
web3_factory.return_value = mock_web3
provider = ethereum.goerli.get_provider("geth")
provider = ethereum.sepolia.get_provider("geth")
provider.provider_settings = {"uri": "http://node.example.com"} # fake
provider.connect()

Expand Down
22 changes: 11 additions & 11 deletions tests/functional/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,26 @@ def _create_deployments(


def test_ethereum_network_configs(config, temp_config):
eth_config = {"ethereum": {"goerli": {"default_provider": "test"}}}
eth_config = {"ethereum": {"sepolia": {"default_provider": "test"}}}
with temp_config(eth_config):
actual = config.get_config("ethereum")
assert actual.goerli.default_provider == "test"
assert actual.sepolia.default_provider == "test"

# Ensure that non-updated fields remain unaffected
assert actual.goerli.block_time == 15
assert actual.sepolia.block_time == 15


def test_network_gas_limit_default(config):
eth_config = config.get_config("ethereum")

assert eth_config.goerli.gas_limit == "auto"
assert eth_config.sepolia.gas_limit == "auto"
assert eth_config.local.gas_limit == "max"


def _goerli_with_gas_limit(gas_limit: GasLimit) -> dict:
def _sepolia_with_gas_limit(gas_limit: GasLimit) -> dict:
return {
"ethereum": {
"goerli": {
"sepolia": {
"default_provider": "test",
"gas_limit": gas_limit,
}
Expand All @@ -124,25 +124,25 @@ def _goerli_with_gas_limit(gas_limit: GasLimit) -> dict:

@pytest.mark.parametrize("gas_limit", ("auto", "max"))
def test_network_gas_limit_string_config(gas_limit, config, temp_config):
eth_config = _goerli_with_gas_limit(gas_limit)
eth_config = _sepolia_with_gas_limit(gas_limit)

with temp_config(eth_config):
actual = config.get_config("ethereum")

assert actual.goerli.gas_limit == gas_limit
assert actual.sepolia.gas_limit == gas_limit

# Local configuration is unaffected
assert actual.local.gas_limit == "max"


@pytest.mark.parametrize("gas_limit", (1234, "1234", 0x4D2, "0x4D2"))
def test_network_gas_limit_numeric_config(gas_limit, config, temp_config):
eth_config = _goerli_with_gas_limit(gas_limit)
eth_config = _sepolia_with_gas_limit(gas_limit)

with temp_config(eth_config):
actual = config.get_config("ethereum")

assert actual.goerli.gas_limit == 1234
assert actual.sepolia.gas_limit == 1234

# Local configuration is unaffected
assert actual.local.gas_limit == "max"
Expand All @@ -153,7 +153,7 @@ def test_network_gas_limit_invalid_numeric_string(config, temp_config):
Test that using hex strings for a network's gas_limit config must be
prefixed with '0x'
"""
eth_config = _goerli_with_gas_limit("4D2")
eth_config = _sepolia_with_gas_limit("4D2")
with pytest.raises(ValueError, match="Gas limit hex str must include '0x' prefix."):
with temp_config(eth_config):
pass
Expand Down
7 changes: 3 additions & 4 deletions tests/functional/test_ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def test_gas_limit_local_networks(ethereum, network_name):


def test_gas_limit_live_networks(ethereum):
network = ethereum.get_network("goerli")
network = ethereum.get_network("sepolia")
assert network.gas_limit == "auto"


Expand Down Expand Up @@ -865,7 +865,7 @@ def test_encode_transaction(tx_type, ethereum, vyper_contract_instance, owner, e
assert actual.gas_limit == eth_tester_provider.max_gas


def test_set_default_network_not_exists(temp_config, ethereum):
def test_set_default_network_not_exists(ethereum):
bad_network = "NOT_EXISTS"
expected = f"No network in 'ethereum' named '{bad_network}'. Options:.*"
with pytest.raises(NetworkNotFoundError, match=expected):
Expand All @@ -874,7 +874,7 @@ def test_set_default_network_not_exists(temp_config, ethereum):

def test_networks(ethereum):
actual = ethereum.networks
for net in ("goerli", "sepolia", "mainnet", LOCAL_NETWORK_NAME):
for net in ("sepolia", "mainnet", LOCAL_NETWORK_NAME):
assert net in actual
assert isinstance(actual[net], NetworkAPI)

Expand All @@ -884,7 +884,6 @@ def test_networks_includes_custom_networks(
):
actual = ethereum.networks
for net in (
"goerli",
"sepolia",
"mainnet",
LOCAL_NETWORK_NAME,
Expand Down
18 changes: 9 additions & 9 deletions tests/functional/test_network_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def test_get_provider_when_not_found(ethereum):
name = "goerli-fork"
name = "sepolia-fork"
network = ethereum.get_network(name)
expected = f"No provider named 'test' in network '{name}' in ecosystem 'ethereum'.*"
with pytest.raises(ProviderNotFoundError, match=expected):
Expand All @@ -19,18 +19,18 @@ def test_get_provider_when_not_found(ethereum):
@pytest.mark.parametrize("scheme", ("http", "https", "ws", "wss"))
def test_get_provider_http(ethereum, scheme):
uri = f"{scheme}://example.com"
network = ethereum.get_network("goerli")
network = ethereum.get_network("sepolia")
actual = network.get_provider(uri)
assert actual.uri == uri
assert actual.network.name == "goerli"
assert actual.network.name == "sepolia"


def test_get_provider_ipc(ethereum):
path = "path/to/geth.ipc"
network = ethereum.get_network("goerli")
network = ethereum.get_network("sepolia")
actual = network.get_provider(path)
assert actual.ipc_path == Path(path)
assert actual.network.name == "goerli"
assert actual.network.name == "sepolia"


def test_get_provider_custom_network(custom_networks_config, ethereum):
Expand All @@ -41,22 +41,22 @@ def test_get_provider_custom_network(custom_networks_config, ethereum):


def test_block_times(ethereum):
assert ethereum.goerli.block_time == 15
assert ethereum.sepolia.block_time == 15


def test_set_default_provider_not_exists(temp_config, ape_caplog, ethereum):
bad_provider = "NOT_EXISTS"
expected = f"Provider '{bad_provider}' not found in network 'ethereum:goerli'."
expected = f"Provider '{bad_provider}' not found in network 'ethereum:sepolia'."
with pytest.raises(NetworkError, match=expected):
ethereum.goerli.set_default_provider(bad_provider)
ethereum.sepolia.set_default_provider(bad_provider)


def test_gas_limits(ethereum, config, project_with_source_files_contract):
"""
Test the default gas limit configurations for local and live networks.
"""
_ = project_with_source_files_contract # Ensure use of project with default config
assert ethereum.goerli.gas_limit == "auto"
assert ethereum.sepolia.gas_limit == "auto"
assert ethereum.local.gas_limit == "max"


Expand Down
13 changes: 5 additions & 8 deletions tests/functional/test_network_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def __call__(self, *args, **kwargs) -> int:
DEFAULT_CHOICES = {
"::geth",
"::test",
":goerli",
":goerli:geth",
":sepolia",
":sepolia:geth",
":local",
Expand All @@ -31,8 +29,6 @@ def __call__(self, *args, **kwargs) -> int:
"ethereum",
"ethereum::test",
"ethereum::geth",
"ethereum:goerli",
"ethereum:goerli:geth",
"ethereum:sepolia",
"ethereum:sepolia:geth",
"ethereum:local",
Expand Down Expand Up @@ -70,7 +66,7 @@ def fn():

@pytest.fixture
def network_with_no_providers(ethereum):
network = ethereum.get_network("goerli-fork")
network = ethereum.get_network("sepolia-fork")
default_provider = network.default_provider
providers = network.__dict__["providers"]

Expand All @@ -82,8 +78,9 @@ def network_with_no_providers(ethereum):
yield network

if default_provider or providers:
network._default_provider = default_provider
network._default_provider = default_provider.name
network.__dict__["providers"] = providers
assert network.default_provider, "Tear-down failed - providers not set."


def test_get_network_choices(networks, ethereum, mocker):
Expand Down Expand Up @@ -128,7 +125,7 @@ def test_get_network_choices_filter_provider(networks):
def test_get_provider_when_no_default(network_with_no_providers):
expected = f"No default provider for network '{network_with_no_providers.name}'"
with pytest.raises(NetworkError, match=expected):
# Not provider installed out-of-the-box for goerli-fork network
# Not provider installed out-of-the-box for sepolia-fork network
provider = network_with_no_providers.get_provider()
assert not provider, f"Provider should be None but got '{provider.name}'"

Expand All @@ -148,7 +145,7 @@ def test_repr_disconnected(networks_disconnected):
assert repr(networks_disconnected) == "<NetworkManager>"
assert repr(networks_disconnected.ethereum) == "<ethereum>"
assert repr(networks_disconnected.ethereum.local) == "<ethereum:local>"
assert repr(networks_disconnected.ethereum.goerli) == "<ethereum:goerli chain_id=5>"
assert repr(networks_disconnected.ethereum.sepolia) == "<ethereum:sepolia chain_id=11155111>"


def test_get_provider_from_choice_custom_provider(networks_connected_to_tester):
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/cli/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

@run_once
def test_cache_init_purge(ape_cli, runner):
cmd = ("cache", "init", "--network", "ethereum:goerli")
cmd = ("cache", "init", "--network", "ethereum:sepolia")
result = runner.invoke(ape_cli, cmd)
assert result.output == "SUCCESS: Caching database initialized for ethereum:goerli.\n"
result = runner.invoke(ape_cli, ("cache", "purge", "--network", "ethereum:goerli"))
assert result.output == "SUCCESS: Caching database purged for ethereum:goerli.\n"
assert result.output == "SUCCESS: Caching database initialized for ethereum:sepolia.\n"
result = runner.invoke(ape_cli, ("cache", "purge", "--network", "ethereum:sepolia"))
assert result.output == "SUCCESS: Caching database purged for ethereum:sepolia.\n"

0 comments on commit 5c96ee7

Please sign in to comment.