Skip to content

Commit b23682c

Browse files
committed
refactor: clearer names
1 parent 9cee781 commit b23682c

6 files changed

Lines changed: 18 additions & 16 deletions

File tree

examples/l2/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ clean_db:
3838
rm -f examples/l2/crates/l2/db
3939

4040
__L2_PROGRAM__:
41-
update_state_transition:
42-
@. ./.env && cd cmd && cargo run --release --bin update_state_transition
41+
prove_state_transition:
42+
@. ./.env && cd cmd && cargo run --release --bin prove_state_transition
4343

44-
verify_state_transition_on_chain:
45-
@. ./.env && cd cmd && cargo run --release --bin verify_state_transition_on_chain
44+
update_state_on_chain:
45+
@. ./.env && cd cmd && cargo run --release --bin update_state_on_chain

examples/l2/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ In Step 1, we execute user transfers and generate a zkVM-based proof of the stat
2020

2121
In Step 2, once the proof is aggregated (every 24 hours), it is verified on-chain to update the global state.
2222

23-
### Step 1: Off-Chain Execution & Proof Generation
23+
### Step 1: Off-Chain Execution + Proof Generation
2424

2525
1. Initialize State: Load or initialize the current system state.
2626
2. Load Transfers: Retrieve or receive the user transfer data for this batch.
@@ -29,7 +29,7 @@ In Step 2, once the proof is aggregated (every 24 hours), it is verified on-chai
2929
5. Submit Proof to Aligned: Send the proof to Aligned Verification Layer
3030
6. Save the binary proof locally for later on-chain verification.
3131

32-
### Step 2: On-Chain State Update
32+
### Step 2: Proof Verification + On-Chain State Update
3333

3434
7. Load the proof binary: Retrieve the saved proof binary from disk.
3535
8. Update On-Chain State: Call the smart contract method `updateStateTransition`, which:
@@ -163,13 +163,13 @@ Pass the output address in the `.env` and [run the l2](#run-the-l2).
163163
- Perform the L2 account updates and prove them in the zkvm:
164164
165165
```shell
166-
make update_state_transition
166+
make prove_state_transition
167167
```
168168
169169
- Update state transition on chain, you should run this after your proof has been aggregated by aligned (this process happens every 24hs):
170170
171171
```shell
172-
make verify_state_transition_on_chain
172+
make update_state_on_chain
173173
```
174174
175175
You should see a transaction receipt in the console and after the stateRoot updated on-chain.

examples/l2/cmd/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ name = "l2_cmd"
1919
path = "./lib.rs"
2020

2121
[[bin]]
22-
name = "update_state_transition"
23-
path = "./update_state_transition.rs"
22+
name = "prove_state_transition"
23+
path = "./prove_state_transition.rs"
2424

2525
[[bin]]
26-
name = "verify_state_transition_on_chain"
27-
path = "./verify_state_transition_on_chain.rs"
26+
name = "update_state_on_chain"
27+
path = "./update_state_on_chain.rs"

examples/l2/cmd/update_state_transition.rs renamed to examples/l2/cmd/prove_state_transition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async fn main() {
1414
let config = load_config();
1515
let mut l2 = L2::new(config);
1616

17-
let proof = l2.update_state_transition().await;
17+
let proof = l2.prove_state_transition_and_send_proof_to_aligned().await;
1818
info!("Serializing and saving proof on disk to be verified later on chain");
1919

2020
let proof_bytes = bincode::serialize(&proof).unwrap();

examples/l2/cmd/verify_state_transition_on_chain.rs renamed to examples/l2/cmd/update_state_on_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ async fn main() {
1616

1717
let proof_bytes = std::fs::read("./proof.bin").unwrap();
1818
let proof = bincode::deserialize(&proof_bytes).unwrap();
19-
l2.verify_state_transition(proof).await;
19+
l2.update_state_on_chain(proof).await;
2020
}

examples/l2/crates/l2/src/l2.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ impl L2 {
2424
}
2525
}
2626

27-
pub async fn update_state_transition(&mut self) -> SP1ProofWithPublicValues {
27+
pub async fn prove_state_transition_and_send_proof_to_aligned(
28+
&mut self,
29+
) -> SP1ProofWithPublicValues {
2830
// 1. Create random transfers
2931
let transfers = generate_random_transfers(&self.db, 10);
3032

@@ -79,7 +81,7 @@ impl L2 {
7981
proof
8082
}
8183

82-
pub async fn verify_state_transition(&mut self, proof: SP1ProofWithPublicValues) {
84+
pub async fn update_state_on_chain(&mut self, proof: SP1ProofWithPublicValues) {
8385
let vk = prover::vk_from_elf(PROGRAM_ELF);
8486
// 5. Check if proof has been aggregated
8587
info!("Checking if proof has been aggregated in the last 24 hours...");

0 commit comments

Comments
 (0)