Skip to content

馃悰 [BUG] - chain.connect(fork=None) silently runs without fork#431

Description

@0xInnominatus

Description

When @chain.connect(chain_id=NNN,fork=...) is given None or an empty string (e.g. fork=os.getenv("ETHEREUM_RPC_URL") when the env var is unset), Wake still starts the dev chain without a fork. Anvil is launched with only --chain-id (and other flags), but no -f.

That is easy to miss: tests that assume mainnet state (real contracts at known addresses, specified chain_id, etc.) run against an empty chain and fail with confusing errors in the middle of test.

Error is always ValueError: non-hexadecimal number found in fromhex() arg at position 1 and some deploys and txs have passed in test, so it's unclear where probleam appears.

Should Wake fail fast when fork is None or empty? Optionally, could it also warn when chain_id is set but no fork URL was provided - to catch misconfigured fork tests? Also it is possible to make error more clear?

Reproduction steps

1. Clone reproduction repo with MRE
2. Compile contracts with eth-wake (`wake compile`)
3. `wake up pytypes`
4. `wake test`

Reproduction URL

https://github.com/0xInnominatus/eth-wake-mre

Screenshots

![DESCRIPTION](LINK.png)

Logs

def test_default():
        token = ERC20.deploy("Example", "EXAMPLE", 100 * 10**18)
>       example = Example.deploy(WETH)

tests\test_default.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pytypes\contracts\Example.py:89: in deploy
    return cls._deploy(request_type, [token], return_tx, Example, from_, value, gas_limit, {}, chain, gas_price, max_fee_per_gas, max_priority_fee_per_gas, access_list, type, block, confirmations)
..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\wake\development\core.py:3246: in _deploy
    return cls._execute(
..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\wake\development\core.py:3381: in _execute
    return chain._transact(
..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\wake\development\core.py:1429: in wrapper
    return f(*args, **kwargs)
..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\wake\development\core.py:2820: in _transact
    if tx.error is not None:
..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\wake\development\transactions.py:85: in wrapper
    return f(self)
..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\wake\development\transactions.py:450: in error
    raw_error = self.raw_error
..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\wake\development\transactions.py:85: in wrapper
    return f(self)
..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\wake\development\transactions.py:498: in raw_error
    revert_data = bytes(read_from_memory(offset, length, trace["memory"]))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

offset = 0, length = 0
memory = ['0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000...0000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x06fdde0300000000000000000000000000000000000000000000000000000000']

    def read_from_memory(offset: int, length: int, memory: List) -> bytearray:
        start_block = offset // 32
        start_offset = offset % 32
        end_block = (offset + length) // 32
        end_offset = (offset + length) % 32

        if start_block == end_block:
            if start_block >= len(memory):
                return bytearray(length)
>           return bytearray.fromhex(memory[start_block])[start_offset:end_offset]
E           ValueError: non-hexadecimal number found in fromhex() arg at position 1

..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\wake\development\internal.py:26: ValueError

OS

Windows, Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions