Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent mode for saya using mock of SNOS #2253

Merged
merged 61 commits into from
Oct 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f5f02d3
updated celestia and publishing proof
matzayonc Jun 4, 2024
86c7b89
merging all if end block specified
matzayonc Jul 1, 2024
f5c7398
running checker on calls
matzayonc Jul 5, 2024
85acffd
feat: Cairo 1 checker program update
tejks Jul 16, 2024
c6045c5
added contract checkr
matzayonc Jul 23, 2024
c2f29c2
choosing saya mode
matzayonc Jul 23, 2024
5679046
fragmented proof verification
matzayonc Jul 30, 2024
f0c5834
batcher input and output parsing
matzayonc Jul 30, 2024
74d98da
working piltover
matzayonc Jul 31, 2024
2ea4210
passing piltover from cli
matzayonc Jul 31, 2024
14b6075
saya flow script
matzayonc Jul 31, 2024
9bc20a9
fixes after rebase and new felts
matzayonc Aug 1, 2024
90169e1
clippy, formatter and warning
matzayonc Aug 1, 2024
bc978c3
Update bin/saya/README.md
matzayonc Aug 6, 2024
73b7408
fixes after rebase and new felts
matzayonc Aug 1, 2024
0537865
fixed failing build
matzayonc Aug 12, 2024
45e0adf
saya.sh small fix
chudkowsky Aug 12, 2024
11bda52
readme update
chudkowsky Aug 12, 2024
ff1b5d2
saya script using tags and sozo from source
matzayonc Aug 13, 2024
aada160
readme update for spawn and move example
chudkowsky Aug 13, 2024
ba2329f
minor test comments
matzayonc Aug 29, 2024
f372bfd
clippy and fixes after rebase
matzayonc Aug 29, 2024
38e4cf2
fixed test
matzayonc Aug 29, 2024
ed3f633
minor debugging
matzayonc Aug 30, 2024
c680b3b
updated saya contracts
matzayonc Sep 2, 2024
92e5590
just an unused import
matzayonc Sep 2, 2024
5d3620c
fixed consecutive proofs
matzayonc Sep 2, 2024
be66305
removed merger program
matzayonc Sep 3, 2024
931580f
limited wait time between transactions
matzayonc Sep 3, 2024
74f7edf
renamed shard file to settlement
matzayonc Sep 3, 2024
f005215
updates serialized args file
matzayonc Sep 3, 2024
de8095d
fix: refacto README + add new scripts + fix sozo issues with migratio…
glihm Sep 6, 2024
d1e83cc
fix: migrate to new prover sdk
glihm Sep 7, 2024
6b8a225
fix: add some comment and fix cairo 1 arguments
glihm Sep 8, 2024
65afea4
adapt saya to new prover, new batcher and checker
chudkowsky Sep 10, 2024
293d391
updated fact registry to herodotus
chudkowsky Sep 12, 2024
80f35f5
retries on onchain contracts
chudkowsky Sep 16, 2024
31519d2
piltover class hash update
chudkowsky Sep 16, 2024
518948e
refactor part1
chudkowsky Sep 24, 2024
0622280
errrors refactor, sharp prover
chudkowsky Oct 1, 2024
7eedc60
updated celestia and json upload
matzayonc Oct 2, 2024
4ed9d3a
publishing to celestia
matzayonc Oct 3, 2024
6b05fa4
Merge pull request #54 from neotheprogramist/celestia-proof
chudkowsky Oct 4, 2024
477afd5
Merge pull request #55 from neotheprogramist/refactor
chudkowsky Oct 4, 2024
d2f837e
Merge pull request #53 from neotheprogramist/saya/new-prover-interface
chudkowsky Oct 4, 2024
61a3bb3
errors, update script
chudkowsky Oct 4, 2024
b5492d3
added a header to celestia data
matzayonc Oct 4, 2024
fbd16d4
height and commitment calculated values
chudkowsky Oct 5, 2024
d23a246
piltover update
chudkowsky Oct 8, 2024
6a1e8d2
Readme
chudkowsky Oct 9, 2024
3941d38
fmt
chudkowsky Oct 9, 2024
51b6025
Merge remote-tracking branch 'origin/main' into saya/settle-katana
chudkowsky Oct 9, 2024
f2136f9
post merge fix
chudkowsky Oct 9, 2024
f5a9e80
fmt
chudkowsky Oct 9, 2024
46a770f
fmt and dependency
chudkowsky Oct 9, 2024
a67233e
fmt again
chudkowsky Oct 9, 2024
a65bb40
fmt
chudkowsky Oct 9, 2024
5356d15
removed unused variable
chudkowsky Oct 9, 2024
3d6be35
rebuild test artefacts
chudkowsky Oct 9, 2024
9ac3bdf
test fix
chudkowsky Oct 9, 2024
e47f0d1
db files update
chudkowsky Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
readme update for spawn and move example
chudkowsky authored and matzayonc committed Sep 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit aada160b9810d34962aaa31ff6e50e494b28bb87
196 changes: 123 additions & 73 deletions bin/saya/README.md
Original file line number Diff line number Diff line change
@@ -2,137 +2,181 @@

