Alpha: rename Tezos_context -> Alpha_context

This commit is contained in:
Grégoire Henry 2018-02-11 19:17:39 +01:00
parent 6a5a235d42
commit 5fff7b3c1b
83 changed files with 166 additions and 166 deletions

View File

@ -30,7 +30,7 @@ These layers follow the linking order: the first modules are the towers
foundation that talk to the raw key-value store, and going forward in
the module list means climbing up the abstraction tower.
The big abstraction barrier: ``Tezos_context``
The big abstraction barrier: ``Alpha_context``
----------------------------------------------
the proof-of-stake algorithm, as described in the white paper, relies on
@ -43,31 +43,31 @@ The proof-of-stake is thus implemented over a generic key-value store
whose keys and associated binary data must implement the abstract
structure.
The ``Tezos_context`` module enforces the separation of concerns
The ``Alpha_context`` module enforces the separation of concerns
between, on one hand, mapping the abstract state of the ledger to the
concrete structure of the key-value store, and, on the other hand,
implementing the proof-of-stake algorithm over this state.
In more practical terms, ``Tezos_context`` defines a type ``t`` that
In more practical terms, ``Alpha_context`` defines a type ``t`` that
represents a state of the ledger. This state is an abstracted out
version of the key-value store that can only be manipulated through the
use of the few selected manipulations reexported by ``Tezos_context``,
use of the few selected manipulations reexported by ``Alpha_context``,
that always preserve the well-typed aspect and internal consistency
invariants of the state.
When validating a block, the low-level state that result from the
predecessor block is read from the disk, then abstracted out to a
``Tezos_context.t``, which is then only updated by high level operations
``Alpha_context.t``, which is then only updated by high level operations
that preserve consistency, and finally, the low level state is extracted
to be committed on disk.
This way, we have two well separated parts in the code. The code below
``Tezos_context`` implements the ledgers state storage, while the code
``Alpha_context`` implements the ledgers state storage, while the code
on top of it is the proof-of-stake algorithm. Thanks to this barrier,
the latter can remain nice, readable OCaml that only manipulates plain
OCaml values.
Below the ``Tezos_context``
Below the ``Alpha_context``
---------------------------
For this part, in a first discovery of the source code, you can start by
@ -137,7 +137,7 @@ These transaction do not go as far as checking that, for instance, when
the destination of a transaction is credited, the source is also
debitted, as in some cases, it might not be the case.
Above the ``Tezos_context``
Above the ``Alpha_context``
---------------------------
The three next sections describe the main entrypoints to the protocol:
@ -158,7 +158,7 @@ understood with minimum OCaml knowledge.
You want to start from the shell entry points (validation of the block
header, validation of an operation, finalization of a block validation),
and follow the control flow until you hit the ``Tezos_context``
and follow the control flow until you hit the ``Alpha_context``
abstraction barrier. This will lead you to reading modules ``Baking``
and ``Amendment``.
@ -175,7 +175,7 @@ Protocol RPC API
~~~~~~~~~~~~~~~~
Finally, the RPCs specific to Alpha are also defined above the
``Tezos_context`` barrier. The definition is split into two parts.
``Alpha_context`` barrier. The definition is split into two parts.
The first part, ``Services``, defines the RPC API: URL schemes with the
types of parameters, and input and output JSON schemas. This interface

View File

