diff --git a/src/node/db/store.ml b/src/node/db/store.ml index 84b726b1d..e4ebb4a3b 100644 --- a/src/node/db/store.ml +++ b/src/node/db/store.ml @@ -86,6 +86,7 @@ module Block = struct header: Block_header.t ; message: string ; operation_list_count: int ; + max_operations_ttl: int ; } module Contents = @@ -97,13 +98,16 @@ module Block = struct let encoding = let open Data_encoding in conv - (fun { header ; message ; operation_list_count } -> - (message, operation_list_count, header)) - (fun (message, operation_list_count, header) -> - { header ; message ; operation_list_count }) - (obj3 + (fun { header ; message ; operation_list_count ; + max_operations_ttl } -> + (message, operation_list_count, max_operations_ttl, header)) + (fun (message, operation_list_count, + max_operations_ttl, header) -> + { header ; message ; max_operations_ttl ; operation_list_count }) + (obj4 (req "message" string) (req "operation_list_count" uint8) + (req "max_operations_ttl" uint16) (req "header" Block_header.encoding)) end)) diff --git a/src/node/db/store.mli b/src/node/db/store.mli index c056a69a0..13d915bc8 100644 --- a/src/node/db/store.mli +++ b/src/node/db/store.mli @@ -89,6 +89,7 @@ module Block : sig header: Block_header.t ; message: string ; operation_list_count: int ; + max_operations_ttl: int ; } module Contents : SINGLE_STORE diff --git a/src/node/shell/state.ml b/src/node/shell/state.ml index 30dbe1228..58bf0988b 100644 --- a/src/node/shell/state.ml +++ b/src/node/shell/state.ml @@ -108,7 +108,7 @@ module Locked_block = struct let header : Block_header.t = { shell ; proto = MBytes.create 0 } in Store.Block.Contents.store (store, genesis.block) { Store.Block.header ; message = "Genesis" ; - operation_list_count = 0 } >>= fun () -> + operation_list_count = 0 ; max_operations_ttl = 0 } >>= fun () -> Context.commit_genesis context_index ~id:genesis.block @@ -342,7 +342,7 @@ module Block = struct let store 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 hash = Block_header.hash_raw bytes in (* let's the validator check the consistency... of fitness, level, ... *) @@ -358,6 +358,7 @@ module Block = struct Store.Block.header = block_header ; message ; operation_list_count = List.length operations ; + max_operations_ttl ; } in Shared.use net_state.block_store begin fun store -> Store.Block.Invalid_block.known store hash >>= fun known_invalid -> diff --git a/src/node/updater/protocol_sigs.mli b/src/node/updater/protocol_sigs.mli index b033fe428..378902c14 100644 --- a/src/node/updater/protocol_sigs.mli +++ b/src/node/updater/protocol_sigs.mli @@ -17,6 +17,7 @@ type validation_result = { context: Context.t ; fitness: Fitness.t ; message: string option ; + max_operations_ttl: int ; } type rpc_context = { diff --git a/src/node/updater/updater.ml b/src/node/updater/updater.ml index 3dda135c8..b422d8a17 100644 --- a/src/node/updater/updater.ml +++ b/src/node/updater/updater.ml @@ -15,6 +15,7 @@ type validation_result = Protocol_sigs.validation_result = { context: Context.t ; fitness: Fitness.t ; message: string option ; + max_operations_ttl: int ; } type rpc_context = Protocol_sigs.rpc_context = { diff --git a/src/node/updater/updater.mli b/src/node/updater/updater.mli index 2bf0f2eba..5ee76d13a 100644 --- a/src/node/updater/updater.mli +++ b/src/node/updater/updater.mli @@ -13,6 +13,7 @@ type validation_result = Protocol_sigs.validation_result = { context: Context.t ; fitness: Fitness.t ; message: string option ; + max_operations_ttl: int ; } type rpc_context = Protocol_sigs.rpc_context = { diff --git a/src/proto/alpha/tezos_context.ml b/src/proto/alpha/tezos_context.ml index 33c0645c1..3560cfb87 100644 --- a/src/proto/alpha/tezos_context.ml +++ b/src/proto/alpha/tezos_context.ml @@ -116,7 +116,7 @@ let init = Init_storage.may_initialize let finalize ?commit_message:message c = let fitness = Fitness.from_int64 (Fitness.current 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 diff --git a/src/proto/demo/main.ml b/src/proto/demo/main.ml index 5bad18aeb..44f36dd02 100644 --- a/src/proto/demo/main.ml +++ b/src/proto/demo/main.ml @@ -87,7 +87,8 @@ let finalize_block ctxt = let fitness = Fitness.get ctxt in let message = Some (Format.asprintf "fitness <- %Ld" 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 diff --git a/src/proto/environment/updater.mli b/src/proto/environment/updater.mli index 046ab4335..052f56907 100644 --- a/src/proto/environment/updater.mli +++ b/src/proto/environment/updater.mli @@ -7,6 +7,7 @@ type validation_result = { context: Context.t ; fitness: Fitness.t ; message: string option ; + max_operations_ttl: int ; } type rpc_context = { diff --git a/src/proto/genesis/main.ml b/src/proto/genesis/main.ml index 4a6ff5e97..d2697beed 100644 --- a/src/proto/genesis/main.ml +++ b/src/proto/genesis/main.ml @@ -93,13 +93,15 @@ let begin_application let message = Some (Format.asprintf "activate %a" Protocol_hash.pp_short hash) in 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) -> let message = Some (Format.asprintf "activate testnet %a" Protocol_hash.pp_short hash) in let expiration = Time.add raw_block.shell.timestamp delay in 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 ~predecessor_context:context @@ -111,7 +113,8 @@ let begin_construction ?proto_header:_ () = (* Dummy result. *) - return { Updater.message = None ; context ; fitness } + return { Updater.message = None ; context ; + fitness ; max_operations_ttl = 0 } let apply_operation _vctxt _ = Lwt.return (Error []) (* absurd *) diff --git a/test/shell/test_store.ml b/test/shell/test_store.ml index a7aa50dbb..88691720f 100644 --- a/test/shell/test_store.ml +++ b/test/shell/test_store.ml @@ -89,7 +89,8 @@ let lolblock ?(operations = []) header = proto = MBytes.of_string header ; } ; operation_list_count = Random.int 32 ; - message = "" + max_operations_ttl = 0 ; + message = "" ; } let b1 = lolblock "Blop !"