Skip to main content

🌌 Alpha_context.v

Proofs

See code, Gitlab , OCaml

The function [current] is valid.
  Lemma current_is_valid ctxt :
    Raw_context.Valid.t ctxt
    Time.Valid.t (Alpha_context.Timestamp.current ctxt).
  Proof.
  Admitted.

The function [predecessor] is valid.
  Lemma predecessor_is_valid ctxt :
    Raw_context.Valid.t ctxt
    Time.Valid.t (Alpha_context.Timestamp.predecessor ctxt).
  Proof.
  Admitted.
End Timestamp.

Module Operation.
The encoding [Alpha_context.Operation.unsigned_encoding] is valid.
  Lemma unsigned_encoding_is_valid :
     kind,
    Data_encoding.Valid.t
    (fun '(_, x)Operation_repr.packed_contents_list.Valid.t kind x)
    Alpha_context.Operation.unsigned_encoding.
  Proof.
    intros.
    Data_encoding.Valid.data_encoding_auto.
  Qed.
  #[global] Hint Resolve unsigned_encoding_is_valid : Data_encoding_db.
End Operation.

Module First_level_of_protocol.
The function [get] is valid.
The function [round_durations] is valid.
  Lemma round_durations_is_valid ctxt
    (H_ctxt : Raw_context.Valid.t ctxt) :
    let round := Alpha_context.Constants.round_durations ctxt in
    Round_repr.Durations.Valid.t round.
  Proof.
    Raw_context.Valid.destruct_rewrite H_ctxt.
    apply H_sim_ctxt.
  Qed.

The function [all] is valid.
  Lemma all_is_valid ctxt
    (H_ctxt : Raw_context.Valid.t ctxt) :
    let ctxt := Alpha_context.Constants.all ctxt in
    Constants_repr.Valid.t ctxt.
  Proof.
  Admitted.
End Constants.

Module Round.
The encoding [Alpha_context.Round.round_durations_encoding] is valid.
  Lemma round_durations_encoding_is_valid :
    Data_encoding.Valid.t
    Round_repr.Durations.Valid.t
    Alpha_context.Round.round_durations_encoding.
  Proof.
    Data_encoding.Valid.data_encoding_auto.
  Qed.
  #[global] Hint Resolve round_durations_encoding_is_valid : Data_encoding_db.

The function [round_duration] is valid.
The function [update] is valid.
The function [get] is valid.
  Lemma get_is_valid ctxt :
    Raw_context.Valid.t ctxt
    letP? round := Proto_alpha.Alpha_context.Round.get ctxt in
    Round_repr.Valid.t round.
  Proof.
  Admitted.
End Round.

Module Gas.
The function [set_limit] is valid.
The function [consume_limit_in_block] is valid.
The function [set_unlimited] is valid.
The function [consume] is valid.
  Lemma consume_is_valid ctxt cost :
    Raw_context.Valid.t ctxt
    Saturation_repr.Valid.t cost
    letP? ctxt := Alpha_context.Gas.consume ctxt cost in
    Raw_context.Valid.t ctxt.
  Proof.
  Admitted.
End Gas.

Module Script.
The function [force_decode_in_context] is valid.
  Lemma force_decode_in_context_is_valid consume_deserialization_gas ctxt lexpr
  : Raw_context.Valid.t ctxt
    letP? '(_, ctxt') :=
      Alpha_context.Script.force_decode_in_context
        consume_deserialization_gas ctxt lexpr in
    Raw_context.Valid.t ctxt'.
  Proof.
    intros H. unfold Alpha_context.Script.force_decode_in_context.
    eapply Error.split_letP. {
      apply Raw_context.consume_gas_is_valid ; [ assumption |].
      destruct consume_deserialization_gas eqn:eq_cons ; [
      apply Script_repr.stable_force_decode_cost_is_valid|
      apply Script_repr.force_decode_cost_is_valid]. }
    clear ctxt H. intros ctxt H.
    eapply Error.split_letP with (fun xTrue) ; [
      
@TODO the 2 lines below give the proof of a [force_decode_is_valid] Lemma
      destruct (@force_decode Script_repr.expr lexpr ) eqn:Hlexpr ;
      unfold Script_repr.force_decode ; rewrite Hlexpr ; easy|].
    intros expr' _. assumption.
  Qed.

