Skip to content

[Move devex] #[entrypoint] annotation with linter enforcement #527

@sblackshear

Description

@sblackshear

It's not currently possible for a Sui Move programmer to distinguish an an entrypoint and a public function that satisfies the entrypoint signature rules. This PR proposes a solution in the form of a linter based on Move source attributes. The idea is that a dev could write something like:

// linter should not complain
#[entrypoint]
public fun valid_entrypoint(o: Object, x: u64, ctx: &mut TxContext) { ... }

// linter should complain
#[entrypoint]
public fun invalid_entrypoint(o: Object): Object { ... }

Suggested approach: integrate this as a source-level linter in sui-move's build command:

  • Build a GlobalEnv for the package being built using this. A GlobalEnv has all sorts of useful info for linters or other tooling--the model.rs file is worth a browse to see what's available.
  • Iterate through the modules being built + their functions, find the ones with entrypoint attributes, enforce the entrypint rules on the signatures of these functions.

Note: this does not solve a related problem: making it impossible to call public functions that satisfy the entrypoint signature rules, but are not intended to be entrypoints. This requires some language changes that will be a bit more work--see proposal here diem/move#76.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions