Skip to content

fix: Remove nest_asyncio dependency#652

Open
sddioulde wants to merge 1 commit intomainfrom
chore/noNestAsyncio
Open

fix: Remove nest_asyncio dependency#652
sddioulde wants to merge 1 commit intomainfrom
chore/noNestAsyncio

Conversation

@sddioulde
Copy link
Copy Markdown
Contributor

@sddioulde sddioulde commented Apr 13, 2026

Description

This PR removes the nest_asyncio dependency.

  • nest_asyncio is unmaintained and breaks on Python 3.12+ (loop_factory parameter mismatch).
  • Introduce _EvmServerAccountSync, a private class backing EvmLocalAccount that calls the three CDP signing endpoints synchronously via the existing Urllib3AuthClient. No new dependencies
  • Remove nest-asyncio from pyproject.toml and regenerates lock files for python/ and examples/python/

Why not a sync-to-async bridge?

The thread-based approaches (e.g. run_coroutine_threadsafe, ThreadPoolExecutor) are patches that create new problems. The fundamental design tension would remain. The real fix is a native sync HTTP path for the subset of operations EvmLocalAccount needs.

Why not generate a second OpenAPI client?

Only 3 endpoints are needed (sign, sign/message, sign/transaction). A full generated sync client would duplicate ~250 files for no benefit. _EvmServerAccountSync is ~80 lines and entirely self-contained.

Closes #591.

Tests

Ran the example examples/python/evm/ecosystem/web3py/evm_local_account.py:

❯ uv run python evm/ecosystem/web3py/evm_local_account.py
Account:  Ethereum Account Address: 0xc689707f26756784105F54c4ED6F5Add524C560A
Account compatible with eth_account:  0xc689707f26756784105F54c4ED6F5Add524C560A

Signing hash...
Signed hash:  SignedMessage(message_hash='0x1234567890123456789012345678901234567890123456789012345678901234', r=57049031682178508804091175920335526583721405066163050094990322523056343807318, s=32387024411922934641529786598997223116757660114616745814065711894492004951358, v=27, signature=HexBytes('0x7e209b90101f84f23e648e4bba412b93af61239d599210cd776f0a638ab6f556479a67fd82fd9a123c358516eaf6c6bd997f05de9f3ff0fda9e2f98c73a7253e1b'))

Signing message...
Signed message:  SignedMessage(message_hash=b"\xb4S\xbdN'\x1e\xed\x98\\\xba\xb8#\x1d\xa6\t\xc4\xce\n\x9c\xf1\xf7c\xb6\xc1YNv1U\x10\xe0\xf1", r=37281278688649902134277016297887397123195561088545803728897652452762120801476, s=23162022271877638489387981734083191566920461287791463242810231539769917352254, v=28, signature=HexBytes('0x526c74ba2ca04d25644efc51679f9e23697d52a1dc70b4319dbf15ad1652ccc433353d72bb695184f9171a5f654b385b705a71be58898994cb2956c485f4a93e1c'))

Signing typed data with domain, types, and message...
Signed typed data for domain, types, and message:  SignedMessage(message_hash=b'L\xc0\x04*\xe2y\x04x!\x9f\xb0\x8cF\xc8\x84\xba+81I8\xad\x9f\x83\xae\xe6\nmV\x11o\xe7', r=107266443067500939413854313789399527890594981381119814998667725749699789847518, s=15453885428980507699597096617208001036297316386222485500001595931329598967832, v=28, signature=HexBytes('0xed26a7bfe224459bd1b4cca5222d1944c09db84af3234b2535038bf1c71dfbde222a96d4da183a52b0fab88c3360424dac2f9a873b0ab20289826fad3829d0181c'))

