-
Notifications
You must be signed in to change notification settings - Fork 46
fast-sync targetA/B #1573
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
fast-sync targetA/B #1573
Conversation
| warn!("Bad signature on message from {:?}", &signed.id); | ||
| // return Err(ClientError::BadJustification( | ||
| // "invalid signature for precommit in grandpa justification".to_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.
enclave-runtime/src/lib.rs
Outdated
| // until fixed properly, we deactivate it altogether in the scope of #1547 | ||
| //if let Err(e) = validate_events(&events_proofs_to_sync, &blocks_to_sync_merkle_roots) { | ||
| // return e.into() | ||
| //} |
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 this causes ParentChainValidation(WrongValue) we skip this for now. needs fixing in #1518 anyway
clangenb
left a comment
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,
| Ok(unseal(self.db_path()) | ||
| .or_else(|e| { | ||
| warn!( | ||
| "can't unseal db at {:?}. error {:?}. trying backup at {:?}", | ||
| self.db_path(), | ||
| e, | ||
| self.backup_path() | ||
| ); | ||
| // create a copy because we will overwrite the db in the next step | ||
| fs::copy(self.db_path(), self.db_path().with_extension("cantunseal")).and_then( | ||
| |_| { | ||
| fs::copy(self.backup_path(), self.db_path()).and_then(|_| { | ||
| unseal(self.db_path()).map_err(|e| { | ||
| warn!("{:?}", e); | ||
| e | ||
| }) | ||
| }) | ||
| }, | ||
| ) | ||
| }) | ||
| .map(|b| Decode::decode(&mut b.as_slice()))??) | ||
| } | ||
|
|
||
| // checks if either the db or its backup can be opened in opaque mode (no unseal) | ||
| fn exists(&self) -> bool { | ||
| SgxFile::open(self.db_path()).is_ok() | ||
| debug!("check if db exists at {:?}", self.db_path()); | ||
| fs::File::open(self.db_path()) | ||
| .or_else(|e| { | ||
| warn!( | ||
| "can't open db at {:?}. error: {:?}. trying restore backup at {:?}", | ||
| self.db_path(), | ||
| e, | ||
| self.backup_path() | ||
| ); | ||
| fs::copy(self.backup_path(), self.db_path()) | ||
| .and_then(|_| fs::File::open(self.db_path())) | ||
| .map_err(|e| { | ||
| warn!("{:?}", e); | ||
| e | ||
| }) | ||
| }) | ||
| .is_ok() |
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.
we finally automate backup restore for sealed db's
while this would merit unit testing, what I manually tested is:
- delete
db.binand the backup will be restored if available - corrupt
db.binusingprintf "\x42" | cat - db.bin > db.bin.corruptand the backup will be restored if available
untested: what if unseal works, but decode doesn't (is this plausible at all? -> yes, if the new enclave changed types. but then the backup is worthless too)
clangenb
left a comment
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! I can see that you tried to be very functional. ;)
…de ETA for syncing parentchains
closes #1570
testing rococo sync
allow plenty of time to fetch the first 1000 blocks.
I was able to import the first chunk of 1000 blocks with this within 10min
testing full story locally