Skip to content

Commit

Permalink
SVM: add a sample stand-alone application based on SVM
Browse files Browse the repository at this point in the history
  • Loading branch information
dmakarov committed Jul 31, 2024
1 parent 27c9796 commit afb7732
Show file tree
Hide file tree
Showing 17 changed files with 15,336 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ members = [
"zk-token-sdk",
]

exclude = ["programs/sbf", "svm/tests/example-programs"]
exclude = [
"programs/sbf",
"svm/json-rpc-example/json-rpc-client",
"svm/json-rpc-example/json-rpc-program",
"svm/json-rpc-example/json-rpc-server",
"svm/tests/example-programs",
]

resolver = "2"

Expand Down
31 changes: 31 additions & 0 deletions svm/json-rpc-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
This is an example application using SVM to implement a tiny subset of
Solana RPC protocol for the purpose of simulating transaction
execution without having to use the entire Solana Runtime.

The exmample consists of two host applications
- json-rpc-server -- the RPC server that accepts incoming RPC requests
and performs transaction simulation sending back the results,
- json-rpc-client -- the RPC client program that sends transactions to
json-rpc-server for simulation,

and

- json-rpc-program is the source code of on-chain program that is
executed in a transaction sent by json-rpc-client.

To run the example, compile the json-rpc-program with `cargo
build-sbf` command. Using solana-test-validator create a ledger, or
use an existing one, and deploy the compiled program to store it in
the ledger. Using agave-ledger-tool dump ledger accounts to a file,
e.g. `accounts.out`. Now start the json-rpc-server, e.g.
```
cargo run --manifest-path json-rpc-server/Cargo.toml -- -l test-ledger -a accounts.json
```

Finally, run the client program.
```
cargo run --manifest-path json-rpc-client/Cargo.toml -- -C config.yml -k json-rpc-program/target/deploy/helloworld-keypair.json -u localhost
```

The client will communicate with the server and print the responses it
recieves from the server.
7 changes: 7 additions & 0 deletions svm/json-rpc-example/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
json_rpc_url: http://127.0.0.1:8899
websocket_url: ''
keypair_path: svm/examples/test.json
address_labels:
'11111111111111111111111111111111': System Program
commitment: confirmed
Loading

0 comments on commit afb7732

Please sign in to comment.