Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve fork config generation for develop. #14285

Merged
merged 15 commits into from
Dec 8, 2023

Conversation

Sventimir
Copy link
Contributor

Explain your changes:

Explain how you tested your changes:

  • CI.

Checklist:

  • Dependency versions are unchanged
    • Notify Velocity team if dependencies must change in CI
  • Modified the current draft of release notes with details on what is completed or incomplete within this project
  • Document code purpose, how to use it
    • Mention expected invariants, implicit constraints
  • Tests were added for the new behavior
    • Document test purpose, significance of failures
    • Test names should reflect their purpose
  • All tests pass (CI will check this if you didn't)
  • Serialized types are in stable-versioned modules
  • Does this close issues? List them

@Sventimir
Copy link
Contributor Author

!ci-build-me

2 similar comments
@Sventimir
Copy link
Contributor Author

!ci-build-me

@Sventimir
Copy link
Contributor Author

!ci-build-me

@Sventimir Sventimir force-pushed the sventimir/fix-fork-generation-develop branch from c932a4b to 2f3f5ab Compare October 12, 2023 14:50
@Sventimir
Copy link
Contributor Author

!ci-build-me

@Sventimir Sventimir force-pushed the sventimir/fix-fork-generation-develop branch from 2f3f5ab to 984d5fa Compare October 13, 2023 08:17
@Sventimir
Copy link
Contributor Author

!ci-build-me

@Sventimir
Copy link
Contributor Author

!ci-build-me

@Sventimir
Copy link
Contributor Author

!ci-build-me

@Sventimir
Copy link
Contributor Author

!ci-build-me

@snaitmouloud-mf
Copy link

@bkase any chance to review this PR ?

Copy link
Member

@bkase bkase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when you hit this graphql endpoint for a node synced to mainnet? Does it hang the node for X seconds? What is X? Something we should keep in mind operationally, though I think we can survive even if it's really slow since only one (or a very small number of) nodes needs to run this

@@ -1,9 +1,21 @@
open Core_kernel

module Fork_config = struct
(* previous_global_slot here is a global slot since genesis. previous
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment bitrot a bit (previous_global_slot renamed)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you inline these comments for each field, that will make it easier to notice when they change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a681c0f.

@Sventimir
Copy link
Contributor Author

!ci-build-me

@Sventimir Sventimir force-pushed the sventimir/fix-fork-generation-develop branch from a681c0f to c83dc68 Compare November 28, 2023 17:54
@Sventimir
Copy link
Contributor Author

!ci-build-me

@@ -2293,15 +2293,6 @@ module Queries = struct
|> Runtime_config.to_yojson |> Yojson.Safe.to_basic )

let fork_config =
let rec map_results ~f = function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map_results ~f xs should be equivalent to List.map ~f xs |> Result.all. In case you find it tedius to define it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it's less efficient, as it iterates over the list twice, doesn't it?

let runtime_config = Mina_lib.runtime_config mina in
match
let open Result.Let_syntax in
let%bind staking_ledger =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a check that the ledger hash of the staking_ledger equal to the staking_epoch.ledger and also the ledger hash of the next_epoch_ledger equal to the next_epoch.ledger.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I obtain a hash from the ledger in order to compare it? I cannot find a function for this in the interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get that by calling Ledger.Any_ledger.M.merkle_root.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 27157c9.

Runtime_config.make_fork_config ~staged_ledger ~global_slot
~staking_ledger ~staking_epoch_seed ~next_epoch_ledger
~next_epoch_seed ~blockchain_length
~protocol_state_hash:protocol_state.previous_state_hash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use the previous_state_hash here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What else should I use? As far as I can see, the protocol_state only contains that and the genesis_state_hash within body, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be the current protocol_state_hash instead of the previous one. You can get the current state_hash by Transition_frontier.Breadcrumb.state_hash best tip.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 27157c9.

@ghost-not-in-the-shell
Copy link
Contributor

Can you expanded a little more on how you tested this PR?

@Sventimir
Copy link
Contributor Author

@ghost-not-in-the-shell , there's an integration test for this in review: #14342. Once it's merged, we can add more checks to it to test this change.

For the time being I tested manually by extracting the runtime config from a running node and started a new network from it. In particular I did synchronise with mainnet, extracted the config and started a berkeley' sandbox network with the state, I had to add an account that I control to the ledger and delegate from all accounts to that one so that I could produce blocks.

}

let ledger_accounts (ledger : Mina_ledger.Ledger.Any_ledger.witness) =
Mina_ledger.Ledger.Any_ledger.M.foldi ~init:[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are just using the foldi here to return a list of accounts. Then why not use the to_list_sequential function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, see 27157c9.

@stevenplatt stevenplatt requested review from bkase and removed request for bkase December 4, 2023 15:28
@stevenplatt
Copy link
Contributor

!ci-build-me

@stevenplatt
Copy link
Contributor

!ci-build-me

@Sventimir Sventimir merged commit ab24cde into develop Dec 8, 2023
1 check passed
@Sventimir Sventimir deleted the sventimir/fix-fork-generation-develop branch December 8, 2023 07:55
@nholland94
Copy link
Member

I'm going to revert this PR as the compatible version was not reviewed yet. The correct order is to have the original PR reviewed first so that changes can be addressed there, before we land any conflict resolving PRs into other branches. The review comments made on this PR should be addressed on the original PR instead, and the review should be finalized there first. Typically, I don't recommend opening merge conflict branches until the first PR is approved in order to avoid this confusion (you will just end up redoing the merge PRs if you have to make changes to the originating PR during review anyway).

nholland94 added a commit that referenced this pull request Jan 2, 2024
…k-generation-develop"

This reverts commit ab24cde, reversing
changes made to 79c6253.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Export genesis ledger for hard fork.
6 participants