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

refactor: root chunk_id should be equal to app_hash #301

Merged
merged 6 commits into from
Jun 3, 2024

Conversation

ogabrielides
Copy link
Collaborator

@ogabrielides ogabrielides commented Jun 3, 2024

Issue being fixed or feature implemented

What was done?

  • Root chunk id is expected to be equal to app_hash instead of null_hash (This facilitates Tenderdash in state sync init phase)
  • Changed API of appy_chunk to accept separately parameters and not in tuple (better clarity)

How Has This Been Tested?

Updated tutorial replication

Breaking Changes

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@ogabrielides ogabrielides changed the title refactor: root chunk_id should be equal to app_hash refactor: root chunk_id should be equal to app_hash Jun 3, 2024
@@ -346,15 +340,14 @@ impl GroveDb {
// state_sync_info: Consumed StateSyncInfo
// app_hash: Snapshot's AppHash
// tx: Transaction for the state sync
// Returns the first set of global chunk ids that can be fetched from sources (+
// the StateSyncInfo transferring ownership back to the caller)
// Returns the StateSyncInfo transferring ownership back to the caller)
pub fn start_snapshot_syncing<'db>(
&'db self,
mut state_sync_info: MultiStateSyncInfo<'db>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

perhaps could be a &mut without that ownership return trick

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this PR doesn't contain changes of #300

grovedb/src/replication.rs Outdated Show resolved Hide resolved
Comment on lines +123 to +128
if global_chunk_id == app_hash {
let array_of_zeros: [u8; 32] = [0; 32];
let root_chunk_prefix_key: crate::SubtreePrefix = array_of_zeros;
return Ok((root_chunk_prefix_key, vec![]));
}

Copy link
Member

Choose a reason for hiding this comment

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

In rust you shouldn't have special numbers, meaning that [0;32] shouldn't have a special signicance, instead you should use enums or Options

@ogabrielides ogabrielides merged commit 36f7468 into develop Jun 3, 2024
7 checks passed
@ogabrielides ogabrielides deleted the refactor/state_sync_adjustements branch June 3, 2024 18:12
ogabrielides added a commit that referenced this pull request Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants