Skip to content

Commit

Permalink
fix readme instructions and test data to run correctly when tutorial …
Browse files Browse the repository at this point in the history
…is followed step by step (#479)

Co-authored-by: dubbelosix <[email protected]>
  • Loading branch information
dubbelosix authored Jul 7, 2023
1 parent 8e4cc3e commit 369d639
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 38 deletions.
2 changes: 1 addition & 1 deletion examples/const-rollup-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// The rollup stores its data in the namespace b"sov-test" on Celestia.
pub const ROLLUP_NAMESPACE_RAW: [u8; 8] = [115, 111, 118, 45, 116, 101, 115, 116];
pub const SEQUENCER_DA_ADDRESS: [u8; 47] = *b"celestia1qp09ysygcx6npted5yc0au6k9lner05yvs9208";
pub const SEQUENCER_DA_ADDRESS: [u8; 47] = *b"celestia1u5duzsla6ugarucp2n8s227dvspkavz8mt6xz4";
2 changes: 1 addition & 1 deletion examples/demo-rollup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ build-sov-cli:
cd ../demo-stf && cargo build --bin sov-cli

test-serialize-create-token: check-container-running build-sov-cli
$(SOV_CLI_REL_PATH) serialize-call ../demo-stf/src/sov-cli/test_data/minter_private_key.json Bank ../demo-stf/src/sov-cli/test_data/create_token.json 0
$(SOV_CLI_REL_PATH) serialize-call ../demo-stf/src/sov-cli/test_data/token_deployer_private_key.json Bank ../demo-stf/src/sov-cli/test_data/create_token.json 0

test-build-blob-from-create-token: test-serialize-create-token
$(SOV_CLI_REL_PATH) make-blob ../demo-stf/src/sov-cli/test_data/create_token.dat > ../demo-stf/src/sov-cli/test_data/test_blob.dat
Expand Down
54 changes: 25 additions & 29 deletions examples/demo-rollup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,37 +192,33 @@ pub enum CallMessage<C: sov_modules_api::Context> {
},
}
```
In the above snippet, we can see that `CallMessage`s in `Bank` support five different types of calls. The `sov-cli` has the ability to parse a JSON file that aligns with any of these calls and subsequently serialize them. The structure of the JSON file, which represents the call, closely mirrors that of the Enum member. Consider the `CreateToken` message as an example:
In the above snippet, we can see that `CallMessage`s in `Bank` support five different types of calls. The `sov-cli` has the ability to parse a JSON file that aligns with any of these calls and subsequently serialize them. The structure of the JSON file, which represents the call, closely mirrors that of the Enum member. Consider the `Transfer` message as an example:
```rust
CreateToken {
/// Random value use to create a unique token address.
salt: u64,
/// The name of the new token.
token_name: String,
/// The initial balance of the new token.
initial_balance: Amount,
/// The address of the account that the new tokens are minted to.
minter_address: C::Address,
/// Authorized minter list.
authorized_minters: Vec<C::Address>,
}
Transfer {
/// The address to which the tokens will be transferred.
to: C::Address,
/// The amount of tokens to transfer.
coins: Coins<C>,
}
```
Here's an example of a JSON representing the above call:
```json
{
"CreateToken": {
"salt": 11,
"token_name": "sov-test-token",
"initial_balance": 1000,
"minter_address": "sov15vspj48hpttzyvxu8kzq5klhvaczcpyxn6z6k0hwpwtzs4a6wkvqmlyjd6",
"authorized_minters": ["sov15vspj48hpttzyvxu8kzq5klhvaczcpyxn6z6k0hwpwtzs4a6wkvqmlyjd6"]
"Transfer":{
"to":"sov1zgfpyysjzgfpyysjzgfpyysjzgfpyysjzgfpyysjzgfpyysjzgfqve8h6h",
"coins":{
"amount":200,
"token_address":"sov1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27svq9m72"
}
}
}
```
The JSON above is the contents of the file `demo-stf/src/sov-cli/test_data/create_token.json`. We'll use this transaction as our example for the rest of the tutorial. In order to serialize the transaction JSON to submit to our local Celestia node, we need to perform 2 operations:
The JSON above is the contents of the file `demo-stf/src/sov-cli/test_data/transfer.json`. We'll use this transaction as our example for the rest of the tutorial. In order to serialize the transaction JSON to submit to our local Celestia node, we need to perform 2 operations:
- Serialize the JSON representation of the transaction.
- Bundle serialized transaction files into a blob (since DA layers accept blobs which can contain multiple transactions).

NOTE: We use transfer as an example here because we already created the token as part of the sanity check above using `make test-create-token`

To serialize transactions, `sov-cli` has a `serialize-call` subcommand, which has the following structure:
```
$ ./target/debug/sov-cli serialize-call -h
Expand All @@ -236,16 +232,16 @@ Arguments:
<CALL_DATA_PATH> Path to the json file containing the parameters for a module call
<NONCE> Nonce for the transaction
```
For our test, we'll use the test private key located at `examples/demo-stf/src/sov-cli/test_data/minter_private_key.json`. This private key also corresponds to the address used in the `minter_address` and `authorized_minters` fields of the `create_token.json` file.
For our test, we'll use the test private key located at `examples/demo-stf/src/sov-cli/test_data/minter_private_key.json`. This private key also corresponds to the address used in the `minter_address` field of the `create_token.json` file. This was the address that `make test-create-token` minted the new tokens to.

2. Lets go ahead and serialize the transaction:
```
$ ./target/debug/sov-cli serialize-call ./examples/demo-stf/src/sov-cli/test_data/minter_private_key.json Bank ./examples/demo-stf/src/sov-cli/test_data/create_token.json 1
$ ./target/debug/sov-cli serialize-call ./examples/demo-stf/src/sov-cli/test_data/minter_private_key.json Bank ./examples/demo-stf/src/sov-cli/test_data/transfer.json 0
```
Once the above command executes successfully, there should be a file named `./examples/demo-stf/src/sov-cli/test_data/create_token.dat`:
Once the above command executes successfully, there should be a file named `./examples/demo-stf/src/sov-cli/test_data/transfer.dat`:
```
$ cat ./examples/demo-stf/src/sov-cli/test_data/create_token.dat
7cb06da843cb98a223cdd4aee61ea4533f99104fe03144720d75800580d9a665be112c73b8d0b02b8de73f678d2432e93f613071e6fd04cc96b6ab5e6952bf007b758bf2e7670fafaf6bf0015ce0ff5aa802306fc7e3f45762853ffc37180fe66800000001000b000000000000000e000000736f762d746573742d746f6b656ee803000000000000a3201954f70ad62230dc3d840a5bf767702c04869e85ab3eee0b962857ba759801000000a3201954f70ad62230dc3d840a5bf767702c04869e85ab3eee0b962857ba75980100000000000000
$ cat ./examples/demo-stf/src/sov-cli/test_data/transfer.dat
725f40c15bed53b271e23dccbbb61736a55a5dd7cf79a31dec928c664c55d6e00f8afb3273bf7ec3409187a848edfed9991ed3126bdca048361aecc3349a180f7b758bf2e7670fafaf6bf0015ce0ff5aa802306fc7e3f45762853ffc37180fe64a00000000011212121212121212121212121212121212121212121212121212121212121212c800000000000000135d23aee8cb15c890831ff36db170157acaac31df9bba6cd40e7329e608eabd0000000000000000
```
The above is the hex representation of the serialized transaction. There is another subcommand for `sov-cli` called `make-blob` that can bundle serialized transaction files into a blob:
```
Expand All @@ -257,12 +253,12 @@ Arguments:
```
We only have one transaction, so we can use that transaction to create the serialized blob, using the `make-blob` `sov-cli` subcommand:
```
$ ./target/debug/sov-cli make-blob ./examples/demo-stf/src/sov-cli/test_data/create_token.dat
01000000d40000007cb06da843cb98a223cdd4aee61ea4533f99104fe03144720d75800580d9a665be112c73b8d0b02b8de73f678d2432e93f613071e6fd04cc96b6ab5e6952bf007b758bf2e7670fafaf6bf0015ce0ff5aa802306fc7e3f45762853ffc37180fe66800000001000b000000000000000e000000736f762d746573742d746f6b656ee803000000000000a3201954f70ad62230dc3d840a5bf767702c04869e85ab3eee0b962857ba759801000000a3201954f70ad62230dc3d840a5bf767702c04869e85ab3eee0b962857ba75980100000000000000
$ ./target/debug/sov-cli make-blob ./examples/demo-stf/src/sov-cli/test_data/transfer.dat
01000000b6000000bb5fb10b2732f7bbee3505c5fc0a43f56b02014169b1f80f9493da65843bbb10ce443c9b583964a9e5224baca492474e87664444cdce0364cbc562bd507e40067b758bf2e7670fafaf6bf0015ce0ff5aa802306fc7e3f45762853ffc37180fe64a00000000011212121212121212121212121212121212121212121212121212121212121212c800000000000000135d23aee8cb15c890831ff36db170157acaac31df9bba6cd40e7329e608eabd0100000000000000
```
4. Let's create the serialized blob and redirect the output to a file so that we can use it later:
```
$ ./target/debug/sov-cli make-blob ./examples/demo-stf/src/sov-cli/test_data/create_token.dat > ./examples/demo-stf/src/sov-cli/test_data/tx_blob
$ ./target/debug/sov-cli make-blob ./examples/demo-stf/src/sov-cli/test_data/transfer.dat > ./examples/demo-stf/src/sov-cli/test_data/tx_blob
```
5. Now that we have a transaction blob, let's switch back to the `examples/demo-rollup` folder and utilize the Makefile to submit the transaction:
```
Expand All @@ -275,7 +271,7 @@ Here the `make submit-txn` command locates the docker container the Celestia ins
### Verify the supply of the new token created

```
$ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"bank_supplyOf","params":["sov16m8fxq0x5wc5aw75fx9rus2p7g2l22zf4re72c3m058g77cdjemsavg2ft"],"id":1}' http://127.0.0.1:12345
$ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"bank_supplyOf","params":["sov1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27svq9m72"],"id":1}' http://127.0.0.1:12345
{"jsonrpc":"2.0","result":{"amount":1000},"id":1}
```

Expand Down
6 changes: 3 additions & 3 deletions examples/demo-rollup/rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# We define the rollup's genesis to occur at Celestia block number `start_height`. The rollup will ignore
# any Celestia blocks before this height
start_height = 671431
start_height = 1

[da]
# The JWT used to authenticate with the celestia light client. Instructions for generating this token can be found in the README
celestia_rpc_auth_token = "MY.SECRET.TOKEN"
celestia_rpc_auth_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJwdWJsaWMiLCJyZWFkIiwid3JpdGUiLCJhZG1pbiJdfQ.YNNrJz6mCD6ypuH9Ay6NuCy1B6oQVTa2wi5-etSeY-8"

This comment has been minimized.

Copy link
@citizen-stig

citizen-stig Jul 7, 2023

Member

I guess this should not be there.

# The address of the *trusted* Celestia light client to interact with
celestia_rpc_address = "http://localhost:11111/"
celestia_rpc_address = "http://127.0.0.1:26658"
# The largest response the rollup will accept from the Celestia node. Defaults to 100 MB
max_celestia_response_body_size = 104_857_600

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-stf/src/sov-cli/test_data/burn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Burn":{
"coins":{
"amount":300,
"token_address":"sov1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27seu4hmg"
"token_address":"sov1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27svq9m72"
}
}
}
4 changes: 2 additions & 2 deletions examples/demo-stf/src/sov-cli/test_data/create_token.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"salt": 11,
"token_name": "sov-test-token",
"initial_balance": 1000,
"minter_address": "sov15vspj48hpttzyvxu8kzq5klhvaczcpyxn6z6k0hwpwtzs4a6wkvqmlyjd6",
"authorized_minters": ["sov15vspj48hpttzyvxu8kzq5klhvaczcpyxn6z6k0hwpwtzs4a6wkvqmlyjd6"]
"minter_address": "sov15vspj48hpttzyvxu8kzq5klhvaczcpyxn6z6k0hwpwtzs4a6wkvqwr57gc",
"authorized_minters": ["sov1l6n2cku82yfqld30lanm2nfw43n2auc8clw7r5u5m6s7p8jrm4zqrr8r94"]
}
}
2 changes: 1 addition & 1 deletion examples/demo-stf/src/sov-cli/test_data/transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"to":"sov1zgfpyysjzgfpyysjzgfpyysjzgfpyysjzgfpyysjzgfpyysjzgfqve8h6h",
"coins":{
"amount":200,
"token_address":"sov1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27seu4hmg"
"token_address":"sov1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27svq9m72"
}
}
}
Expand Down

0 comments on commit 369d639

Please sign in to comment.