Context: remove the default message
If we want to includes hash of the context in the block header, we cannot have a (default) commit message that includes the block hash. We break this circular dependency by removing the default commit message.
This commit is contained in:
parent
881186c58f
commit
270dc3e9e8
@ -150,7 +150,7 @@ type t = global_state
|
|||||||
|
|
||||||
module Locked_block = struct
|
module Locked_block = struct
|
||||||
|
|
||||||
let store_genesis store genesis commit =
|
let store_genesis store genesis context =
|
||||||
let shell : Block_header.shell_header = {
|
let shell : Block_header.shell_header = {
|
||||||
level = 0l ;
|
level = 0l ;
|
||||||
proto_level = 0 ;
|
proto_level = 0 ;
|
||||||
@ -162,8 +162,8 @@ module Locked_block = struct
|
|||||||
} in
|
} in
|
||||||
let header : Block_header.t = { shell ; proto = MBytes.create 0 } in
|
let header : Block_header.t = { shell ; proto = MBytes.create 0 } in
|
||||||
Store.Block.Contents.store (store, genesis.block)
|
Store.Block.Contents.store (store, genesis.block)
|
||||||
{ Store.Block.header ; message = "Genesis" ;
|
{ Store.Block.header ; message = Some "Genesis" ;
|
||||||
max_operations_ttl = 0 ; context = commit ;
|
max_operations_ttl = 0 ; context ;
|
||||||
max_number_of_operations = [];
|
max_number_of_operations = [];
|
||||||
max_operation_data_length = 0;
|
max_operation_data_length = 0;
|
||||||
} >>= fun () ->
|
} >>= fun () ->
|
||||||
@ -442,19 +442,11 @@ module Block = struct
|
|||||||
|
|
||||||
let store
|
let store
|
||||||
net_state block_header operations
|
net_state block_header operations
|
||||||
{ Updater.context ; fitness ; message ; max_operations_ttl ;
|
{ Updater.context ; message ; max_operations_ttl ;
|
||||||
max_number_of_operations ; max_operation_data_length } =
|
max_number_of_operations ; max_operation_data_length } =
|
||||||
let bytes = Block_header.to_bytes block_header in
|
let bytes = Block_header.to_bytes block_header in
|
||||||
let hash = Block_header.hash_raw bytes in
|
let hash = Block_header.hash_raw bytes in
|
||||||
(* let's the validator check the consistency... of fitness, level, ... *)
|
(* let's the validator check the consistency... of fitness, level, ... *)
|
||||||
let message =
|
|
||||||
match message with
|
|
||||||
| Some message -> message
|
|
||||||
| None ->
|
|
||||||
Format.asprintf "%a(%ld): %a"
|
|
||||||
Block_hash.pp_short hash
|
|
||||||
block_header.shell.level
|
|
||||||
Fitness.pp fitness in
|
|
||||||
Shared.use net_state.block_store begin fun store ->
|
Shared.use net_state.block_store begin fun store ->
|
||||||
Store.Block.Invalid_block.known store hash >>= fun known_invalid ->
|
Store.Block.Invalid_block.known store hash >>= fun known_invalid ->
|
||||||
fail_when known_invalid (failure "Known invalid") >>=? fun () ->
|
fail_when known_invalid (failure "Known invalid") >>=? fun () ->
|
||||||
@ -463,7 +455,7 @@ module Block = struct
|
|||||||
return None
|
return None
|
||||||
else begin
|
else begin
|
||||||
Context.commit
|
Context.commit
|
||||||
~time:block_header.shell.timestamp ~message context >>= fun commit ->
|
~time:block_header.shell.timestamp ?message context >>= fun commit ->
|
||||||
let contents = {
|
let contents = {
|
||||||
Store.Block.header = block_header ;
|
Store.Block.header = block_header ;
|
||||||
message ;
|
message ;
|
||||||
|
@ -129,7 +129,7 @@ module Block : sig
|
|||||||
val net_id: t -> Net_id.t
|
val net_id: t -> Net_id.t
|
||||||
val net_state: t -> Net.t
|
val net_state: t -> Net.t
|
||||||
val level: t -> Int32.t
|
val level: t -> Int32.t
|
||||||
val message: t -> string
|
val message: t -> string option
|
||||||
val max_operations_ttl: t -> int
|
val max_operations_ttl: t -> int
|
||||||
val max_number_of_operations: t -> int list
|
val max_number_of_operations: t -> int list
|
||||||
val max_operation_data_length: t -> int
|
val max_operation_data_length: t -> int
|
||||||
|
@ -111,14 +111,14 @@ let checkout_exn index key =
|
|||||||
| Some p -> Lwt.return p
|
| Some p -> Lwt.return p
|
||||||
|
|
||||||
|
|
||||||
let raw_commit ~time ~message context =
|
let raw_commit ~time ?(message = "") context =
|
||||||
let info =
|
let info =
|
||||||
Irmin.Info.v ~date:(Time.to_seconds time) ~author:"Tezos" message in
|
Irmin.Info.v ~date:(Time.to_seconds time) ~author:"Tezos" message in
|
||||||
GitStore.Commit.v
|
GitStore.Commit.v
|
||||||
context.index.repo ~info ~parents:context.parents context.tree
|
context.index.repo ~info ~parents:context.parents context.tree
|
||||||
|
|
||||||
let commit ~time ~message context =
|
let commit ~time ?message context =
|
||||||
raw_commit ~time ~message context >>= fun commit ->
|
raw_commit ~time ?message context >>= fun commit ->
|
||||||
Lwt.return (GitStore.Commit.hash commit)
|
Lwt.return (GitStore.Commit.hash commit)
|
||||||
|
|
||||||
(*-- Generic Store Primitives ------------------------------------------------*)
|
(*-- Generic Store Primitives ------------------------------------------------*)
|
||||||
|
@ -61,7 +61,7 @@ val checkout: index -> Context_hash.t -> context option Lwt.t
|
|||||||
val checkout_exn: index -> Context_hash.t -> context Lwt.t
|
val checkout_exn: index -> Context_hash.t -> context Lwt.t
|
||||||
val commit:
|
val commit:
|
||||||
time:Time.t ->
|
time:Time.t ->
|
||||||
message:string ->
|
?message:string ->
|
||||||
context ->
|
context ->
|
||||||
Context_hash.t Lwt.t
|
Context_hash.t Lwt.t
|
||||||
val set_head: index -> Net_id.t -> Context_hash.t -> unit Lwt.t
|
val set_head: index -> Net_id.t -> Context_hash.t -> unit Lwt.t
|
||||||
|
@ -82,7 +82,7 @@ module Block = struct
|
|||||||
|
|
||||||
type contents = {
|
type contents = {
|
||||||
header: Block_header.t ;
|
header: Block_header.t ;
|
||||||
message: string ;
|
message: string option ;
|
||||||
max_operations_ttl: int ;
|
max_operations_ttl: int ;
|
||||||
max_number_of_operations: int list;
|
max_number_of_operations: int list;
|
||||||
max_operation_data_length: int;
|
max_operation_data_length: int;
|
||||||
@ -111,7 +111,7 @@ module Block = struct
|
|||||||
max_number_of_operations ; max_operation_data_length ;
|
max_number_of_operations ; max_operation_data_length ;
|
||||||
context })
|
context })
|
||||||
(obj6
|
(obj6
|
||||||
(req "message" string)
|
(opt "message" string)
|
||||||
(req "max_operations_ttl" uint16)
|
(req "max_operations_ttl" uint16)
|
||||||
(req "max_number_of_operations" (list uint16))
|
(req "max_number_of_operations" (list uint16))
|
||||||
(req "max_operation_data_length" uint16)
|
(req "max_operation_data_length" uint16)
|
||||||
|
@ -86,7 +86,7 @@ module Block : sig
|
|||||||
|
|
||||||
type contents = {
|
type contents = {
|
||||||
header: Block_header.t ;
|
header: Block_header.t ;
|
||||||
message: string ;
|
message: string option ;
|
||||||
max_operations_ttl: int ;
|
max_operations_ttl: int ;
|
||||||
max_number_of_operations: int list;
|
max_number_of_operations: int list;
|
||||||
max_operation_data_length: int;
|
max_operation_data_length: int;
|
||||||
|
@ -87,7 +87,7 @@ let lolblock ?(operations = []) header =
|
|||||||
proto = MBytes.of_string header ;
|
proto = MBytes.of_string header ;
|
||||||
} ;
|
} ;
|
||||||
max_operations_ttl = 0 ;
|
max_operations_ttl = 0 ;
|
||||||
message = "" ;
|
message = None ;
|
||||||
context = Context_hash.zero ;
|
context = Context_hash.zero ;
|
||||||
max_number_of_operations = [] ;
|
max_number_of_operations = [] ;
|
||||||
max_operation_data_length = 0 ;
|
max_operation_data_length = 0 ;
|
||||||
|
Loading…
Reference in New Issue
Block a user