reth
reth copied to clipboard
feature request: python bindings for ExEx
Description
Following the announcement of ExEx, I can imagine this would be very useful for indexers, real-time analytics teams etc. with a background in python.
I can imagine searchers could find benefit in this, especially for rollups. For Ethereum mainnet, this may not be as useful since they typically want to know if a tx in the mempool (or bundle?) gets included.
We probably need a Notification class, and I'm thinking it could be something that simply tracks state changes in a contract:
class ExExNotifications:
def __init__(self, contract_address: str):
self.address = contract_address
def state_write(self) -> bool:
# logic here checks state of the previous contract and returns True if state was changed
def state_read(self) -> bool:
# logic here returns True if contract's state was read by any other contract in the block
async def listen(self):
# async method to listen to state changes
# rest of the logic invoking exex to fetch old and new states
Which could then be used as follows:
from pyreth import exex
trigger = exex.Notifications(some_contract_address):
with trigger.sync():
if trigger.state_read():
# check, for example, if peripheral contracts have their states changed
# example an AMM's exponential moving average price oracle was read. check if lending market
# dependent on the oracle has it's state changed.
if trigger.state_write():
# do something if, say, state price of the AMM changed
Additional context
No response
for this we'd need a bunch of wrapper types with pyo3 that define the py <-> rust interface and then a way to call this from rust
https://pyo3.rs/v0.21.2/python-from-rust
@bout3fiddy you can have a wrapper around rust with pyo3, or simpler, just write a simple network code with ExEx in rust, and send notification to another python service.
This issue is stale because it has been open for 21 days with no activity.
@bout3fiddy you can have a wrapper around rust with pyo3, or simpler, just write a simple network code with ExEx in rust, and send notification to another python service.
this is correct, see https://reth.rs/developers/exex/remote.html for an example of such a service.
I will close this issue as not planned, let me know if you have something else in mind that's not covered by a Remote ExEx!