View this page as Markdown

observe_after_step

Schedules one keyed READ at the checkpoint after a zero-based PROGRAM step.

Example

Local

WITH actors AS (
  SELECT
    '0x1000000000000000000000000000000000000001'::ADDRESS AS sender,
    '0x2000000000000000000000000000000000000002'::ADDRESS AS writer
),
runnable_candidate AS (
  SELECT
    'pass'::VARCHAR AS candidate_key,
    program([execute_call(
      sender,
      writer,
      '0x000000000000000000000000000000000000000000000000000000000000002a'::BYTES,
      1::UINT256,
      100000::UBIGINT
    )]) AS program,
    [observe_after_step('writer.slot.checkpoint'::VARCHAR, 0::UINTEGER, storage_at(writer, '0x0000000000000000000000000000000000000000000000000000000000000000'::BYTES32))] AS observations
  FROM actors
)
SELECT
  candidate_key,
  len(observations)::INTEGER AS scheduled_observations,
  observations[1] IS NOT NULL AS scheduled
FROM runnable_candidate;
-- => [{"candidate_key":"pass","scheduled_observations":1,"scheduled":"true"}]

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

observe_after_step(VARCHAR, UINTEGER, READ) #

Schedules one keyed READ at the checkpoint after a zero-based PROGRAM step.

Inputs

Name Type Use
observation_key VARCHAR

Non-NULL valid UTF-8 key; the consumed request requires 1-256 bytes and no NUL byte.

required positional
step_index UINTEGER

Zero-based UINTEGER step index. Out-of-range points are unavailable; points after skipped steps are skipped.

required positional
read READ

Non-NULL READ evaluated against the retained post-step state.

required positional

Returns

Name Type
observation OBSERVATION

Post-step OBSERVATION. Returns one OBSERVATION that expands to a single after_step point.

Guidance

Request validation

Key length, NUL bytes, and duplicate points are validated when the observation list is consumed. A request may contain at most 256 expanded points across all OBSERVATION values.

Related functions

Category and tags

Category
Simulation
Tag
Simulate