Fix client activation when ELC updater is enabled#72
Draft
izquierdo-datachain wants to merge 12 commits into
Draft
Fix client activation when ELC updater is enabled#72izquierdo-datachain wants to merge 12 commits into
izquierdo-datachain wants to merge 12 commits into
Conversation
Activating a client requires updating the EKI, which involves: * Registering the enclave key in the counterparty chain. * Confirming that the transaction to register the enclave key in the counterparty was finalized. To confirm finality, the Relayer needs to query the counterparty using GetLatestFinalizedHeader(), then check if the transaction's block height is lower than the finalized height, or not. If ELC updater is not in use, GetLatestFinalizedHeader() queries the origin prover directly. But if ELC updater is in use, it tries to get the latest record available from ELC updater. The problem is that before this commit, ELC updater itself cannot insert any record because: * It needs to update the ELC before any record can be inserted. * To update the ELC, it needs to call SetupHeadersForUpdate() which queries the on-chain light client. * But the on-chain light client is not activated yet, so the state is zeroed-out. So there's a chicken-and-egg problem: activation requires records, but records can't be produced until activation is done. This commit fixes the issue by making ELC updater's call to SetupHeadersForUpdate() query the ELC in LCP instead of querying the on-chain light client when there are no records yet. This works because the ELC has non-zero state when the client creation step of the handshake is done, and it's the same thing that updateELC() does.
This reverts commit 918f98d.
c5358d5 to
2e79492
Compare
This reverts commit 7c9ef04.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Activating a client requires updating the EKI, which involves:
To confirm finality, the Relayer needs to query the counterparty using GetLatestFinalizedHeader(), then check if the transaction's block height is lower than the finalized height, or not.
If ELC updater is not in use, GetLatestFinalizedHeader() queries the origin prover directly. But if ELC updater is in use, it tries to get the latest record available from ELC updater.
The problem is that before this commit, ELC updater itself cannot insert any record because:
So there's a chicken-and-egg problem: activation requires records, but records can't be produced until activation is done.
This commit fixes the issue by making ELC updater's call to SetupHeadersForUpdate() query the ELC in LCP instead of querying the on-chain light client when there are no records yet. This works because the ELC has non-zero state when the client creation step of the handshake is done, and it's the same thing that updateELC() does.