athenavm / athena

Athena monorepo
https://www.athenavm.org/
Apache License 2.0
17 stars 2 forks source link

Add logs #92

Open lrettig opened 2 months ago

lrettig commented 2 months ago

We need EVM-style logs, i.e., a running program needs a way to log the fact that a particular event occurred (coins sent, program spawned, etc.).

poszu commented 1 month ago

@lrettig do you mean regular logs that are printed to stdout or something more sophisticated? The programs can already write to stdout by using the WRITE syscall with the stdout file descriptor. E.g, println!() works like this and I assume that log::info!() and others with a subscriber configured to print on stdout would work as well.

lrettig commented 2 weeks ago

No, something more sophisticated. I know the name "log" is misleading, but I'm envisioning something more like how logs/events work in EVM: https://medium.com/mycrypto/understanding-event-logs-on-the-ethereum-blockchain-f4ae7ba50378

EVM has opcodes for emitting logs, and they're actual data committed to the blockchain and that all nodes achieve consensus on. They're stored in a log trie that's part of the account state trie.

We don't have to do the exact same thing, but at the very least we definitely want to support some kind of events that both user-facing applications, as well as backend infrastructure (e.g., explorers, data indexers) can subscribe to.

poszu commented 2 weeks ago

OK, so it's more like events. Are events specific to a program (e.g. every program can define a new kind of event only understandable by it)? We could support it by:

lrettig commented 2 weeks ago

yes, they're specific to a program, but we also want standards (like ERC-20) so, e.g., all token programs use the same log messages to make indexing easy. The more interesting question here isn't the opcode we use but how these data are surfaced to the application layer (which we probably need to handle on the go-sm side, e.g., via API changes)