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

Investigate and implement sui-specific native calls #411

Open
brson opened this issue Feb 1, 2024 · 3 comments · May be fixed by #418 or #419
Open

Investigate and implement sui-specific native calls #411

brson opened this issue Feb 1, 2024 · 3 comments · May be fixed by #418 or #419
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@brson
Copy link
Collaborator

brson commented Feb 1, 2024

We are in the process of migrating to the sui codebase. There are likely new native function calls on sui that we do not implement, either in std or in their own sui library.

Look into this and see what we need to add to move-native to make this work.

If there are natives called by sui directly they should probably live in a new sui module inside of move-native, as the calls used by std live in a corresponding std module.

@brson brson added enhancement New feature or request help wanted Extra attention is needed labels Feb 1, 2024
@ksolana
Copy link
Collaborator

ksolana commented Mar 3, 2024

Seems like there are two parts to it

  1. make sure all the methods are there e.g. there is bcs::native_to_bytes in both move/move-native as well as sui/move/move-native so we count it as being there
  2. make sure all the methods implement the same thing. Most methods in sui have been modified for the cost/gas calculations. We can do this in a follow up step once the migration is complete.

@ksolana
Copy link
Collaborator

ksolana commented Mar 3, 2024

For step#1.

Comparing all the files.

ls sui/external-crates/move/crates/move-stdlib/src/natives/
bcs.rs       debug.rs     hash.rs      helpers.rs   mod.rs       signer.rs    string.rs    type_name.rs unit_test.rs vector.rs

ls move/language/move-stdlib/src/natives/
bcs.rs       event.rs     helpers.rs   signer.rs    type_name.rs vector.rs
debug.rs     hash.rs      mod.rs       string.rs    unit_test.rs

Seems like move/move-stdlib has one extra file event.rs

Comparing for presence of methods in these files. Methods should at least have the same signature.

  • bcs.rs
  • debug.rs
    • New functions: native_print_nop, native_print_stack_trace_nop
    • Different signatures: make_native_print, make_native_print_stack_trace, make_all
    • Others: Change in scope of some imported types like MoveStructLayout etc.
  • hash.rs
  • helpers.rs
  • mod.rs
    • New functions: unit_test:PoisionGasParameters
  • signer.rs
  • string.rs
  • type_name.rs
    • New functions: make_native_get
    • Different signatures: native_get
  • unit_test.rs
    • New functions: native_poison, make_native_poison
    • Others: New class PoisonGasParameters, GasParameters has one more param poison
  • vector.rs

@ksolana
Copy link
Collaborator

ksolana commented Mar 9, 2024

There are two native functions that are absent in move-language/move(after checking out @brson's updated branch)

// from crates/mysten-util-mem/src/allocators.rs
// Linux/BSD call system allocator (currently malloc).
pub unsafe extern "C" fn malloc_usable_size(_ptr: *const c_void) -> usize
// from crates/mysten-util-mem/src/malloc_size.rs
pub type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize

This is used for calling size_of for various allocations. All the various size_of implementations are in https://github.com/MystenLabs/sui/tree/main/crates/mysten-util-mem.

Do we still want to implement(import) them in move-native?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
2 participants