Do we need Ethereum-like events on Miden #2152
Replies: 2 comments 4 replies
-
|
Could we flash out the use case a bit more? My current assumptions:
Are these correct? I'm specifically curious about the second point because things like "react to a deposit into a smart contract" should be pretty easy to do by just observing account updates that we already get from the network (after 0xMiden/miden-client#467 is done). |
Beta Was this translation helpful? Give feedback.
-
|
A concrete first design can be fairly minimal. Assuming we keep the trust in the node centralized, we can avoid changing the block header at this point, and have the node simply collect the event logs for offchain (gRPC) access. Rename
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Ethereum-like events on Miden
Some builders coming from Ethereum have asked for “events” on Miden. They are used to wiring their apps around event streams: backends and frontends subscribe to specific contracts and react when those contracts emit events.
Recap what are Ethereum-like events
On Ethereum and other EVM chains, events are logs emitted by smart contracts during execution. Contracts call emit
MyEvent(arg1, arg2, ...).The EVM writes a log entry containing:
These logs become part of the transaction receipt. They are not readable on-chain and only for off-chain consumption. But they are accessible via APIs like
eth_getLogsandeth_subscribe.How they are used today:
Solana doesn't have events like this but Solana programs also emit log messages.
How can we replicate this on Miden?
On Miden, clients can already subscribe to certain note tags. And with 0xMiden/miden-client#467 we will allow clients to ract to certain "events".
However, currently it is not possible to react to a deposit into a smart contract or to the creation of a new smart contract of a certain type. Ideally, builders or developers could set certain flags in their code when to emit events. We do already support events in the VM, as far as I know they just stay local. So a rather straight forward implementation would be
For any public action (network account changes, public accounts, maybe public notes?) we can expose the event logs with the transaction. Then, anyone can subscribe via
getEventsfor historical queriessubscribeEventsfor live streamsThis is very familiar for EVM devs, it's clean and simple and easy to filter. The problem might be, events are fully public and we add more data to the network.
I am sure there are better options.
Beta Was this translation helpful? Give feedback.
All reactions