Proto: return the maximum TTL for operations

This commit is contained in:
Grégoire Henry 2017-04-18 11:29:14 +02:00
parent 747cdb1963
commit 8d5155cf32
11 changed files with 28 additions and 13 deletions

View File

@ -86,6 +86,7 @@ module Block = struct
header: Block_header.t ; header: Block_header.t ;
message: string ; message: string ;
operation_list_count: int ; operation_list_count: int ;
max_operations_ttl: int ;
} }
module Contents = module Contents =
@ -97,13 +98,16 @@ module Block = struct
let encoding = let encoding =
let open Data_encoding in let open Data_encoding in
conv conv
(fun { header ; message ; operation_list_count } -> (fun { header ; message ; operation_list_count ;
(message, operation_list_count, header)) max_operations_ttl } ->
(fun (message, operation_list_count, header) -> (message, operation_list_count, max_operations_ttl, header))
{ header ; message ; operation_list_count }) (fun (message, operation_list_count,
(obj3 max_operations_ttl, header) ->
{ header ; message ; max_operations_ttl ; operation_list_count })
(obj4
(req "message" string) (req "message" string)
(req "operation_list_count" uint8) (req "operation_list_count" uint8)
(req "max_operations_ttl" uint16)
(req "header" Block_header.encoding)) (req "header" Block_header.encoding))
end)) end))

View File

@ -89,6 +89,7 @@ module Block : sig
header: Block_header.t ; header: Block_header.t ;
message: string ; message: string ;
operation_list_count: int ; operation_list_count: int ;
max_operations_ttl: int ;
} }
module Contents : SINGLE_STORE module Contents : SINGLE_STORE

View File

@ -108,7 +108,7 @@ module Locked_block = struct
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 = "Genesis" ;
operation_list_count = 0 } >>= fun () -> operation_list_count = 0 ; max_operations_ttl = 0 } >>= fun () ->
Context.commit_genesis Context.commit_genesis
context_index context_index
~id:genesis.block ~id:genesis.block
@ -342,7 +342,7 @@ module Block = struct
let store let store
net_state block_header operations net_state block_header operations
{ Updater.context ; fitness ; message } = { Updater.context ; fitness ; message ; max_operations_ttl } =
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, ... *)
@ -358,6 +358,7 @@ module Block = struct
Store.Block.header = block_header ; Store.Block.header = block_header ;
message ; message ;
operation_list_count = List.length operations ; operation_list_count = List.length operations ;
max_operations_ttl ;
} in } 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 ->

View File

@ -17,6 +17,7 @@ type validation_result = {
context: Context.t ; context: Context.t ;
fitness: Fitness.t ; fitness: Fitness.t ;
message: string option ; message: string option ;
max_operations_ttl: int ;
} }
type rpc_context = { type rpc_context = {

View File

@ -15,6 +15,7 @@ type validation_result = Protocol_sigs.validation_result = {
context: Context.t ; context: Context.t ;
fitness: Fitness.t ; fitness: Fitness.t ;
message: string option ; message: string option ;
max_operations_ttl: int ;
} }
type rpc_context = Protocol_sigs.rpc_context = { type rpc_context = Protocol_sigs.rpc_context = {

View File

@ -13,6 +13,7 @@ type validation_result = Protocol_sigs.validation_result = {
context: Context.t ; context: Context.t ;
fitness: Fitness.t ; fitness: Fitness.t ;
message: string option ; message: string option ;
max_operations_ttl: int ;
} }
type rpc_context = Protocol_sigs.rpc_context = { type rpc_context = Protocol_sigs.rpc_context = {

View File

@ -116,7 +116,7 @@ let init = Init_storage.may_initialize
let finalize ?commit_message:message c = let finalize ?commit_message:message c =
let fitness = Fitness.from_int64 (Fitness.current c) in let fitness = Fitness.from_int64 (Fitness.current c) in
let context = Storage.recover c in let context = Storage.recover c in
{ Updater.context ; fitness ; message } { Updater.context ; fitness ; message ; max_operations_ttl = 60 }
let configure_sandbox = Init_storage.configure_sandbox let configure_sandbox = Init_storage.configure_sandbox

View File

@ -87,7 +87,8 @@ let finalize_block ctxt =
let fitness = Fitness.get ctxt in let fitness = Fitness.get ctxt in
let message = Some (Format.asprintf "fitness <- %Ld" fitness) in let message = Some (Format.asprintf "fitness <- %Ld" fitness) in
let fitness = Fitness.from_int64 fitness in let fitness = Fitness.from_int64 fitness in
return { Updater.message ; context = ctxt.context ; fitness } return { Updater.message ; context = ctxt.context ; fitness ;
max_operations_ttl = 0 }
let rpc_services = Services.rpc_services let rpc_services = Services.rpc_services

View File

@ -7,6 +7,7 @@ type validation_result = {
context: Context.t ; context: Context.t ;
fitness: Fitness.t ; fitness: Fitness.t ;
message: string option ; message: string option ;
max_operations_ttl: int ;
} }
type rpc_context = { type rpc_context = {

View File

@ -93,13 +93,15 @@ let begin_application
let message = let message =
Some (Format.asprintf "activate %a" Protocol_hash.pp_short hash) in Some (Format.asprintf "activate %a" Protocol_hash.pp_short hash) in
Updater.activate ctxt hash >>= fun ctxt -> Updater.activate ctxt hash >>= fun ctxt ->
return { Updater.message ; context = ctxt ; fitness } return { Updater.message ; context = ctxt ;
fitness ; max_operations_ttl = 0 }
| Activate_testnet (hash, delay) -> | Activate_testnet (hash, delay) ->
let message = let message =
Some (Format.asprintf "activate testnet %a" Protocol_hash.pp_short hash) in Some (Format.asprintf "activate testnet %a" Protocol_hash.pp_short hash) in
let expiration = Time.add raw_block.shell.timestamp delay in let expiration = Time.add raw_block.shell.timestamp delay in
Updater.fork_test_network ctxt hash expiration >>= fun ctxt -> Updater.fork_test_network ctxt hash expiration >>= fun ctxt ->
return { Updater.message ; context = ctxt ; fitness } return { Updater.message ; context = ctxt ; fitness ;
max_operations_ttl = 0 }
let begin_construction let begin_construction
~predecessor_context:context ~predecessor_context:context
@ -111,7 +113,8 @@ let begin_construction
?proto_header:_ ?proto_header:_
() = () =
(* Dummy result. *) (* Dummy result. *)
return { Updater.message = None ; context ; fitness } return { Updater.message = None ; context ;
fitness ; max_operations_ttl = 0 }
let apply_operation _vctxt _ = let apply_operation _vctxt _ =
Lwt.return (Error []) (* absurd *) Lwt.return (Error []) (* absurd *)

View File

@ -89,7 +89,8 @@ let lolblock ?(operations = []) header =
proto = MBytes.of_string header ; proto = MBytes.of_string header ;
} ; } ;
operation_list_count = Random.int 32 ; operation_list_count = Random.int 32 ;
message = "" max_operations_ttl = 0 ;
message = "" ;
} }
let b1 = lolblock "Blop !" let b1 = lolblock "Blop !"