The Provenance Blockchain trigger module implements comprehensive block-level processing through BeginBlocker and EndBlocker ABCI calls that manage the complete trigger lifecycle from event detection to action execution. The EndBlocker monitors transaction events, block height, and block time to detect trigger activation conditions and queue eligible triggers for execution, while the BeginBlocker processes queued triggers by executing their actions with proper gas metering, event emission, and throttling controls that enforce a maximum of 5 actions and 2,000,000 gas limit per block to ensure optimal network performance and resource management.
Begin Blocker
The BeginBlocker abci call is invoked on the beginning of each block. Triggers will be dequeued and ran.
Trigger Execution
The following steps are performed on each BeginBlocker:
- A Trigger is removed from the Queue
- The Gas Limit for the Trigger is retrieved from the store
- A GasMeter is created for the Trigger
- An Action on the Trigger is ran updating and verifying gas usage against the GasMeter
- The events for the Action are emitted
- Step 5 is repeated until no more Actions exist for the trigger
- Step 1 is repeated until the Queue is empty or the throttling limit has been reached
Note
We have implemented a throttling limit within the module's BeginBlocker, effectively enforcing a maximum of 5 actions and a gas limit of 2,000,000 per BeginBlock.
End Blocker
The EndBlocker abci call is ran at the end of each block. The EventManager, BlockHeight, and BlockTime are monitored and used to detect Trigger activation.
Block Event Detection
The following is logic is used to detect the activation of a Trigger:
- The EventManager is utilized to traverse the transaction events from the newly created block
- The Event Listener table filters for Triggers containing a TransactionEvent matching the transaction event types and containing the defined Attributes
- The Event Listener table filters for Triggers containing a BlockHeightEvent that is greater than or equal to the current BlockHeight
- The Event Listener table filters for Triggers containing a BlockTimeEvent that is greater than or equal to the current BlockTime
- These Triggers are then unregistered and added to the Queue