ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
872 stars 133 forks source link

Access List Error in eth-ape >= 0.7.5 #1881

Closed salparadi closed 7 months ago

salparadi commented 7 months ago

Environment information

$ ape --version
0.7.6

$ ape plugins list
Installed Plugins
  alchemy      0.7.0
  arbitrum     0.7.2
  base         0.7.1
  bsc          0.7.1
  etherscan    0.7.0
  fantom       0.7.1
  foundry      0.7.2
  infura       0.7.0
  optimism     0.7.2
  polygon      0.7.1
  solidity     0.7.1
  tokens       0.7.0
  vyper        0.7.0
$ cat ape-config.yaml
default_ecosystem: ethereum

vyper:
  version: 0.3.10

ethereum:
  default_network: mainnet
  mainnet:
    default_provider: geth
  mainnet_fork:
    default_provider: foundry

geth:
  ethereum:
    mainnet:
      uri: http://x.x.x.x:xxxx
      chain_id: 1

foundry:
  host: http://127.0.0.1:6969
  fork:
    ethereum:
      mainnet:
        upstream_provider: infura
        evm_version: shanghai
        block_number: ${BLOCK}

What went wrong?

Test script I have been using for a while now has started throwing errors related to access list in Ape 0.7.5 and higher.

  1. Created an access list using Anvil and eth_createAccessList.
  2. Pass that access_list into a contract call with raw calldata
tx = contract(
    data=calldata,
    gas=200_000, 
    max_fee=70_000_000_000,
    max_priority_fee=1,
    value=tx_value,
    nonce=nonce,
    sender=account, 
    access_list=access_list,
)
  1. In Ape 0.7.4 and lower, this works perfectly. Now after 0.7.5, it throws an error. The error goes away if I remove the access_list parameter.
Traceback (most recent call last):
  File "/Users/xxx/opt/anaconda3/envs/ape/lib/python3.10/site-packages/eth_pydantic_types/serializers.py", line 3, in <lambda>
    hex_serializer = plain_serializer_function_ser_schema(function=lambda x: x.hex())
AttributeError: 'str' object has no attribute 'hex'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/xxx/Scripts/xxx/xxx.py", line 1036, in <module>
    main()
  File "/Users/xxx/Scripts/xxx/xxx.py", line 706, in main
    tx = arb_contract(
  File "/Users/xxx/opt/anaconda3/envs/ape/lib/python3.10/site-packages/ape/contracts/base.py", line 849, in __call__
    return super().__call__(*args, **kwargs)
  File "/Users/xxx/opt/anaconda3/envs/ape/lib/python3.10/site-packages/ape/api/address.py", line 102, in __call__
    return sender.call(txn, **kwargs)
  File "/Users/xxx/opt/anaconda3/envs/ape/lib/python3.10/site-packages/ape/api/accounts.py", line 152, in call
    signed_txn = self.sign_transaction(txn, **signer_options)
  File "/Users/xxx/opt/anaconda3/envs/ape/lib/python3.10/site-packages/ape_accounts/accounts.py", line 218, in sign_transaction
    txn.model_dump(exclude_none=True, by_alias=True), self.__key
  File "/Users/xxx/opt/anaconda3/envs/ape/lib/python3.10/site-packages/ethpm_types/base.py", line 17, in model_dump
    return super().model_dump(*args, **kwargs)
  File "/Users/xxx/opt/anaconda3/envs/ape/lib/python3.10/site-packages/pydantic/main.py", line 308, in model_dump
    return self.__pydantic_serializer__.to_python(
pydantic_core._pydantic_core.PydanticSerializationError: Error calling function `<lambda>`: AttributeError: 'str' object has no attribute 'hex'
linear[bot] commented 7 months ago

APE-1651 Access List Error in eth-ape >= 0.7.5