-
Notifications
You must be signed in to change notification settings - Fork 665
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
feat(state-sync): Download state header from external storage #10515
feat(state-sync): Download state header from external storage #10515
Conversation
58d8e48
to
79478f4
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #10515 +/- ##
==========================================
- Coverage 71.92% 71.83% -0.09%
==========================================
Files 720 723 +3
Lines 146747 146893 +146
Branches 146747 146893 +146
==========================================
- Hits 105553 105526 -27
- Misses 36331 36495 +164
- Partials 4863 4872 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
2d94fc1
to
ad4dfd0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I have some readability suggestions and nits. Generally speaking the state sync code is hard to read, it's very nested and convoluted. I would suggest refactoring it later into smaller methods and using early returns to cut down on the nesting.
It's fine for me but I'll let someone more familiar with state sync approve. cc @telezhnaya or @posvyatokum
chain/client/src/sync/state.rs
Outdated
state_parts_arbiter_handle: &ArbiterHandle, | ||
state_parts_mpsc_tx: Sender<StateSyncGetResult>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: mayber rename to state_files_* ? But let's put renaming of existing structs in a new PR.
ad4dfd0
to
7679583
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look, I have addressed the comments I got so far.
chain/client/src/sync/state.rs
Outdated
} | ||
match header_result { | ||
Ok(header) => { | ||
if !shard_sync_download.downloads[0].done { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. I separated the header store logic and the error handling for part and header.
chain/client/src/sync/state.rs
Outdated
epoch_id: &EpochId, | ||
epoch_height: EpochHeight, | ||
chain_id: &str, | ||
semaphore: Arc<Semaphore>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we only have one file to download, we don't need it. I have removed the semaphore for header.
chain/client/src/sync/state.rs
Outdated
@@ -541,34 +593,58 @@ impl StateSync { | |||
/// Makes a StateRequestHeader header to one of the peers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
chain/client/src/sync/state.rs
Outdated
} | ||
match header_result { | ||
Ok(header) => { | ||
if !shard_sync_download.downloads[0].done { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
chain/client/src/sync/state.rs
Outdated
}), | ||
); | ||
} | ||
StateSyncInner::PartsFromExternal { chain_id, semaphore, external } => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
In a previous PR, we have introduced the option to upload the state parts to external storage. In this PR we are changing the way that state sync headers are requested, introducing to download from external storage. The motivation behind this is that sometimes peers may not track all shards making it impossible for them to share the state sync header.
7679583
to
4d1151f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Now that we have both upload and download can you also add a test for it? Either nayduck or integration test would probably work.
part_id: Option<PartId>, | ||
result: Result<StateSyncFileDownloadResult, String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the part id to the inside of StateSyncFileDownloadResult::StatePart?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because in case of error, we would not know which part failed.
chain/client/src/sync/state.rs
Outdated
let (file_type, download_idx) = if let Some(part_id) = part_id { | ||
(StateFileType::part_str(), part_id.idx) | ||
} else { | ||
(StateFileType::header_str(), 0) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the info about the type is duplicated in the result enum and the part id optionality. Ideally it should only be one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
4d1151f
to
f5adcca
Compare
f5adcca
to
1e4ed4f
Compare
The external storage state sync is covered by |
In a previous PR, we have introduced the option to upload the state parts to external storage.
In this PR we are changing the way that state sync headers are requested, introducing to download
from external storage. The motivation behind this is that sometimes peers may not track all shards
making it impossible for them to share the state sync header.
The most important change is in commit #3
I had an rpc node running on mainnet and testnet and it was able to sync. Grafana The long testnet sync header download was because there was not node to upload the state in the external bucket. Node started downloading as soon as I started the uploading node.