Signing typed data with full message...
Signed typed data full message:  SignedMessage(message_hash=b'L\xc0\x04*\xe2y\x04x!\x9f\xb0\x8cF\xc8\x84\xba+81I8\xad\x9f\x83\xae\xe6\nmV\x11o\xe7', r=107266443067500939413854313789399527890594981381119814998667725749699789847518, s=15453885428980507699597096617208001036297316386222485500001595931329598967832, v=28, signature=HexBytes('0xed26a7bfe224459bd1b4cca5222d1944c09db84af3234b2535038bf1c71dfbde222a96d4da183a52b0fab88c3360424dac2f9a873b0ab20289826fad3829d0181c'))

Signing typed data with bytes32 type...
Signed typed data with bytes32 type:  SignedMessage(message_hash=b'\xdc\xa4\xe9\r\xb9\xab\xc4Fyh`\xcc\xb8\xcce\xc1(\xc7\xcd\xbf)\xaca\x17&]mT\xc8\x8e\x030', r=12049388963802520052021406745481047750563729256420919116922636096368824510750, s=22071225130946302413119945222290129036807470982698496412919856288352468205610, v=28, signature=HexBytes('0x1aa3b66490cc1b5e22a26a9f7062d2e72df118a68808cafce1218cdc505b691e30cbdee816d119c982de578900b9920244f0f7f535112550c603dfee73a8002a1c'))

Signing typed data with without EIP712Domain type...
Signed typed data without EIP712Domain type:  SignedMessage(message_hash=b'l\xe5\x15o+\xa0(~\x9c\xd0\xffY\xc8\xfb\xce\x8e\xa6\xad\xdc3)\x12\x97\xfd\x14h\xda5\xc6\xb9\x05\xf1', r=21467194425975604222216938815393764240616707750017619813957818133867607634623, s=10500184178148141259044591778704833252369946689249246684299606691393129545293, v=27, signature=HexBytes('0x2f760060073f9cb74a123fb4af6e7342581ff6ad166aa2b4e9b6d16cf36c32bf1736e4c55e8f93ea4f0b26fa77e7a65ee8ea10c08b1e53e3b893cd2f8311fe4d1b'))

Signing transaction...
Signed transaction:  SignedTransaction(raw_transaction=HexBytes('0x02f87283014a340c843b9aca00843b9aca0082520894000000000000000000000000000000000000dead8502540be40080c001a0c85e3f3d2315610dc38749b1e768644e3f26556ad46ff250903792447ab998d2a07877ef1915ba857d6e69be9486bdf4ce5e075180665db83a6d988529e44c4e36'), hash=HexBytes('0x9485f3425c82dbda7b83aec485e6c1d4362a5abb874495ac7270b83891f257a3'), r=1343594100203957376813748127806706357161470955636795865396747980682439950336, s=5460044033801821160132930038842125800782084568080257075633, v=231)

Requesting ETH from faucet for account...
Received funds from faucet...
Transaction sent! Hash: 9485f3425c82dbda7b83aec485e6c1d4362a5abb874495ac7270b83891f257a3
Transaction confirmed in block 40162443
Transaction status: Success

Checklist

A couple of things to include in your PR for completeness:

  • Updated the typescript README if relevant
  • Updated the python README if relevant
  • Added a changelog entry
  • Added e2e tests if introducing new functionality

@cb-heimdall
Copy link
Copy Markdown

cb-heimdall commented Apr 13, 2026

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@sddioulde sddioulde changed the title Chore/no nest asyncio fix: Remove nest_asyncio dependency Apr 13, 2026
@sddioulde sddioulde force-pushed the chore/noNestAsyncio branch 2 times, most recently from 40472cf to d4a1e25 Compare April 13, 2026 03:49
@sddioulde sddioulde force-pushed the chore/noNestAsyncio branch from 4c83272 to 9e61361 Compare April 13, 2026 15:16
@sddioulde sddioulde marked this pull request as ready for review April 13, 2026 15:31
@sddioulde sddioulde requested review from 0xRAG and CarsonRoscoe April 13, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Python: Move away from nest_async (is not compatible with modern Python) and is unmaintained.

2 participants