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

Improve LIP 0052 - CCM execution, recover, and support functions #483

Closed
mjerkov opened this issue Sep 12, 2023 · 0 comments · Fixed by #477
Closed

Improve LIP 0052 - CCM execution, recover, and support functions #483

mjerkov opened this issue Sep 12, 2023 · 0 comments · Fixed by #477

Comments

@mjerkov
Copy link
Contributor

mjerkov commented Sep 12, 2023

Motivation

The following issues have been noticed in LIP 0052 (with the second bullet point in 1. also present in LIP 0051):

  1. Regarding the execution of the cross-chain transfer CCM on the foreign chain:
  • There is no fee charged in the case of ccm.status != CCM_STATUS_CODE_OK. This means that NFT can be transferred cross-chain to the foreign chain's sender address for free if the CCM status is different than CCM_STATUS_CODE_OK.
  • For clarity, event data for EVENT_NAME_CCM_TRANSFER should include also receivignChainID and sendingChainID, especially for reasons mentioned above.
  1. The recover function will crash if the corresponding NFT substore entry does not exist.
  2. Create and destroy events have inconsistent event data.
  3. The supportAllNFTs function should first check if ALL_SUPPORTED_NFTS_KEY key is already present in the supported NFTs substore.
  4. The removeSupportAllNFTsFromCollection function should check that the ChainID argument is not equal to OWN_CHAIN_ID.

Current Specifications

  1. During the CCM execution on the receiving foreign chain, fee is not charged in the case of ccm.status != CCM_STATUS_CODE_OK. Also, receivingChainID and sendingChainID are not in the event data, i.e. in the ccmTransferEventDataSchema for the event EVENT_NAME_CCM_TRANSFER.
  2. There is no check if the corresponding NFT substore entry exists.
  3. The create event has address, nftID, and collectionID data fields, while destroy has address and nftID data fields.
  4. There is no check if ALL_SUPPORTED_NFTS_KEY key is already present in the supported NFTs substore.
  5. There is no check to ensure that chainID is not equal to OWN_CHAIN_ID.

Proposed Specifications

  1. Add the Fee.payFee method to the code that handles the CCM execution on the foreign receiving chain when ccm.status != CCM_STATUS_CODE_OK:
Fee.payFee(FEE_CREATE_NFT)

Also, add the receivingChainID and sendingChainID in the ccmTransferEventDataSchema for the event EVENT_NAME_CCM_TRANSFER event and update the corresponding code in execution of the cross-chain transfer CCM.

  1. Add the following code to the recover function:
try:
    nft = getNFT(nftID)
except:
    emitFailedRecoverEvent(terminatedChainID, nftID, RESULT_NFT_NOT_FOUND)
    raise Exception("NFT substore entry does not exist")

Also, use the new nft in the code of the recover function where applicable.

  1. Remove collectionID as a data field from the create event.

  2. In supportAllNFTs function, add the following code:

if supportedNFTsStore[ALL_SUPPORTED_NFTS_KEY] exists:
    return
  1. In removeSupportAllNFTsFromCollection function, add the following code:
if chainID == OWN_CHAIN_ID:
    raise Exception("Invalid operation. Support for native NFTs cannot be removed.")

Affected LIPs

0052

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant