Skip to main content

🐣 Bootstrap_storage.v

Proofs

See code, Gitlab , OCaml

The function [init_account] is valid.
[init_account] with no public key and zero amount is an identity
Lemma init_account_identity ctxt public_key_hash :
  let bootstrap_account := {|
    Parameters_repr.bootstrap_account.public_key_hash := public_key_hash;
    Parameters_repr.bootstrap_account.public_key := None;
    Parameters_repr.bootstrap_account.amount := Tez_repr.zero;
    Parameters_repr.bootstrap_account.delegate_to := None;
    Parameters_repr.bootstrap_account.consensus_key := None;
  |} in
  letP? '(ctxt', l) := Bootstrap_storage.init_account (ctxt, [])
                                             bootstrap_account in
    l = [] ctxt = ctxt'.
Proof.
  easy.
Qed.

The function [init_contract] is valid.
The function [init_value] is valid.
The function [cycle_end] is valid.
[cycle_end] is an identity when there are no rewards in

the next cycle

When cycle reaches [Int32.max_int] and assumming that there are no negative indexes on the [Storage.Ramp_up.Rewards], [cycle_end] becomes an identity.
Lemma cycle_max_int_id ctxt :
  ( (i : Int32.t),
      Int32.Valid.negative i
      Storage.Ramp_up.Rewards.(Storage_sigs.Indexed_data_storage.find)
                                ctxt i = Pervasives.Ok None)
  letP? ctxt' := Bootstrap_storage.cycle_end ctxt Int32.max_int in
  ctxt' = ctxt.
Proof.
  intros.
  unfold Bootstrap_storage.cycle_end.
  assert (HCycle_repr_succ_overflows : Cycle_repr.succ Int32.max_int = Int32.min_int) by lia.
  rewrite HCycle_repr_succ_overflows. unfold Int32.min_int.
  now rewrite H.
Qed.

[cycle_end] succedes when [Storage.Ramp_up.Rewards.(_.find)] succedes
Lemma cycle_end_is_ok ctxt last_cycle :
  Pervasives.is_ok (Storage.Ramp_up.Rewards.(
           Storage_sigs.Indexed_data_storage.find)
      ctxt (Cycle_repr.succ last_cycle))
  Pervasives.is_ok (Bootstrap_storage.cycle_end ctxt last_cycle).
Proof.
  intros.
  unfold Bootstrap_storage.cycle_end.
  destruct (Storage.Ramp_up.Rewards.(
             Storage_sigs.Indexed_data_storage.find) _ _) eqn:?;
           [|easy].
  destruct o; simpl; try easy.
Admitted.