BYTENAI

Playground

Playground

Pick an argument and read what the compiler actually printed for it. These are recordings, not live runs: this host has no compiler process, and it will not pretend to be one.

The run

$ smurf run genesis.smurf --do transfer --arg amount=100.4exit 3
space Genesis
  genesis root=dcb9f8d48daf2cc728db2ddf53da9b35783cd616ddd02b6cab921546e81396b5
refused: precondition: require #2 is false: source.energy >= amount

Recorded by tools/smurf-fixtures.sh from smurf (../smurf); re-run that script and compare. The recording is 18654 bytes, sha256 d2977e431fde7e2c84d0c8d05aa8d2d8acb1fcc1ef794320b995b05b39bebf15.

The three phases

Every transition runs require, then apply, then ensure, in that order. Here is the recorded trace of the ten-unit transfer, so the names are not an assertion:

$ smurf trace genesis.smurf --do transfer --arg amount=10exit 0
transition transfer (1 parameter(s))
  phase 1  require x2
  phase 2  apply x2
  phase 3  ensure x1
  changed source.energy = f64:90.0
  changed target.energy = f64:10.0
  committed root=f99950eab83d71d1a239f0981249a185e457f663cf31fc5d40ca9c579b8d6d3d (was dcb9f8d48daf2cc728db2ddf53da9b35783cd616ddd02b6cab921546e81396b5)

The state

The transition was refused: a require failed, so no field changed and the root is the genesis root. A refusal is a result, not a crash.

Why these arguments

0 writes nothing and the root does not move. 10 and 100 are the ordinary case and its edge. 100.4, -5, 1e9 and abc are refusals, and the refusal is the interesting half: the transition runs its requires before it writes a byte.

The trace page shows the same run with its phases counted.

Back to the language