This documentation outlines the operation of the Saya executable, a CLI-based service designed to interact with blockchain components for state management and updates. Saya supports operations on Celestia nodes and integrates with Katana blocks to provide a streamlined blockchain interaction process.

## Key Features

- **Celestia Node Integration**: Allows publishing state updates to a Celestia node (WIP).
- **Katana Block Fetching**: Saya can fetch blocks from Katana, aiding in local blockchain simulations and testing.

## Prerequisites

Ensure you have the following set up:

- Rust and Cargo installed on your system.
- Access to Katana node URLs if needed.
- Access to Celestia and/or Katana node URLs if needed.

## Basic Usage Example

Below is a command-line example that demonstrates how to run the Saya executable with necessary parameters:

```bash
cargo run --bin saya -- --rpc-url http://localhost:5050 --da-chain celestia --celestia-node-url http://127.0.0.1:26658 --celestia-namespace mynm --celestia-node-auth-token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.....
```

## Detailed Workflow

1. Prepare fact registry contract

## Detailed Workflow For Persistent Mode with Shard Dungeon example
1. Clone repo with Shard Dungeon next to Dojo repository `git clone https://github.com/neotheprogramist/shard-dungeon.git`
Declare or use already declared `class-hash`: `0x7f6076572e04d7182a1c5c9f1f4c15aafcb069b1bfdb3de4d7c9e47c99deeb4`.

Deploy or use already deployed `contract`: `0x217746a5f74c2e5b6fa92c97e902d8cd78b1fabf1e8081c4aa0d2fe159bc0eb`.

In the repository https://github.com/HerodotusDev/integrity run

```bash
fact_registry/1-declare.sh # extract `class-hash`
fact_registry/1-deploy.sh <CLASS_HASH> # use at <FACT_REGISTRY>
```

2. Spawn world

You must choose a world's name as you may deploy the exact same code as an other person trying this example. The world's name must fit into 31 characters.

```bash
sozo build --manifest-path ../shard-dungeon/Scarb.toml
cargo run -r --bin sozo -- \
build \
--manifest-path examples/spawn-and-move/Scarb.toml

sozo migrate apply \
--manifest-path ../shard-dungeon/Scarb.toml \
cargo run -r --bin sozo -- \
migrate apply \
--manifest-path examples/spawn-and-move/Scarb.toml \
--rpc-url <SEPOLIA_ENDPOINT> \
--private-key <SEPOLIA_ACCOUNT_PRIVATE_KEY> \
--private-key <SEPOLIA_PRIVATE_KEY> \
--account-address <SEPOLIA_ACCOUNT_ADDRESS> \
--fee-estimate-multiplier 20 \
--name <WORLD_NAME>
```

Once the migration is done, please take note of the address of the world as it will be re-used in the commands below.

3. Preparing world
1. Set world configs

```bash
sozo \
execute <SAYA_WORLD_ADDRESS> set_differ_program_hash \
-c 2265722951651489608338464389196546125983429710081933755514038580032192121109 \
--manifest-path ../shard-dungeon/Scarb.toml \
```bash
cargo run -r --bin sozo -- \
execute <WORLD_ADDRESS> set_differ_program_hash \
-c 0xa73dd9546f9858577f9fdbe43fd629b6f12dc638652e11b6e29155f4c6328 \
--manifest-path examples/spawn-and-move/Scarb.toml \
--rpc-url <SEPOLIA_ENDPOINT> \
--private-key <SEPOLIA_ACCOUNT_PRIVATE_KEY> \
--private-key <SEPOLIA_PRIVATE_KEY> \
--account-address <SEPOLIA_ACCOUNT_ADDRESS> \
--fee-estimate-multiplier 20 \
--world <WORLD_NAME> \
--world <WORLD_ADDRESS> \
--wait

