Skip to content

Conversation

@brenzi
Copy link
Collaborator

@brenzi brenzi commented Jan 15, 2024

closes #1570

  • enable fast-sync as well for Target A/B
  • in spite of expectations, fast-sync alone didn't solve Rococo-runtime as target-a panics upon parentchain sync #1547. but we have workarounds in this PR
  • implement failover to DB backup for sealed files
  • implement lockfile-based startup pausing for convenience when working with k8s

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

./integritee-service -c -u ws://172.17.0.1 --target-a-parentchain-rpc-url wss://rococo-rpc.polkadot.io --target-a-parentchain-rpc-port 443 run --skip-ra --dev --shielding-target target_a &> worker1-rococo-live.log 

testing full story locally

# on host
zombienet-linux-x64 spawn --provider native zombienet/rococo-local-with-integritee.toml

# wait > 30 relaychain blocks to see the effect of this PR

# console on docker
./integritee-service -c -u ws://172.17.0.1 --target-a-parentchain-rpc-url ws://172.17.0.1 --target-a-parentchain-rpc-port 9999 run --skip-ra --dev --shielding-target target_a &> worker1-rococo.log

# next docker console
alias relay="./integritee-cli -u ws://172.17.0.1 -p 9999" 
alias integritee="./integritee-cli -u ws://172.17.0.1"
read MRENCLAVE <<< $(integritee list-workers | awk '/  MRENCLAVE: / { print $2; exit }')
echo $MRENCLAVE
alias incognitee="./integritee-cli -u ws://172.17.0.1 trusted --mrenclave $MRENCLAVE"
read VAULT <<< $(incognitee get-shard-vault)
echo $VAULT
relay transfer //Charlie $VAULT 12000000000000
incognitee balance //Charlie
# should be ~12 units after a while
incognitee --direct unshield-funds //Charlie //Charlie2 1000000000000
relay balance //Charlie2
# should be ~1 unit after a while

Comment on lines +154 to +157
warn!("Bad signature on message from {:?}", &signed.id);
// return Err(ClientError::BadJustification(
// "invalid signature for precommit in grandpa justification".to_string(),
// ))
Copy link
Collaborator Author

@brenzi brenzi Jan 15, 2024

Choose a reason for hiding this comment

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

this is a temporary workaround for #1547 but needs to be fixed properly

=> #1574

@brenzi brenzi added A0-core Affects a core part B1-releasenotes C1-low 📌 Does not elevate a release containing this beyond "low priority" E0-breaksnothing labels Jan 15, 2024
Comment on lines 485 to 488
// 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()
//}
Copy link
Collaborator Author

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

@brenzi brenzi marked this pull request as ready for review January 15, 2024 16:35
@brenzi brenzi requested a review from clangenb January 15, 2024 17:12
Copy link
Contributor

@clangenb clangenb left a comment

Choose a reason for hiding this comment

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

LGTM,

Comment on lines +128 to +169
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()
Copy link
Collaborator Author

@brenzi brenzi Jan 16, 2024

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:

  1. delete db.bin and the backup will be restored if available
  2. corrupt db.bin using printf "\x42" | cat - db.bin > db.bin.corrupt and 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)

Copy link
Contributor

@clangenb clangenb left a 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. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-core Affects a core part B1-releasenotes C1-low 📌 Does not elevate a release containing this beyond "low priority" E0-breaksnothing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

derive shard creation header for target A/B too

3 participants