Proto/Alpha: minor renaming
This commit is contained in:
parent
565654a242
commit
d06fcebd1f
@ -28,7 +28,7 @@ let rec compute_stamp
|
|||||||
let rec loop () =
|
let rec loop () =
|
||||||
let proof_of_work_nonce = generate_proof_of_work_nonce () in
|
let proof_of_work_nonce = generate_proof_of_work_nonce () in
|
||||||
let unsigned_header =
|
let unsigned_header =
|
||||||
Tezos_context.Block.forge_header
|
Tezos_context.Block_header.forge_unsigned
|
||||||
shell { priority ; seed_nonce_hash ; proof_of_work_nonce } in
|
shell { priority ; seed_nonce_hash ; proof_of_work_nonce } in
|
||||||
let signed_header =
|
let signed_header =
|
||||||
Ed25519.Signature.append delegate_sk unsigned_header in
|
Ed25519.Signature.append delegate_sk unsigned_header in
|
||||||
@ -51,7 +51,7 @@ let inject_block cctxt block
|
|||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
(List.map Operation_list_hash.compute (List.map (List.map (function Client_node_rpcs.Blob op -> Tezos_data.Operation.hash op | Hash oph -> oph)) operations)) in
|
(List.map Operation_list_hash.compute (List.map (List.map (function Client_node_rpcs.Blob op -> Tezos_data.Operation.hash op | Hash oph -> oph)) operations)) in
|
||||||
let shell =
|
let shell =
|
||||||
{ Block_header.net_id = bi.net_id ; level = bi.level ;
|
{ Tezos_data.Block_header.net_id = bi.net_id ; level = bi.level ;
|
||||||
proto_level = bi.proto_level ;
|
proto_level = bi.proto_level ;
|
||||||
predecessor = bi.hash ; timestamp ; fitness ; operations_hash } in
|
predecessor = bi.hash ; timestamp ; fitness ; operations_hash } in
|
||||||
compute_stamp cctxt block
|
compute_stamp cctxt block
|
||||||
|
@ -273,7 +273,7 @@ module Helpers = struct
|
|||||||
let block cctxt block shell proto =
|
let block cctxt block shell proto =
|
||||||
call_error_service1 cctxt
|
call_error_service1 cctxt
|
||||||
Services.Helpers.Parse.block block
|
Services.Helpers.Parse.block block
|
||||||
({ shell ; proto } : Block_header.t)
|
({ shell ; proto } : Block_header.raw)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -353,7 +353,7 @@ module Helpers : sig
|
|||||||
val block:
|
val block:
|
||||||
Client_rpcs.config ->
|
Client_rpcs.config ->
|
||||||
block -> Block_header.shell_header -> MBytes.t ->
|
block -> Block_header.shell_header -> MBytes.t ->
|
||||||
Block.proto_header tzresult Lwt.t
|
Block_header.proto_header tzresult Lwt.t
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
"Roll_repr",
|
"Roll_repr",
|
||||||
"Vote_repr",
|
"Vote_repr",
|
||||||
"Operation_repr",
|
"Operation_repr",
|
||||||
"Block_repr",
|
"Block_header_repr",
|
||||||
|
|
||||||
"Storage_sigs",
|
"Storage_sigs",
|
||||||
"Storage_functors",
|
"Storage_functors",
|
||||||
|
@ -261,7 +261,7 @@ let begin_application ctxt block pred_timestamp =
|
|||||||
|
|
||||||
let finalize_application ctxt block miner =
|
let finalize_application ctxt block miner =
|
||||||
(* end of level (from this point nothing should fail) *)
|
(* end of level (from this point nothing should fail) *)
|
||||||
let priority = block.Block.proto.priority in
|
let priority = block.Block_header.proto.priority in
|
||||||
let reward = Mining.base_mining_reward ctxt ~priority in
|
let reward = Mining.base_mining_reward ctxt ~priority in
|
||||||
Nonce.record_hash ctxt
|
Nonce.record_hash ctxt
|
||||||
miner reward block.proto.seed_nonce_hash >>=? fun ctxt ->
|
miner reward block.proto.seed_nonce_hash >>=? fun ctxt ->
|
||||||
|
@ -12,7 +12,7 @@ open Tezos_hash
|
|||||||
(** Block header *)
|
(** Block header *)
|
||||||
|
|
||||||
(** Exported type *)
|
(** Exported type *)
|
||||||
type header = {
|
type t = {
|
||||||
shell: Block_header.shell_header ;
|
shell: Block_header.shell_header ;
|
||||||
proto: proto_header ;
|
proto: proto_header ;
|
||||||
signature: Ed25519.Signature.t ;
|
signature: Ed25519.Signature.t ;
|
||||||
@ -24,6 +24,14 @@ and proto_header = {
|
|||||||
proof_of_work_nonce: MBytes.t ;
|
proof_of_work_nonce: MBytes.t ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type block_header = t
|
||||||
|
|
||||||
|
type raw = Tezos_data.Block_header.t
|
||||||
|
type shell_header = Tezos_data.Block_header.shell_header
|
||||||
|
|
||||||
|
let raw_encoding = Tezos_data.Block_header.encoding
|
||||||
|
let shell_header_encoding = Tezos_data.Block_header.shell_header_encoding
|
||||||
|
|
||||||
let proto_header_encoding =
|
let proto_header_encoding =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
@ -49,6 +57,17 @@ let unsigned_header_encoding =
|
|||||||
Block_header.shell_header_encoding
|
Block_header.shell_header_encoding
|
||||||
proto_header_encoding
|
proto_header_encoding
|
||||||
|
|
||||||
|
let encoding =
|
||||||
|
let open Data_encoding in
|
||||||
|
conv
|
||||||
|
(fun { shell ; proto ; signature } ->
|
||||||
|
(shell, (proto, signature)))
|
||||||
|
(fun (shell, (proto, signature)) ->
|
||||||
|
{ shell ; proto ; signature })
|
||||||
|
(merge_objs
|
||||||
|
Block_header.shell_header_encoding
|
||||||
|
signed_proto_header_encoding)
|
||||||
|
|
||||||
(** Constants *)
|
(** Constants *)
|
||||||
|
|
||||||
let max_header_length =
|
let max_header_length =
|
||||||
@ -61,10 +80,10 @@ let max_header_length =
|
|||||||
type error +=
|
type error +=
|
||||||
| Cant_parse_proto_header
|
| Cant_parse_proto_header
|
||||||
|
|
||||||
let parse_header
|
let parse
|
||||||
({ shell = { net_id ; level ; proto_level ; predecessor ;
|
({ shell = { net_id ; level ; proto_level ; predecessor ;
|
||||||
timestamp ; fitness ; operations_hash } ;
|
timestamp ; fitness ; operations_hash } ;
|
||||||
proto } : Block_header.t) : header tzresult =
|
proto } : Block_header.t) : block_header tzresult =
|
||||||
match Data_encoding.Binary.of_bytes signed_proto_header_encoding proto with
|
match Data_encoding.Binary.of_bytes signed_proto_header_encoding proto with
|
||||||
| None -> Error [Cant_parse_proto_header]
|
| None -> Error [Cant_parse_proto_header]
|
||||||
| Some (proto, signature) ->
|
| Some (proto, signature) ->
|
||||||
@ -73,5 +92,14 @@ let parse_header
|
|||||||
timestamp ; fitness ; operations_hash } in
|
timestamp ; fitness ; operations_hash } in
|
||||||
Ok { shell ; proto ; signature }
|
Ok { shell ; proto ; signature }
|
||||||
|
|
||||||
let forge_header shell proto =
|
let forge_unsigned shell proto =
|
||||||
Data_encoding.Binary.to_bytes unsigned_header_encoding (shell, proto)
|
Data_encoding.Binary.to_bytes unsigned_header_encoding (shell, proto)
|
||||||
|
|
||||||
|
let hash_raw = Block_header.hash
|
||||||
|
let hash { shell ; proto ; signature } =
|
||||||
|
Block_header.hash
|
||||||
|
{ shell ;
|
||||||
|
proto =
|
||||||
|
Data_encoding.Binary.to_bytes
|
||||||
|
signed_proto_header_encoding
|
||||||
|
(proto, signature ) }
|
@ -10,7 +10,7 @@
|
|||||||
open Tezos_hash
|
open Tezos_hash
|
||||||
|
|
||||||
(** Exported type *)
|
(** Exported type *)
|
||||||
type header = {
|
type t = {
|
||||||
shell: Block_header.shell_header ;
|
shell: Block_header.shell_header ;
|
||||||
proto: proto_header ;
|
proto: proto_header ;
|
||||||
signature: Ed25519.Signature.t ;
|
signature: Ed25519.Signature.t ;
|
||||||
@ -22,21 +22,28 @@ and proto_header = {
|
|||||||
proof_of_work_nonce: MBytes.t ;
|
proof_of_work_nonce: MBytes.t ;
|
||||||
}
|
}
|
||||||
|
|
||||||
(** The maximum size of block headers in bytes *)
|
type block_header = t
|
||||||
|
|
||||||
|
type raw = Tezos_data.Block_header.t
|
||||||
|
type shell_header = Tezos_data.Block_header.shell_header
|
||||||
|
|
||||||
|
val encoding: block_header Data_encoding.encoding
|
||||||
|
val raw_encoding: raw Data_encoding.t
|
||||||
|
val proto_header_encoding: proto_header Data_encoding.encoding
|
||||||
|
val shell_header_encoding: shell_header Data_encoding.encoding
|
||||||
|
|
||||||
val max_header_length: int
|
val max_header_length: int
|
||||||
|
(** The maximum size of block headers in bytes *)
|
||||||
|
|
||||||
|
val parse: Block_header.t -> block_header tzresult
|
||||||
(** Parse the protocol-specific part of a block header. *)
|
(** Parse the protocol-specific part of a block header. *)
|
||||||
val parse_header: Block_header.t -> header tzresult
|
|
||||||
|
|
||||||
val proto_header_encoding:
|
val forge_unsigned:
|
||||||
proto_header Data_encoding.encoding
|
|
||||||
|
|
||||||
val unsigned_header_encoding:
|
|
||||||
(Block_header.shell_header * proto_header) Data_encoding.encoding
|
|
||||||
|
|
||||||
val forge_header:
|
|
||||||
Block_header.shell_header -> proto_header -> MBytes.t
|
Block_header.shell_header -> proto_header -> MBytes.t
|
||||||
(** [forge_header shell_hdr proto_hdr] is the binary serialization
|
(** [forge_header shell_hdr proto_hdr] is the binary serialization
|
||||||
(using [unsigned_header_encoding]) of a block header,
|
(using [unsigned_header_encoding]) of a block header,
|
||||||
comprising both the shell and the protocol part of the header,
|
comprising both the shell and the protocol part of the header,
|
||||||
without the signature. *)
|
without the signature. *)
|
||||||
|
|
||||||
|
val hash: block_header -> Block_hash.t
|
||||||
|
val hash_raw: raw -> Block_hash.t
|
@ -20,12 +20,12 @@ let max_number_of_operations =
|
|||||||
Tezos_context.Constants.max_number_of_operations
|
Tezos_context.Constants.max_number_of_operations
|
||||||
|
|
||||||
let max_block_length =
|
let max_block_length =
|
||||||
Tezos_context.Block.max_header_length
|
Tezos_context.Block_header.max_header_length
|
||||||
|
|
||||||
let rpc_services = Services_registration.rpc_services
|
let rpc_services = Services_registration.rpc_services
|
||||||
|
|
||||||
type validation_mode =
|
type validation_mode =
|
||||||
| Application of Tezos_context.Block.header * Tezos_context.public_key_hash
|
| Application of Tezos_context.Block_header.t * Tezos_context.public_key_hash
|
||||||
| Construction of { pred_block : Block_hash.t ; timestamp : Time.t }
|
| Construction of { pred_block : Block_hash.t ; timestamp : Time.t }
|
||||||
|
|
||||||
type validation_state =
|
type validation_state =
|
||||||
@ -40,7 +40,7 @@ let precheck_block
|
|||||||
~ancestor_context:_
|
~ancestor_context:_
|
||||||
~ancestor_timestamp:_
|
~ancestor_timestamp:_
|
||||||
raw_block =
|
raw_block =
|
||||||
Lwt.return (Tezos_context.Block.parse_header raw_block) >>=? fun _ ->
|
Lwt.return (Tezos_context.Block_header.parse raw_block) >>=? fun _ ->
|
||||||
(* TODO: decide what other properties should be checked *)
|
(* TODO: decide what other properties should be checked *)
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ let begin_application
|
|||||||
~predecessor_timestamp:pred_timestamp
|
~predecessor_timestamp:pred_timestamp
|
||||||
~predecessor_fitness:pred_fitness
|
~predecessor_fitness:pred_fitness
|
||||||
raw_block =
|
raw_block =
|
||||||
Lwt.return (Tezos_context.Block.parse_header raw_block) >>=? fun header ->
|
Lwt.return (Tezos_context.Block_header.parse raw_block) >>=? fun header ->
|
||||||
let level = header.shell.level in
|
let level = header.shell.level in
|
||||||
let fitness = pred_fitness in
|
let fitness = pred_fitness in
|
||||||
let timestamp = header.shell.timestamp in
|
let timestamp = header.shell.timestamp in
|
||||||
|
@ -118,14 +118,14 @@ let check_timestamp c priority pred_timestamp =
|
|||||||
fail_unless Timestamp.(minimal_time <= timestamp)
|
fail_unless Timestamp.(minimal_time <= timestamp)
|
||||||
(Timestamp_too_early (minimal_time, timestamp))
|
(Timestamp_too_early (minimal_time, timestamp))
|
||||||
|
|
||||||
let check_mining_rights c { Block.proto = { priority } }
|
let check_mining_rights c { Block_header.proto = { priority } }
|
||||||
pred_timestamp =
|
pred_timestamp =
|
||||||
let level = Level.current c in
|
let level = Level.current c in
|
||||||
Roll.mining_rights_owner c level ~priority >>=? fun delegate ->
|
Roll.mining_rights_owner c level ~priority >>=? fun delegate ->
|
||||||
check_timestamp c priority pred_timestamp >>=? fun () ->
|
check_timestamp c priority pred_timestamp >>=? fun () ->
|
||||||
return delegate
|
return delegate
|
||||||
|
|
||||||
let pay_mining_bond c { Block.proto = { priority } } id =
|
let pay_mining_bond c { Block_header.proto = { priority } } id =
|
||||||
if Compare.Int.(priority >= Constants.first_free_mining_slot c)
|
if Compare.Int.(priority >= Constants.first_free_mining_slot c)
|
||||||
then return c
|
then return c
|
||||||
else
|
else
|
||||||
@ -216,13 +216,8 @@ let check_hash hash stamp_threshold =
|
|||||||
let word = String.get_int64 bytes 0 in
|
let word = String.get_int64 bytes 0 in
|
||||||
Compare.Uint64.(word < stamp_threshold)
|
Compare.Uint64.(word < stamp_threshold)
|
||||||
|
|
||||||
let check_header_hash {Block.shell;proto;signature} stamp_threshold =
|
let check_header_hash header stamp_threshold =
|
||||||
let hash =
|
let hash = Block_header.hash header in
|
||||||
Block_hash.hash_bytes [
|
|
||||||
Data_encoding.Binary.to_bytes
|
|
||||||
(Data_encoding.tup2
|
|
||||||
Block.unsigned_header_encoding Ed25519.Signature.encoding)
|
|
||||||
((shell, proto), signature)] in
|
|
||||||
check_hash hash stamp_threshold
|
check_hash hash stamp_threshold
|
||||||
|
|
||||||
type error +=
|
type error +=
|
||||||
@ -238,8 +233,8 @@ let check_proof_of_work_stamp ctxt block =
|
|||||||
|
|
||||||
let check_signature ctxt block id =
|
let check_signature ctxt block id =
|
||||||
Public_key.get ctxt id >>=? fun key ->
|
Public_key.get ctxt id >>=? fun key ->
|
||||||
let check_signature key { Block.proto ; shell ; signature } =
|
let check_signature key { Block_header.proto ; shell ; signature } =
|
||||||
let unsigned_header = Block.forge_header shell proto in
|
let unsigned_header = Block_header.forge_unsigned shell proto in
|
||||||
Ed25519.Signature.check key signature unsigned_header in
|
Ed25519.Signature.check key signature unsigned_header in
|
||||||
if check_signature key block then
|
if check_signature key block then
|
||||||
return ()
|
return ()
|
||||||
@ -250,7 +245,7 @@ let max_fitness_gap ctxt =
|
|||||||
let slots = Int64.of_int (Constants.max_signing_slot ctxt + 1) in
|
let slots = Int64.of_int (Constants.max_signing_slot ctxt + 1) in
|
||||||
Int64.add slots 1L
|
Int64.add slots 1L
|
||||||
|
|
||||||
let check_fitness_gap ctxt (block : Block.header) =
|
let check_fitness_gap ctxt (block : Block_header.t) =
|
||||||
let current_fitness = Fitness.current ctxt in
|
let current_fitness = Fitness.current ctxt in
|
||||||
Lwt.return (Fitness.to_int64 block.shell.fitness) >>=? fun announced_fitness ->
|
Lwt.return (Fitness.to_int64 block.shell.fitness) >>=? fun announced_fitness ->
|
||||||
let gap = Int64.sub announced_fitness current_fitness in
|
let gap = Int64.sub announced_fitness current_fitness in
|
||||||
|
@ -29,7 +29,7 @@ val minimal_time: context -> int -> Time.t -> Time.t tzresult Lwt.t
|
|||||||
|
|
||||||
val pay_mining_bond:
|
val pay_mining_bond:
|
||||||
context ->
|
context ->
|
||||||
Block.header ->
|
Block_header.t ->
|
||||||
public_key_hash ->
|
public_key_hash ->
|
||||||
context tzresult Lwt.t
|
context tzresult Lwt.t
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ val pay_endorsement_bond:
|
|||||||
* the bond have been payed if the slot is below [Constants.first_free_mining_slot].
|
* the bond have been payed if the slot is below [Constants.first_free_mining_slot].
|
||||||
*)
|
*)
|
||||||
val check_mining_rights:
|
val check_mining_rights:
|
||||||
context -> Block.header -> Time.t -> public_key_hash tzresult Lwt.t
|
context -> Block_header.t -> Time.t -> public_key_hash tzresult Lwt.t
|
||||||
|
|
||||||
(** [check_signing_rights c slot contract] verifies that:
|
(** [check_signing_rights c slot contract] verifies that:
|
||||||
* the slot is valid;
|
* the slot is valid;
|
||||||
@ -85,13 +85,13 @@ val first_endorsement_slots:
|
|||||||
Level.t -> int list tzresult Lwt.t
|
Level.t -> int list tzresult Lwt.t
|
||||||
|
|
||||||
val check_signature:
|
val check_signature:
|
||||||
context -> Block.header -> public_key_hash -> unit tzresult Lwt.t
|
context -> Block_header.t -> public_key_hash -> unit tzresult Lwt.t
|
||||||
|
|
||||||
val check_hash: Block_hash.t -> int64 -> bool
|
val check_hash: Block_hash.t -> int64 -> bool
|
||||||
val check_proof_of_work_stamp:
|
val check_proof_of_work_stamp:
|
||||||
context -> Block.header -> unit tzresult Lwt.t
|
context -> Block_header.t -> unit tzresult Lwt.t
|
||||||
|
|
||||||
val check_fitness_gap:
|
val check_fitness_gap:
|
||||||
context -> Block.header -> unit tzresult Lwt.t
|
context -> Block_header.t -> unit tzresult Lwt.t
|
||||||
|
|
||||||
val dawn_of_a_new_cycle: context -> Cycle.t option tzresult Lwt.t
|
val dawn_of_a_new_cycle: context -> Cycle.t option tzresult Lwt.t
|
||||||
|
@ -619,8 +619,8 @@ module Helpers = struct
|
|||||||
let block custom_root =
|
let block custom_root =
|
||||||
RPC.service
|
RPC.service
|
||||||
~description:"Parse a block"
|
~description:"Parse a block"
|
||||||
~input: Block_header.encoding
|
~input: Block_header.raw_encoding
|
||||||
~output: (wrap_tzerror Block.proto_header_encoding)
|
~output: (wrap_tzerror Block_header.proto_header_encoding)
|
||||||
RPC.Path.(custom_root / "helpers" / "parse" / "block" )
|
RPC.Path.(custom_root / "helpers" / "parse" / "block" )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ open Tezos_context
|
|||||||
|
|
||||||
type rpc_context = {
|
type rpc_context = {
|
||||||
block_hash: Block_hash.t ;
|
block_hash: Block_hash.t ;
|
||||||
block_header: Block_header.t ;
|
block_header: Block_header.raw ;
|
||||||
operation_hashes: unit -> Operation_hash.t list list Lwt.t ;
|
operation_hashes: unit -> Operation_hash.t list list Lwt.t ;
|
||||||
operations: unit -> Operation.raw list list Lwt.t ;
|
operations: unit -> Operation.raw list list Lwt.t ;
|
||||||
context: Tezos_context.t ;
|
context: Tezos_context.t ;
|
||||||
@ -474,7 +474,7 @@ let forge_block _ctxt
|
|||||||
((net_id, predecessor, timestamp, fitness, operations_hash),
|
((net_id, predecessor, timestamp, fitness, operations_hash),
|
||||||
(level, priority, proto_level, seed_nonce_hash, proof_of_work_nonce)) : MBytes.t tzresult Lwt.t =
|
(level, priority, proto_level, seed_nonce_hash, proof_of_work_nonce)) : MBytes.t tzresult Lwt.t =
|
||||||
let level = Raw_level.to_int32 level in
|
let level = Raw_level.to_int32 level in
|
||||||
return (Block.forge_header
|
return (Block_header.forge_unsigned
|
||||||
{ net_id ; level ; proto_level ; predecessor ;
|
{ net_id ; level ; proto_level ; predecessor ;
|
||||||
timestamp ; fitness ; operations_hash }
|
timestamp ; fitness ; operations_hash }
|
||||||
{ priority ; seed_nonce_hash ; proof_of_work_nonce })
|
{ priority ; seed_nonce_hash ; proof_of_work_nonce })
|
||||||
@ -521,7 +521,7 @@ let parse_operations ctxt (operations, check) =
|
|||||||
let () = register1 Services.Helpers.Parse.operations parse_operations
|
let () = register1 Services.Helpers.Parse.operations parse_operations
|
||||||
|
|
||||||
let parse_block _ctxt raw_block =
|
let parse_block _ctxt raw_block =
|
||||||
Lwt.return (Block.parse_header raw_block) >>=? fun { proto } ->
|
Lwt.return (Block_header.parse raw_block) >>=? fun { proto } ->
|
||||||
return proto
|
return proto
|
||||||
|
|
||||||
let () = register1 Services.Helpers.Parse.block parse_block
|
let () = register1 Services.Helpers.Parse.block parse_block
|
||||||
|
@ -30,7 +30,7 @@ module Operation = struct
|
|||||||
type t = operation
|
type t = operation
|
||||||
include Operation_repr
|
include Operation_repr
|
||||||
end
|
end
|
||||||
module Block = Block_repr
|
module Block_header = Block_header_repr
|
||||||
module Vote = struct
|
module Vote = struct
|
||||||
include Vote_repr
|
include Vote_repr
|
||||||
include Vote_storage
|
include Vote_storage
|
||||||
|
@ -529,9 +529,9 @@ module Operation : sig
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Block : sig
|
module Block_header : sig
|
||||||
|
|
||||||
type header = {
|
type t = {
|
||||||
shell: Block_header.shell_header ;
|
shell: Block_header.shell_header ;
|
||||||
proto: proto_header ;
|
proto: proto_header ;
|
||||||
signature: Ed25519.Signature.t ;
|
signature: Ed25519.Signature.t ;
|
||||||
@ -543,18 +543,31 @@ module Block : sig
|
|||||||
proof_of_work_nonce: MBytes.t ;
|
proof_of_work_nonce: MBytes.t ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type block_header = t
|
||||||
|
|
||||||
|
type raw = Tezos_data.Block_header.t
|
||||||
|
type shell_header = Tezos_data.Block_header.shell_header
|
||||||
|
|
||||||
|
val hash: block_header -> Block_hash.t
|
||||||
|
val hash_raw: raw -> Block_hash.t
|
||||||
|
|
||||||
|
val encoding: block_header Data_encoding.encoding
|
||||||
|
val raw_encoding: raw Data_encoding.t
|
||||||
|
val proto_header_encoding: proto_header Data_encoding.encoding
|
||||||
|
val shell_header_encoding: shell_header Data_encoding.encoding
|
||||||
|
|
||||||
val max_header_length: int
|
val max_header_length: int
|
||||||
|
(** The maximum size of block headers in bytes *)
|
||||||
|
|
||||||
val parse_header: Block_header.t -> header tzresult
|
val parse: Block_header.t -> block_header tzresult
|
||||||
|
(** Parse the protocol-specific part of a block header. *)
|
||||||
|
|
||||||
val proto_header_encoding:
|
val forge_unsigned:
|
||||||
proto_header Data_encoding.encoding
|
|
||||||
|
|
||||||
val unsigned_header_encoding:
|
|
||||||
(Block_header.shell_header * proto_header) Data_encoding.encoding
|
|
||||||
|
|
||||||
val forge_header:
|
|
||||||
Block_header.shell_header -> proto_header -> MBytes.t
|
Block_header.shell_header -> proto_header -> MBytes.t
|
||||||
|
(** [forge_header shell_hdr proto_hdr] is the binary serialization
|
||||||
|
(using [unsigned_header_encoding]) of a block header,
|
||||||
|
comprising both the shell and the protocol part of the header,
|
||||||
|
without the signature. *)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ let rpc_config : Client_rpcs.config = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let dictator_sk =
|
let dictator_sk =
|
||||||
Environment.Ed25519.Secret_key.of_b58check_exn
|
Ed25519.Secret_key.of_b58check_exn
|
||||||
"edskRhxswacLW6jF6ULavDdzwqnKJVS4UcDTNiCyiH6H8ZNnn2pmNviL7\
|
"edskRhxswacLW6jF6ULavDdzwqnKJVS4UcDTNiCyiH6H8ZNnn2pmNviL7\
|
||||||
pRNz9kRxxaWQFzEQEcZExGHKbwmuaAcoMegj5T99z"
|
pRNz9kRxxaWQFzEQEcZExGHKbwmuaAcoMegj5T99z"
|
||||||
|
|
||||||
@ -57,7 +57,6 @@ module Account = struct
|
|||||||
}
|
}
|
||||||
|
|
||||||
let encoding =
|
let encoding =
|
||||||
let open Environment.Ed25519 in
|
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
(fun { alias ; sk ; pk ; pkh ; contract } ->
|
(fun { alias ; sk ; pk ; pkh ; contract } ->
|
||||||
@ -67,9 +66,9 @@ module Account = struct
|
|||||||
{ alias ; sk ; pk ; pkh ; contract })
|
{ alias ; sk ; pk ; pkh ; contract })
|
||||||
(obj5
|
(obj5
|
||||||
(req "alias" string)
|
(req "alias" string)
|
||||||
(req "sk" Secret_key.encoding)
|
(req "sk" Ed25519.Secret_key.encoding)
|
||||||
(req "pk" Public_key.encoding)
|
(req "pk" Ed25519.Public_key.encoding)
|
||||||
(req "pkh" Public_key_hash.encoding)
|
(req "pkh" Ed25519.Public_key_hash.encoding)
|
||||||
(req "contract" Contract.encoding))
|
(req "contract" Contract.encoding))
|
||||||
|
|
||||||
let pp_account ppf account =
|
let pp_account ppf account =
|
||||||
@ -80,7 +79,7 @@ module Account = struct
|
|||||||
let sk, pk = match keys with
|
let sk, pk = match keys with
|
||||||
| Some keys -> keys
|
| Some keys -> keys
|
||||||
| None -> Sodium.Sign.random_keypair () in
|
| None -> Sodium.Sign.random_keypair () in
|
||||||
let pkh = Environment.Ed25519.Public_key.hash pk in
|
let pkh = Ed25519.Public_key.hash pk in
|
||||||
let contract = Contract.default_contract pkh in
|
let contract = Contract.default_contract pkh in
|
||||||
{ alias ; contract ; pkh ; pk ; sk }
|
{ alias ; contract ; pkh ; pk ; sk }
|
||||||
|
|
||||||
@ -92,7 +91,6 @@ module Account = struct
|
|||||||
}
|
}
|
||||||
|
|
||||||
let destination_encoding =
|
let destination_encoding =
|
||||||
let open Environment.Ed25519 in
|
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
(fun { alias ; pk ; pkh ; contract } ->
|
(fun { alias ; pk ; pkh ; contract } ->
|
||||||
@ -101,8 +99,8 @@ module Account = struct
|
|||||||
{ alias ; pk ; pkh ; contract })
|
{ alias ; pk ; pkh ; contract })
|
||||||
(obj4
|
(obj4
|
||||||
(req "alias" string)
|
(req "alias" string)
|
||||||
(req "pk" Public_key.encoding)
|
(req "pk" Ed25519.Public_key.encoding)
|
||||||
(req "pkh" Public_key_hash.encoding)
|
(req "pkh" Ed25519.Public_key_hash.encoding)
|
||||||
(req "contract" Contract.encoding))
|
(req "contract" Contract.encoding))
|
||||||
|
|
||||||
let pp_destination ppf destination =
|
let pp_destination ppf destination =
|
||||||
@ -110,53 +108,52 @@ module Account = struct
|
|||||||
Format.fprintf ppf "%s" (Data_encoding_ezjsonm.to_string json)
|
Format.fprintf ppf "%s" (Data_encoding_ezjsonm.to_string json)
|
||||||
|
|
||||||
let create_destination ~alias ~contract ~pk =
|
let create_destination ~alias ~contract ~pk =
|
||||||
let pkh = Environment.Ed25519.Public_key.hash pk in
|
let pkh = Ed25519.Public_key.hash pk in
|
||||||
{ alias ; contract ; pk ; pkh }
|
{ alias ; contract ; pk ; pkh }
|
||||||
|
|
||||||
type bootstrap_accounts = { b1 : t ; b2 : t ; b3 : t ; b4 : t ; b5 : t ; }
|
type bootstrap_accounts = { b1 : t ; b2 : t ; b3 : t ; b4 : t ; b5 : t ; }
|
||||||
|
|
||||||
let bootstrap_accounts =
|
let bootstrap_accounts =
|
||||||
let open Environment.Ed25519 in
|
|
||||||
let bootstrap1_pk =
|
let bootstrap1_pk =
|
||||||
Public_key.of_b58check_exn
|
Ed25519.Public_key.of_b58check_exn
|
||||||
"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" in
|
"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" in
|
||||||
let bootstrap2_pk =
|
let bootstrap2_pk =
|
||||||
Public_key.of_b58check_exn
|
Ed25519.Public_key.of_b58check_exn
|
||||||
"edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9" in
|
"edpktzNbDAUjUk697W7gYg2CRuBQjyPxbEg8dLccYYwKSKvkPvjtV9" in
|
||||||
let bootstrap3_pk =
|
let bootstrap3_pk =
|
||||||
Public_key.of_b58check_exn
|
Ed25519.Public_key.of_b58check_exn
|
||||||
"edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV" in
|
"edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV" in
|
||||||
let bootstrap4_pk =
|
let bootstrap4_pk =
|
||||||
Public_key.of_b58check_exn
|
Ed25519.Public_key.of_b58check_exn
|
||||||
"edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU" in
|
"edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU" in
|
||||||
let bootstrap5_pk =
|
let bootstrap5_pk =
|
||||||
Public_key.of_b58check_exn
|
Ed25519.Public_key.of_b58check_exn
|
||||||
"edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" in
|
"edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" in
|
||||||
let bootstrap1_sk =
|
let bootstrap1_sk =
|
||||||
Secret_key.of_b58check_exn
|
Ed25519.Secret_key.of_b58check_exn
|
||||||
"edskRuR1azSfboG86YPTyxrQgosh5zChf5bVDmptqLTb5EuXAm9\
|
"edskRuR1azSfboG86YPTyxrQgosh5zChf5bVDmptqLTb5EuXAm9\
|
||||||
rsnDYfTKhq7rDQujdn5WWzwUMeV3agaZ6J2vPQT58jJAJPi" in
|
rsnDYfTKhq7rDQujdn5WWzwUMeV3agaZ6J2vPQT58jJAJPi" in
|
||||||
let bootstrap2_sk =
|
let bootstrap2_sk =
|
||||||
Secret_key.of_b58check_exn
|
Ed25519.Secret_key.of_b58check_exn
|
||||||
"edskRkJz4Rw2rM5NtabEWMbbg2bF4b1nfFajaqEuEk4SgU7eeDby\
|
"edskRkJz4Rw2rM5NtabEWMbbg2bF4b1nfFajaqEuEk4SgU7eeDby\
|
||||||
m9gVQtBTbYo32WUg2zb5sNBkD1whRN7zX43V9bftBbtaKc" in
|
m9gVQtBTbYo32WUg2zb5sNBkD1whRN7zX43V9bftBbtaKc" in
|
||||||
let bootstrap3_sk =
|
let bootstrap3_sk =
|
||||||
Secret_key.of_b58check_exn
|
Ed25519.Secret_key.of_b58check_exn
|
||||||
"edskS3qsqsNgdjUqeMsVcEwBn8dkZ5iDRz6aF21KhcCtRiAkWByp\
|
"edskS3qsqsNgdjUqeMsVcEwBn8dkZ5iDRz6aF21KhcCtRiAkWByp\
|
||||||
USbicccR4Vgqm9UdW2Vabuos6seezqgbXTrmcbLUG4rdAC" in
|
USbicccR4Vgqm9UdW2Vabuos6seezqgbXTrmcbLUG4rdAC" in
|
||||||
let bootstrap4_sk =
|
let bootstrap4_sk =
|
||||||
Secret_key.of_b58check_exn
|
Ed25519.Secret_key.of_b58check_exn
|
||||||
"edskRg9qcPqaVQa6jXWNMU5p71tseSuR7NzozgqZ9URsVDi81wTyP\
|
"edskRg9qcPqaVQa6jXWNMU5p71tseSuR7NzozgqZ9URsVDi81wTyP\
|
||||||
JdFSBdeakobyHUi4Xgu61jgKRQvkhXrPmEdEUfiqfiJFL" in
|
JdFSBdeakobyHUi4Xgu61jgKRQvkhXrPmEdEUfiqfiJFL" in
|
||||||
let bootstrap5_sk =
|
let bootstrap5_sk =
|
||||||
Secret_key.of_b58check_exn
|
Ed25519.Secret_key.of_b58check_exn
|
||||||
"edskS7rLN2Df3nbS1EYvwJbWo4umD7yPM1SUeX7gp1WhCVpMFXjcC\
|
"edskS7rLN2Df3nbS1EYvwJbWo4umD7yPM1SUeX7gp1WhCVpMFXjcC\
|
||||||
yM58xs6xsnTsVqHQmJQ2RxoAjJGedWfvFmjQy6etA3dgZ" in
|
yM58xs6xsnTsVqHQmJQ2RxoAjJGedWfvFmjQy6etA3dgZ" in
|
||||||
let cpt = ref 0 in
|
let cpt = ref 0 in
|
||||||
match List.map begin fun (pk, sk) ->
|
match List.map begin fun (pk, sk) ->
|
||||||
incr cpt ;
|
incr cpt ;
|
||||||
let alias = Printf.sprintf "bootstrap%d" !cpt in
|
let alias = Printf.sprintf "bootstrap%d" !cpt in
|
||||||
let pkh = Environment.Ed25519.Public_key.hash pk in
|
let pkh = Ed25519.Public_key.hash pk in
|
||||||
{ alias ; contract = Contract.default_contract pkh; pkh ; pk ; sk }
|
{ alias ; contract = Contract.default_contract pkh; pkh ; pk ; sk }
|
||||||
end [
|
end [
|
||||||
bootstrap1_pk, bootstrap1_sk;
|
bootstrap1_pk, bootstrap1_sk;
|
||||||
@ -256,7 +253,7 @@ module Protocol = struct
|
|||||||
~period:next_level.voting_period
|
~period:next_level.voting_period
|
||||||
~proposals
|
~proposals
|
||||||
() >>=? fun bytes ->
|
() >>=? fun bytes ->
|
||||||
let signed_bytes = Environment.Ed25519.Signature.append sk bytes in
|
let signed_bytes = Ed25519.Signature.append sk bytes in
|
||||||
return (Tezos_data.Operation.of_bytes_exn signed_bytes)
|
return (Tezos_data.Operation.of_bytes_exn signed_bytes)
|
||||||
|
|
||||||
let ballot ?(block = `Prevalidation) ~src:({ pk; sk } : Account.t) ~proposal ballot =
|
let ballot ?(block = `Prevalidation) ~src:({ pk; sk } : Account.t) ~proposal ballot =
|
||||||
@ -269,7 +266,7 @@ module Protocol = struct
|
|||||||
~proposal
|
~proposal
|
||||||
~ballot
|
~ballot
|
||||||
() >>=? fun bytes ->
|
() >>=? fun bytes ->
|
||||||
let signed_bytes = Environment.Ed25519.Signature.append sk bytes in
|
let signed_bytes = Ed25519.Signature.append sk bytes in
|
||||||
return (Tezos_data.Operation.of_bytes_exn signed_bytes)
|
return (Tezos_data.Operation.of_bytes_exn signed_bytes)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -284,11 +281,11 @@ module Assert = struct
|
|||||||
match pkh1, pkh2 with
|
match pkh1, pkh2 with
|
||||||
| None, None -> true
|
| None, None -> true
|
||||||
| Some pkh1, Some pkh2 ->
|
| Some pkh1, Some pkh2 ->
|
||||||
Environment.Ed25519.Public_key_hash.equal pkh1 pkh2
|
Ed25519.Public_key_hash.equal pkh1 pkh2
|
||||||
| _ -> false in
|
| _ -> false in
|
||||||
let prn = function
|
let prn = function
|
||||||
| None -> "none"
|
| None -> "none"
|
||||||
| Some pkh -> Environment.Ed25519.Public_key_hash.to_hex pkh in
|
| Some pkh -> Ed25519.Public_key_hash.to_hex pkh in
|
||||||
Assert.equal ?msg ~prn ~eq pkh1 pkh2
|
Assert.equal ?msg ~prn ~eq pkh1 pkh2
|
||||||
|
|
||||||
let equal_tez ?msg tz1 tz2 =
|
let equal_tez ?msg tz1 tz2 =
|
||||||
@ -421,10 +418,10 @@ module Mining = struct
|
|||||||
let proof_of_work_nonce =
|
let proof_of_work_nonce =
|
||||||
Sodium.Random.Bigbytes.generate Constants.proof_of_work_nonce_size in
|
Sodium.Random.Bigbytes.generate Constants.proof_of_work_nonce_size in
|
||||||
let unsigned_header =
|
let unsigned_header =
|
||||||
Block.forge_header
|
Block_header.forge_unsigned
|
||||||
shell { priority ; seed_nonce_hash ; proof_of_work_nonce } in
|
shell { priority ; seed_nonce_hash ; proof_of_work_nonce } in
|
||||||
let signed_header =
|
let signed_header =
|
||||||
Environment.Ed25519.Signature.append delegate_sk unsigned_header in
|
Ed25519.Signature.append delegate_sk unsigned_header in
|
||||||
let block_hash = Block_hash.hash_bytes [signed_header] in
|
let block_hash = Block_hash.hash_bytes [signed_header] in
|
||||||
if Mining.check_hash block_hash stamp_threshold then
|
if Mining.check_hash block_hash stamp_threshold then
|
||||||
proof_of_work_nonce
|
proof_of_work_nonce
|
||||||
@ -452,7 +449,7 @@ module Mining = struct
|
|||||||
Operation_list_list_hash.compute
|
Operation_list_list_hash.compute
|
||||||
[Operation_list_hash.compute operation_hashes] in
|
[Operation_list_hash.compute operation_hashes] in
|
||||||
let shell =
|
let shell =
|
||||||
{ Block_header.net_id = bi.net_id ; predecessor = bi.hash ;
|
{ Tezos_data.Block_header.net_id = bi.net_id ; predecessor = bi.hash ;
|
||||||
timestamp ; fitness ; operations_hash ;
|
timestamp ; fitness ; operations_hash ;
|
||||||
level = Raw_level.to_int32 level.level ;
|
level = Raw_level.to_int32 level.level ;
|
||||||
proto_level } in
|
proto_level } in
|
||||||
@ -471,7 +468,7 @@ module Mining = struct
|
|||||||
~seed_nonce_hash
|
~seed_nonce_hash
|
||||||
~proof_of_work_nonce
|
~proof_of_work_nonce
|
||||||
() >>=? fun unsigned_header ->
|
() >>=? fun unsigned_header ->
|
||||||
let signed_header = Environment.Ed25519.Signature.append src_sk unsigned_header in
|
let signed_header = Ed25519.Signature.append src_sk unsigned_header in
|
||||||
Client_node_rpcs.inject_block rpc_config
|
Client_node_rpcs.inject_block rpc_config
|
||||||
?force signed_header
|
?force signed_header
|
||||||
[List.map (fun h -> Client_node_rpcs.Blob h) operations] >>=? fun block_hash ->
|
[List.map (fun h -> Client_node_rpcs.Blob h) operations] >>=? fun block_hash ->
|
||||||
@ -535,7 +532,7 @@ module Endorse = struct
|
|||||||
~block:hash
|
~block:hash
|
||||||
~slot:slot
|
~slot:slot
|
||||||
() >>=? fun bytes ->
|
() >>=? fun bytes ->
|
||||||
let signed_bytes = Environment.Ed25519.Signature.append src_sk bytes in
|
let signed_bytes = Ed25519.Signature.append src_sk bytes in
|
||||||
return (Tezos_data.Operation.of_bytes_exn signed_bytes)
|
return (Tezos_data.Operation.of_bytes_exn signed_bytes)
|
||||||
|
|
||||||
let signing_slots
|
let signing_slots
|
||||||
|
Loading…
Reference in New Issue
Block a user