-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description This PR adds a new command line utility that: * Syncs to all end-of-epoch checkpoints found either on a given list or by binary search (less efficient) * Check that a TID in a checkpoint sequence number is valid, based on checking committee certificates on the checkpoint, and print the effects digest. * Prints all events in a TID or the objects with OID * Checks that all types are correct by checking the transactions that created the modules are correct. ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [x] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes Added a basic light client to cryptographically check outcomes of transactions without a full node.
- Loading branch information
Showing
11 changed files
with
1,069 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,3 +65,5 @@ yarn-error.log* | |
# misc | ||
*.key | ||
.env | ||
checkpoints_dir/* | ||
light_client.yaml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,29 @@ | ||
[package] | ||
name = "sui-light-client" | ||
version = "0.0.0" | ||
authors = ["Mysten Labs <build@mystenlabs.com>"] | ||
license = "Apache-2.0" | ||
publish = false | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
async-trait.workspace = true | ||
bcs.workspace = true | ||
bytes.workspace = true | ||
clap.workspace = true | ||
move-core-types.workspace = true | ||
serde.workspace = true | ||
tokio = { workspace = true, features = ["full"] } | ||
serde_yaml.workspace = true | ||
serde_json.workspace = true | ||
sui-types.workspace = true | ||
sui-config.workspace = true | ||
sui-rest-api.workspace = true | ||
sui-json.workspace = true | ||
sui-sdk.workspace = true | ||
move-binary-format.workspace = true | ||
sui-json-rpc-types.workspace = true | ||
sui-package-resolver.workspace = true | ||
workspace-hack.workspace = true | ||
|
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,62 @@ | ||
This crate contains a Command Line Interface light client for Sui. | ||
|
||
# What is a light client? | ||
|
||
A light client allows checking the authenticity and validity of on-chain state, such as transactions, their effects including events and object contents, without the cost of running a full node. | ||
|
||
Running a *full node* requires downloading the full sequence of all transaction and re-executing them. Then the full state of the blockchain is available locally to serve reads. This is however an expensive process in terms of network bandwidth needed to download the full sequence of transactions, as well as CPU to re-execute it, and storage to store the full state of the blockchain. | ||
|
||
Alternatively, a *light client* only needs to download minimal information to authenticate blockchain state. Specifically in Sui, the light client needs to *sync* all end-of-epoch checkpoints that contain information about the committee in the next epoch. Sync involves downloading the checkpoints and checking their validity by checking their certificate. | ||
|
||
Once all end-of-epoch checkpoints are downloaded and checked, any event or current object can be checked for its validity. To do that the light client downloads the checkpoint in which the transaction was executed, and the effects structure that summarizes its effects on the system, including events emitted and objects created. The chain of validity from the checkpoint to the effects and its contents is checked via the certificate on the checkpoint and the hashes of all structures. | ||
|
||
## Ensuring valid data display | ||
|
||
A light client can ensure the correctness of the event and object data using the techniques defined above. However, the light client CLI utility also needs to pretty-print the structures in JSON, which requires knowledge of the correct type for each event or object. Types themselves are defined in modules that have been uploaded by past transactions. Therefore to ensure correct display the light client authenticates that all modules needed to display sought items are also correct. | ||
|
||
# Usage | ||
|
||
The light client requires a config file and a directory to cache checkpoints, and then can be used to check the validity of transaction and their events or of objects. | ||
|
||
## Setup | ||
|
||
The config file for the light client takes a URL for a full node, a directory (that must exist) and within the directory to name of the genesis blob for the Sui network. | ||
|
||
``` | ||
full_node_url: "http://ord-mnt-rpcbig-06.mainnet.sui.io:9000" | ||
checkpoint_summary_dir: "checkpoints_dir" | ||
genesis_filename: "genesis.blob" | ||
``` | ||
|
||
The genesis blob for the Sui mainnet can be found here: https://github.com/MystenLabs/sui-genesis/blob/main/mainnet/genesis.blob | ||
|
||
## Sync | ||
|
||
Every day there is a need to download new checkpoints through sync by doing: | ||
``` | ||
$ sui-light-client --config light_client.yaml sync | ||
``` | ||
|
||
Where `light_client.yaml` is the config file above. | ||
|
||
This command will download all end-of-epoch checkpoints, and check them for validity. They will be cached within the checkpoint summary directory for use by future invocations. | ||
|
||
## Check Transaction | ||
|
||
To check a transaction was executed, as well as the events it emitted do: | ||
``` | ||
$ sui-light-client --config light_client.yaml transaction -t 8RiKBwuAbtu8zNCtz8SrcfHyEUzto6zi6cMVA9t4WhWk | ||
``` | ||
|
||
Where the base58 encoding of the transaction ID is specified. If the transaction has been executed the transaction ID the effects digest are displayed and all the events are printed in JSON. If not an error is printed. | ||
|
||
## Check Object | ||
|
||
To check an object provide its ID in the following way: | ||
|
||
``` | ||
$ sui-light-client --config light_client.yaml object -o 0xc646887891adfc0540ec271fd0203603fb4c841a119ec1e00c469441 | ||
abfc7078 | ||
``` | ||
|
||
The object ID is represented in Hex as displayed in explorers. If the object exists in the latest state it is printed out in JSON, otherwise an error is printed. |
Binary file not shown.
Binary file not shown.
241 changes: 241 additions & 0 deletions
241
crates/sui-light-client/example_config/checkpoints.yaml
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,241 @@ | ||
--- | ||
checkpoints: | ||
- 9769 | ||
- 85168 | ||
- 161191 | ||
- 237073 | ||
- 314159 | ||
- 391106 | ||
- 467715 | ||
- 544977 | ||
- 621932 | ||
- 699409 | ||
- 777073 | ||
- 855529 | ||
- 933558 | ||
- 1012470 | ||
- 1091910 | ||
- 1173702 | ||
- 1256190 | ||
- 1337873 | ||
- 1419253 | ||
- 1501013 | ||
- 1584196 | ||
- 1668109 | ||
- 1751874 | ||
- 1834590 | ||
- 1916297 | ||
- 2000175 | ||
- 2084049 | ||
- 2168005 | ||
- 2250903 | ||
- 2334168 | ||
- 2417421 | ||
- 2495128 | ||
- 2570034 | ||
- 2652538 | ||
- 2735784 | ||
- 2819885 | ||
- 2904615 | ||
- 2989850 | ||
- 3075163 | ||
- 3159887 | ||
- 3242932 | ||
- 3326629 | ||
- 3411439 | ||
- 3497547 | ||
- 3583788 | ||
- 3670032 | ||
- 3756381 | ||
- 3842519 | ||
- 3928856 | ||
- 4013665 | ||
- 4097705 | ||
- 4181848 | ||
- 4265292 | ||
- 4349350 | ||
- 4434571 | ||
- 4520053 | ||
- 4604626 | ||
- 4690286 | ||
- 4775956 | ||
- 4861543 | ||
- 4947195 | ||
- 5032820 | ||
- 5118242 | ||
- 5202725 | ||
- 5288609 | ||
- 5372921 | ||
- 5457660 | ||
- 5542432 | ||
- 5626760 | ||
- 5711370 | ||
- 5797373 | ||
- 5879574 | ||
- 5963033 | ||
- 6046743 | ||
- 6131062 | ||
- 6214826 | ||
- 6299220 | ||
- 6384698 | ||
- 6470176 | ||
- 6555788 | ||
- 6641761 | ||
- 6727742 | ||
- 6813666 | ||
- 6899343 | ||
- 6985580 | ||
- 7071243 | ||
- 7157572 | ||
- 7236855 | ||
- 7320634 | ||
- 7405767 | ||
- 7492092 | ||
- 7578531 | ||
- 7664526 | ||
- 7750844 | ||
- 7837503 | ||
- 7924010 | ||
- 8010882 | ||
- 8097645 | ||
- 8183394 | ||
- 8267271 | ||
- 8352690 | ||
- 8438247 | ||
- 8522890 | ||
- 8607837 | ||
- 8692744 | ||
- 8778859 | ||
- 8865934 | ||
- 8952829 | ||
- 9039835 | ||
- 9127064 | ||
- 9214068 | ||
- 9300670 | ||
- 9387109 | ||
- 9474152 | ||
- 9561269 | ||
- 9648291 | ||
- 9735352 | ||
- 9822167 | ||
- 9908936 | ||
- 9994979 | ||
- 10081675 | ||
- 10167633 | ||
- 10254487 | ||
- 10341483 | ||
- 10428012 | ||
- 10513353 | ||
- 10598015 | ||
- 10682552 | ||
- 10768423 | ||
- 10854304 | ||
- 10940240 | ||
- 11025133 | ||
- 11110103 | ||
- 11194784 | ||
- 11279841 | ||
- 11365521 | ||
- 11449649 | ||
- 11534251 | ||
- 11617930 | ||
- 11703090 | ||
- 11788579 | ||
- 11872271 | ||
- 11954340 | ||
- 12036283 | ||
- 12118867 | ||
- 12203710 | ||
- 12288701 | ||
- 12371056 | ||
- 12455242 | ||
- 12538236 | ||
- 12622207 | ||
- 12707145 | ||
- 12792939 | ||
- 12878539 | ||
- 12964017 | ||
- 13051100 | ||
- 13137943 | ||
- 13225111 | ||
- 13312203 | ||
- 13399384 | ||
- 13486469 | ||
- 13573601 | ||
- 13660779 | ||
- 13747752 | ||
- 13834743 | ||
- 13921887 | ||
- 14008996 | ||
- 14096054 | ||
- 14182989 | ||
- 14269910 | ||
- 14356818 | ||
- 14443761 | ||
- 14530700 | ||
- 14617058 | ||
- 14703203 | ||
- 14790153 | ||
- 14877013 | ||
- 14964004 | ||
- 15050988 | ||
- 15137713 | ||
- 15223813 | ||
- 15310110 | ||
- 15396780 | ||
- 15483660 | ||
- 15570385 | ||
- 15657283 | ||
- 15744204 | ||
- 15831226 | ||
- 15918264 | ||
- 16005062 | ||
- 16091615 | ||
- 16178482 | ||
- 16265597 | ||
- 16352351 | ||
- 16438966 | ||
- 16524785 | ||
- 16611455 | ||
- 16698156 | ||
- 16784805 | ||
- 16871290 | ||
- 16957808 | ||
- 17044258 | ||
- 17131348 | ||
- 17218451 | ||
- 17305557 | ||
- 17392505 | ||
- 17479622 | ||
- 17566665 | ||
- 17653575 | ||
- 17740541 | ||
- 17827321 | ||
- 17914284 | ||
- 18001295 | ||
- 18088340 | ||
- 18175280 | ||
- 18262205 | ||
- 18349168 | ||
- 18435944 | ||
- 18522654 | ||
- 18609656 | ||
- 18696658 | ||
- 18783763 | ||
- 18870895 | ||
- 18957862 | ||
- 19044828 | ||
- 19131908 | ||
- 19219072 | ||
- 19306266 | ||
- 19393285 | ||
- 19480396 | ||
- 19567401 | ||
- 19654408 | ||
- 19741517 | ||
- 19828638 | ||
- 19915729 | ||
- 20002850 | ||
- 20089954 | ||
- 20177021 | ||
- 20264101 |
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,3 @@ | ||
full_node_url: "http://ord-mnt-rpcbig-06.mainnet.sui.io:9000" | ||
checkpoint_summary_dir: "checkpoints_dir" | ||
genesis_filename: "genesis.blob" |
Oops, something went wrong.
ce89a52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sui-typescript-docs – ./sdk/docs
sui-wallet-kit.vercel.app
sui-typescript-docs-git-main-mysten-labs.vercel.app
sui-typescript-docs-mysten-labs.vercel.app
sdk.mystenlabs.com
sui-typescript-docs.vercel.app
sdks.mystenlabs.com
ce89a52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sui-core – ./docs/site
sui-core.vercel.app
sui-core-git-main-sui-foundation.vercel.app
sui-core-sui-foundation.vercel.app
www.docs.sui.io
docs.sui.io