-
Notifications
You must be signed in to change notification settings - Fork 214
Prepare Commit
Dan Connolly edited this page Dec 12, 2024
·
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:
- prepare: validate inputs and otherwise check preconditions (see
assert.type
,assertProposalShape
, patternfit
, ...) - 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!
See also:
This wiki is for developing agoric-sdk. For help using Agoric SDK, see https://docs.agoric.com/ and https://agoric-sdk.pages.dev/