Skip to content
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
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Overview

This repo contains essential programs for the **Logos Execution Zone (LEZ)** — a zkVM-based execution environment built on [RISC Zero](https://risczero.com/). Programs run inside the RISC Zero zkVM (`riscv32im-risc0-zkvm-elf` target) and interact with the LEZ runtime via the `nssa_core` library from `logos-execution-zone`.
This repo contains essential programs for the **Logos Execution Zone (LEZ)** — a zkVM-based execution environment built on [RISC Zero](https://risczero.com/). Programs run inside the RISC Zero zkVM (`riscv32im-risc0-zkvm-elf` target) and interact with the LEZ runtime via the `lee_core` library from `logos-execution-zone`.

Five programs are implemented:
- **token** — Fungible and non-fungible token program (create, mint, burn, transfer, print NFTs)
Expand Down Expand Up @@ -81,7 +81,7 @@ Generated IDL files live in `artifacts/`. CI checks that every program under `*/

## Deployment

`wallet` and `spel` are CLI tools that ship with the [SPEL](https://github.com/logos-co/spel.git) toolchain. `wallet` requires `NSSA_WALLET_HOME_DIR` to point to a directory containing the wallet config.
`wallet` and `spel` are CLI tools that ship with the [SPEL](https://github.com/logos-co/spel.git) toolchain. `wallet` requires `LEE_WALLET_HOME_DIR` to point to a directory containing the wallet config.

**Note:** `spel` and `wallet` may use different versions of the wallet package. If `spel --idl <IDL> <PROGRAM_FUNCTION> ...` fails, ensure `seq_poll_timeout_millis` is set in the wallet config at `~/.nssa/wallet`.

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ exclude = [
resolver = "2"

[workspace.dependencies]
nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4", features = ["host"], package = "lee_core" }
nssa = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4", features = ["test-utils"], package = "lee" }
lee_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4", features = ["host"] }
lee = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4", features = ["test-utils"] }
token_core = { path = "programs/token/core" }
token_program = { path = "programs/token" }
amm_core = { path = "programs/amm/core" }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# lez-programs

Essential programs for the **Logos Execution Zone (LEZ)** — a zkVM-based execution environment built on [RISC Zero](https://risczero.com/). Programs run inside the RISC Zero zkVM (`riscv32im-risc0-zkvm-elf` target) and interact with the LEZ runtime via the `nssa_core` library.
Essential programs for the **Logos Execution Zone (LEZ)** — a zkVM-based execution environment built on [RISC Zero](https://risczero.com/). Programs run inside the RISC Zero zkVM (`riscv32im-risc0-zkvm-elf` target) and interact with the LEZ runtime via the `lee_core` library.

## Programs

Expand Down
2 changes: 1 addition & 1 deletion apps/amm/tests/custom-token.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function saveShot(app, name) {
function resolveTokenD() {
const out = execFileSync("wallet", ["account", "id", "--account-id", "token-d-def"], {
encoding: "utf8",
env: { ...process.env, LEE_WALLET_HOME_DIR: WALLET_HOME, NSSA_WALLET_HOME_DIR: WALLET_HOME },
env: { ...process.env, LEE_WALLET_HOME_DIR: WALLET_HOME },
});
const id = (out.match(/[1-9A-HJ-NP-Za-km-z]{32,44}/) || [])[0];
if (!id)
Expand Down
6 changes: 2 additions & 4 deletions apps/amm/tests/testnet/setup-amm-testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ cd "$REPO_ROOT"
# TEST WALLET — isolated + deterministic
###############################################################################

# Dedicated wallet home for tests. Kept out of git (see .gitignore). Exported
# under both env var names so whichever the installed `wallet`/`spel` expects is
# satisfied (the current wallet uses LEE_WALLET_HOME_DIR).
# Dedicated wallet home for tests. Kept out of git (see .gitignore). The v0.2.x
# wallet/spel read LEE_WALLET_HOME_DIR (the old NSSA_WALLET_HOME_DIR is unused).
TEST_WALLET_HOME="${TEST_WALLET_HOME:-$SCRIPT_DIR/.wallet}"
export LEE_WALLET_HOME_DIR="$TEST_WALLET_HOME"
export NSSA_WALLET_HOME_DIR="$TEST_WALLET_HOME"

# The deterministic test seed. A wallet restored from this mnemonic yields the
# same account ids every time, which is why they can be shared/pinned.
Expand Down
1 change: 0 additions & 1 deletion apps/token/tests/run-basecamp-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ QT_FORCE_STDERR_LOGGING=1 \
QML_DISABLE_DISK_CACHE=1 \
QML_INSPECTOR_PORT="${inspector_port}" \
LEE_WALLET_HOME_DIR="${wallet_home}" \
NSSA_WALLET_HOME_DIR="${wallet_home}" \
LD_LIBRARY_PATH="${bundle_root}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" \
"${basecamp_bin}" --user-dir "${run_root}/user" -platform offscreen \
>"${run_root}/basecamp.log" 2>&1 &
Expand Down
2 changes: 0 additions & 2 deletions docs/token/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ below was exercised with the `spel` CLI **v0.5.0**; where v0.6.0 differs it is c
```bash
export LEE_WALLET_HOME_DIR="$HOME/.lee/wallet"
```
Older toolchain builds read `NSSA_WALLET_HOME_DIR` instead — set whichever yours expects, and
use the **same** one everywhere.
- Wallet pointed at your sequencer:
```bash
wallet config set sequencer_addr https://testnet.lez.logos.co/
Expand Down
2 changes: 1 addition & 1 deletion modules/amm/ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ amm_core = { workspace = true }
borsh = { workspace = true }
clock_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4" }
hex = "0.4"
nssa_core = { workspace = true }
lee_core = { workspace = true }
risc0-binfmt = { version = "=3.0.4", default-features = false }
risc0-zkvm = { workspace = true }
serde = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion modules/amm/ffi/src/account.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::str::FromStr;

use nssa_core::{
use lee_core::{
account::{Account, AccountId, Data, Nonce},
program::ProgramId,
};
Expand Down
2 changes: 1 addition & 1 deletion modules/amm/ffi/src/api/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use amm_core::{compute_config_pda, AmmConfig};
use nssa_core::{account::Account, program::ProgramId};
use lee_core::{account::Account, program::ProgramId};
use serde_json::{json, Value};

use super::{ConfigAccountRequest, ConfigIdRequest};
Expand Down
2 changes: 1 addition & 1 deletion modules/amm/ffi/src/api/context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::BTreeSet;

use nssa_core::{account::AccountId, program::ProgramId};
use lee_core::{account::AccountId, program::ProgramId};
use serde_json::{json, Value};
use token_core::TokenDefinition;

Expand Down
2 changes: 1 addition & 1 deletion modules/amm/ffi/src/api/holding.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use nssa_core::{account::AccountId, program::ProgramId};
use lee_core::{account::AccountId, program::ProgramId};
use token_core::TokenHolding;

use crate::account::{decode_account, AccountRead};
Expand Down
6 changes: 3 additions & 3 deletions modules/amm/ffi/src/api/liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use amm_core::{
isqrt_product, mul_div_floor, spot_price_q64_64, PoolDefinition, FEE_BPS_DENOMINATOR,
MINIMUM_LIQUIDITY,
};
use nssa_core::account::AccountId;
use lee_core::account::AccountId;
use serde_json::{json, Value};

use super::{
Expand Down Expand Up @@ -633,7 +633,7 @@ pub(super) fn sync_reserves_plan(request: SyncReservesPlanRequest) -> Result<Val
#[cfg(test)]
mod tests {
use amm_core::{compute_config_pda, compute_pool_pda, compute_vault_pda, AmmConfig};
use nssa_core::account::{Account, AccountId, Data};
use lee_core::account::{Account, AccountId, Data};

use super::*;
use crate::account::{account_read, AccountRead};
Expand All @@ -657,7 +657,7 @@ mod tests {
}

/// A valid AMM config account read so `derive_pair` succeeds in plan tests.
fn valid_config(amm: nssa_core::program::ProgramId) -> AccountRead {
fn valid_config(amm: lee_core::program::ProgramId) -> AccountRead {
let token_program = parse_program_id(&"01".repeat(32)).unwrap();
let twap_program = parse_program_id(&"02".repeat(32)).unwrap();
let account = Account {
Expand Down
2 changes: 1 addition & 1 deletion modules/amm/ffi/src/api/oracle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use amm_core::Instruction;
use nssa_core::account::AccountId;
use lee_core::account::AccountId;
use serde_json::{json, Value};
use twap_oracle_core::{compute_oracle_price_account_pda, compute_price_observations_pda};

Expand Down
2 changes: 1 addition & 1 deletion modules/amm/ffi/src/api/pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use amm_core::{
compute_vault_pda,
};
use clock_core::CLOCK_01_PROGRAM_ACCOUNT_ID;
use nssa_core::{account::AccountId, program::ProgramId};
use lee_core::{account::AccountId, program::ProgramId};
use serde_json::{json, Value};
use twap_oracle_core::compute_current_tick_account_pda;

Expand Down
6 changes: 3 additions & 3 deletions modules/amm/ffi/src/api/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use amm_core::{
compute_pool_pda, mul_div_ceil, mul_div_floor, price_impact_bps, swap_exact_in_amounts,
swap_exact_out_amounts, PoolDefinition, FEE_BPS_DENOMINATOR,
};
use nssa_core::account::AccountId;
use lee_core::account::AccountId;
use risc0_binfmt::ProgramBinary;
use serde_json::{json, Value};

Expand Down Expand Up @@ -429,7 +429,7 @@ pub(super) fn swap_exact_out_plan(request: SwapExactOutPlanRequest) -> Result<Va
pub(super) fn program_id(request: ProgramIdRequest) -> Result<Value, String> {
let elf = hex::decode(&request.elf).map_err(|error| format!("invalid elf hex: {error}"))?;
let binary = ProgramBinary::decode(&elf).map_err(|error| format!("{error:?}"))?;
let image_id: nssa_core::program::ProgramId = binary
let image_id: lee_core::program::ProgramId = binary
.compute_image_id()
.map_err(|error| format!("{error:?}"))?
.into();
Expand All @@ -439,7 +439,7 @@ pub(super) fn program_id(request: ProgramIdRequest) -> Result<Value, String> {
#[cfg(test)]
mod tests {
use amm_core::PoolDefinition;
use nssa_core::account::AccountId;
use lee_core::account::AccountId;

use super::*;
use crate::account::{AccountRead, WalletAccount};
Expand Down
2 changes: 1 addition & 1 deletion modules/amm/ffi/src/api/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use amm_core::{
compute_vault_pda, isqrt_product, AmmConfig, Instruction, PoolDefinition, MINIMUM_LIQUIDITY,
};
use clock_core::CLOCK_01_PROGRAM_ACCOUNT_ID;
use nssa_core::{
use lee_core::{
account::{Account, AccountId, Data, Nonce},
program::ProgramId,
};
Expand Down
2 changes: 1 addition & 1 deletion modules/amm/ffi/src/api/token_holdings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub(super) fn token_holdings(request: TokenHoldingsRequest) -> Result<Value, Str
#[cfg(test)]
mod tests {
use amm_core::{compute_config_pda, AmmConfig};
use nssa_core::{
use lee_core::{
account::{Account, AccountId, Data},
program::ProgramId,
};
Expand Down
2 changes: 1 addition & 1 deletion modules/token/ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
hex = "0.4"
nssa_core = { workspace = true }
lee_core = { workspace = true }
risc0-binfmt = { version = "=3.0.4", default-features = false }
risc0-zkvm = { workspace = true }
serde = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion modules/token/ffi/src/account.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use nssa_core::{
use lee_core::{
account::{Account, AccountId, Data, Nonce},
program::ProgramId,
};
Expand Down
2 changes: 1 addition & 1 deletion modules/token/ffi/src/api/decode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use nssa_core::{
use lee_core::{
account::{Account, AccountId},
program::ProgramId,
};
Expand Down
2 changes: 1 addition & 1 deletion modules/token/ffi/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ impl fmt::Display for TokenApiError {

impl Error for TokenApiError {}

fn parse_token_program_id(value: &str) -> Result<nssa_core::program::ProgramId, TokenApiError> {
fn parse_token_program_id(value: &str) -> Result<lee_core::program::ProgramId, TokenApiError> {
parse_program_id(value).map_err(|_| TokenApiError::new("bad_request"))
}
6 changes: 3 additions & 3 deletions modules/token/ffi/src/api/plan.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use nssa_core::account::AccountId;
use lee_core::account::AccountId;
use risc0_binfmt::ProgramBinary;
use serde_json::{json, Value};
use token_core::{Instruction, MetadataStandard, NewTokenDefinition, NewTokenMetadata};
Expand All @@ -18,7 +18,7 @@ use crate::account::{account_id_from_hex, account_id_hex, program_id_bytes};
pub fn program_id(request: ProgramIdRequest) -> TokenResult {
let elf = hex::decode(&request.elf).map_err(|_| TokenApiError::new("bad_request"))?;
let binary = ProgramBinary::decode(&elf).map_err(|_| TokenApiError::new("bad_request"))?;
let image_id: nssa_core::program::ProgramId = binary
let image_id: lee_core::program::ProgramId = binary
.compute_image_id()
.map_err(|_| TokenApiError::new("backend_error"))?
.into();
Expand Down Expand Up @@ -298,7 +298,7 @@ fn reject_zero_account_id(account_id: AccountId, code: &'static str) -> Result<(
}

fn plan_response<const N: usize>(
program_id: nssa_core::program::ProgramId,
program_id: lee_core::program::ProgramId,
account_ids: [AccountId; N],
signing_requirements: [bool; N],
instruction: Instruction,
Expand Down
2 changes: 1 addition & 1 deletion modules/token/ffi/src/api/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use nssa_core::{
use lee_core::{
account::{Account, AccountId, Data, Nonce},
program::ProgramId,
};
Expand Down
2 changes: 1 addition & 1 deletion programs/amm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
workspace = true

[dependencies]
nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4", features = ["host"], package = "lee_core" }
lee_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4", features = ["host"] }
clock_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4" }
amm_core = { path = "core" }
token_core = { path = "../token/core" }
Expand Down
2 changes: 1 addition & 1 deletion programs/amm/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
workspace = true

[dependencies]
nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4", features = ["host"], package = "lee_core" }
lee_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.4", features = ["host"] }
spel-framework-macros = { git = "https://github.com/logos-co/spel.git", rev = "1ef0500f8fc8ce3ddf95523726ae159db83f744f", package = "spel-framework-macros" }
token_core = { path = "../../token/core" }
borsh = { version = "1.5", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion programs/amm/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! This crate contains core data structures and utilities for the AMM Program.

use borsh::{BorshDeserialize, BorshSerialize};
use nssa_core::{
use lee_core::{
account::{AccountId, AccountWithMetadata, Data},
program::{PdaSeed, ProgramId},
};
Expand Down
2 changes: 1 addition & 1 deletion programs/amm/examples/amm_pdas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use amm_core::{
compute_config_pda, compute_liquidity_token_pda, compute_lp_lock_holding_pda, compute_pool_pda,
compute_vault_pda,
};
use nssa_core::{account::AccountId, program::ProgramId};
use lee_core::{account::AccountId, program::ProgramId};
use twap_oracle_core::compute_current_tick_account_pda;

// Accepts a ProgramId as 8 comma-separated u32 limbs, a 64-char ImageID hex, or a base58
Expand Down
2 changes: 1 addition & 1 deletion programs/amm/src/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use amm_core::{
AmmConfig, PoolDefinition,
};
use clock_core::CLOCK_01_PROGRAM_ACCOUNT_ID;
use nssa_core::{
use lee_core::{
account::{AccountWithMetadata, Data},
program::{AccountPostState, ChainedCall, ProgramId},
};
Expand Down
4 changes: 2 additions & 2 deletions programs/amm/src/create_oracle_price_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use amm_core::{
PoolDefinition,
};
use clock_core::CLOCK_01_PROGRAM_ACCOUNT_ID;
use nssa_core::{
use lee_core::{
account::{Account, AccountWithMetadata},
program::{AccountPostState, ChainedCall, ProgramId},
};
Expand Down Expand Up @@ -152,7 +152,7 @@ pub fn create_oracle_price_account(
#[cfg(test)]
mod tests {
use amm_core::compute_pool_pda_seed;
use nssa_core::account::{Account, AccountId, Data, Nonce};
use lee_core::account::{Account, AccountId, Data, Nonce};

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions programs/amm/src/create_price_observations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use amm_core::{
compute_config_pda, compute_pool_pda, compute_pool_pda_seed, AmmConfig, PoolDefinition,
};
use clock_core::CLOCK_01_PROGRAM_ACCOUNT_ID;
use nssa_core::{
use lee_core::{
account::{Account, AccountWithMetadata},
program::{AccountPostState, ChainedCall, ProgramId},
};
Expand Down Expand Up @@ -134,7 +134,7 @@ pub fn create_price_observations(
#[cfg(test)]
mod tests {
use amm_core::compute_pool_pda_seed;
use nssa_core::account::{Account, AccountId, Data, Nonce};
use lee_core::account::{Account, AccountId, Data, Nonce};
use twap_oracle_core::compute_current_tick_account_pda;

use super::*;
Expand Down
4 changes: 2 additions & 2 deletions programs/amm/src/initialize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use amm_core::{compute_config_pda, compute_config_pda_seed, AmmConfig};
use nssa_core::{
use lee_core::{
account::{Account, AccountId, AccountWithMetadata, Data},
program::{AccountPostState, Claim, ProgramId},
};
Expand Down Expand Up @@ -51,7 +51,7 @@ pub fn initialize(
#[cfg(test)]
mod tests {
use amm_core::compute_config_pda;
use nssa_core::account::{AccountId, Nonce};
use lee_core::account::{AccountId, Nonce};

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion programs/amm/src/new_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use amm_core::{
MINIMUM_LIQUIDITY,
};
use clock_core::CLOCK_01_PROGRAM_ACCOUNT_ID;
use nssa_core::{
use lee_core::{
account::{Account, AccountWithMetadata, Data},
program::{AccountPostState, ChainedCall, Claim, ProgramId},
};
Expand Down
2 changes: 1 addition & 1 deletion programs/amm/src/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use amm_core::{
PoolDefinition, MINIMUM_LIQUIDITY,
};
use clock_core::CLOCK_01_PROGRAM_ACCOUNT_ID;
use nssa_core::{
use lee_core::{
account::{AccountWithMetadata, Data},
program::{AccountPostState, ChainedCall, ProgramId},
};
Expand Down
2 changes: 1 addition & 1 deletion programs/amm/src/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use amm_core::{
};
pub use amm_core::{compute_liquidity_token_pda_seed, compute_vault_pda_seed, PoolDefinition};
use clock_core::CLOCK_01_PROGRAM_ACCOUNT_ID;
use nssa_core::{
use lee_core::{
account::{AccountId, AccountWithMetadata, Data},
program::{AccountPostState, ChainedCall, ProgramId},
};
Expand Down
2 changes: 1 addition & 1 deletion programs/amm/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use amm_core::{
read_vault_fungible_balances, spot_price_q64_64, AmmConfig, PoolDefinition, MINIMUM_LIQUIDITY,
};
use clock_core::CLOCK_01_PROGRAM_ACCOUNT_ID;
use nssa_core::{
use lee_core::{
account::{AccountWithMetadata, Data},
program::{AccountPostState, ChainedCall, ProgramId},
};
Expand Down
Loading
Loading