diff --git a/docs/basic-tutorials/upgrading-contracts.mdx b/docs/basic-tutorials/upgrading-contracts.mdx index 92925dcd..7f9c2e8b 100644 --- a/docs/basic-tutorials/upgrading-contracts.mdx +++ b/docs/basic-tutorials/upgrading-contracts.mdx @@ -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 diff --git a/docs/fundamentals-and-concepts/events.mdx b/docs/fundamentals-and-concepts/events.mdx index b5deb8ca..e37ba934 100644 --- a/docs/fundamentals-and-concepts/events.mdx +++ b/docs/fundamentals-and-concepts/events.mdx @@ -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