sozo \
execute <SAYA_WORLD_ADDRESS> set_merger_program_hash \
-c 2265722951651489608338464389196546125983429710081933755514038580032192121109 \
--manifest-path ../shard-dungeon/Scarb.toml \
cargo run -r --bin sozo -- \
execute <WORLD_ADDRESS> set_merger_program_hash \
-c 0xc105cf2c69201005df3dad0050f5289c53d567d96df890f2142ad43a540334 \
--manifest-path examples/spawn-and-move/Scarb.toml \
--rpc-url <SEPOLIA_ENDPOINT> \
--private-key <SEPOLIA_ACCOUNT_PRIVATE_KEY> \
--private-key <SEPOLIA_PRIVATE_KEY> \
--account-address <SEPOLIA_ACCOUNT_ADDRESS> \
--fee-estimate-multiplier 20 \
--world <WORLD_NAME> \
--world <WORLD_ADDRESS> \
--wait

sozo \
execute <SAYA_WORLD_ADDRESS> set_facts_registry \
-c <SAYA_FACT_REGISTRY_ADDRESS> \
--manifest-path ../shard-dungeon/Scarb.toml \
cargo run -r --bin sozo -- \
execute <WORLD_ADDRESS> set_facts_registry \
-c 0x217746a5f74c2e5b6fa92c97e902d8cd78b1fabf1e8081c4aa0d2fe159bc0eb \
--manifest-path examples/spawn-and-move/Scarb.toml \
--rpc-url <SEPOLIA_ENDPOINT> \
--private-key <SEPOLIA_ACCOUNT_PRIVATE_KEY> \
--private-key <SEPOLIA_PRIVATE_KEY> \
--account-address <SEPOLIA_ACCOUNT_ADDRESS> \
--fee-estimate-multiplier 20 \
--world <WORLD_NAME> \
--wait
--world <WORLD_ADDRESS> \
--wait
```

4.
Set SAYA_FORK_BLOCK_NUMBER to the latest block including the preparations (check here https://sepolia.starkscan.co/, remember to switch to sepolia!)."

You can now run `cargo run -r --bin katana -- --rpc-url <SEPOLIA_ENDPOINT> --fork-block-number <SAYA_FORK_BLOCK_NUMBER>` in another terminal."

5. Preparing Piltover Contract
4. Preparing Piltover Contract
```bash
sncast -a <SAYA_SNCAST_ACCOUNT_NAME> -u <SEPOLIA_ENDPOINT> deploy \
--class-hash <SAYA_PILTOVER_CLASS_HASH> \
-c <SEPOLIA_ACCOUNT_ADDRESS> 0 <SAYA_FORK_BLOCK_NUMBER + 1> 0
```
Save the address of the deployed contract, we will use it later as SAYA_PILTOVER_ADDRESS
```bash
```bash
sncast -a <SAYA_SNCAST_ACCOUNT_NAME> -u <SEPOLIA_ENDPOINT> --wait invoke \
--contract-address <SAYA_PILTOVER_ADDRESS> --function set_program_info -c 0x042066b8031c907125abd1acb9265ad2ad4b141858d1e1e3caafb411d9ab71cc 42
```
```bash
```bash
sncast -a <SAYA_SNCAST_ACCOUNT_NAME> -u <SEPOLIA_ENDPOINT> --wait invoke \
--contract-address <SAYA_PILTOVER_ADDRESS> --function set_facts_registry -c <SAYA_FACT_REGISTRY_ADDRESS>
```
6. Making example transactions with ShardDungeon
```bash
sozo execute shard_dungeon::systems::metagame::metagame register_player \
-c str:mateo \
--manifest-path ../shard-dungeon/Scarb.toml \
--rpc-url http://localhost:5050 \
--private-key <SEPOLIA_ACCOUNT_PRIVATE_KEY> \
--account-address <SEPOLIA_ACCOUNT_ADDRESS> \
--world <SAYA_WORLD_ADDRESS> \
--wait
```
```bash
sozo execute shard_dungeon::systems::hazard_hall::hazard_hall enter_dungeon \
--manifest-path ../shard-dungeon/Scarb.toml \
--rpc-url http://localhost:5050 \
--private-key <SEPOLIA_ACCOUNT_PRIVATE_KEY> \
--account-address <SEPOLIA_ACCOUNT_ADDRESS> \
--world <SAYA_WORLD_ADDRESS> \
--wait
```
5. Start katana

Start a local instance of Katana configured to work with the newly deployed contract. You should wait your world to be integrated into the latest block (and not the pending).
Once block in which the transaction that deploys the world is mined, you can start `katana` in forking mode.

```bash
sozo execute shard_dungeon::systems::hazard_hall::hazard_hall fate_strike \
--manifest-path ../shard-dungeon/Scarb.toml \
--rpc-url http://localhost:5050 \
--private-key <SEPOLIA_ACCOUNT_PRIVATE_KEY> \
--account-address <SEPOLIA_ACCOUNT_ADDRESS> \
--world <SAYA_WORLD_ADDRESS> \
--wait
cargo run -r --bin katana -- \
--rpc-url <SEPOLIA_ENDPOINT> \
--fork-block-number <LATEST_BLOCK>
```

5. Run transactions on `katana`

Finally, modify the state of the world using specific actions:

```bash
sozo execute shard_dungeon::systems::hazard_hall::hazard_hall fate_strike \
--manifest-path ../shard-dungeon/Scarb.toml \
cargo run -r --bin sozo -- execute dojo_examples::actions::actions spawn \
--manifest-path examples/spawn-and-move/Scarb.toml \
--rpc-url http://localhost:5050 \
--private-key <SEPOLIA_ACCOUNT_PRIVATE_KEY> \
--private-key <SEPOLIA_PRIVATE_KEY> \
--account-address <SEPOLIA_ACCOUNT_ADDRESS> \
--world <SAYA_WORLD_ADDRESS> \
--world <WORLD_ADDRESS> \
--wait
```

Before running `saya`, we can check the actual value for some models on Sepolia, to then see them updated by the proof being verified and the state of the world being updated.
In the `spawn-and-move` example, the `Position` model is used to store some data associated with the player,
being the contract address of the contract that called `spawn` (hence, your account address).
By default on Sepolia, it should be set like to unknown position, being like:

```bash
sozo -- model get Inventory <SEPOLIA_ACCOUNT_ADDRESS> \
--manifest-path ../shard-dungeon/Scarb.toml \
cargo run -r --bin sozo -- model get Position <ACCOUNT_ADDRESS> \
--manifest-path examples/spawn-and-move/Scarb.toml \
--rpc-url <SEPOLIA_ENDPOINT> \
--world <SAYA_WORLD_ADDRESS>
--world <WORLD_ADDRESS>
```
7. Finally we can run saya

```json
// Expected on Sepolia as we've executed the transaction on the Katana shard.
{
player : <SEPOLIA_ACCOUNT_ADDRESS>,
vec : {
x : 0,
y : 0
}
}

// Expected on Katana.
{
player : <SEPOLIA_ACCOUNT_ADDRESS>,
vec : {
x : 10,
y : 10
}
}
```

6. Run saya

The <PROVER_URL> could be `http://prover.visoft.dev:3618` if you have a registered key or a link to a self hosted instance of `https://github.com/neotheprogramist/http-prover`.
The <PROVER_KEY> is the private key produced by `keygen` installed with `cargo install --git https://github.com/neotheprogramist/http-prover keygen`. Pass the public key to server operator or the prover program.

If you are on an `amd64` architecture, go ahead and run the `http-prover` locally to see how it works and run this whole pipeline locally.
If not (this includes Apple Silicon), some emulation will take place to run the prover on your machine, and this is very very slow.

It's important that the `--start-block` of Saya is the first block produced by Katana as for now Katana is not fetching events from the forked network.

Starknet sepolia network chain id is `0x00000000000000000000000000000000000000000000534e5f5345504f4c4941`.

```bash
cargo run -r --bin saya -- \
@@ -148,4 +192,10 @@ cargo run -r --bin saya -- \
--signer-address <SEPOLIA_ACCOUNT_ADDRESS> \
--private-key <SAYA_PROVER_KEY> \
--start-block <SAYA_FORK_BLOCK_NUMBER + 1>
```
```

After this command, Saya will pick up the blocks with transactions, generate the proof for the state transition, and send it to the base layer world contract.

Once the world on Sepolia is updated, you can issue again the `model get` command as seen before, and you should see the `katana` shard state reflected on Sepolia.

Ensure to replace placeholders (`<>`) with appropriate values for your configuration and environment. This documentation provides a comprehensive overview for developers and operators to effectively utilize the Saya service in blockchain applications.