cartesi / rollups-contracts

Smart Contracts for Cartesi Rollups
https://cartesi.github.io/rollups-contracts/
Apache License 2.0
17 stars 37 forks source link

Add `output` to `OutputExecuted` event #212

Closed guidanoli closed 5 months ago

guidanoli commented 6 months ago

📚 Context

In the context of the Output Unification effort, there will be a single event for all output executed called, intuitively, OutputExecuted. This event can be listened to by outsiders to index what on-chain side effects have taken effect until any given point. For example, if you are monitoring the assets locked in a given application, there are two main routes: polling or folding.

You can monitor deposits via the InputAdded event emitted by the InputBox contract. If the input is coming from a portal, you can decode the input and figure out who transferred, what asset, how much, and to which application.

Previously, if you wanted to monitor withdrawals, you'd have to listen to events emitted by each token contract supported by the application. Now, if you're indexing this kind of information for all applications that use Cartesi, the problem only gets harder.

Furthermore, it would be impossible to monitor Ether withdrawals, since they do not necessarily trigger events that can be listened to from outside the blockchain.

Of course, you could go another way, and ask the user to input a GraphQL endpoint, and from there extract the output blob. But then you're relying on a centralized solution. Why not use the blockchain for this information, since that's where it actually happens, right?

✔️ Solution

We can modify the OutputExecuted event to include the output blob. With this, it would be much easier to monitor deposits as well as any other on-chain action taking place. Also, you wouldn't have to monitor several token contracts. Instead, you'd only have to monitor the InputBox and Application contracts.

:books: Requirements

guidanoli commented 6 months ago

FYI @tuler

guidanoli commented 6 months ago

Would this be interesting for the node, @cartesi/node-unit?

gligneul commented 6 months ago

Would this be interesting for the node, @cartesi/node-unit?

Maybe in the future but not for now.