State Update

contract UpdateState is MApprovalChain, LibConstants, IVerifierActions, MFreezable, MOperator, PublicInputOffsets

The StarkEx contract tracks the state of the off-chain exchange service by storing Merkle roots of the vault state (off-chain account state) and the order state (including fully executed and partially fulfilled orders).

The Operator is the only entity entitled to submit state updates by calling updateState and this is only allowed if the contract is not in the frozen state (see FullWithdrawals). The call includes the public input of a STARK proof, and additional data (applicationData) that includes information not attested to by the proof.

The public input includes the current (initial) and next (final) Merkle roots as mentioned above, the heights of the Merkle trees and for each ramping operation (deposit, withdraw, full withdraw) the following information:

  1. ID of the vault (off-chain account)

  2. Stark Key of the vault owner

  3. Token ID of the currency in the vault

  4. Vault balance before the operation

  5. Vault balance after the operation

The above information is used by the exchange contract in order to update the pending accounts used for deposits (see Deposits) and withdrawals (see Withdrawals).

The applicationData holds the number of ramping operations included in the batch as well as the key of the entity requesting each full withdrawal (see FullWithdrawals). The latter is required in case an entity that isn’t the owner of a vault requests a full withdrawal for that vault. In such a case the exchange contract marks the request as serviced but without performing the withdrawal.

The STARK proof attesting to the validity of the state update is submitted separately by the exchange service to (one or more) STARK integrity verifier contract(s) (see IDexStatementVerifier). Likewise, the signatures of committee members attesting to the availability of the vault and order data is submitted separately by the exchange service to (one or more) availability verifier contract(s) (see Committee).

The state update is only accepted by the exchange contract if the integrity verifier and availability verifier contracts have indeed received such proof of soundness and data availability.

function updateState(uint256[] calldata publicInput, uint256[] calldata applicationData)