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

Add getMessageFeeTokenIDFromCCM method to Interoperability module #437

Merged
merged 5 commits into from
Aug 10, 2023

Conversation

ricott1
Copy link
Contributor

@ricott1 ricott1 commented Aug 4, 2023

Closes #436.

@ricott1 ricott1 requested a review from gkoumout August 7, 2023 13:28
@@ -2551,7 +2551,7 @@ def verifyCrossChainMessage(trs: Transaction, ccm: CCM) -> None:
def beforeCrossChainCommandExecution(trs: Transaction, ccm: CCM) -> None:
relayerAddress = sha256(trs.senderPublicKey)[:ADDRESS_LENGTH]

messageFeeTokenID = Interoperability.getMessageFeeTokenID(ccm.receivingChainID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question to make sure I understand: That means that our previous protocol was wrong because we are already in the receiving chain while running this code, i.e., ccm.receivingChainID = OWN_CHAIN_ID, right?

Btw, while checking this I had a look in the getMessageFeeTokenID function and it seems to me that it does not have the right functionality for sidechains in case it gets as input OWN_CHAIN_ID. See my comment in LIP 45.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. Im wondering if using the sending chain is 'secure' in this sense, or if we should try to get it from the receiving chain in case that fails

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that using the sending chain should be fine, since you run the ccm hooks in case you apply it (then you should be the receiving chain) or forward it. In both cases, the sending chain should be the one defining the channel and hence the message fee token ID correctly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. In the "normal case" of direct channel communication, we are always running this in the receiving chain, so we should be checking the sending chain channel.

For the forwarding it is not that important I guess, this is why we did not pay much attention here: Since all channels between mainchain and sidechains have the same message fee token (no matter if is LSK or anything else in the future), then checking sending/receiving chain should give the same result, so sending chain is also fine. Perhaps we should document that it is very important to maintain this property in the future (i.e., "all channels with mainchain should use the same message fee token"), this is something that auditors were asking I guess..

@@ -1405,6 +1405,13 @@ def getMessageFeeTokenID(chainID: ChainID) -> TokenID:
return channel(chainID).messageFeeTokenID
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment about the old getMessageFeeTokenID function:

In case the arg chainID = OWN_CHAIN_ID and OWN_CHAIN_ID is a sidechain, I guess the intended behavior is to output some error "input chain is own chain", but according to current specs it would just return the messageFeeTokenID used in the channel with mainchain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, which is probably at least misleading. We should probably just return an error as you suggest.

@ricott1 ricott1 requested a review from gkoumout August 9, 2023 08:11
@ricott1
Copy link
Contributor Author

ricott1 commented Aug 9, 2023

Related PR: LiskArchive/lisk-sdk#8806

Copy link
Contributor

@janhack janhack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editorial approval

@janhack janhack merged commit 30c3ebd into main Aug 10, 2023
@janhack janhack deleted the ale_add_getMessageFeeTokenIDFromCCM branch August 10, 2023 09:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add getMessageFeeTokenIDFromCCM method to LIP0045
5 participants