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

new template app #271

Merged
merged 7 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions crates/utils/tm-prover/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl Default for Config {
.parse()
.unwrap(),
storage_key: String::default(),
storage_namespace: None,
}
}
}
Expand Down Expand Up @@ -141,4 +142,9 @@ pub struct Config {
/// Storage key of the state item for which proofs must be retrieved
#[clap(long)]
pub storage_key: String,

/// Storage namespace of the state item for which proofs must be retrieved
/// (only makes sense when dealing with maps)
#[clap(long)]
pub storage_namespace: Option<String>,
}
3 changes: 2 additions & 1 deletion crates/utils/tm-prover/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub async fn prove(
verbose: _,
contract_address,
storage_key,
storage_namespace,
}: TmProverConfig,
) -> Result<ProofOutput> {
let options = Options {
Expand Down Expand Up @@ -115,7 +116,7 @@ pub async fn prove(
.await?;

let path = WASM_STORE_KEY.to_owned();
let data = CwAbciKey::new(contract_address, storage_key, None);
let data = CwAbciKey::new(contract_address, storage_key, storage_namespace);
let result = client
.abci_query(Some(path), data, Some(proof_height), true)
.await?;
Expand Down
2 changes: 2 additions & 0 deletions examples/pingpong/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target-dir = "target"
47 changes: 47 additions & 0 deletions examples/pingpong/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Ping Pong

This is a minimal Quartz demo app to serve as a scaffold to learn and build off of.

It allows users to submit a message encrypted to the enclave's pubkey,
and receive a response from the enclave encrypted to their own pubkey.
<!--
See the [getting started guide](/docs/getting_started.md) to get it quickly
setup on a local testnet without SGX or on a real testnet using an Azure SGX
node.

See this [video of an early demo of the app at the Flashbots
TEE-salon](https://www.youtube.com/watch?v=3Tv6k02zvBc&t=2517s).
-->

# Step by Step

1) Run

```
quartz --mock-sgx dev --unsafe-trust-latest --contract-manifest contracts/Cargo.toml
```

2. Copy the contract address from the output and paste it onto line 46 of the `send_message.rs` script.
3. Copy the pub key from the handshake and paste it onto line 18 of `send_message.rs`.

The pubkey in the `Ping` struct will be the user's pubkey, which you can leave untouched.

4. Next, send this transaction to "Ping" the enclave.
```
cargo run --bin send_message
```

5. Watch the logs from `quartz dev`. You should see the decrypted message printed.

Now let's find the enclave's response.

6. Query the contract for its messages
```
neutrond query wasm contract-state smart $CONTRACT '{
"get_all_messages": {}
}' -o json
```

7. Copy the value from, what should be, the only entry in the map.

8. Go to `send_message.rs` and paste the hex value onto line 67. Run `decrypt_enclave_response` to see the decrypted output.
11 changes: 11 additions & 0 deletions examples/pingpong/cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[template]
description = "An functioning example of a quartz app"

ignore = [
"target/",
"contracts/target",
"contracts/schema",
"enclave/target",
"enclave/src/prost/*",
"frontend/package-lock.json",
]
5 changes: 5 additions & 0 deletions examples/pingpong/contracts/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[alias]
wasm = "build --target wasm32-unknown-unknown --release --lib"
wasm-debug = "build --target wasm32-unknown-unknown --lib"
schema = "run schema"
unit-test = "test --lib"
Loading
Loading