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

Implement sidechain State Recovery Initialization Command validation #7035

Closed
Tracked by #6915
mitsuaki-u opened this issue Feb 22, 2022 · 0 comments · Fixed by #7176
Closed
Tracked by #6915

Implement sidechain State Recovery Initialization Command validation #7035

mitsuaki-u opened this issue Feb 22, 2022 · 0 comments · Fixed by #7176
Assignees
Labels
framework/module/interoperability Interoperability module
Milestone

Comments

@mitsuaki-u
Copy link
Contributor

mitsuaki-u commented Feb 22, 2022

Description

Add command to initialize state recovery.

if trs.params.chainID == MAINCHAIN_ID or trs.params.chainID == ownChainAccount.ID:
    return False

# The commands fails if the sidechain is already terminated on this chain
if terminatedStateAccount(trs.params.chainID) exists and terminatedStateAccount(trs.params.chainID).initialized == True:
    return False

let deserializedInteropAccount be the deserialization of trs.params.sidechainChainAccount
# The commands fails if the sidechain is not terminated on the mainchain but the sidechain already violated the liveness requirement
if (deserializedInteropAccount.status != CHAIN_TERMINATED
    and chainAccount(MAINCHAIN_ID).lastCertificate.timestamp - deserializedInteropAccount.lastCertificate.timestamp <= LIVENESS_LIMIT):
    return False

interopAccKey = uint32be(MODULE_ID_INTEROPERABILITY) || STORE_PREFIX_CHAIN_DATA || uint32be(trs.params.chainID)

query = { key: interopAccKey,
          value: SHA-256(trs.params.sidechainChainAccount),
          bitmap: trs.params.bitmap }

proofOfInclusion = { siblingHashes: trs.params.siblingHashes, queries : [query] }

if terminatedStateAccount(trs.params.chainID) exists:
    return SMTVerify([interopAccKey], proofOfInclusion, terminatedStateAccount(trs.params.chainID).mainchainStateRoot)
else:
    return SMTVerify([interopAccKey], proofOfInclusion, chainAccount(MAINCHAIN_ID).lastCertificate.stateRoot)

Acceptance Criteria

  • Add unit tests for recovery initialization
@ishantiw ishantiw added framework/module/interoperability Interoperability module and removed framework labels Feb 23, 2022
@milenagojkovic milenagojkovic added this to the Sprint 68 milestone Apr 25, 2022
@milenagojkovic milenagojkovic modified the milestones: Sprint 68, Sprint 69 May 7, 2022
ishantiw added a commit that referenced this issue May 20, 2022
 Implement sidechain State Recovery Initialization Command validation - Closes #7035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework/module/interoperability Interoperability module
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

5 participants