Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the move module for cross-chain airdrop #623

Merged
merged 3 commits into from
Mar 10, 2022
Merged

Conversation

666lcz
Copy link
Contributor

@666lcz 666lcz commented Mar 2, 2022

This PR implements the Move component as mentioned in the NFT Mirroring design doc . The goal of this PR is not to write a rigorous and production ready contract with all the features in ERC-721 standard, but just to have a minimal version to unblock the MVP before GDC.

The major TODOs are(in separate PRs)

  • Represent token_id in u256 (see discussion in [RFC] Add Starcoin-framework as a dependency #616)
  • Implement the Sparse Set. Right now the time complexity for checking the uniqueness of (eth_contract_address, eth_token_id) is O(M+N) where M is the number of mirrored ETH contracts and N is the max number of claimed token ids for a given eth contract address). Implementing the sparse set will reduce the time complexity to O(1) but will take more efforts.

@666lcz
Copy link
Contributor Author

666lcz commented Mar 2, 2022

I received the following compiler error

➜ cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.51s
     Running unittests (/Users/cl/ml/fastnft/target/debug/deps/sui_framework-e9d21590967f6d70)

running 2 tests
bug[ICE12001]: BYTECODE GENERATION FAILED
  ┌─ /Users/cl/ml/fastnft/sui_programmability/framework/../examples/../framework/sources/CrossChainAirdrop.move:5:13
  │
5 │ module Sui::CrossChainAirdrop {
  │             ^^^^^^^^^^^^^^^^^ IR ERROR: TODO Structs are not *yet* supported in constant type layouts

error: test failed, to rerun pass '--lib'

Does anyone know what does this mean?

UPDATE:

resolved in https://mysten-labs.slack.com/archives/C02DRAL32GN/p1646256086677789

@666lcz 666lcz force-pushed the chris/erc721 branch 2 times, most recently from 7279caf to bc50f45 Compare March 2, 2022 23:39
@666lcz 666lcz marked this pull request as ready for review March 2, 2022 23:52
@666lcz 666lcz force-pushed the chris/erc721 branch 2 times, most recently from c40db39 to 3bb6d4a Compare March 3, 2022 03:31
Copy link
Contributor

@lxfind lxfind left a comment

Choose a reason for hiding this comment

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

Very nice!
A few nits.

Copy link
Contributor

@oxade oxade left a comment

Choose a reason for hiding this comment

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

Hard requirement: TxContext must be last arg for entry functions.
Format is: [ObjectArgs.... Pure/Primitive Args... TxContext]

@666lcz 666lcz requested a review from oxade March 4, 2022 22:21
Copy link
Contributor

@oxade oxade left a comment

Choose a reason for hiding this comment

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

Another request:
Sorry for holding up the PR.
I think if a module has entry functions it is important that we test exercising the functions from systems outside of Move (CLI tests, Client unit tests, Authority unit tests, etc) for the following reasons:

  1. It shows others how to use the contract without understanding Move details
  2. It proves that the contract entry functions are conformant
  3. It helps us exercise our linter (and in future pre-execution logic)

For examples see https://github.com/MystenLabs/fastnft/blob/main/sui/src/unit_tests/cli_tests.rs#L557
https://github.com/MystenLabs/fastnft/blob/main/sui_core/src/unit_tests/client_tests.rs#L855

@666lcz 666lcz requested a review from oxade March 9, 2022 06:09
let fields = &token["contents"]["fields"];
assert_eq!(fields["source_token_id"]["fields"]["id"], SOURCE_TOKEN_ID);

// TODO: verify the other string fields once SuiJSON has better support for rendering
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can still compare ASCII bytes right?

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 have a hard time figuring out how to convert serde_json::Value to bytes, let me know if you know how to do it

Copy link
Contributor

@oxade oxade left a comment

Choose a reason for hiding this comment

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

Looks good!
Only a some renaming nits that may cause ambiguity, and one test case that could be more complete, but overall looks good, thanks for updating the tests!

@666lcz 666lcz merged commit 3566aed into main Mar 10, 2022
@666lcz 666lcz deleted the chris/erc721 branch March 10, 2022 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants