From 791100d274e2a744b917230e06f6fe86bfec2acd Mon Sep 17 00:00:00 2001 From: emberian Date: Mon, 12 Feb 2024 14:48:13 -0500 Subject: [PATCH 1/6] Update fork.mlh --- src/config/fork.mlh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/fork.mlh b/src/config/fork.mlh index 1380176a044..c09b7b0434c 100644 --- a/src/config/fork.mlh +++ b/src/config/fork.mlh @@ -1,3 +1,3 @@ [%%undef fork_blockchain_length] -[%%undef fork_previous_state_hash] +[%%undef fork_state_hash] [%%undef fork_global_slot_since_genesis] From a267396a833cb971ca3300cc15ab7d4c59e092d6 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 13 Feb 2024 19:31:12 +0000 Subject: [PATCH 2/6] Use the correct values for the fork config In particular: * we want to use the best tip's hash * the genesis block already has blockchain length set to the fork's blockchain length, so we're double counting if we manually attempt to do it here. This change makes these so. It works out actually simpler than the code that was written. --- src/lib/mina_graphql/mina_graphql.ml | 5 +-- src/lib/runtime_config/runtime_config.ml | 39 ++++-------------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index b82e04836c9..a28697bf29d 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -2318,6 +2318,7 @@ module Queries = struct Transition_frontier.Breadcrumb.staged_ledger breadcrumb |> Staged_ledger.ledger in + let state_hash = Transition_frontier.Breadcrumb.state_hash breadcrumb in let protocol_state = Transition_frontier.Breadcrumb.protocol_state breadcrumb in @@ -2372,8 +2373,8 @@ module Queries = struct next_epoch.ledger.hash ) ) ; let%bind new_config = Runtime_config.make_fork_config ~staged_ledger ~global_slot - ~staking_ledger ~staking_epoch_seed ~next_epoch_ledger - ~next_epoch_seed ~blockchain_length ~protocol_state runtime_config + ~state_hash ~staking_ledger ~staking_epoch_seed ~next_epoch_ledger + ~next_epoch_seed ~blockchain_length runtime_config in let%map () = let open Async.Deferred.Infix in diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index 0ec546788e2..26ed25d02b9 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -1456,9 +1456,9 @@ let ledger_of_accounts accounts = ; add_genesis_winner = Some false } -let make_fork_config ~staged_ledger ~global_slot ~blockchain_length - ~protocol_state ~staking_ledger ~staking_epoch_seed ~next_epoch_ledger - ~next_epoch_seed (runtime_config : t) = +let make_fork_config ~staged_ledger ~global_slot ~state_hash ~blockchain_length + ~staking_ledger ~staking_epoch_seed ~next_epoch_ledger ~next_epoch_seed + (runtime_config : t) = let open Async.Deferred.Result.Let_syntax in let global_slot = Mina_numbers.Global_slot_since_hard_fork.to_int global_slot @@ -1474,37 +1474,10 @@ let make_fork_config ~staged_ledger ~global_slot ~blockchain_length |> ledger_accounts in let ledger = Option.value_exn runtime_config.ledger in - let previous_length = - let open Option.Let_syntax in - let%bind proof = runtime_config.proof in - let%map fork = proof.fork in - fork.previous_length + blockchain_length - in - let protocol_constants = Mina_state.Protocol_state.constants protocol_state in - let genesis = - { Genesis.k = - Some - (Unsigned.UInt32.to_int - protocol_constants.Genesis_constants.Protocol.Poly.k ) - ; delta = Some (Unsigned.UInt32.to_int protocol_constants.delta) - ; slots_per_epoch = - Some (Unsigned.UInt32.to_int protocol_constants.slots_per_epoch) - ; slots_per_sub_window = - Some (Unsigned.UInt32.to_int protocol_constants.slots_per_sub_window) - ; genesis_state_timestamp = - Some - (Block_time.to_string_exn protocol_constants.genesis_state_timestamp) - ; grace_period_slots = - Some (Unsigned.UInt32.to_int protocol_constants.grace_period_slots) - } - in let fork = Fork_config. - { previous_state_hash = - Mina_base.State_hash.to_base58_check - protocol_state.Mina_state.Protocol_state.Poly.previous_state_hash - ; previous_length = - Option.value ~default:blockchain_length previous_length + { previous_state_hash = Mina_base.State_hash.to_base58_check state_hash + ; previous_length = blockchain_length ; previous_global_slot = global_slot } in @@ -1539,7 +1512,7 @@ let make_fork_config ~staged_ledger ~global_slot ~blockchain_length artificially add it. In fact, it wouldn't work at all, because the new node would try to create this account at startup, even though it already exists, leading to an error.*) - ~epoch_data ~genesis + ~epoch_data ~ledger: { ledger with base = Accounts accounts From 62f7cc5769bd92eba9c947934d6e9b31ec200910 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 13 Feb 2024 21:24:45 +0000 Subject: [PATCH 3/6] Remove merges-cleanly job for rampup, now that it is retired --- buildkite/src/Jobs/Lint/Merge.dhall | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/buildkite/src/Jobs/Lint/Merge.dhall b/buildkite/src/Jobs/Lint/Merge.dhall index b24b2ebaa09..ffa9c46f1b4 100644 --- a/buildkite/src/Jobs/Lint/Merge.dhall +++ b/buildkite/src/Jobs/Lint/Merge.dhall @@ -52,16 +52,6 @@ Pipeline.build image = (../../Constants/ContainerImages.dhall).toolchainBase } } - , Command.build - Command.Config::{ - commands = [ Cmd.run "buildkite/scripts/merges-cleanly.sh rampup"] - , label = "Check merges cleanly into rampup" - , key = "clean-merge-rampup" - , target = Size.Small - , docker = Some Docker::{ - image = (../../Constants/ContainerImages.dhall).toolchainBase - } - } , Command.build Command.Config::{ commands = [ Cmd.run "true" ] : List Cmd.Type From b29f82b80f66dee2945a68772f4121d1bd4320ac Mon Sep 17 00:00:00 2001 From: ember arlynx Date: Tue, 13 Feb 2024 16:35:44 -0500 Subject: [PATCH 4/6] ignore rampup --- buildkite/src/Jobs/Lint/Merge.dhall | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/buildkite/src/Jobs/Lint/Merge.dhall b/buildkite/src/Jobs/Lint/Merge.dhall index b24b2ebaa09..ffa9c46f1b4 100644 --- a/buildkite/src/Jobs/Lint/Merge.dhall +++ b/buildkite/src/Jobs/Lint/Merge.dhall @@ -52,16 +52,6 @@ Pipeline.build image = (../../Constants/ContainerImages.dhall).toolchainBase } } - , Command.build - Command.Config::{ - commands = [ Cmd.run "buildkite/scripts/merges-cleanly.sh rampup"] - , label = "Check merges cleanly into rampup" - , key = "clean-merge-rampup" - , target = Size.Small - , docker = Some Docker::{ - image = (../../Constants/ContainerImages.dhall).toolchainBase - } - } , Command.build Command.Config::{ commands = [ Cmd.run "true" ] : List Cmd.Type From da28a8b7d67fccc024d9020ce0cb0c203864541e Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 13 Feb 2024 21:34:30 +0000 Subject: [PATCH 5/6] Use the correct values for the fork config In particular: * we want to use the best tip's hash * the genesis block already has blockchain length set to the fork's blockchain length, so we're double counting if we manually attempt to do it here. This change makes these so. It works out actually simpler than the code that was written.# Please enter the commit message for your changes. Lines starting --- src/lib/mina_graphql/mina_graphql.ml | 5 ++-- src/lib/runtime_config/runtime_config.ml | 36 ++++-------------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index 4d19a9278ab..c10d5758021 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -4301,6 +4301,7 @@ module Queries = struct Transition_frontier.Breadcrumb.staged_ledger breadcrumb |> Staged_ledger.ledger in + let state_hash = Transition_frontier.Breadcrumb.state_hash breadcrumb in let protocol_state = Transition_frontier.Breadcrumb.protocol_state breadcrumb in @@ -4355,8 +4356,8 @@ module Queries = struct next_epoch.ledger.hash ) ) ; let%bind new_config = Runtime_config.make_fork_config ~staged_ledger ~global_slot - ~staking_ledger ~staking_epoch_seed ~next_epoch_ledger - ~next_epoch_seed ~blockchain_length ~protocol_state runtime_config + ~state_hash ~staking_ledger ~staking_epoch_seed ~next_epoch_ledger + ~next_epoch_seed ~blockchain_length runtime_config in let%map () = let open Async.Deferred.Infix in diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index e3a5d3df229..0ddb347ef30 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -1293,9 +1293,9 @@ let ledger_of_accounts accounts = ; add_genesis_winner = Some false } -let make_fork_config ~staged_ledger ~global_slot ~blockchain_length - ~protocol_state ~staking_ledger ~staking_epoch_seed ~next_epoch_ledger - ~next_epoch_seed (runtime_config : t) = +let make_fork_config ~staged_ledger ~global_slot ~state_hash ~blockchain_length + ~staking_ledger ~staking_epoch_seed ~next_epoch_ledger ~next_epoch_seed + (runtime_config : t) = let open Async.Deferred.Result.Let_syntax in let global_slot = Mina_numbers.Global_slot.to_int global_slot in let blockchain_length = Unsigned.UInt32.to_int blockchain_length in @@ -1309,34 +1309,10 @@ let make_fork_config ~staged_ledger ~global_slot ~blockchain_length |> ledger_accounts in let ledger = Option.value_exn runtime_config.ledger in - let previous_length = - let open Option.Let_syntax in - let%bind proof = runtime_config.proof in - let%map fork = proof.fork in - fork.previous_length + blockchain_length - in - let protocol_constants = Mina_state.Protocol_state.constants protocol_state in - let genesis = - { Genesis.k = - Some - (Unsigned.UInt32.to_int - protocol_constants.Genesis_constants.Protocol.Poly.k ) - ; delta = Some (Unsigned.UInt32.to_int protocol_constants.delta) - ; slots_per_epoch = - Some (Unsigned.UInt32.to_int protocol_constants.slots_per_epoch) - ; slots_per_sub_window = - Some (Unsigned.UInt32.to_int protocol_constants.slots_per_sub_window) - ; genesis_state_timestamp = - Some (Block_time.to_string protocol_constants.genesis_state_timestamp) - } - in let fork = Fork_config. - { previous_state_hash = - Mina_base.State_hash.to_base58_check - protocol_state.Mina_state.Protocol_state.Poly.previous_state_hash - ; previous_length = - Option.value ~default:blockchain_length previous_length + { previous_state_hash = Mina_base.State_hash.to_base58_check state_hash + ; previous_length = blockchain_length ; previous_global_slot = global_slot } in @@ -1371,7 +1347,7 @@ let make_fork_config ~staged_ledger ~global_slot ~blockchain_length artificially add it. In fact, it wouldn't work at all, because the new node would try to create this account at startup, even though it already exists, leading to an error.*) - ~epoch_data ~genesis + ~epoch_data ~ledger: { ledger with base = Accounts accounts From 32b85639c575225769846534e6692a2ef72db1f5 Mon Sep 17 00:00:00 2001 From: georgeee Date: Wed, 14 Feb 2024 10:48:27 +0100 Subject: [PATCH 6/6] Do not include runtime config into fork export Problem: compiled parameters are explicitly listed in the fork config exported with the Graphql. This may leas to bugs when using the fork config in laucnhing a fork network. Solution: do not include runtime config into fork config. --- src/lib/runtime_config/runtime_config.ml | 30 ++++++++++-------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index d152011f47b..023910dcfa1 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -1338,24 +1338,18 @@ let make_fork_config ~staged_ledger ~global_slot ~state_hash ~blockchain_length { ledger = ledger_of_accounts accounts; seed = next_epoch_seed } ) } in - let update = - make - (* add_genesis_winner must be set to false, because this - config effectively creates a continuation of the current - blockchain state and therefore the genesis ledger already - contains the winner of the previous block. No need to - artificially add it. In fact, it wouldn't work at all, - because the new node would try to create this account at - startup, even though it already exists, leading to an error.*) - ~epoch_data - ~ledger: - { ledger with - base = Accounts accounts - ; add_genesis_winner = Some false - } - ~proof:(Proof_keys.make ~fork ()) () - in - combine runtime_config update + make + (* add_genesis_winner must be set to false, because this + config effectively creates a continuation of the current + blockchain state and therefore the genesis ledger already + contains the winner of the previous block. No need to + artificially add it. In fact, it wouldn't work at all, + because the new node would try to create this account at + startup, even though it already exists, leading to an error.*) + ~epoch_data + ~ledger: + { ledger with base = Accounts accounts; add_genesis_winner = Some false } + ~proof:(Proof_keys.make ~fork ()) () let slot_tx_end_or_default, slot_chain_end_or_default = let f compile get_runtime t =