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:
2. A Trigger is removed from the Queue.
3. The Gas Limit for the Trigger is retrieved from the store.
4. A GasMeter is created for the Trigger.
5. An Action on the Trigger is ran updating and verifying gas usage against the GasMeter
6. The events for the Action are emitted.
7. Step 5 is repeated until no more Actions exist for the trigger.
8. 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
EventManageris utilized to traverse the transaction events from the newly created block. - The
Event Listenertable filters forTriggerscontaining aTransactionEventmatching the transaction event types and containing the definedAttributes. - The
Event Listenertable filters forTriggerscontaining aBlockHeightEventthat is greater than or equal to the currentBlockHeight. - The
Event Listenertable filters forTriggerscontaining aBlockTimeEventthat is greater than or equal to the currentBlockTime. - These
Triggersare then unregistered and added to theQueue.