The function [force_bytes_in_context] is valid.
The function [consume_decoding_gas] is valid.
  Lemma consume_decoding_gas_is_valid available_gas lexpr :
    Saturation_repr.Valid.t available_gas
    letP? gas :=
      Alpha_context.Script.consume_decoding_gas available_gas lexpr in
    Saturation_repr.Valid.t available_gas.
  Proof.
  Admitted.
End Script.

Module Origination_nonce.
  (* @TODO: validity of functions of this module *)
End Origination_nonce.

Module Contract.
  (* @TODO: validity of functions of this module *)
End Contract.

Module Tx_rollup_message.
  (* @TODO: validity of functions of this module *)
End Tx_rollup_message.

Module Big_map.
  Module Id.
The encoding [Alpha_context.Big_map.Id.encoding] is valid.
    Lemma encoding_is_valid :
      Data_encoding.Valid.t (fun _True) Alpha_context.Big_map.Id.encoding.
    Proof.
      Data_encoding.Valid.data_encoding_auto.
    Qed.
    #[global] Hint Resolve encoding_is_valid : Data_encoding_db.
  End Id.

The function [get_opt] is valid.
The function [list_key_values] is valid.
The function [_exists] is valid.
  Lemma _exists_is_valid ctxt id :
    Raw_context.Valid.t ctxt
    letP? '(ctxt, _) := Alpha_context.Big_map._exists ctxt id in
    Raw_context.Valid.t ctxt.
  Proof.
  Admitted.
End Big_map.

Module Sapling.
  Module Id.
The encoding [Alpha_context.Sapling.Id.encoding] is valid.
    Lemma encoding_is_valid :
      Data_encoding.Valid.t (fun _True) Alpha_context.Sapling.Id.encoding.
    Proof.
      Data_encoding.Valid.data_encoding_auto.
    Qed.
    #[global] Hint Resolve encoding_is_valid : Data_encoding_db.
  End Id.
End Sapling.

Module Delegate.
  (* @TODO: validity of functions of this module *)
End Delegate.

Module Stake_distribution.
  (* @TODO: validity of functions of this module *)
End Stake_distribution.

Module Consensus.
  (* @TODO: validity of functions of this module *)
End Consensus.

The function [prepare_first_block] is valid. Lemma prepare_first_block_is_valid chain_id standalone typecheck level timestamp (H_standalone : Raw_context.standalone.Valid.simulation standalone) (H_typecheck : forall ctxt script, Raw_context.Valid.t ctxt -> letP? '(_, ctxt) := typecheck ctxt script in Raw_context.Valid.t ctxt ) (H_level : Int32.Valid.t level) (H_timestamp : Time.Valid.t timestamp) : letP? ctxt := Alpha_context.prepare_first_block chain_id (Raw_context.to_context standalone) typecheck level timestamp in Raw_context.Valid.t ctxt. Proof. now apply Init_storage.prepare_first_block_is_valid. Qed.
The function [prepare] is valid.
The function [finalize] is valid.
Lemma finalize_is_valid message ctxt fitness :
  Raw_context.Valid.t ctxt
  letP? _ := Alpha_context.finalize message ctxt fitness in
  True.
Proof.
  intros.
  unfold Alpha_context.finalize.
  eapply Error.split_letP; [
    now apply Level_storage.last_allowed_fork_level_is_valid |
    easy
  ].
Qed.

The function [Alpha_context.record_dictator_proposal_seen] is valid.
The function [fresh_internal_nonce] is valid.