Skip to content

Prepare Commit

Dan Connolly edited this page May 12, 2022 · 4 revisions

roughly...

An input validation bug (IOU link) led to a whole AMM pool getting wedged. Eek! How do we prevent that?!

The typical pattern is:

  1. prepare: validate inputs and otherwise check preconditions (see assert.type, assertProposalShape, pattern fit, ...)
  2. commit: zcf.reallocate(seat1, seat2) etc.

The commit should finish in the same turn as when the preconditions were established. At a turn boundary, state may change, invalidating preconditions.

The commit operation must be atomic. try / catch can be used to make an atomic operation out of multiple steps: in the catch, abort the vat so that the partially committed state is not observable. Death before confusion!

Clone this wiki locally