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

[Move] Move disassembler gets function signatures wrong #1973

Closed
sblackshear opened this issue May 16, 2022 · 1 comment · Fixed by #1976
Closed

[Move] Move disassembler gets function signatures wrong #1973

sblackshear opened this issue May 16, 2022 · 1 comment · Fixed by #1976
Assignees
Labels
Priority: High Very important task, not blocking but potentially delaying milestones or limiting our offering Type: Bug Something isn't working

Comments

@sblackshear
Copy link
Collaborator

sblackshear commented May 16, 2022

Take a look at https://explorer.devnet.sui.io/objects/0x8d5a425ca0b1fbaac4d89c3d0847af7ca60603e1 (disassembled bytecode from the M1 package from tutorial) vs the source code from the tutorial. A lot of the function signatures do not match--e.g., sword_create(&mut Forge) in the bytecode vs sword_create(&mut Forge, u64, u64, address, &mut TxContext) in the source.

The bug is clearly in the disassembler, since you can invoke sword_create via wallet call with the 4 specified arguments, and wallet object shows the same incorrect signature:

λ wallet object --id 0x8d5a425ca0b1fbaac4d89c3d0847af7ca60603e1 --json
{
  "contents": {
    "M1": "// Move bytecode v5\nmodule 8d5a425ca0b1fbaac4d89c3d0847af7ca60603e1.M1 {\nstruct Forge has store, key {\n\tid: VersionedID,\n\tswords_created: u64\n}\nstruct Sword has store, key {\n\tid: VersionedID,\n\tmagic: u64,\n\tstrength: u64\n}\n\ninit(loc0: &mut TxContext) {\nB0:\n\t0: CopyLoc[0](Arg0: &mut TxContext)\n\t1: Call[6](new_id(&mut TxContext): VersionedID)\n\t2: LdU64(0)\n\t3: Pack[0](Forge)\n\t4: StLoc[1](loc0: Forge)\n\t5: MoveLoc[1](loc0: Forge)\n\t6: MoveLoc[0](Arg0: &mut TxContext)\n\t7: FreezeRef\n\t8: Call[7](sender(&TxContext): address)\n\t9: Call[0](transfer<Forge>(Forge, address))\n\t10: Ret\n}\npublic magic(): u64 {\nB0:\n\t0: MoveLoc[0](Arg0: &Sword)\n\t1: ImmBorrowField[0](Sword.magic: u64)\n\t2: ReadRef\n\t3: Ret\n}\npublic strength(): u64 {\nB0:\n\t0: MoveLoc[0](Arg0: &Sword)\n\t1: ImmBorrowField[1](Sword.strength: u64)\n\t2: ReadRef\n\t3: Ret\n}\npublic(script) sword_create(loc0: &mut Forge) {\nB0:\n\t0: MoveLoc[4](Arg4: &mut TxContext)\n\t1: Call[6](new_id(&mut TxContext): VersionedID)\n\t2: MoveLoc[1](Arg1: u64)\n\t3: MoveLoc[2](Arg2: u64)\n\t4: Pack[1](Sword)\n\t5: StLoc[5](loc0: Sword)\n\t6: MoveLoc[5](loc0: Sword)\n\t7: MoveLoc[3](Arg3: address)\n\t8: Call[1](transfer<Sword>(Sword, address))\n\t9: CopyLoc[0](Arg0: &mut Forge)\n\t10: ImmBorrowField[2](Forge.swords_created: u64)\n\t11: ReadRef\n\t12: LdU64(1)\n\t13: Add\n\t14: MoveLoc[0](Arg0: &mut Forge)\n\t15: MutBorrowField[2](Forge.swords_created: u64)\n\t16: WriteRef\n\t17: Ret\n}\npublic(script) sword_transfer() {\nB0:\n\t0: MoveLoc[0](Arg0: Sword)\n\t1: MoveLoc[1](Arg1: address)\n\t2: Call[1](transfer<Sword>(Sword, address))\n\t3: Ret\n}\npublic swords_created(): u64 {\nB0:\n\t0: MoveLoc[0](Arg0: &Forge)\n\t1: ImmBorrowField[2](Forge.swords_created: u64)\n\t2: ReadRef\n\t3: Ret\n}\n}"
  },
  "owner": "Immutable",
  "tx_digest": "1QesgzISV1jlfQ309pg/QTaILBCT5ZyERaUxSEnc4nw="
}

This is very important to fix, because otherwise folks looking at function signatures in the explorer are going to get very confused.

@sblackshear sblackshear added Type: Bug Something isn't working Priority: Critical This task must be completed or something bad will happen e.g. missing a major milestone, major bug Priority: High Very important task, not blocking but potentially delaying milestones or limiting our offering and removed Priority: Critical This task must be completed or something bad will happen e.g. missing a major milestone, major bug labels May 16, 2022
@sblackshear sblackshear self-assigned this May 16, 2022
@sblackshear
Copy link
Collaborator Author

sblackshear commented May 16, 2022

move-language/move#142 to fix on the Move side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High Very important task, not blocking but potentially delaying milestones or limiting our offering Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant