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

Update cross chain registration command #7657

Closed
Tracked by #7211
ishantiw opened this issue Oct 18, 2022 · 0 comments
Closed
Tracked by #7211

Update cross chain registration command #7657

ishantiw opened this issue Oct 18, 2022 · 0 comments
Assignees
Labels
framework/module/interoperability Interoperability module
Milestone

Comments

@ishantiw
Copy link
Contributor

ishantiw commented Oct 18, 2022

Description

  • Update schema
registrationCCMParamsSchema = {
    "type": "object",
    "required" : [
        "name",
        "messageFeeTokenID"
    ],
    "properties": {
        "name": {
            "dataType": "string",
            "fieldNumber": 1
        },
        "messageFeeTokenID": {
            "dataType": "bytes",
            "length": TOKEN_ID_LENGTH,
            "fieldNumber": 2
        }
    }
}
  • Update verification
def verify(ccu: Transaction, ccm: CCM) -> None:
    if channel(ccm.sendingChainID).inbox.size != 0:
        raise Exception("Registration message must be the first message in the inbox.")

    if ccm.status != CCM_STATUS_CODE_OK:
        raise Exception("Registration message must have status OK.")

    if ownChainAccount.chainID != ccm.receivingChainID:
        raise Exception("Registration message must be sent to the chain account ID of the chain.")

    if ownChainAccount.name != ccm.params.name:
        raise Exception("Registration message must contain the name of the registered chain.")

    if channel(ccm.sendingChainID).messageFeeTokenID != ccm.params.messageFeeTokenID:
        raise Exception("Registration message must contain the same message fee token ID as the chain account.")

    # Processing on the mainchain.
    if ownChainAccount.chainID == CHAIN_ID_MAINCHAIN:
        if ccm.nonce != 0:
            raise Exception("Registration message must have nonce 0.")
    # Processing on a sidechain.
    else:
        if ccm.sendingChainID != CHAIN_ID_MAINCHAIN:
            raise Exception("Registration message must be sent from the mainchain.")
  • Update execute method
def execute(ccu: Transaction, ccm: CCM) -> None:
    # Activate the chain account.
    chainAccount(ccm.sendingChainID).status = CHAIN_STATUS_ACTIVE
    # Emit chain account updated event.
    emitEvent(
        module = MODULE_NAME_INTEROPERABILITY,
        name = EVENT_NAME_CHAIN_ACCOUNT_UPDATED,
        data = chainAccount(ccm.sendingChainID),
        topics = [ccm.sendingChainID]
    )

Acceptance Criteria

  • Should have all the unit tests

Additional Information

@ishantiw ishantiw added the framework/module/interoperability Interoperability module label Oct 18, 2022
@shuse2 shuse2 added this to the Sprint 81 milestone Oct 24, 2022
@Phanco Phanco self-assigned this Oct 27, 2022
@shuse2 shuse2 modified the milestones: Sprint 81, Sprint 82 Nov 7, 2022
ishantiw pushed a commit that referenced this issue Nov 17, 2022
### What was the problem?

This PR resolves #7657 

### How was it solved?

Updated schema `registrationCCMParamsSchema`
Updated `execute` function 
Implemented `verify` function

### How was it tested?

Update unit test and passed
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

No branches or pull requests

3 participants