@ -40,11 +40,11 @@ let block_forged ?prev ops =
let open Proto in
let generate_proof_of_work_nonce () =
Rand.generate
Proto.Tezos_context.Constants.proof_of_work_nonce_size in
Proto.Alpha_context.Constants.proof_of_work_nonce_size in
let generate_seed_nonce () =
match Proto.Nonce_storage.of_bytes @@
Rand.generate
Proto.Tezos_context.Constants.nonce_length with
Proto.Alpha_context.Constants.nonce_length with
| Error _ -> assert false
| Ok nonce -> nonce in
Block_repr.forge_header (block ops)

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
type block_info = {
hash: Block_hash.t ;

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
type block_info = {
hash: Block_hash.t ;

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val run:
#Client_commands.full_context ->

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Logging.Client.Endorsement

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val forge_endorsement:
#Client_commands.full_context ->

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Logging.Client.Baking
@ -28,7 +28,7 @@ let forge_block_header
let rec loop () =
let proof_of_work_nonce = generate_proof_of_work_nonce () in
let unsigned_header =
Tezos_context.Block_header.forge_unsigned
Alpha_context.Block_header.forge_unsigned
shell { priority ; seed_nonce_hash ; proof_of_work_nonce } in
Client_keys.append delegate_sk unsigned_header >>=? fun signed_header ->
let block_hash = Block_hash.hash_bytes [signed_header] in
@ -43,7 +43,7 @@ let empty_proof_of_work_nonce =
(String.make Constants_repr.proof_of_work_nonce_size '\000')
let forge_faked_proto_header ~priority ~seed_nonce_hash =
Tezos_context.Block_header.forge_unsigned_proto_header
Alpha_context.Block_header.forge_unsigned_proto_header
{ priority ; seed_nonce_hash ;
proof_of_work_nonce = empty_proof_of_work_nonce }

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val generate_seed_nonce: unit -> Nonce.t
(** [generate_seed_nonce ()] is a random nonce that is typically used

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
let bake_block (cctxt : #Client_commands.full_context) block
?force ?max_priority ?(free_baking=false) ?src_sk delegate =

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
(** Mine a block *)
val bake_block:

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
type operation = {
hash: Operation_hash.t ;
@ -43,7 +43,7 @@ type valid_endorsement = {
(*
let filter_valid_endorsement cctxt ({ hash ; content } : operation) =
let open Tezos_context in
let open Alpha_context in
match content with
| None
| Some { contents = Anonymous_operations _ }

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
type operation = {
hash: Operation_hash.t ;

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
let inject_seed_nonce_revelation rpc_config block ?async nonces =
let operations =

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val inject_seed_nonce_revelation:
#RPC_context.simple ->

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Cli_entries
type error += Bad_tez_arg of string * string (* Arg_name * value *)

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val tez_sym: string

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Tezos_micheline
open Client_proto_contracts
open Client_keys

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val list_contract_labels :
#Client_commands.full_context ->

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Tezos_micheline
open Client_proto_context
open Client_proto_contracts

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
module ContractEntity = struct
type t = Contract.t

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Cli_entries
module RawContractAlias :

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Client_proto_contracts
let group =

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
(* TODO locking... *)

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val mem:
#Client_commands.wallet ->

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Tezos_micheline
open Michelson_v1_printer

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Tezos_micheline
module Program : Client_aliases.Alias

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
let make_call1 cctxt s=
RPC_context.make_call1 (s Block_services.S.proto_path) cctxt
@ -184,7 +184,7 @@ module Helpers = struct
block ~branch ~source ?sourcePubKey ~counter
~amount ~destination ?parameters ~fee ()=
operations cctxt block ~branch ~source ?sourcePubKey ~counter ~fee
Tezos_context.[Transaction { amount ; parameters ; destination }]
Alpha_context.[Transaction { amount ; parameters ; destination }]
let origination cctxt
block ~branch
~source ?sourcePubKey ~counter
@ -193,7 +193,7 @@ module Helpers = struct
?(delegatable = true)
?delegatePubKey ?script ~fee () =
operations cctxt block ~branch ~source ?sourcePubKey ~counter ~fee
Tezos_context.[
Alpha_context.[
Origination { manager = managerPubKey ;
delegate = delegatePubKey ;
script ;
@ -204,7 +204,7 @@ module Helpers = struct
let delegation cctxt
block ~branch ~source ?sourcePubKey ~counter ~fee delegate =
operations cctxt block ~branch ~source ?sourcePubKey ~counter ~fee
Tezos_context.[Delegation delegate]
Alpha_context.[Delegation delegate]
end
module Delegate = struct
let operations cctxt
@ -215,15 +215,15 @@ module Helpers = struct
let endorsement cctxt
b ~branch ~source ~block ~slot () =
operations cctxt b ~branch ~source
Tezos_context.[Endorsement { block ; slot }]
Alpha_context.[Endorsement { block ; slot }]
let proposals cctxt
b ~branch ~source ~period ~proposals () =
operations cctxt b ~branch ~source
Tezos_context.[Proposals { period ; proposals }]
Alpha_context.[Proposals { period ; proposals }]
let ballot cctxt
b ~branch ~source ~period ~proposal ~ballot () =
operations cctxt b ~branch ~source
Tezos_context.[Ballot { period ; proposal ; ballot }]
Alpha_context.[Ballot { period ; proposal ; ballot }]
end
module Dictator = struct
let operation cctxt

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
type block = Block_services.block

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val print_expr :
Format.formatter ->

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Tezos_micheline
open Script_typed_ir
open Script_tc_errors

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Tezos_micheline

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Tezos_micheline
val print_expr :

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
let (//) = Filename.concat

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val init :
?exe:string ->
@ -19,7 +19,7 @@ val init :
forked Tezos node and the block info of the block from where the
tests will begin. *)
val level : Block_services.block -> Tezos_context.Level.t tzresult Lwt.t
val level : Block_services.block -> Alpha_context.Level.t tzresult Lwt.t
module Account : sig

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
module Helpers = Proto_alpha_helpers
module Assert = Helpers.Assert

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
module Helpers = Proto_alpha_helpers
module Assert = Helpers.Assert

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
module Helpers = Proto_alpha_helpers
module Assert = Helpers.Assert

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Proto_alpha_helpers
let demo_protocol =

View File

@ -43,7 +43,7 @@
"Init_storage",
"Public_key_storage",
"Tezos_context",
"Alpha_context",
"Script_typed_ir",
"Gas",

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
let () = ()

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
val may_start_new_voting_cycle:
context -> context tzresult Lwt.t

View File

@ -9,7 +9,7 @@
(** Tezos Protocol Implementation - Main Entry Points *)
open Tezos_context
open Alpha_context
type error += Wrong_voting_period of Voting_period.t * Voting_period.t (* `Temporary *)
type error += Wrong_endorsement_predecessor of Block_hash.t * Block_hash.t (* `Temporary *)

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Tezos_context
open Alpha_context
open Misc
type error += Invalid_fitness_gap of int64 * int64 (* `Permanent *)
@ -114,7 +114,7 @@ let minimal_time c priority pred_timestamp =
let check_timestamp c priority pred_timestamp =
minimal_time c priority pred_timestamp >>=? fun minimal_time ->
let timestamp = Tezos_context.Timestamp.current c in
let timestamp = Alpha_context.Timestamp.current c in
fail_unless Timestamp.(minimal_time <= timestamp)
(Timestamp_too_early (minimal_time, timestamp))

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Tezos_context
open Alpha_context
open Misc
type error += Invalid_fitness_gap of int64 * int64 (* `Permanent *)

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
(* FIXME: this really is a preliminary estimation of costs,
everything in this file needs to be tweaked and proofread. *)

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
type t
type cost

View File

@ -9,13 +9,13 @@
(* Tezos Protocol Implementation - Protocol Signature Instance *)
type operation = Tezos_context.operation
type operation = Alpha_context.operation
let parse_operation = Tezos_context.Operation.parse
let acceptable_passes = Tezos_context.Operation.acceptable_passes
let parse_operation = Alpha_context.Operation.parse
let acceptable_passes = Alpha_context.Operation.acceptable_passes
let max_block_length =
Tezos_context.Block_header.max_header_length
Alpha_context.Block_header.max_header_length
let validation_passes =
Updater.[ { max_size = 32 * 1024 ; max_op = None } ; (* 32kB FIXME *)
@ -25,31 +25,31 @@ let rpc_services = Services_registration.rpc_services
type validation_mode =
| Application of {
block_header : Tezos_context.Block_header.t ;
baker : Tezos_context.public_key_hash ;
block_header : Alpha_context.Block_header.t ;
baker : Alpha_context.public_key_hash ;
}
| Partial_construction of {
predecessor : Block_hash.t ;
}
| Full_construction of {
predecessor : Block_hash.t ;
block_proto_header : Tezos_context.Block_header.proto_header ;
baker : Tezos_context.public_key_hash ;
block_proto_header : Alpha_context.Block_header.proto_header ;
baker : Alpha_context.public_key_hash ;
}
type validation_state =
{ mode : validation_mode ;
ctxt : Tezos_context.t ;
ctxt : Alpha_context.t ;
op_count : int }
let current_context { ctxt } =
return (Tezos_context.finalize ctxt).context
return (Alpha_context.finalize ctxt).context
let precheck_block
~ancestor_context:_
~ancestor_timestamp:_
raw_block =
Lwt.return (Tezos_context.Block_header.parse raw_block) >>=? fun _ ->
Lwt.return (Alpha_context.Block_header.parse raw_block) >>=? fun _ ->
(* TODO: decide what other properties should be checked *)
return ()
@ -58,11 +58,11 @@ let begin_application
~predecessor_timestamp:pred_timestamp
~predecessor_fitness:pred_fitness
raw_block =
Lwt.return (Tezos_context.Block_header.parse raw_block) >>=? fun block_header ->
Lwt.return (Alpha_context.Block_header.parse raw_block) >>=? fun block_header ->
let level = block_header.shell.level in
let fitness = pred_fitness in
let timestamp = block_header.shell.timestamp in
Tezos_context.init ~level ~timestamp ~fitness ctxt >>=? fun ctxt ->
Alpha_context.init ~level ~timestamp ~fitness ctxt >>=? fun ctxt ->
Apply.begin_application
ctxt block_header pred_timestamp >>=? fun (ctxt, baker) ->
let mode = Application { block_header ; baker } in
@ -79,7 +79,7 @@ let begin_construction
() =
let level = Int32.succ pred_level in
let fitness = pred_fitness in
Tezos_context.init ~timestamp ~level ~fitness ctxt >>=? fun ctxt ->
Alpha_context.init ~timestamp ~level ~fitness ctxt >>=? fun ctxt ->
begin
match proto_header with
| None ->
@ -107,7 +107,7 @@ let apply_operation ({ mode ; ctxt ; op_count } as data) operation =
| Full_construction { predecessor ; block_proto_header ; baker } ->
predecessor,
block_proto_header.priority,
Some (Tezos_context.Contract.default_contract baker) in
Some (Alpha_context.Contract.default_contract baker) in
Apply.apply_operation
ctxt baker_contract pred_block block_prio operation
>>=? fun (ctxt, _contracts, _ignored_script_error) ->
@ -116,25 +116,25 @@ let apply_operation ({ mode ; ctxt ; op_count } as data) operation =
let finalize_block { mode ; ctxt ; op_count } = match mode with
| Partial_construction _ ->
let ctxt = Tezos_context.finalize ctxt in
let ctxt = Alpha_context.finalize ctxt in
return ctxt
| Application
{ baker ; block_header = { proto = block_proto_header } }
| Full_construction { block_proto_header ; baker } ->
Apply.finalize_application ctxt block_proto_header baker >>=? fun ctxt ->
let { level } : Tezos_context.Level.t =
Tezos_context. Level.current ctxt in
let { level } : Alpha_context.Level.t =
Alpha_context. Level.current ctxt in
let priority = block_proto_header.priority in
let level = Tezos_context.Raw_level.to_int32 level in
let fitness = Tezos_context.Fitness.current ctxt in
let level = Alpha_context.Raw_level.to_int32 level in
let fitness = Alpha_context.Fitness.current ctxt in
let commit_message =
Format.asprintf
"lvl %ld, fit %Ld, prio %d, %d ops"
level fitness priority op_count in
let ctxt = Tezos_context.finalize ~commit_message ctxt in
let ctxt = Alpha_context.finalize ~commit_message ctxt in
return ctxt
let compare_operations op1 op2 =
Apply.compare_operations op1 op2
let configure_sandbox = Tezos_context.configure_sandbox
let configure_sandbox = Alpha_context.configure_sandbox

View File

@ -9,4 +9,4 @@
(** Tezos Protocol Implementation - Protocol Signature Instance *)
include Updater.PROTOCOL with type operation = Tezos_context.Operation.t
include Updater.PROTOCOL with type operation = Alpha_context.Operation.t

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
open Script
open Script_typed_ir
open Script_tc_errors

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
type error += Overflow of Script.location
type error += Reject of Script.location
@ -18,7 +18,7 @@ val dummy_storage_fee : Tez.t
val execute:
Contract.origination_nonce ->
Contract.t -> Contract.t -> Tezos_context.t ->
Contract.t -> Contract.t -> Alpha_context.t ->
Script.t -> Tez.t ->
Script.expr -> Gas.t ->
(Script.expr * Script.expr * Gas.t * context * Contract.origination_nonce *
@ -26,7 +26,7 @@ val execute:
val trace:
Contract.origination_nonce ->
Contract.t -> Contract.t -> Tezos_context.t ->
Contract.t -> Contract.t -> Alpha_context.t ->
Script.t -> Tez.t ->
Script.expr -> Gas.t ->
((Script.expr * Script.expr * Gas.t * context * Contract.origination_nonce * Script_typed_ir.ex_big_map option) *

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
open Micheline
open Script
open Script_typed_ir
@ -2136,7 +2136,7 @@ let hash_data typ data =
let big_map_mem ctx contract key { diff ; key_type } =
match map_get key diff with
| None -> Tezos_context.Contract.Big_map_storage.mem ctx contract (hash_data key_type key)
| None -> Alpha_context.Contract.Big_map_storage.mem ctx contract (hash_data key_type key)
| Some None -> Lwt.return false
| Some (Some _) -> Lwt.return true
@ -2144,7 +2144,7 @@ let big_map_get ctx contract key { diff ; key_type ; value_type } =
match map_get key diff with
| Some x -> return x
| None ->
Tezos_context.Contract.Big_map_storage.get_opt
Alpha_context.Contract.Big_map_storage.get_opt
ctx contract
(hash_data key_type key) >>=? begin function
| None -> return None

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
open Script_tc_errors
type ('ta, 'tb) eq = Eq : ('same, 'same) eq
@ -38,9 +38,9 @@ val map_get : 'key -> ('key, 'value) Script_typed_ir.map -> 'value option
val map_key_ty : ('a, 'b) Script_typed_ir.map -> 'a Script_typed_ir.comparable_ty
val map_size : ('a, 'b) Script_typed_ir.map -> Script_int.n Script_int.num
val big_map_mem : context -> Tezos_context.Contract.t -> 'key -> ('key, 'value) Script_typed_ir.big_map -> bool Lwt.t
val big_map_mem : context -> Alpha_context.Contract.t -> 'key -> ('key, 'value) Script_typed_ir.big_map -> bool Lwt.t
val big_map_get :
context -> Tezos_context.Contract.t -> 'key -> ('key, 'value) Script_typed_ir.big_map ->
context -> Alpha_context.Contract.t -> 'key -> ('key, 'value) Script_typed_ir.big_map ->
'value option tzresult Lwt.t
val big_map_update :
'key -> 'value option -> ('key, 'value) Script_typed_ir.big_map ->

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
open Script
open Script_typed_ir

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
open Micheline
open Script
open Script_typed_ir

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
open Script_int

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Data_encoding
open Tezos_context
open Alpha_context
let operations custom_root =
RPC_service.post_service
@ -617,7 +617,7 @@ module Helpers = struct
(req "nonce_hash" Nonce_hash.encoding)
(dft "proof_of_work_nonce"
(Fixed.bytes
Tezos_context.Constants.proof_of_work_nonce_size)
Alpha_context.Constants.proof_of_work_nonce_size)
empty_proof_of_work_nonce))
~output: (obj1 (req "proto_header" bytes))
RPC_path.(custom_root / "helpers" / "forge" / "block_proto_header")

View File

@ -7,14 +7,14 @@
(* *)
(**************************************************************************)
open Tezos_context
open Alpha_context
type rpc_context = {
block_hash: Block_hash.t ;
block_header: Block_header.raw ;
operation_hashes: unit -> Operation_hash.t list list Lwt.t ;
operations: unit -> Operation.raw list list Lwt.t ;
context: Tezos_context.t ;
context: Alpha_context.t ;
}
let rpc_init (rpc_context : Updater.rpc_context Lwt.t) =
@ -23,7 +23,7 @@ let rpc_init (rpc_context : Updater.rpc_context Lwt.t) =
let level = Int32.succ block_header.shell.level in
let timestamp = block_header.shell.timestamp in
let fitness = block_header.shell.fitness in
Tezos_context.init ~level ~timestamp ~fitness context >>=? fun context ->
Alpha_context.init ~level ~timestamp ~fitness context >>=? fun context ->
return { block_hash ; block_header ; operation_hashes ; operations ; context }
let rpc_services = ref (RPC_directory.empty : Updater.rpc_context Lwt.t RPC_directory.t)
@ -255,7 +255,7 @@ let minimal_timestamp ctxt prio =
let () = register1
Services.Helpers.minimal_timestamp
(fun ctxt () slot ->
let timestamp = Tezos_context.Timestamp.current ctxt in
let timestamp = Alpha_context.Timestamp.current ctxt in
minimal_timestamp ctxt slot timestamp)
let () =
@ -268,7 +268,7 @@ let () =
| None -> Error_monad.fail Operation.Cannot_parse_operation
| Some (shell, contents) ->
let operation = { hash ; shell ; contents ; signature } in
let level = Tezos_context.Level.current ctxt in
let level = Alpha_context.Level.current ctxt in
Baking.baking_priorities ctxt level >>=? fun (Misc.LCons (baker_pkh, _)) ->
let baker_contract = Contract.default_contract baker_pkh in
let block_prio = 0 in

View File

@ -9,7 +9,7 @@
open Proto_alpha.Error_monad
open Proto_alpha.Tezos_context
open Proto_alpha.Alpha_context
type account = {
hpub : Ed25519.Public_key_hash.t ;

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
(** Facilities to deal with accounts , bootstrap accounts and make new
accounts *)

View File

@ -10,7 +10,7 @@
(** Functions to build and apply operations *)
open Proto_alpha
open Tezos_context
open Alpha_context
val operation :
tc:context -> ?baker:Helpers_account.t -> ?src:Helpers_account.t ->

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
module Assert = struct
let fail expected given msg =

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val fail : string -> string -> string -> 'a
(** Raises [Failed] with the passed parameters

View File

@ -12,7 +12,7 @@ open Error_monad
type shell_header = Block_header.shell_header
type tezos_header = Block_header.t
type protocol_header = Proto_alpha.Tezos_context.Block_header.proto_header
type protocol_header = Proto_alpha.Alpha_context.Block_header.proto_header
type operation_header = Operation.shell_header
type init_block = {
@ -33,7 +33,7 @@ type result = {
hash : Block_hash.t ;
level : Int32.t ;
validation : Updater.validation_result ;
tezos_context : Proto_alpha.Tezos_context.t
tezos_context : Proto_alpha.Alpha_context.t
}
let get_op_header_res (res : result) : operation_header = {
@ -43,7 +43,7 @@ let get_op_header_res (res : result) : operation_header = {
let get_proto_header priority : protocol_header = {
priority ;
proof_of_work_nonce = Helpers_crypto.generate_proof_of_work_nonce ();
seed_nonce_hash = Proto_alpha.Tezos_context.Nonce.hash @@ Helpers_crypto.generate_seed_nonce ()
seed_nonce_hash = Proto_alpha.Alpha_context.Nonce.hash @@ Helpers_crypto.generate_seed_nonce ()
}
let get_op_header pbh : operation_header = {
@ -64,7 +64,7 @@ let init (pred_shell_header : shell_header) pred_block_hash
let (sourced_operations, operation_hashs) = List.split src_ops_hashs in
let proto_header = get_proto_header priority in
let proto_header_bytes =
Proto_alpha.Tezos_context.Block_header.forge_unsigned_proto_header
Proto_alpha.Alpha_context.Block_header.forge_unsigned_proto_header
proto_header
in
let timestamp =
@ -127,7 +127,7 @@ let get_header_hash
shell = shell_header ;
proto = init_block.proto_header_bytes
} in
Proto_alpha.Tezos_context.init
Proto_alpha.Alpha_context.init
validation_result.context
~level
~timestamp

View File

@ -13,7 +13,7 @@ open Proto_alpha
type shell_header = Block_header.shell_header
type tezos_header = Block_header.t
type protocol_header = Tezos_context.Block_header.proto_header
type protocol_header = Alpha_context.Block_header.proto_header
type operation_header = Operation.shell_header
(** Block before application *)
@ -37,23 +37,23 @@ type result = {
hash : Block_hash.t;
level : Int32.t;
validation : Updater.validation_result;
tezos_context : Tezos_context.t;
tezos_context : Alpha_context.t;
}
val get_op_header_res : result -> operation_header
val get_proto_header : int -> protocol_header
val get_op_header : Block_hash.t -> operation_header
val make_sourced_operation :
Operation.shell_header ->
Tezos_context.proto_operation *
Alpha_context.proto_operation *
Helpers_account.t ->
((Proto_alpha.Main.operation * Helpers_account.t) * Operation_hash.t) proto_tzresult
val init :
shell_header -> Block_hash.t -> Int32.t -> int ->
(Tezos_context.proto_operation * Helpers_account.t) list ->
(Alpha_context.proto_operation * Helpers_account.t) list ->
Context.t -> init_block proto_tzresult
val init_of_result :
?priority:int -> res:result ->
ops:(Tezos_context.proto_operation * Helpers_account.t) list ->
ops:(Alpha_context.proto_operation * Helpers_account.t) list ->
init_block proto_tzresult
val get_level : string option -> int32
val get_header_hash :
@ -64,11 +64,11 @@ val begin_construction_pre :
val make : init_block -> result proto_tzresult Lwt.t
val make_init :
shell_header -> Block_hash.t -> Int32.t -> int ->
(Tezos_context.proto_operation * Helpers_account.t) list ->
(Alpha_context.proto_operation * Helpers_account.t) list ->
Context.t -> result proto_tzresult Lwt.t
val of_res :
?priority:int ->
?ops:(Tezos_context.proto_operation * Helpers_account.t) list ->
?ops:(Alpha_context.proto_operation * Helpers_account.t) list ->
res:result ->
unit -> result proto_tzresult Lwt.t
val endorsement :

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Proto_alpha.Tezos_context
open Proto_alpha.Alpha_context
exception Tez_error

View File

@ -7,11 +7,11 @@
(* *)
(**************************************************************************)
open Proto_alpha.Tezos_context
open Proto_alpha.Alpha_context
exception Tez_error
(** Common casts between Tezos_context types *)
(** Common casts between Alpha_context types *)
val tez_of_int : int -> Tez.tez
val cents_of_int : int -> Tez.tez

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Proto_alpha.Tezos_context
open Proto_alpha.Alpha_context
let generate_proof_of_work_nonce () =
Rand.generate Constants.proof_of_work_nonce_size

View File

@ -10,4 +10,4 @@
(** Extension of the Sodium module with helpers functions *)
val generate_proof_of_work_nonce : unit -> MBytes.t
val generate_seed_nonce : unit -> Proto_alpha.Tezos_context.Nonce.nonce
val generate_seed_nonce : unit -> Proto_alpha.Alpha_context.Nonce.nonce

View File

@ -37,7 +37,7 @@ let main () =
} in
let proto_header =
Data_encoding.Binary.to_bytes
Tezos_context.Block_header.proto_header_encoding
Alpha_context.Block_header.proto_header_encoding
(Helpers_block.get_proto_header 0) in
let tezos_header = { Block_header.shell = header ; proto = proto_header } in
Proto_alpha.Main.begin_construction
@ -51,7 +51,7 @@ let main () =
() >>=? fun vstate ->
let hash = Block_header.hash tezos_header in
Proto_alpha.Main.finalize_block vstate >>=? fun validation ->
Tezos_context.init
Alpha_context.init
~level: (Int32.succ header.level)
~timestamp: header.timestamp
~fitness: header.fitness

View File

@ -9,12 +9,12 @@
open Proto_alpha
open Error_monad
open Tezos_context
open Alpha_context
let sourced ops = Sourced_operations ops
let manager (src : Helpers_account.t) ?(fee = Tez.zero) operations context =
Tezos_context.init ~level:0l ~timestamp:(Time.now ()) ~fitness:[] context >>=? fun context ->
Alpha_context.init ~level:0l ~timestamp:(Time.now ()) ~fitness:[] context >>=? fun context ->
Contract.get_counter context src.contract >>=? fun counter ->
let counter = Int32.succ counter in
return @@

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
(** Functions building operations *)
@ -46,7 +46,7 @@ val origination_full :
proto_operation proto_tzresult Lwt.t
val transaction_full :
?fee:Tez.tez -> ?parameters:Proto_alpha.Tezos_context.Script.expr -> Helpers_account.t -> Contract.contract -> Tez.t ->
?fee:Tez.tez -> ?parameters:Proto_alpha.Alpha_context.Script.expr -> Helpers_account.t -> Contract.contract -> Tez.t ->
Alpha_environment.Context.t -> proto_operation proto_tzresult Lwt.t
val delegate :

View File

@ -9,7 +9,7 @@
open Proto_alpha
open Error_monad
open Tezos_context
open Alpha_context
let init_amount = 20000
@ -28,7 +28,7 @@ let execute_code_pred
(Some op) op_header dummy_protop in
let dummy_nonce = Contract.initial_origination_nonce apply_op.hash in
let amount = Tez.zero in
let gaz = Gas.of_int (Tezos_context.Constants.max_gas tc) in
let gaz = Gas.of_int (Alpha_context.Constants.max_gas tc) in
let return = Script_interpreter.execute
dummy_nonce op.contract dst
tc script amount argument gaz in

View File

@ -8,11 +8,11 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
val init_amount : int
val execute_code_pred :
?tc:Tezos_context.t -> Helpers_block.result -> Script.t -> Script.expr ->
?tc:Alpha_context.t -> Helpers_block.result -> Script.t -> Script.expr ->
(Script.expr * Script.expr * Gas.t * context * Contract.origination_nonce * Script_typed_ir.ex_big_map option)
proto_tzresult Lwt.t

View File

@ -7,7 +7,7 @@
(* *)
(**************************************************************************)
open Proto_alpha.Tezos_context
open Proto_alpha.Alpha_context
open Helpers_assert
let endorsement_rights ~tc () =

View File

@ -12,9 +12,9 @@ open Proto_alpha
(** Wrappers around Services_registration calls *)
val endorsement_rights :
tc:Tezos_context.context -> unit ->
(int * Tezos_context.public_key_hash) list tzresult Lwt.t
tc:Alpha_context.context -> unit ->
(int * Alpha_context.public_key_hash) list tzresult Lwt.t
val baking_rights :
tc:Tezos_context.context -> unit ->
(int * Tezos_context.public_key_hash) list tzresult Lwt.t
tc:Alpha_context.context -> unit ->
(int * Alpha_context.public_key_hash) list tzresult Lwt.t

View File

@ -24,14 +24,14 @@ module Script = Helpers_script
module Shorthands = struct
let to_tc_full ctxt level fitness =
Tezos_context.init
Alpha_context.init
ctxt
~level
~fitness
~timestamp:(Time.now())
let get_tc_full (res:Block.result) =
Tezos_context.init
Alpha_context.init
res.validation.context
~level:res.level
~timestamp:res.tezos_header.shell.timestamp
@ -40,7 +40,7 @@ module Shorthands = struct
let get_balance_res (account:Account.t) (result:Block.result) =
let open Alpha_environment.Error_monad in
get_tc_full result >>=? fun tc ->
Tezos_context.Contract.get_balance tc account.contract
Alpha_context.Contract.get_balance tc account.contract
let chain_empty_block (result:Block.result) =
Block.empty

View File

@ -19,14 +19,14 @@ module Assert = Helpers.Assert
let (>>??) = Helpers.Assert.(>>??)
let (>>=??) = Helpers.Assert.(>>=??)
let parse_expr s : Proto_alpha.Tezos_context.Script.expr tzresult =
let parse_expr s : Proto_alpha.Alpha_context.Script.expr tzresult =
Micheline_parser.no_parsing_error (Michelson_v1_parser.parse_expression s) >>? fun parsed ->
ok parsed.expanded
let parse_script code_str storage_str : Proto_alpha.Tezos_context.Script.t tzresult =
let parse_script code_str storage_str : Proto_alpha.Alpha_context.Script.t tzresult =
parse_expr code_str >>? fun code ->
parse_expr storage_str >>? fun storage ->
ok { Proto_alpha.Tezos_context.Script.code ; storage }
ok { Proto_alpha.Alpha_context.Script.code ; storage }
let code = {|
{ parameter (list (pair string int)) ;
@ -47,7 +47,7 @@ let expect_big_map tc contract print_key key_type print_data data_type contents
iter_p
(fun (n, exp) ->
let key = Proto_alpha.Script_ir_translator.hash_data key_type n in
Proto_alpha.Tezos_context.Contract.Big_map_storage.get_opt tc contract key >>=? fun data ->
Proto_alpha.Alpha_context.Contract.Big_map_storage.get_opt tc contract key >>=? fun data ->
match data, exp with
| None, None ->
debug " - big_map[%a] is not defined (ok)" print_key n ;
@ -86,9 +86,9 @@ let main () =
expect_big_map tc contract
(fun ppf k -> Format.fprintf ppf "%s" k)
Proto_alpha.Script_typed_ir.String_t
(fun ppf n -> Format.fprintf ppf "%s" (Proto_alpha.Tezos_context.Script_int.to_string n))
(fun ppf n -> Format.fprintf ppf "%s" (Proto_alpha.Alpha_context.Script_int.to_string n))
Proto_alpha.Script_typed_ir.Int_t
(List.map (fun (n, v) -> (n, Option.map ~f:Proto_alpha.Tezos_context.Script_int.of_int v)) exp) in
(List.map (fun (n, v) -> (n, Option.map ~f:Proto_alpha.Alpha_context.Script_int.of_int v)) exp) in
expect_big_map tc
[ "A", Some 1 ; "B", Some 2 ; "C", None ; "D", None ] >>=?? fun () ->
debug "initial big map is ok" ;

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
open Error_monad
let name = "Isolate Endorsement"
@ -46,7 +46,7 @@ let test_wrong_delegate endorse_a starting_block =
let test_endorsement_payment () =
Init.main () >>=? fun root ->
let bootstrap_accounts = Account.bootstrap_accounts in
let open Proto_alpha.Tezos_context in
let open Proto_alpha.Alpha_context in
get_tc_full root >>=? fun tc ->
let level = Level.succ tc @@ Level.current tc in
Proto_alpha.Services_registration.endorsement_rights tc level None >>=? fun (_, endorsers) ->

View File

@ -8,7 +8,7 @@
(**************************************************************************)
open Proto_alpha
open Tezos_context
open Alpha_context
let name = "Isolate Michelson"
module Logger = Logging.Make(struct let name = name end)
@ -25,15 +25,15 @@ open Shorthands
let (>>??) = Assert.(>>??)
let (>>=??) = Assert.(>>=??)
let parse_param s : Proto_alpha.Tezos_context.Script.expr =
let parse_param s : Proto_alpha.Alpha_context.Script.expr =
let (parsed, _) = Michelson_v1_parser.parse_expression s in
parsed.expanded
let parse_script code_str storage_str : Proto_alpha.Tezos_context.Script.t =
let parse_script code_str storage_str : Proto_alpha.Alpha_context.Script.t =
let code = parse_param code_str in
let storage = parse_param storage_str in
let return: Proto_alpha.Tezos_context.Script.t = {code ; storage} in
let return: Proto_alpha.Alpha_context.Script.t = {code ; storage} in
return
@ -291,7 +291,7 @@ let test_example () =
let bootstrap_0 = List.nth Account.bootstrap_accounts 0 in
get_balance_res bootstrap_0 sb >>=?? fun _balance ->
let amount = Proto_alpha.Tezos_context.Tez.to_string @@ Cast.cents_of_int Script.init_amount in
let amount = Proto_alpha.Alpha_context.Tez.to_string @@ Cast.cents_of_int Script.init_amount in
(* Get the current balance of the contract *)
test_output ~location: __LOC__ "balance" "Unit" "Unit" ("\"" ^ amount ^ "\"") >>=? fun _ ->
@ -435,7 +435,7 @@ let test_example () =
test_contract ~tc "create_contract" account_str account_str >>=? fun (cs, tc) ->
Assert.equal_int 1 @@ List.length cs ;
let contract = List.hd cs in
Proto_alpha.Tezos_context.Contract.get_script tc contract >>=?? fun res ->
Proto_alpha.Alpha_context.Contract.get_script tc contract >>=?? fun res ->
let script = Option.unopt_exn (Failure "get_script") res in
Script.execute_code_pred ~tc sb script (parse_param "\"abc\"") >>=?? fun (_, ret, _, _, _, _) ->
Assert.equal_string ~msg: __LOC__ "\"abc\"" @@ string_of_canon ret ;

View File

@ -65,7 +65,7 @@ let test_basic (): unit tzresult Lwt.t =
(* Check sender/receiver balance post transaction *)
transfer (account_a, account_b, 1000) >>=
Assert.ok_contract ~msg: __LOC__ >>=? fun (_,tc) ->
Proto_alpha.Tezos_context.Contract.get_balance tc account_a.contract >>=? fun _balance ->
Proto_alpha.Alpha_context.Contract.get_balance tc account_a.contract >>=? fun _balance ->
Assert.equal_cents_balance ~msg: __LOC__ ~tc (account_a.contract, init_amount * 100 - 1000 - 10) >>=? fun () ->
Assert.equal_cents_balance ~msg: __LOC__ ~tc (account_b.contract, 1001000) >>=? fun () ->
debug "Transfer balances" ;