Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Update event docs to mention system events (#535)
Browse files Browse the repository at this point in the history
* Mention system events

* Mention types of diagnostic events

* format
  • Loading branch information
sisuresh authored Aug 7, 2023
1 parent 4d500ba commit dbd834a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/basic-tutorials/upgrading-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ pub fn upgrade(e: Env, new_wasm_hash: BytesN<32>) {
}
```

The `update_current_contract_wasm` host function will also emit a `SYSTEM` contract [event] that contains the old and new wasm reference, allowing downstream users to be notified when a contract they use is updated. The event structure will have `topics = ["executable_update", old_executable: ContractExecutable, old_executable: ContractExecutable]` and `data = []`.

[here]: https://docs.rs/soroban-sdk/0.9.2/soroban_sdk/struct.Env.html#method.update_current_contract_wasm
[event]: ../fundamentals-and-concepts/events.mdx#event-types

## Tests

Expand Down
16 changes: 15 additions & 1 deletion docs/fundamentals-and-concepts/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,26 @@ struct TransactionMetaV3

[Link](https://github.com/stellar/stellar-xdr/blob/eab1622f18b8101aa0cea76361c08beaeaa8d715/Stellar-ledger.x#L444) to the XDR above.

### Event types

There are three `ContractEventType`'s -

1. `CONTRACT` events are events emitted by contracts that use the
`contract_event` host function to convey state changes.
2. `SYSTEM` events are events emitted by the host. At the moment, there's only one system event emitted by the host. It is emitted when the `update_current_contract_wasm` host function is called, where `topics = ["executable_update", old_executable: ContractExecutable, old_executable: ContractExecutable]` and `data = []`.
3. `DIAGNOSTIC` events are meant for debugging and will not be emitted unless the host instance explictly enables it. You can read more about this below.

## What are diagnosticEvents?

While looking at the `TransactionMetaV3` XDR struct above, you may have noticed
the `diagnosticEvents` field. This list will be empty by default unless your
stellar-core instance has `ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=true` in its config
file. If diagnostic events are enabled, this list will not only include all ContractEvents in `events`, but will also include events from failed contract calls, and additional diagnostic events emitted by the host. These events can be identified by `type == DIAGNOSTIC`, and they're defined below.
file. If diagnostic events are enabled, this list will not only include all
ContractEvents in `events`, but will also include events from failed contract
calls, errors from the host, events to trace the contract call stack, and logs
from the `log_from_linear_memory` host function. These events can be identified
by `type == DIAGNOSTIC`. The diagnostic events emitted by the host to track the
call stack are defined below.

### fn_call

Expand Down

0 comments on commit dbd834a

Please sign in to comment.