package octez-protocol-alpha-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=c6df840ebbf115e454db949028c595bec558a59a66cade73b52a6d099d6fa4d4
sha512=d8aee903b9fe130d73176bc8ec38b78c9ff65317da3cb4f3415f09af0c625b4384e7498201fdb61aa39086a7d5d409d0ab3423f9bc3ab989a680cf444a79bc13
doc/octez-protocol-alpha-libs.test-helpers/Tezos_alpha_test_helpers/Liquidity_baking_machine/index.html
Module Tezos_alpha_test_helpers.Liquidity_baking_machine
Source
This module provides the means to test extensively the Liquidity Baking (LB) feature. We recall that this feature is built upon three smart contracts: (1) a CPMM contract initially based on Dexter 2, and (2) two tokens contracts. Our objective is to run “scenarios” consisting in interleaved, realistic calls to these contracts, and to assert these scenarios do not yield any undesirable behaviors.
To that end, three “machines” are provided.
- The
SymbolicMachine
allows to simulate scenarios involving the LB feature completely off-chain. It can be seen as an abstraction of the concrete implementation provided by the Tezos node. - The
ConcreteMachine
allows to execute scenarios on-chain. - The
ValidationMachine
combines the two previously mentioned machines. In other words, theValidationMachine
makes theSymbolicMachine
and theConcreteMachine
execute the same scenarios, and asserts they remain synchronized after each baked block.
The ValidationMachine
allows to (1) validate the
SymbolicMachine
(i.e., the reimplementation of the LB contracts logic) against the real implementation provided by Tezos, and the contracts originated by the protocol correctly implement the LB logic, as implemented by the SymbolicMachine
. That is, the ValidationMachine
reports desynchronization of the two machines, but cannot explain this desynchronization.
Machine State Characterization
As far as liquidity baking is concerned, an account can hold three kinds of tokens: xtz
, tzbtc
, and liquidity
.
A value of type specs
allows to specify an initial state of a “machine”.
In a nutshell, it consists in specifying the minimal balances of the CPMM contracts and a set of implicit contracts. The two machines provided by this module has a build
function which turns a specs
into a consistent initial state for this machine.
type 'a env = private {
cpmm_contract : 'a;
tzbtc_contract : 'a;
tzbtc_admin : 'a;
liquidity_contract : 'a;
liquidity_admin : 'a;
implicit_accounts : 'a list;
holder : 'a;
subsidy : xtz;
}
A value of type 'a env
(where 'a
is the type of contract identifiers) summarizes the different contracts involved in the LB feature.
Values of type env
are constructed by the build
function of the machines.
A value of type 'a step
(where 'a
is the type used to identify contracts) describes a consistent sequence of LB smart contract calls.
For instance, SellTzBTC
consists in approving an allowance in the TzBTC
contract, then calling the token_to_xtz
entry point of the CPMM
.
A summary of the state of a machine, parameterized by the type of contract identifier.
The Symbolic Machine
In the SymbolicMachine
, a contract is identified by a symbolic value.
A machine that can execute scenarios onchain.