diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 578850785b856fe100713730c4cc59baf1f0f684..3394195ddb7eeb4dbf4b2a2ab9c954c1faabe408 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -199,33 +199,46 @@ let constants_mainnet = (minus overhead), since we need to limit our proofs to those that can fit in an operation. *) rejection_max_proof_size = 30000; - (* This is the first block of cycle 618, which is expected to be - about one year after the activation of protocol J. - See https://tzstats.com/cycle/618 *) + (* This is the first block of cycle 618, which is expected to + be about one year after the activation of protocol J. See + https://tzstats.com/cycle/618 *) sunset_level = 3_473_409l; }; dal = default_dal; sc_rollup = - { - enable = false; - (* The following value is chosen to prevent spam. *) - origination_size = 6_314; - challenge_window_in_blocks = sc_rollup_challenge_window_in_blocks; - (* The following value is chosen to limit the length of inbox refutation proofs. *) - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2373 - check this is reasonable. *) - max_number_of_messages_per_commitment_period = 32_765; - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2756 - The following constants need to be refined. *) - stake_amount = Tez.of_mutez_exn 10_000_000_000L; - commitment_period_in_blocks = 30; - max_lookahead_in_blocks = 30_000l; - max_active_outbox_levels = sc_rollup_max_active_outbox_levels; - max_outbox_messages_per_level = sc_rollup_max_outbox_messages_per_level; - number_of_sections_in_dissection = 32; - timeout_period_in_blocks = sc_rollup_timeout_period_in_blocks; - max_number_of_stored_cemented_commitments = 5; - }; + (let commitment_period_in_blocks = 30 in + { + enable = false; + (* The following value is chosen to prevent spam. *) + origination_size = 6_314; + challenge_window_in_blocks = sc_rollup_challenge_window_in_blocks; + commitment_period_in_blocks; + (* + + The following value is chosen to limit the length of inbox + refutation proofs. In the worst case, the length of inbox + refutation proofs are logarithmic (in basis 2) in the + number of messages in the inboxes during the commitment + period. + + With the following value, an inbox refutation proof is + made of at most 35 hashes, hence a payload bounded by + 35 * 48 bytes, which far below than the 32kb of a Tezos + operations. + + *) + max_number_of_messages_per_commitment_period = + commitment_period_in_blocks * 10_000_000; + (* TODO: https://gitlab.com/tezos/tezos/-/issues/2756 + The following constants need to be refined. *) + stake_amount = Tez.of_mutez_exn 10_000_000_000L; + max_lookahead_in_blocks = 30_000l; + max_active_outbox_levels = sc_rollup_max_active_outbox_levels; + max_outbox_messages_per_level = sc_rollup_max_outbox_messages_per_level; + number_of_sections_in_dissection = 32; + timeout_period_in_blocks = sc_rollup_timeout_period_in_blocks; + max_number_of_stored_cemented_commitments = 5; + }); } let default_dal_sandbox = diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index c38aaca8542d66a2845b0abf2d83c1394ecfc876..f7de291e1bb59d2a6ae88762fedb2772a3dc509e 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -935,11 +935,22 @@ let prepare_first_block ~level ~timestamp ctxt = enable = c.sc_rollup.enable; origination_size = c.sc_rollup.origination_size; challenge_window_in_blocks = c.sc_rollup.challenge_window_in_blocks; - (* The following value is chosen to limit the maximal - length of an inbox refutation proof. *) - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2373 - check this is reasonable. *) - max_number_of_messages_per_commitment_period = 32_765; + (* + + The following value is chosen to limit the length of inbox + refutation proofs. In the worst case, the length of inbox + refutation proofs are logarithmic (in basis 2) in the + number of messages in the inboxes during the commitment + period. + + With the following value, an inbox refutation proof is + made of at most 35 hashes, hence a payload bounded by + 35 * 48 bytes, which far below than the 32kb of a Tezos + operations. + + *) + max_number_of_messages_per_commitment_period = + c.sc_rollup.commitment_period_in_blocks * 10_000_000; (* TODO: https://gitlab.com/tezos/tezos/-/issues/2756 The following constants need to be refined. *) stake_amount = Tez_repr.of_mutez_exn 10_000_000_000L; diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 77660df040249912946c7ea6aae5a2e97c845901..53f70e3a3f424dcb08e6a69e60d508798744d749 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -445,8 +445,8 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum ?baking_reward_bonus_per_slot ?baking_reward_fixed_portion ?origination_size ?blocks_per_cycle ?cycles_per_voting_period ?tx_rollup_enable ?tx_rollup_sunset_level ?tx_rollup_origination_size ?sc_rollup_enable - ?dal_enable ?hard_gas_limit_per_block ?nonce_revelation_threshold - initial_accounts = + ?sc_rollup_max_number_of_messages_per_commitment_period ?dal_enable + ?hard_gas_limit_per_block ?nonce_revelation_threshold initial_accounts = let open Tezos_protocol_alpha_parameters in let constants = Default_parameters.constants_test in let min_proposal_quorum = @@ -505,6 +505,11 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum let sc_rollup_enable = Option.value ~default:constants.sc_rollup.enable sc_rollup_enable in + let sc_rollup_max_number_of_messages_per_commitment_period = + Option.value + ~default:constants.sc_rollup.max_number_of_messages_per_commitment_period + sc_rollup_max_number_of_messages_per_commitment_period + in let dal_enable = Option.value ~default:constants.dal.feature_enable dal_enable in @@ -538,7 +543,13 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum sunset_level = tx_rollup_sunset_level; origination_size = tx_rollup_origination_size; }; - sc_rollup = {constants.sc_rollup with enable = sc_rollup_enable}; + sc_rollup = + { + constants.sc_rollup with + enable = sc_rollup_enable; + max_number_of_messages_per_commitment_period = + sc_rollup_max_number_of_messages_per_commitment_period; + }; dal = {constants.dal with feature_enable = dal_enable}; hard_gas_limit_per_block; nonce_revelation_threshold; @@ -591,7 +602,8 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum ?endorsing_reward_per_slot ?baking_reward_bonus_per_slot ?baking_reward_fixed_portion ?origination_size ?blocks_per_cycle ?cycles_per_voting_period ?tx_rollup_enable ?tx_rollup_sunset_level - ?tx_rollup_origination_size ?sc_rollup_enable ?dal_enable + ?tx_rollup_origination_size ?sc_rollup_enable + ?sc_rollup_max_number_of_messages_per_commitment_period ?dal_enable ?hard_gas_limit_per_block ?nonce_revelation_threshold (initial_accounts : (Account.t * Tez.t * Signature.Public_key_hash.t option) list) = @@ -611,6 +623,7 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum ?tx_rollup_sunset_level ?tx_rollup_origination_size ?sc_rollup_enable + ?sc_rollup_max_number_of_messages_per_commitment_period ?dal_enable ?hard_gas_limit_per_block ?nonce_revelation_threshold diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index dc3d70f88721a826b74698d965ab36d7270c1068..ce57cd710fba101fed451684c63ea1e9c08adf2d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -128,6 +128,7 @@ val genesis : ?tx_rollup_sunset_level:int32 -> ?tx_rollup_origination_size:int -> ?sc_rollup_enable:bool -> + ?sc_rollup_max_number_of_messages_per_commitment_period:int -> ?dal_enable:bool -> ?hard_gas_limit_per_block:Gas.Arith.integral -> ?nonce_revelation_threshold:int32 -> @@ -272,6 +273,7 @@ val prepare_initial_context_params : ?tx_rollup_sunset_level:int32 -> ?tx_rollup_origination_size:int -> ?sc_rollup_enable:bool -> + ?sc_rollup_max_number_of_messages_per_commitment_period:int -> ?dal_enable:bool -> ?hard_gas_limit_per_block:Gas.Arith.integral -> ?nonce_revelation_threshold:int32 -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index f4a461f70e4044a96c21312945b2a75b8b2a456d..b102aa4a31ede8e50dda2f9a10fe711696e2bed5 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -449,7 +449,8 @@ let init_gen tup ?rng_state ?commitments ?(initial_balances = []) ?endorsing_reward_per_slot ?baking_reward_bonus_per_slot ?baking_reward_fixed_portion ?origination_size ?blocks_per_cycle ?cycles_per_voting_period ?tx_rollup_enable ?tx_rollup_sunset_level - ?tx_rollup_origination_size ?sc_rollup_enable ?dal_enable + ?tx_rollup_origination_size ?sc_rollup_enable + ?sc_rollup_max_number_of_messages_per_commitment_period ?dal_enable ?hard_gas_limit_per_block ?nonce_revelation_threshold () = let n = tup_n tup in let accounts = @@ -482,6 +483,7 @@ let init_gen tup ?rng_state ?commitments ?(initial_balances = []) ?tx_rollup_sunset_level ?tx_rollup_origination_size ?sc_rollup_enable + ?sc_rollup_max_number_of_messages_per_commitment_period ?dal_enable ?hard_gas_limit_per_block ?nonce_revelation_threshold diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index e9e504eb5f2238c5908a648618184dc1ea0a95e0..66fed3b9e5c5966ee04b024d8c75bad8a91d44a2 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -273,6 +273,7 @@ type 'accounts init := ?tx_rollup_sunset_level:int32 -> ?tx_rollup_origination_size:int -> ?sc_rollup_enable:bool -> + ?sc_rollup_max_number_of_messages_per_commitment_period:int -> ?dal_enable:bool -> ?hard_gas_limit_per_block:Gas.Arith.integral -> ?nonce_revelation_threshold:int32 -> diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml index 071046c2ad161ff18a63452bc1fc7dd0495c439a..3e92585ca863b1db406c396fd9f41213debbcb8f 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml @@ -81,7 +81,15 @@ let assert_equal_z ~loc x y = [sc_rollup_enable] constant is set to true. It returns the created context and contracts. *) let context_init ?(sc_rollup_challenge_window_in_blocks = 10) + ?sc_rollup_max_number_of_messages_per_commitment_period ?(timeout_period_in_blocks = 10) tup = + let max_number_of_messages_per_commitment_period = + match sc_rollup_max_number_of_messages_per_commitment_period with + | None -> + Context.default_test_constants.sc_rollup + .max_number_of_messages_per_commitment_period + | Some v -> v + in Context.init_with_constants_gen tup { @@ -92,6 +100,7 @@ let context_init ?(sc_rollup_challenge_window_in_blocks = 10) Context.default_test_constants.sc_rollup with enable = true; challenge_window_in_blocks = sc_rollup_challenge_window_in_blocks; + max_number_of_messages_per_commitment_period; timeout_period_in_blocks; }; } @@ -1393,7 +1402,25 @@ let test_insufficient_ticket_balances () = output) let test_inbox_max_number_of_messages_per_commitment_period () = - let* block, (account1, account2) = context_init Context.T2 in + let sc_rollup_max_number_of_messages_per_commitment_period = + (* + + We set this parameter constant with a low value for this test + because the default value is too high to be tested. + + This limit exists to implement a (theoretical) defensive + programming scheme against large inbox refutations proofs. It + is theoretical because the lenght of these proofs is + logarithmic in the number of messages. + + *) + 1000 + in + let* block, (account1, account2) = + context_init + ~sc_rollup_max_number_of_messages_per_commitment_period + Context.T2 + in let* block, rollup = sc_originate block account1 "unit" in let* constants = Context.get_constants (B block) in let Constants.Parametric.{max_number_of_messages_per_commitment_period; _} = diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml index beef07429ecd0569e98bffc5c807cafa22c11acd..76c1beaa3bacf437fb21690520722b12c9a31466 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml @@ -46,7 +46,17 @@ let new_context_with_stakers nb_stakers = let*? initial_balances = List.init ~when_negative_length:[] nb_stakers (fun _ -> initial_balance) in - let* b, contracts = Context.init_n ~initial_balances nb_stakers () in + let sc_rollup_max_number_of_messages_per_commitment_period = + (* The default value is too large for testing. *) + 1000 + in + let* b, contracts = + Context.init_n + ~initial_balances + nb_stakers + ~sc_rollup_max_number_of_messages_per_commitment_period + () + in let+ inc = Incremental.begin_construction b in let state = Incremental.validation_state inc in let ctxt = state.ctxt in diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out index 26dade38ca1b1ab478fdc6c76a335585e153b956..d0820eac95fd49ea77d5bc4f82a49251be7e8258 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out @@ -50,7 +50,7 @@ "redundancy_factor": 4, "segment_size": 4096 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, - "sc_rollup_max_number_of_messages_per_commitment_period": 32765, + "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", "sc_rollup_commitment_period_in_blocks": 30, "sc_rollup_max_lookahead_in_blocks": 30000, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out index 147daeffe854454f77a7f097aab23a06b4e3345c..8e88f208fcd9b030e4ee891f8b862a3676f7cc97 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out @@ -50,7 +50,7 @@ "redundancy_factor": 4, "segment_size": 4096 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, - "sc_rollup_max_number_of_messages_per_commitment_period": 32765, + "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", "sc_rollup_commitment_period_in_blocks": 30, "sc_rollup_max_lookahead_in_blocks": 30000, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out index b2b35d89d30c21bde806eacbc568f1b28a06a55c..2e32dff28cc8ee4f041352cff91a0f0de1232220 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out @@ -50,7 +50,7 @@ "redundancy_factor": 4, "segment_size": 4096 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, - "sc_rollup_max_number_of_messages_per_commitment_period": 32765, + "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", "sc_rollup_commitment_period_in_blocks": 30, "sc_rollup_max_lookahead_in_blocks": 30000, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out index f8ede612433b081f139ddfd985d91e4f7340b05e..5b37e1c8add2ba6317807712ea378376e986a2cd 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out @@ -50,7 +50,7 @@ "redundancy_factor": 4, "segment_size": 4096 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, - "sc_rollup_max_number_of_messages_per_commitment_period": 32765, + "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", "sc_rollup_commitment_period_in_blocks": 30, "sc_rollup_max_lookahead_in_blocks": 30000, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out index f8ede612433b081f139ddfd985d91e4f7340b05e..5b37e1c8add2ba6317807712ea378376e986a2cd 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out @@ -50,7 +50,7 @@ "redundancy_factor": 4, "segment_size": 4096 }, "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, - "sc_rollup_max_number_of_messages_per_commitment_period": 32765, + "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", "sc_rollup_commitment_period_in_blocks": 30, "sc_rollup_max_lookahead_in_blocks": 30000, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (no_commitment_publ.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (no_commitment_publ.out index 7bb192ce8263db688e796e1a0a9efe691a29a003..a379c4399ca03eee55b1e7d83642b4fb52c9b08a 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (no_commitment_publ.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (no_commitment_publ.out @@ -106,7 +106,7 @@ This sequence of operations was run: "redundancy_factor": 4, "segment_size": 4096 }, "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 1, - "sc_rollup_max_number_of_messages_per_commitment_period": 32765, + "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", "sc_rollup_commitment_period_in_blocks": 30, "sc_rollup_max_lookahead_in_blocks": 30000, @@ -215,7 +215,7 @@ This sequence of operations was run: "redundancy_factor": 4, "segment_size": 4096 }, "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 1, - "sc_rollup_max_number_of_messages_per_commitment_period": 32765, + "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", "sc_rollup_commitment_period_in_blocks": 30, "sc_rollup_max_lookahead_in_blocks": 30000, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out index 059fa042c164e7c8d2e68010dc7d317e866c599b..18df2c9eb118b7fa0737dd11575efa3731d4023a 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out @@ -106,7 +106,7 @@ This sequence of operations was run: "redundancy_factor": 4, "segment_size": 4096 }, "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 1, - "sc_rollup_max_number_of_messages_per_commitment_period": 32765, + "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", "sc_rollup_commitment_period_in_blocks": 30, "sc_rollup_max_lookahead_in_blocks": 30000, @@ -215,7 +215,7 @@ This sequence of operations was run: "redundancy_factor": 4, "segment_size": 4096 }, "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 1, - "sc_rollup_max_number_of_messages_per_commitment_period": 32765, + "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", "sc_rollup_commitment_period_in_blocks": 30, "sc_rollup_max_lookahead_in_blocks": 30000,