From 6ae558bb1cea2915899bbb08ef43fa5a776eea4b Mon Sep 17 00:00:00 2001 From: sydhds Date: Mon, 6 Jan 2025 11:05:06 +0100 Subject: [PATCH 1/3] Add event limits section --- docs/build/smart-contract/basic-concepts/events.mdx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/build/smart-contract/basic-concepts/events.mdx b/docs/build/smart-contract/basic-concepts/events.mdx index 6d1667810..9a45558be 100644 --- a/docs/build/smart-contract/basic-concepts/events.mdx +++ b/docs/build/smart-contract/basic-concepts/events.mdx @@ -21,6 +21,12 @@ In Massa's smart contracts, events provide a way to emit runtime messages that c In Massa, events are not stored in the blockchain ledger, meaning they are ephemeral. Therefore, events should not be used as a source of persistent data. Instead, they are suitable for temporary tasks such as monitoring, logging, or providing real-time feedback. For use cases that require persistent data, storage should be used. +## Limits + +In order to prevent high RAM usage and flooding, some limits are applied regarding to events: +* Maximum number of events in a smart contract: 25 +* Message maximum size (in bytes): 512 + ## Emitting a custom event To emit a custom event in a smart contract, you can use the generateEvent function (assuming this utility is available in your environment): From 8697e3f00429b3d267dc24b3cc8f6dd81326f519 Mon Sep 17 00:00:00 2001 From: Damir Vodenicarevic Date: Thu, 9 Jan 2025 15:20:41 +0100 Subject: [PATCH 2/3] Update docs/build/smart-contract/basic-concepts/events.mdx --- docs/build/smart-contract/basic-concepts/events.mdx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/build/smart-contract/basic-concepts/events.mdx b/docs/build/smart-contract/basic-concepts/events.mdx index 9a45558be..c59b27fc8 100644 --- a/docs/build/smart-contract/basic-concepts/events.mdx +++ b/docs/build/smart-contract/basic-concepts/events.mdx @@ -23,10 +23,9 @@ For use cases that require persistent data, storage should be used. ## Limits -In order to prevent high RAM usage and flooding, some limits are applied regarding to events: -* Maximum number of events in a smart contract: 25 -* Message maximum size (in bytes): 512 - +Due to the high throughput and low hardware requirements of Massa, memory usage linked to event emission needs to be capped. To achieve this, several limits need to be respected: +* Up to 25 events can be emitted in total during one execution (operation, async message or deferred call) regardless of the number of sub-calls happening. Attempting to emit more events results in a runtime exception being raised causing the execution to fail & revert. Note that this limit only applies to events explicitly emitted by smart contract code using the `generateEvent` ABI or similar. System events such as execution failure notifications are not subject to this limit. +* The maximum size of the event message is 512 bytes. Any attempt to emit a longer message by smart contract code using the `generateEvent` ABI or similar results in an exception being raised causing the execution to fail & revert. For system events (not explicitly emitted by smart contract code), any overflowing message is silently truncated down to 512 bytes. ## Emitting a custom event To emit a custom event in a smart contract, you can use the generateEvent function (assuming this utility is available in your environment): From 906020b9df389281478c8c81faf22df183b55440 Mon Sep 17 00:00:00 2001 From: Damir Vodenicarevic Date: Thu, 9 Jan 2025 15:25:40 +0100 Subject: [PATCH 3/3] Update docs/build/smart-contract/basic-concepts/events.mdx --- docs/build/smart-contract/basic-concepts/events.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/build/smart-contract/basic-concepts/events.mdx b/docs/build/smart-contract/basic-concepts/events.mdx index c59b27fc8..82e8c3ade 100644 --- a/docs/build/smart-contract/basic-concepts/events.mdx +++ b/docs/build/smart-contract/basic-concepts/events.mdx @@ -26,6 +26,8 @@ For use cases that require persistent data, storage should be used. Due to the high throughput and low hardware requirements of Massa, memory usage linked to event emission needs to be capped. To achieve this, several limits need to be respected: * Up to 25 events can be emitted in total during one execution (operation, async message or deferred call) regardless of the number of sub-calls happening. Attempting to emit more events results in a runtime exception being raised causing the execution to fail & revert. Note that this limit only applies to events explicitly emitted by smart contract code using the `generateEvent` ABI or similar. System events such as execution failure notifications are not subject to this limit. * The maximum size of the event message is 512 bytes. Any attempt to emit a longer message by smart contract code using the `generateEvent` ABI or similar results in an exception being raised causing the execution to fail & revert. For system events (not explicitly emitted by smart contract code), any overflowing message is silently truncated down to 512 bytes. + + ## Emitting a custom event To emit a custom event in a smart contract, you can use the generateEvent function (assuming this utility is available in your environment):