AnvilLaunch

Documentation for eth_defi.provider.anvil.AnvilLaunch Python class.

class AnvilLaunch

Bases: object

Control Anvil processes launched on background.

Comes with a helpful close() method when it is time to put Anvil rest.

The chain_id, upstream_rpc_urls, fork_block_number and effective_fork_url fields are the canonical launch metadata exposed to callers. The module-level metadata registry mirrors these values only so that later create_multi_provider_web3(launch.json_rpc_url) calls can attach the same context to retry diagnostics.

Attributes summary

chain_id

effective_fork_url

fork_block_number

proxy

upstream_rpc_urls

Methods summary

__init__(port, cmd, json_rpc_url, process[, ...])

close([log_level, block, block_timeout])

Close the background Anvil process.

__init__(port, cmd, json_rpc_url, process, chain_id=None, upstream_rpc_urls=(), fork_block_number=None, effective_fork_url=None, proxy=None, _proxy_managed=True)
Parameters
Return type

None

close(log_level=None, block=True, block_timeout=30)

Close the background Anvil process.

If this instance owns the RPCProxy (i.e. it was auto-created, not passed in by the caller), the proxy is shut down after Anvil exits and its per-provider statistics are logged.

Parameters
  • log_level (Optional[int]) – Dump Anvil messages to logging

  • block – Block the execution until anvil is gone

  • block_timeout – How long time we try to kill Anvil until giving up.

Returns

Anvil stdout, stderr as string

Return type

tuple[bytes, bytes]