Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deepcopy network #1466

Merged
merged 3 commits into from
May 15, 2022
Merged

Conversation

BlinkyStitt
Copy link
Collaborator

@BlinkyStitt BlinkyStitt commented Mar 9, 2022

If we copy instead of deepcopy, then when the network name is overwritten with the RPC url, later calls do not set "explorer" or "chain_id" (since line 87 is looking for names and not RPCs).

Without this change, the active_network config is missing: , 'chainid': '1', 'explorer': 'https://api.etherscan.io/api'}

>>> print(CONFIG.active_network)
{'name': 'Hardhat (Mainnet Fork)', 'id': 'hardhat-fork', 'cmd': 'npx hardhat node', 'host': 'http://127.0.0.1', 'multicall2': '0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696', 'cmd_settings': {'port': 8545, 'fork': 'https://turbo-eth.stytt.com/', 'chain_id': 1}, 'settings': {'gas_limit': 'max', 'gas_buffer': 1, 'gas_price': 0, 'max_fee': None, 'priority_fee': None, 'reverting_tx_gas_limit': 'max', 'default_contract_owner': True, 'cmd_settings': None}, 'chainid': '1', 'explorer': 'https://api.etherscan.io/api'}

>>> network.disconnect()
Terminating local RPC client...

>>> network.connect("hardhat-fork")
Launching 'npx hardhat node --port 8545 --fork https://turbo-eth.stytt.com/'...

>>> print(CONFIG.active_network)
{'name': 'Hardhat (Mainnet Fork)', 'id': 'hardhat-fork', 'cmd': 'npx hardhat node', 'host': 'http://127.0.0.1', 'multicall2': '0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696', 'cmd_settings': {'port': 8545, 'fork': 'https://turbo-eth.stytt.com/', 'chain_id': 1}, 'settings': {'gas_limit': 'max', 'gas_buffer': 1, 'gas_price': 0, 'max_fee': None, 'priority_fee': None, 'reverting_tx_gas_limit': 'max', 'default_contract_owner': True, 'cmd_settings': None}}

Checklist

  • I have confirmed that my PR passes all linting checks
  • I have included test cases
  • I have updated the documentation
  • I have added an entry to the changelog

If we copy instead of deepcopy, then when the network name is overwritten with the RPC url, later calls do not set "explorer" or "chain_id" (since line 87 is looking for names and not RPCs).

Without this change, the `active_network` config is missing: `, 'chainid': '1', 'explorer': 'https://api.etherscan.io/api'}`

```
>>> print(CONFIG.active_network)
{'name': 'Hardhat (Mainnet Fork)', 'id': 'hardhat-fork', 'cmd': 'npx hardhat node', 'host': 'http://127.0.0.1', 'multicall2': '0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696', 'cmd_settings': {'port': 8545, 'fork': 'https://turbo-eth.stytt.com/', 'chain_id': 1}, 'settings': {'gas_limit': 'max', 'gas_buffer': 1, 'gas_price': 0, 'max_fee': None, 'priority_fee': None, 'reverting_tx_gas_limit': 'max', 'default_contract_owner': True, 'cmd_settings': None}, 'chainid': '1', 'explorer': 'https://api.etherscan.io/api'}

>>> network.disconnect()
Terminating local RPC client...

>>> network.connect("hardhat-fork")
Launching 'npx hardhat node --port 8545 --fork https://turbo-eth.stytt.com/'...

>>> print(CONFIG.active_network)
{'name': 'Hardhat (Mainnet Fork)', 'id': 'hardhat-fork', 'cmd': 'npx hardhat node', 'host': 'http://127.0.0.1', 'multicall2': '0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696', 'cmd_settings': {'port': 8545, 'fork': 'https://turbo-eth.stytt.com/', 'chain_id': 1}, 'settings': {'gas_limit': 'max', 'gas_buffer': 1, 'gas_price': 0, 'max_fee': None, 'priority_fee': None, 'reverting_tx_gas_limit': 'max', 'default_contract_owner': True, 'cmd_settings': None}, 'chainid': '1', 'explorer': 'https://api.etherscan.io/api'}
```
@BlinkyStitt
Copy link
Collaborator Author

I'm not sure the best way to write a test. I don't think tests when run with xdist will like having their rpc killed.

@iamdefinitelyahuman iamdefinitelyahuman merged commit d2d2a3a into eth-brownie:master May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants