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 mainchain Message Recovery Command execution #7023

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

Implement mainchain Message Recovery Command execution #7023

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

Comments

@mitsuaki-u
Copy link
Contributor

mitsuaki-u commented Feb 21, 2022

Description

Add message recovery command execution to mainchain interoperability module.

let trsSenderAddress be the address of the trs.senderPublicKey

# Set CCM status to recovered and assign fee to trs sender
updatedCCMs = []
for ccm in deserializedCCMs:
    
    for each module mdl for which beforeRecoverCCM exists:
        mdl.beforeRecoverCCM(trsSenderAddress, ccm)
        if the previous call fails:
            execution fails and trs is invalid
    ccm.status = CCM_STATUS_RECOVERED
    ccm.fee = 0
    push serialized(ccm) to updatedCCMs # CCM is serialized again

# Update sidechain outbox root
proof = { size: terminatedOutboxAccount(trs.params.chainID).outboxSize,
    idxs: trs.params.idxs,
    siblingHashes: trs.params.siblingHashes}

terminatedOutboxAccount(trs.params.chainID).outboxRoot = RMTCalculateRoot([SHA-256(ccmData) for CCMData in updatedCCMs], proof)

# Process recovery
for ccm in deserializedCCMs:
    swap ccm.sendingChainID and ccm.receivingChainID 

    # On sidechain, this case is always triggered and the message logic should be supported
    if ccm.receivingChainID == ownChainAccount.ID:
        if (ccm.moduleID, ccm.crossChainCommandID) is supported:
            call the logic associated with (ccm.moduleID, ccm.crossChainCommandID) on ccm
    elif ownChainAccount.ID == MAINCHAIN_ID:
        # Only send messages to active and live chains
        if (chainAccount(ccm.receivingChainID) exists
            and chainAccount(ccm.receivingChainID).status == CHAIN_ACTIVE 
            and isLive(ccm.receivingChainID):
            addToOutbox(ccm.receivingChainID, ccm)

Acceptance Criteria

  • Add unit tests for message recovery
@ishantiw ishantiw added the framework/module/interoperability Interoperability module label Feb 23, 2022
@milenagojkovic milenagojkovic added this to the Sprint 68 milestone Apr 25, 2022
@mehmetegemen mehmetegemen self-assigned this Apr 25, 2022
@milenagojkovic milenagojkovic linked a pull request Apr 29, 2022 that will close this issue
@milenagojkovic milenagojkovic modified the milestones: Sprint 68, Sprint 69 May 7, 2022
ishantiw added a commit that referenced this issue May 18, 2022
Implement message recovery commands - Closes #7023
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