State
The cron module keeps state of the following primary objects:
Params
Schedules
Schedule execution tracking
Params
Params is a module-wide configuration structure that stores system parameters and defines overall functioning of the cron module.
Params:
0x01 | ProtocolBuffer(Params)
message Params {
string security_address = 1; // Emergency removal authority
uint64 limit = 2; // Max schedules executed per block
}Schedule
Schedule defines the scheduled execution configuration.
Schedule:
0x02 | []byte(name) | ProtocolBuffer(Schedule)
message Schedule {
string name = 1; // Schedule identifier
uint64 period = 2; // Execution interval in blocks
repeated MsgExecuteContract msgs = 3; // Messages to execute
uint64 last_execute_height = 4; // Last execution block height
}ScheduleCount
ScheduleCount tracks the total number of schedules for governance limits.
ScheduleCount:
0x03 | ProtocolBuffer(ScheduleCount)
ExecutionStage
ExecutionStage controls the height offset used in schedule readiness checking:
Height Offset Logic in intervalPassed function:
Usage in Message Retrieval:
EXECUTION_STAGE_END_BLOCKER: Checks if schedules will be ready in the next block (for hash calculation)
EXECUTION_STAGE_BEGIN_BLOCKER: Checks if schedules are ready in the current block (for immediate execution)
Cross-Block State (tm-secret-enclave)
The cron module also maintains state across block boundaries using the tm-secret-enclave component:
Implicit Hash Storage
This storage maintains the SHA-256 hash of scheduled messages between blocks:
Block N-1: Hash calculated and stored during EndBlock
Block N: Hash retrieved and included in block header
Verification: Hash verified during message execution in enclave
Last updated
Was this helpful?