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 createTerminatedStateAccount internal function #7052

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

Implement createTerminatedStateAccount internal function #7052

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

Comments

@mitsuaki-u
Copy link
Contributor

Description

Add function below to interoperability store:

createTerminatedStateAccount(chainID, stateRoot = None):
    if stateRoot:
        if chainAccount(chainID) exists:
            chainAccount(chainID).status = CHAIN_TERMINATED
            remove the entry with storeKey = uint32be(chainID) from the outbox root substore

        terminatedState = {
            "stateRoot": stateRoot, 
            "mainchainStateRoot": EMPTY_BYTES,
            "initialized": True
        }

    elif chainAccount(chainID) exists:
        chainAccount(chainID).status = CHAIN_TERMINATED
        remove the entry with storeKey = uint32be(chainID) from the outbox root substore

        terminatedState = {
            "stateRoot": chainAccount(chainID).lastCertificate.stateRoot, 
            "mainchainStateRoot": EMPTY_BYTES,
            "initialized": True
        }
    # State root is not available, set it to empty bytes temporarily. 
    # This should only happen on a sidechain.
    else:
        # Processing on the mainchain
        if ownChainAccount.ID == MAINCHAIN_ID:
            # If the account does not exist on the mainchain, the input chainID is invalid.
            return False

        terminatedState = {
            "stateRoot": EMPTY_BYTES,
            "mainchainStateRoot": chainAccount(MAINCHAIN_ID).lastCertificate.stateRoot, 
            "initialized": False
        }

    create an entry in the terminated state substore with 
        storeKey = uint32be(chainID) 
        storeValue = serialization of terminatedState

    return True

Acceptance Criteria

  • Add unit tests for all function paths
@mitsuaki-u mitsuaki-u added the framework/module/interoperability Interoperability module label Feb 24, 2022
@milenagojkovic milenagojkovic added this to the Sprint 64 milestone Feb 28, 2022
@milenagojkovic milenagojkovic modified the milestones: Sprint 64, Sprint 65 Mar 14, 2022
@Incede Incede self-assigned this Mar 24, 2022
@milenagojkovic milenagojkovic modified the milestones: Sprint 65, Sprint 66 Mar 28, 2022
ishantiw added a commit that referenced this issue Apr 4, 2022
 Implement createTerminatedStateAccount internal function - Closes #7052
@ishantiw ishantiw closed this as completed Apr 4, 2022
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.

4 participants