Reorg programming model to be more top-down

First explain how a client interacts with existing programs and why
you'd do that. Next, mention that users can contribute their own programs.
Then explain how those programs can be written in any language.
Finally, mention persistent storage, which is only needed by
stateful programs.
This commit is contained in:
Greg Fitzgerald 2018-12-05 13:54:44 -07:00 committed by Grimes
parent 1bcafca690
commit a29b307554
1 changed files with 13 additions and 14 deletions

View File

@ -1,12 +1,12 @@
# Programming Model
The Solana *runtime* can execute untrusted on-chain programs written in any
programming language that can target the Berkley Packet Filter (BPF) safe
execution environment. The Solana SDK offers the best support for C programs,
which is compiled to BPF using the [LLVM compiler
infrastructure](https://llvm.org). Alternatively, a client might choose to
bypass LLVM and use Python, Lua or C++ to generate BPF directly via the [BPF
Compiler Collection](https://github.com/iovisor/bcc) (BCC).
A client interacts with a Solana cluster by sending it *transactions* with one
or more *instructions*. The Solana *runtime* passes those instructions to
user-contributed *programs*. An instruction might, for example, tell a program
to move *tokens* from one *account* to another or create an interactive
contract that governs how tokens are moved. Instructions are executed
atomically. If any instruction is invalid, any changes made within the
transaction are discarded.
## Deploying Programs to a Cluster
@ -18,13 +18,12 @@ The cluster stores the program locally and makes it available to clients via a
*program ID*. The program ID is a *public key* generated by the client and is
used to reference the program in subsequent transactions.
## Interacting with On-chain Programs
After a program has been deployed, a client utilizes it by sending transactions
to the Solana cluster. A transaction contains one or more *instructions*. Each
instruction references the program ID that corresponds to the program that the
runtime should use to execute it. Instructions are executed atomically. If any
instruction is invalid, any changes made within the transaction are discarded.
A program may be written in any programming language that can target the
Berkley Packet Filter (BPF) safe execution environment. The Solana SDK offers
the best support for C programs, which is compiled to BPF using the [LLVM
compiler infrastructure](https://llvm.org). Alternatively, a client might
choose to bypass LLVM and use Python, Lua or C++ to generate BPF directly via
the [BPF Compiler Collection](https://github.com/iovisor/bcc) (BCC).
## Storing State between Transactions