forked from anza-xyz/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comments and docs on rbpf tests (anza-xyz#52)
* Comments and docs on rbpf tests * Add doc on entrypoint
- Loading branch information
Showing
3 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
external-crates/move/solana/move-mv-llvm-compiler/docs/Entrypoint.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Documentation on entry point as it pertains to solana contracts | ||
|
||
Each solana contract must have an **entrypoint** which receives inputs from the environment. It is similar | ||
to `main` function in C/C++ programs. The runtime/client will prepare the input which entrypoint function receives. | ||
|
||
## Format of entry point | ||
Entry point functions have a specific format and it is generated by the [EntrypointGenerator](https://github.com/anza-xyz/sui/blob/solana/external-crates/move/solana/move-to-solana/src/stackless/entrypoint.rs). | ||
|
||
`ModuleContext::translate` function calls the entry point generator function for *scripts*. | ||
|
||
## Format of input.json file | ||
* - accounts -- a vector of SolanaAccountInfo items. | ||
* - program_id -- SolanaPubkey, and | ||
* - instruction_data -- a byte array that is a list of `(u64, u8*)` i.e., Length of the data (8 bytes) followed by the byte sequence. | ||
|
||
```json | ||
{ | ||
"program_id": "DozgQiYtGbdyniV2T74xMdmjZJvYDzoRFFqw7UR5MwPK", | ||
"accounts": [ | ||
{ | ||
"key": "524HMdYYBy6TAn4dK5vCcjiTmT2sxV6Xoue5EXrz22Ca", | ||
"owner": "BPFLoaderUpgradeab1e11111111111111111111111", | ||
"is_signer": false, | ||
"is_writable": true, | ||
"lamports": 1000, | ||
"data": [0, 0, 0, 3] | ||
} | ||
], | ||
"instruction_data": [ | ||
11, 0, 0, 0, 0, 0, 0, 0, | ||
104, 101, 108, 108, 111, 95, 95, 109, 97, 105, 110] | ||
} | ||
``` | ||
|
||
## Single entry point vs. multiple entry points | ||
Move contracts can have multiple entry points. A specific entry point can be called | ||
by specifying the entrypoint name in instruction_data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters