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

Implement sendInternal method in interoperability store #7040

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

Implement sendInternal method in interoperability store #7040

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

Comments

@mitsuaki-u
Copy link
Contributor

mitsuaki-u commented Feb 23, 2022

Description

Create and send a cross chain message:

sendInternal(feeAddress, moduleID, crossChainCommandID, receivingChainID, fee, status, params):
    # Processing on the mainchain
    if ownChainAccount.ID == MAINCHAIN_ID:
        # Chain has to exist on mainchain
        if chainAccount(receivingChainID) does not exists:
            return False
        partnerChainID = receivingChainID
    # Processing on a sidechain
    else:
        # Check for direct channel
        if chainAccount(receivingChainID) does not exists:
            partnerChainID = mainchainID
        else:
            partnerChainID = receivingChainID

    # Chain must be live; This checks is always on the receivingChainID
    if not isLive(receivingChainID):
        return False
    # Chain status must be active
    if not chainAccount(partnerChainID).status == CHAIN_ACTIVE:
        return False

    # Create cross-chain message
    ccm = {
        "nonce": ownChainAccount.nonce,
        "moduleID": moduleID,
        "crossChainCommandID": crossChainCommandID,
        "sendingChainID": ownChainAccount.ID,
        "receivingChainID": receivingChainID,
        "fee": fee,
        "status": status,
        "params": params
    }

    if validateFormat(ccm) == False:
        return False

    for each module mdl for which beforeSendCCM exists:
        mdl.beforeSendCCM(feeAddress, ccm)
        if the previous call fails:
            return False

    addToOutbox(partnerChainID, ccm)
    ownChainAccount.nonce += 1
    
    return True

Acceptance Criteria

  • Add unit tests for sendInternal
@ishantiw ishantiw added framework/module/interoperability Interoperability module and removed framework labels Feb 23, 2022
@mitsuaki-u mitsuaki-u changed the title Implement sendInternal method in interop store Implement sendInternal method in interoperability store Feb 23, 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
@ishantiw ishantiw self-assigned this Mar 22, 2022
@milenagojkovic milenagojkovic modified the milestones: Sprint 65, Sprint 66 Mar 28, 2022
ishantiw added a commit that referenced this issue Mar 30, 2022
Implement sendInternal function for mainchain/sidechain stores - Closes #7040
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.

3 participants