Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

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
@mehmetegemen mehmetegemen moved this from Backlog to In Progress in Lisk SDK Version 6.0.0 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
@milenagojkovic milenagojkovic moved this from In Progress to Pending Review in Lisk SDK Version 6.0.0 May 12, 2022
ishantiw added a commit that referenced this issue May 18, 2022
Implement message recovery commands - Closes #7023
Repository owner moved this from Pending Review to Done in Lisk SDK Version 6.0.0 May 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
framework/module/interoperability Interoperability module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants