From a5cec8fca0be2debff1065e6d722bd0725be95a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Sat, 2 Jun 2018 14:58:08 +0200 Subject: [PATCH] Proto: move back `max_operation_data_length` as a constants --- src/bin_client/test/demo/main.ml | 10 +++--- src/bin_client/test/demo/main.mli | 10 ++++++ src/bin_client/test/test_injection.sh | 2 +- .../sigs/v1/updater.mli | 8 ++--- .../tezos_protocol_environment.ml | 3 +- .../tezos_protocol_environment.mli | 2 +- src/lib_shell/block_directory.ml | 2 +- src/lib_shell/block_validator.ml | 5 ++- src/lib_shell/prevalidation.ml | 15 ++++----- src/lib_shell/state.ml | 10 ++---- src/lib_shell/state.mli | 1 - src/lib_shell/store.ml | 11 +++---- src/lib_shell/store.mli | 1 - src/lib_shell/test/test_locator.ml | 1 - src/lib_shell/test/test_store.ml | 1 - .../lib_protocol/src/alpha_context.ml | 2 -- .../lib_protocol/src/alpha_context.mli | 5 ++- .../lib_protocol/src/constants_repr.ml | 32 +++++++++---------- .../lib_protocol/src/constants_storage.ml | 3 -- src/proto_alpha/lib_protocol/src/main.ml | 3 ++ .../lib_protocol/src/parameters_repr.ml | 10 +----- .../lib_protocol/test/helpers/block.ml | 2 -- .../lib_protocol/test/helpers/block.mli | 1 - src/proto_demo/lib_protocol/src/main.ml | 5 ++- src/proto_genesis/lib_protocol/src/main.ml | 6 ++-- 25 files changed, 64 insertions(+), 87 deletions(-) create mode 100644 src/bin_client/test/demo/main.mli diff --git a/src/bin_client/test/demo/main.ml b/src/bin_client/test/demo/main.ml index 67f75a5b2..f66eddfae 100644 --- a/src/bin_client/test/demo/main.ml +++ b/src/bin_client/test/demo/main.ml @@ -36,6 +36,7 @@ type operation = { } let max_block_length = 42 +let max_operation_data_length = 42 let validation_passes = [] let acceptable_passes _op = [] @@ -80,7 +81,8 @@ end let precheck_block ~ancestor_context:_ ~ancestor_timestamp:_ - (_raw_block : block_header) = + (raw_block: block_header) = + Fitness.to_int64 raw_block.shell.fitness >>=? fun _ -> return () let begin_application @@ -111,8 +113,7 @@ let finalize_block ctxt = let message = Some (Format.asprintf "fitness <- %Ld" fitness) in let fitness = Fitness.from_int64 fitness in return ({ Updater.message ; context = ctxt.context ; fitness ; - max_operations_ttl = 0 ; max_operation_data_length = 0 ; - last_allowed_fork_level = 0l ; + max_operations_ttl = 0 ; last_allowed_fork_level = 0l ; }, ()) let rpc_services = RPC_directory.empty @@ -121,6 +122,5 @@ let init ctxt block_header = let fitness = block_header.Block_header.fitness in let message = None in return { Updater.message ; context = ctxt ; fitness ; - max_operations_ttl = 0 ; max_operation_data_length = 0 ; - last_allowed_fork_level = 0l ; + max_operations_ttl = 0 ; last_allowed_fork_level = 0l ; } diff --git a/src/bin_client/test/demo/main.mli b/src/bin_client/test/demo/main.mli new file mode 100644 index 000000000..29ea145db --- /dev/null +++ b/src/bin_client/test/demo/main.mli @@ -0,0 +1,10 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* All rights reserved. No warranty, explicit or implicit, provided. *) +(* *) +(**************************************************************************) + +include Updater.PROTOCOL diff --git a/src/bin_client/test/test_injection.sh b/src/bin_client/test/test_injection.sh index 00ff484bd..aeb1ed7f5 100755 --- a/src/bin_client/test/test_injection.sh +++ b/src/bin_client/test/test_injection.sh @@ -31,7 +31,7 @@ done sleep 2 # autogenerated from the demo source -protocol_version="PsgZ1PB2h82sTKznNbmZxtbsU432eKDv1W6cf1cJFhCFmGYSiJs" +protocol_version="PrqKneMJTqCkD5bXFb4w3nidsW9kem1DjmmchwFTHqztK7V3QRq" $admin_client inject protocol "$test_dir/demo" $admin_client list protocols diff --git a/src/lib_protocol_environment/sigs/v1/updater.mli b/src/lib_protocol_environment/sigs/v1/updater.mli index 5c50c3d01..9d030ba3a 100644 --- a/src/lib_protocol_environment/sigs/v1/updater.mli +++ b/src/lib_protocol_environment/sigs/v1/updater.mli @@ -24,9 +24,6 @@ type validation_result = { (** An optional informative message to be used as in the 'git commit' of the block's context. *) - max_operation_data_length: int ; - (** The maximum size of operations in bytes. *) - max_operations_ttl: int ; (** The "time-to-live" of operation for the next block: any operations whose 'branch' is older than 'ttl' blocks in the @@ -58,9 +55,12 @@ type rpc_context = { access to the standard library and the Environment module. *) module type PROTOCOL = sig - (** The maximum size of block headers in bytes. *) + (** The maximum size of a block header in bytes. *) val max_block_length: int + (** The maximum size of an operation in bytes. *) + val max_operation_data_length: int + (** The number of validation passes (length of the list) and the operation's quota for each pass. *) val validation_passes: quota list diff --git a/src/lib_protocol_environment/tezos_protocol_environment.ml b/src/lib_protocol_environment/tezos_protocol_environment.ml index 6893f0e2a..10c12c553 100644 --- a/src/lib_protocol_environment/tezos_protocol_environment.ml +++ b/src/lib_protocol_environment/tezos_protocol_environment.ml @@ -35,7 +35,6 @@ module Make (Context : CONTEXT) = struct context: Context.t ; fitness: Fitness.t ; message: string option ; - max_operation_data_length: int ; max_operations_ttl: int ; last_allowed_fork_level: Int32.t ; } @@ -58,6 +57,7 @@ module Make (Context : CONTEXT) = struct type rpc_context type 'a tzresult val max_block_length: int + val max_operation_data_length: int val validation_passes: quota list type block_header_data val block_header_data_encoding: block_header_data Data_encoding.t @@ -578,7 +578,6 @@ module Make (Context : CONTEXT) = struct context: Context.t ; fitness: Fitness.t ; message: string option ; - max_operation_data_length: int ; max_operations_ttl: int ; last_allowed_fork_level: Int32.t ; } diff --git a/src/lib_protocol_environment/tezos_protocol_environment.mli b/src/lib_protocol_environment/tezos_protocol_environment.mli index edcc2803e..ab5fa1ba6 100644 --- a/src/lib_protocol_environment/tezos_protocol_environment.mli +++ b/src/lib_protocol_environment/tezos_protocol_environment.mli @@ -28,7 +28,6 @@ module Make (Context : CONTEXT) : sig context: Context.t ; fitness: Fitness.t ; message: string option ; - max_operation_data_length: int ; max_operations_ttl: int ; last_allowed_fork_level: Int32.t ; } @@ -51,6 +50,7 @@ module Make (Context : CONTEXT) : sig type rpc_context type 'a tzresult val max_block_length: int + val max_operation_data_length: int val validation_passes: quota list type block_header_data val block_header_data_encoding: block_header_data Data_encoding.t diff --git a/src/lib_shell/block_directory.ml b/src/lib_shell/block_directory.ml index 1554dcded..8ed37f33f 100644 --- a/src/lib_shell/block_directory.ml +++ b/src/lib_shell/block_directory.ml @@ -98,7 +98,7 @@ let build_raw_rpc_directory Block_services.protocol_data ; test_chain_status ; max_operations_ttl = State.Block.max_operations_ttl block ; - max_operation_data_length = State.Block.max_operation_data_length block ; + max_operation_data_length = Next_proto.max_operation_data_length ; max_block_header_length = Next_proto.max_block_length ; operation_list_quota = List.map diff --git a/src/lib_shell/block_validator.ml b/src/lib_shell/block_validator.ml index 5939c6682..80fada844 100644 --- a/src/lib_shell/block_validator.ml +++ b/src/lib_shell/block_validator.ml @@ -129,15 +129,14 @@ let apply_block invalid_block hash @@ Too_many_operations { pass = i + 1 ; found = List.length ops ; max }) >>=? fun () -> - let max_size = State.Block.max_operation_data_length pred in iter_p (fun op -> let size = Data_encoding.Binary.length Operation.encoding op in fail_unless - (size <= max_size) + (size <= Proto.max_operation_data_length) (invalid_block hash @@ Oversized_operation { operation = Operation.hash op ; - size ; max = max_size })) ops >>=? fun () -> + size ; max = Proto.max_operation_data_length })) ops >>=? fun () -> return ()) operations Proto.validation_passes >>=? fun () -> let operation_hashes = List.map (List.map Operation.hash) operations in diff --git a/src/lib_shell/prevalidation.ml b/src/lib_shell/prevalidation.ml index 423b78b28..2d45f78c4 100644 --- a/src/lib_shell/prevalidation.ml +++ b/src/lib_shell/prevalidation.ml @@ -49,8 +49,7 @@ let rec apply_operations apply_operation state r max_ops ~sort ops = type prevalidation_state = State : { proto : 'a proto ; state : 'a ; - max_number_of_operations : int ; - max_operation_data_length : int } + max_number_of_operations : int } -> prevalidation_state and 'a proto = @@ -64,8 +63,6 @@ let start_prevalidation timestamp = predecessor_timestamp ; level = predecessor_level } } = State.Block.header predecessor in - let max_operation_data_length = - State.Block.max_operation_data_length predecessor in State.Block.context predecessor >>= fun predecessor_context -> Context.get_protocol predecessor_context >>= fun protocol -> let predecessor = State.Block.hash predecessor in @@ -107,12 +104,12 @@ let start_prevalidation (* FIXME arbitrary value, to be customisable *) let max_number_of_operations = 1000 in return (State { proto = (module Proto) ; state ; - max_number_of_operations ; max_operation_data_length }) + max_number_of_operations }) let prevalidate (State { proto = (module Proto) ; state ; - max_number_of_operations ; max_operation_data_length }) + max_number_of_operations }) ~sort (ops : (Operation_hash.t * Operation.t) list)= let ops = List.map @@ -145,8 +142,8 @@ let prevalidate let size = Data_encoding.Binary.length Operation.encoding op in if max_ops <= 0 then fail Too_many_operations - else if size > max_operation_data_length then - fail (Oversized_operation { size ; max = max_operation_data_length }) + else if size > Proto.max_operation_data_length then + fail (Oversized_operation { size ; max = Proto.max_operation_data_length }) else Proto.apply_operation state parse_op >>=? fun (state, receipt) -> return (state, receipt) in @@ -162,7 +159,7 @@ let prevalidate (fun map (h, op, err) -> Operation_hash.Map.add h (op, err) map) r.branch_refused invalid_ops } in Lwt.return (State { proto = (module Proto) ; state ; - max_number_of_operations ; max_operation_data_length }, + max_number_of_operations }, r) let end_prevalidation (State { proto = (module Proto) ; state }) = diff --git a/src/lib_shell/state.ml b/src/lib_shell/state.ml index 0a6675cf1..d5e504187 100644 --- a/src/lib_shell/state.ml +++ b/src/lib_shell/state.ml @@ -221,9 +221,8 @@ module Locked_block = struct let header : Block_header.t = { shell ; protocol_data = MBytes.create 0 } in Store.Block.Contents.store (store, genesis.block) { Store.Block.header ; message = Some "Genesis" ; - max_operations_ttl = 0 ; context ; - max_operation_data_length = 0 ; - metadata = MBytes.create 0 ; + max_operations_ttl = 0 ; + context ; metadata = MBytes.create 0 ; } >>= fun () -> Lwt.return header @@ -443,8 +442,6 @@ module Block = struct let message { contents = { message } } = message let max_operations_ttl { contents = { max_operations_ttl } } = max_operations_ttl - let max_operation_data_length { contents = { max_operation_data_length } } = - max_operation_data_length let is_genesis b = Block_hash.equal b.hash b.chain_state.genesis.block @@ -543,7 +540,7 @@ module Block = struct chain_state block_header block_header_metadata operations operations_metadata { Tezos_protocol_environment_shell.context ; message ; - max_operations_ttl ; max_operation_data_length } = + max_operations_ttl } = let bytes = Block_header.to_bytes block_header in let hash = Block_header.hash_raw bytes in fail_unless @@ -580,7 +577,6 @@ module Block = struct block_header ; message ; max_operations_ttl ; - max_operation_data_length ; context = commit ; metadata = block_header_metadata ; } in diff --git a/src/lib_shell/state.mli b/src/lib_shell/state.mli index 33711fbf6..e6e2511e8 100644 --- a/src/lib_shell/state.mli +++ b/src/lib_shell/state.mli @@ -119,7 +119,6 @@ module Block : sig val level: t -> Int32.t val message: t -> string option val max_operations_ttl: t -> int - val max_operation_data_length: t -> int val metadata: t -> MBytes.t val is_genesis: t -> bool diff --git a/src/lib_shell/store.ml b/src/lib_shell/store.ml index fdf6a9a7b..0ac424dc5 100644 --- a/src/lib_shell/store.ml +++ b/src/lib_shell/store.ml @@ -84,7 +84,6 @@ module Block = struct header: Block_header.t ; message: string option ; max_operations_ttl: int ; - max_operation_data_length: int; context: Context_hash.t ; metadata: MBytes.t ; } @@ -99,18 +98,16 @@ module Block = struct let open Data_encoding in conv (fun { header ; message ; max_operations_ttl ; - max_operation_data_length ; context ; metadata } -> + context ; metadata } -> (message, max_operations_ttl, - max_operation_data_length, context, metadata, header )) + context, metadata, header )) (fun (message, max_operations_ttl, - max_operation_data_length, context, metadata, header ) -> + context, metadata, header ) -> { header ; message ; max_operations_ttl ; - max_operation_data_length ; context ; metadata }) - (obj6 + (obj5 (opt "message" string) (req "max_operations_ttl" uint16) - (req "max_operation_data_length" uint16) (req "context" Context_hash.encoding) (req "metadata" bytes) (req "header" Block_header.encoding)) diff --git a/src/lib_shell/store.mli b/src/lib_shell/store.mli index 61dada155..e09388aa6 100644 --- a/src/lib_shell/store.mli +++ b/src/lib_shell/store.mli @@ -88,7 +88,6 @@ module Block : sig header: Block_header.t ; message: string option ; max_operations_ttl: int ; - max_operation_data_length: int; context: Context_hash.t ; metadata: MBytes.t ; } diff --git a/src/lib_shell/test/test_locator.ml b/src/lib_shell/test/test_locator.ml index 39ce1c9bc..5683ce695 100644 --- a/src/lib_shell/test/test_locator.ml +++ b/src/lib_shell/test/test_locator.ml @@ -96,7 +96,6 @@ let make_empty_chain (chain:State.Chain.t) n : Block_hash.t Lwt.t = context = empty_context ; fitness = [] ; message = None ; - max_operation_data_length = 0 ; max_operations_ttl = 0 ; last_allowed_fork_level = 0l ; } in diff --git a/src/lib_shell/test/test_store.ml b/src/lib_shell/test/test_store.ml index a539db81d..1023f9685 100644 --- a/src/lib_shell/test/test_store.ml +++ b/src/lib_shell/test/test_store.ml @@ -89,7 +89,6 @@ let lolblock ?(operations = []) header = max_operations_ttl = 0 ; message = None ; context = Context_hash.zero ; - max_operation_data_length = 0 ; } let b1 = lolblock "Blop !" diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.ml b/src/proto_alpha/lib_protocol/src/alpha_context.ml index 5139efde3..2c201072e 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/src/alpha_context.ml @@ -129,9 +129,7 @@ let prepare = Init_storage.prepare let finalize ?commit_message:message c = let fitness = Fitness.from_int64 (Fitness.current c) in let context = Raw_context.recover c in - let constants = Raw_context.constants c in { Updater.context ; fitness ; message ; max_operations_ttl = 60 ; - max_operation_data_length = constants.max_operation_data_length ; last_allowed_fork_level = Raw_level.to_int32 @@ Level.last_allowed_fork_level c; } diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 48993996e..9ddbc063f 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -300,6 +300,7 @@ module Constants : sig proof_of_work_nonce_size : int ; nonce_length : int ; max_revelations_per_block : int ; + max_operation_data_length : int ; } val fixed_encoding: fixed Data_encoding.t val fixed: fixed @@ -307,7 +308,7 @@ module Constants : sig val proof_of_work_nonce_size: int val nonce_length: int val max_revelations_per_block: int - + val max_operation_data_length: int (** Constants parameterized by context *) type parametric = { @@ -322,7 +323,6 @@ module Constants : sig hard_gas_limit_per_block: Z.t ; proof_of_work_threshold: int64 ; dictator_pubkey: Signature.Public_key.t ; - max_operation_data_length: int ; tokens_per_roll: Tez.t ; michelson_maximum_type_size: int; seed_nonce_revelation_tip: Tez.t ; @@ -351,7 +351,6 @@ module Constants : sig val hard_storage_limit_per_block: context -> Int64.t val proof_of_work_threshold: context -> int64 val dictator_pubkey: context -> Signature.Public_key.t - val max_operation_data_length: context -> int val tokens_per_roll: context -> Tez.t val michelson_maximum_type_size: context -> int val block_reward: context -> Tez.t diff --git a/src/proto_alpha/lib_protocol/src/constants_repr.ml b/src/proto_alpha/lib_protocol/src/constants_repr.ml index be1575fe4..4b0aeaf82 100644 --- a/src/proto_alpha/lib_protocol/src/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/src/constants_repr.ml @@ -11,36 +11,43 @@ let version_number = "\000" let proof_of_work_nonce_size = 8 let nonce_length = 32 let max_revelations_per_block = 32 +let max_operation_data_length = 16 * 1024 ; (* 16kB *) type fixed = { proof_of_work_nonce_size : int ; nonce_length : int ; max_revelations_per_block : int ; + max_operation_data_length : int ; } let fixed_encoding = let open Data_encoding in conv (fun c -> - ( c.proof_of_work_nonce_size, - c.nonce_length, - c.max_revelations_per_block )) - (fun ( proof_of_work_nonce_size, - nonce_length, - max_revelations_per_block ) -> + (c.proof_of_work_nonce_size, + c.nonce_length, + c.max_revelations_per_block, + c.max_operation_data_length)) + (fun (proof_of_work_nonce_size, + nonce_length, + max_revelations_per_block, + max_operation_data_length) -> { proof_of_work_nonce_size ; nonce_length ; max_revelations_per_block ; + max_operation_data_length ; } ) - (obj3 + (obj4 (req "proof_of_work_nonce_size" uint8) (req "nonce_length" uint8) - (req "max_revelations_per_block" uint8)) + (req "max_revelations_per_block" uint8) + (req "max_operation_data_length" int31)) let fixed = { proof_of_work_nonce_size ; nonce_length ; max_revelations_per_block ; + max_operation_data_length ; } type parametric = { @@ -55,7 +62,6 @@ type parametric = { hard_gas_limit_per_block: Z.t ; proof_of_work_threshold: int64 ; dictator_pubkey: Signature.Public_key.t ; - max_operation_data_length: int ; tokens_per_roll: Tez_repr.t ; michelson_maximum_type_size: int; seed_nonce_revelation_tip: Tez_repr.t ; @@ -85,8 +91,6 @@ let default = { dictator_pubkey = Signature.Public_key.of_b58check_exn "edpkugeDwmwuwyyD3Q5enapgEYDxZLtEUFFSrvVwXASQMVEqsvTqWu" ; - max_operation_data_length = - 16 * 1024 ; (* 16kB *) tokens_per_roll = Tez_repr.(mul_exn one 10_000) ; michelson_maximum_type_size = 1000 ; @@ -122,7 +126,6 @@ let parametric_encoding = c.hard_gas_limit_per_block), ((c.proof_of_work_threshold, c.dictator_pubkey, - c.max_operation_data_length, c.tokens_per_roll, c.michelson_maximum_type_size, c.seed_nonce_revelation_tip, @@ -145,7 +148,6 @@ let parametric_encoding = hard_gas_limit_per_block), ((proof_of_work_threshold, dictator_pubkey, - max_operation_data_length, tokens_per_roll, michelson_maximum_type_size, seed_nonce_revelation_tip, @@ -168,7 +170,6 @@ let parametric_encoding = hard_gas_limit_per_block ; proof_of_work_threshold ; dictator_pubkey ; - max_operation_data_length ; tokens_per_roll ; michelson_maximum_type_size ; seed_nonce_revelation_tip ; @@ -193,10 +194,9 @@ let parametric_encoding = (req "hard_gas_limit_per_operation" z) (req "hard_gas_limit_per_block" z)) (merge_objs - (obj10 + (obj9 (req "proof_of_work_threshold" int64) (req "dictator_pubkey" Signature.Public_key.encoding) - (req "max_operation_data_length" int31) (req "tokens_per_roll" Tez_repr.encoding) (req "michelson_maximum_type_size" uint16) (req "seed_nonce_revelation_tip" Tez_repr.encoding) diff --git a/src/proto_alpha/lib_protocol/src/constants_storage.ml b/src/proto_alpha/lib_protocol/src/constants_storage.ml index 72c529cf7..4ae89a699 100644 --- a/src/proto_alpha/lib_protocol/src/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/src/constants_storage.ml @@ -49,9 +49,6 @@ let proof_of_work_threshold c = let dictator_pubkey c = let constants = Raw_context.constants c in constants.dictator_pubkey -let max_operation_data_length c = - let constants = Raw_context.constants c in - constants.max_operation_data_length let tokens_per_roll c = let constants = Raw_context.constants c in constants.tokens_per_roll diff --git a/src/proto_alpha/lib_protocol/src/main.ml b/src/proto_alpha/lib_protocol/src/main.ml index 83f33a418..2984f6c42 100644 --- a/src/proto_alpha/lib_protocol/src/main.ml +++ b/src/proto_alpha/lib_protocol/src/main.ml @@ -43,6 +43,9 @@ let acceptable_passes = Alpha_context.Operation.acceptable_passes let max_block_length = Alpha_context.Block_header.max_header_length +let max_operation_data_length = + Alpha_context.Constants.max_operation_data_length + let validation_passes = Updater.[ { max_size = 32 * 1024 ; max_op = Some 32 } ; (* 32kB FIXME *) { max_size = 32 * 1024 ; max_op = None } ; (* 32kB FIXME *) diff --git a/src/proto_alpha/lib_protocol/src/parameters_repr.ml b/src/proto_alpha/lib_protocol/src/parameters_repr.ml index 19d8bdbeb..34530276f 100644 --- a/src/proto_alpha/lib_protocol/src/parameters_repr.ml +++ b/src/proto_alpha/lib_protocol/src/parameters_repr.ml @@ -72,9 +72,6 @@ let constants_encoding = and dictator_pubkey = opt Signature.Public_key.(=) default.dictator_pubkey c.dictator_pubkey - and max_operation_data_length = - opt Compare.Int.(=) - default.max_operation_data_length c.max_operation_data_length and tokens_per_roll = opt Tez_repr.(=) default.tokens_per_roll c.tokens_per_roll @@ -120,7 +117,6 @@ let constants_encoding = hard_gas_limit_per_block), ((proof_of_work_threshold, dictator_pubkey, - max_operation_data_length, tokens_per_roll, michelson_maximum_type_size, seed_nonce_revelation_tip, @@ -143,7 +139,6 @@ let constants_encoding = hard_gas_limit_per_block), ((proof_of_work_threshold, dictator_pubkey, - max_operation_data_length, tokens_per_roll, michelson_maximum_type_size, seed_nonce_revelation_tip, @@ -180,8 +175,6 @@ let constants_encoding = unopt default.proof_of_work_threshold proof_of_work_threshold ; dictator_pubkey = unopt default.dictator_pubkey dictator_pubkey ; - max_operation_data_length = - unopt default.max_operation_data_length max_operation_data_length ; tokens_per_roll = unopt default.tokens_per_roll tokens_per_roll ; michelson_maximum_type_size = @@ -217,10 +210,9 @@ let constants_encoding = (opt "hard_gas_limit_per_operation" z) (opt "hard_gas_limit_per_block" z)) (merge_objs - (obj10 + (obj9 (opt "proof_of_work_threshold" int64) (opt "dictator_pubkey" Signature.Public_key.encoding) - (opt "max_operation_data_length" int31) (opt "tokens_per_roll" Tez_repr.encoding) (opt "michelson_maximum_type_size" uint16) (opt "seed_nonce_revelation_tip" Tez_repr.encoding) diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index fc2ab3cf5..a9d6d14eb 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -234,7 +234,6 @@ let genesis ?(hard_gas_limit_per_block = Constants_repr.default.hard_gas_limit_per_block) ?(proof_of_work_threshold = Int64.(neg one)) ?(dictator_pubkey = Constants_repr.default.dictator_pubkey) - ?(max_operation_data_length = Constants_repr.default.max_operation_data_length) ?(tokens_per_roll = Constants_repr.default.tokens_per_roll) ?(michelson_maximum_type_size = Constants_repr.default.michelson_maximum_type_size) ?(seed_nonce_revelation_tip = Constants_repr.default.seed_nonce_revelation_tip) @@ -280,7 +279,6 @@ let genesis hard_gas_limit_per_block ; proof_of_work_threshold ; dictator_pubkey ; - max_operation_data_length ; tokens_per_roll ; michelson_maximum_type_size ; seed_nonce_revelation_tip ; diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index d12c98bf9..1e57e4957 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -72,7 +72,6 @@ val genesis: ?hard_gas_limit_per_block:Z.t -> ?proof_of_work_threshold:int64 -> ?dictator_pubkey:public_key -> - ?max_operation_data_length:int -> ?tokens_per_roll:Tez_repr.tez -> ?michelson_maximum_type_size:int -> ?seed_nonce_revelation_tip:Tez_repr.tez -> diff --git a/src/proto_demo/lib_protocol/src/main.ml b/src/proto_demo/lib_protocol/src/main.ml index 99459eb6b..c5ab7eabc 100644 --- a/src/proto_demo/lib_protocol/src/main.ml +++ b/src/proto_demo/lib_protocol/src/main.ml @@ -38,6 +38,7 @@ type operation = { } let max_block_length = 42 +let max_operation_data_length = 0 let validation_passes = [] let acceptable_passes _op = [] @@ -114,8 +115,7 @@ let finalize_block ctxt = let message = Some (Format.asprintf "fitness <- %Ld" fitness) in let fitness = Fitness.from_int64 fitness in return ({ Updater.message ; context = ctxt.context ; fitness ; - max_operations_ttl = 0 ; max_operation_data_length = 0 ; - last_allowed_fork_level = 0l ; + max_operations_ttl = 0 ; last_allowed_fork_level = 0l ; }, ()) let rpc_services = Services.rpc_services @@ -124,6 +124,5 @@ let init context block_header = return { Updater.message = None ; context ; fitness = block_header.Block_header.fitness ; max_operations_ttl = 0 ; - max_operation_data_length = 0 ; last_allowed_fork_level = block_header.level ; } diff --git a/src/proto_genesis/lib_protocol/src/main.ml b/src/proto_genesis/lib_protocol/src/main.ml index f190e28c4..0b3c4b717 100644 --- a/src/proto_genesis/lib_protocol/src/main.ml +++ b/src/proto_genesis/lib_protocol/src/main.ml @@ -78,6 +78,8 @@ let max_block_length = delay = 0L }) + Signature.size +let max_operation_data_length = 0 + let check_signature ctxt { shell ; protocol_data = { command ; signature } } = let bytes = Data.Command.forge shell command in Data.Pubkey.get_pubkey ctxt >>= fun public_key -> @@ -107,7 +109,6 @@ let prepare_application ctxt command level timestamp fitness = Updater.activate ctxt hash >>= fun ctxt -> return { Updater.message ; context = ctxt ; fitness ; max_operations_ttl = 0 ; - max_operation_data_length = 0 ; last_allowed_fork_level = level ; } | Activate_testchain { protocol = hash ; delay } -> @@ -117,7 +118,6 @@ let prepare_application ctxt command level timestamp fitness = Updater.fork_test_chain ctxt ~protocol:hash ~expiration >>= fun ctxt -> return { Updater.message ; context = ctxt ; fitness ; max_operations_ttl = 0 ; - max_operation_data_length = 0 ; last_allowed_fork_level = Int32.succ level ; } @@ -145,7 +145,6 @@ let begin_construction (* Dummy result. *) return { Updater.message = None ; context = ctxt ; fitness ; max_operations_ttl = 0 ; - max_operation_data_length = 0 ; last_allowed_fork_level = 0l ; } | Some { command ; _ }-> @@ -183,6 +182,5 @@ let init ctxt block_header = return { Updater.message = None ; context = ctxt ; fitness = block_header.Block_header.fitness ; max_operations_ttl = 0 ; - max_operation_data_length = 0 ; last_allowed_fork_level = block_header.level ; }