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

fix: issues where was difficult to change network-config defaults in L2 sub-classes #1877

Merged
merged 3 commits into from
Jan 23, 2024

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Jan 22, 2024

What I did

L2 network subclasses still wasn't quite for most of the L2s because they changed the default tx.
Now it works great.

For example, this is how BSC looks:


def _create_config() -> NetworkConfig:
    return create_network_config(block_time=3, default_transaction_type=TransactionType.STATIC)


class BSCConfig(BaseEthereumConfig):
    DEFAULT_TRANSACTION_TYPE: ClassVar[int] = TransactionType.STATIC.value
    NETWORKS: ClassVar[Dict[str, Tuple[int, int]]] = NETWORKS
    mainnet: NetworkConfig = _create_config()
    testnet: NetworkConfig = _create_config()

which is a big reduction in custom code needing to maintain

note: l2 plugins can still configure normally, this is only a way to make it simpler for them as an option

How I did it

  1. Use class vars DEFAULT_TX_TYPE and NETWORKS
  2. Better merging of config data
  3. Make local computed so it can utilize the class vars
  4. When automatically creating the forked network, use the DEFAULT

How to verify it

Checklist

  • All changes are completed
  • New test cases have been added
  • Documentation has been updated

@antazoey antazoey merged commit e1c0863 into ApeWorX:main Jan 23, 2024
15 checks passed
@antazoey antazoey deleted the fix/default-tx-custom-no-cfg branch January 23, 2024 14:24
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