refactor!: rename nssa crate to lee

BREAKING CHANGE:
- Crate `nssa` renamed to `lee`; update `Cargo.toml` dependencies from `nssa = { workspace = true }` to `lee = { workspace = true }`.
- Crate `nssa_core` renamed to `lee_core`; update similarly.
- Crate `key_protocol` moved under `lee`; update `Cargo.toml` dependencies from `key_protocol = { workspace = true }` to `lee_key_protocol = { workspace = true }`.
- Type `NSSATransaction` (in `common`) renamed to `LeeTransaction`.
- Error type `nssa::error::NssaError` renamed to `lee::error::LeeError`.
- Error type `nssa_core::error::NssaCoreError` renamed to `lee_core::error::LeeCoreError`.
- All `use nssa::` and `use nssa_core::` import paths must be updated to `use lee::` and `use lee_core::` respectively.
- Guest programs must replace `write_nssa_outputs` with `write_lee_outputs`.
- The sequencer RocksDB column family for the chain state was renamed. Existing databases are incompatible and must be wiped before running the new version.
- Domain separators updated: `"NSSA_seed"` → `"LEE_seed"` (key derivation), `"NSSA/v0.2/KDF-SHA256/"` → `"LEE/v0.2/KDF-SHA256/"` (encryption KDF), `"/NSSA/v0.2/AccountId/PDA/"` →
  `"/LEE/v0.2/AccountId/PDA/"` (public PDA address derivation). All previously derived keys, encrypted outputs, and public PDA addresses are invalidated.
This commit is contained in:
Sergio Chouhy
2026-06-01 17:11:42 -03:00
parent d3390efc6d
commit 4bcffafe27
305 changed files with 1985 additions and 1915 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ license = { workspace = true }
workspace = true
[dependencies]
nssa_core.workspace = true
lee_core.workspace = true
authenticated_transfer_core.workspace = true
clock_core.workspace = true
faucet_core.workspace = true
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs};
/// A variant of `noop` that asserts every `pre_state.is_authorized == true` before echoing
/// the `post_states`. Any unauthorized `pre_state` panics the guest, failing the whole
@@ -15,7 +15,7 @@ fn main() {
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
for pre in &pre_states {
assert!(
@@ -1,6 +1,5 @@
use nssa_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput,
read_nssa_inputs,
use lee_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs,
};
/// PDA authorization program that delegates balance operations to `authenticated_transfer`.
@@ -39,7 +38,7 @@ fn main() {
instruction: (pda_seed, auth_transfer_id, amount, is_withdraw),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
if is_withdraw {
let Ok([pda_pre, recipient_pre]) = <[_; 2]>::try_from(pre_states.clone()) else {
+2 -2
View File
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = u128;
@@ -11,7 +11,7 @@ fn main() {
instruction: balance_to_burn,
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,7 +1,6 @@
use authenticated_transfer_core::Instruction as AuthTransferInstruction;
use nssa_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput,
read_nssa_inputs,
use lee_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs,
};
use risc0_zkvm::serde::to_vec;
@@ -20,7 +19,7 @@ fn main() {
instruction: (balance, auth_transfer_id, num_chain_calls, pda_seed),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([recipient_pre, sender_pre]) = <[_; 2]>::try_from(pre_states) else {
return;
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = (Option<Vec<u8>>, bool);
@@ -12,7 +12,7 @@ fn main() {
instruction: (data_opt, should_claim),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = ();
@@ -11,7 +11,7 @@ fn main() {
instruction: (),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,7 +1,7 @@
use nssa_core::{
use lee_core::{
Timestamp,
program::{
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_nssa_inputs,
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs,
},
};
use risc0_zkvm::serde::to_vec;
@@ -20,7 +20,7 @@ fn main() {
instruction: (clock_program_id, timestamp),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let post_states: Vec<_> = pre_states
.iter()
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = Vec<u8>;
@@ -12,7 +12,7 @@ fn main() {
instruction: data,
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,6 +1,6 @@
use nssa_core::{
use lee_core::{
account::Account,
program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs},
program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs},
};
type Instruction = ();
@@ -14,7 +14,7 @@ fn main() {
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,7 +1,7 @@
use nssa_core::{
use lee_core::{
account::AccountId,
program::{
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_nssa_inputs,
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs,
},
};
use risc0_zkvm::serde::to_vec;
@@ -18,7 +18,7 @@ fn main() {
instruction: (faucet_program_id, vault_program_id, recipient_id, amount),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let post_states: Vec<_> = pre_states
.iter()
@@ -24,9 +24,8 @@
//! called by any program. In production, a callback would typically verify the caller
//! if it needs to trust the context it is called from.
use nssa_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput,
read_nssa_inputs,
use lee_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs,
};
use serde::{Deserialize, Serialize};
@@ -48,7 +47,7 @@ fn main() {
instruction,
},
instruction_words,
) = read_nssa_inputs::<CallbackInstruction>();
) = read_lee_inputs::<CallbackInstruction>();
// pre_states[0] = vault (after transfer out), pre_states[1] = receiver (after transfer out)
let Ok([vault_pre, receiver_pre]) = <[_; 2]>::try_from(pre_states) else {
@@ -31,15 +31,14 @@
//!
//! # Tests
//!
//! See `nssa/src/state.rs` for integration tests:
//! See `lee/src/state.rs` for integration tests:
//! - `flash_swap_successful`: full round-trip, funds returned, state unchanged
//! - `flash_swap_callback_keeps_funds_rollback`: callback keeps funds, full rollback
//! - `flash_swap_self_call_targets_correct_program`: zero-amount self-call isolation test
//! - `flash_swap_standalone_invariant_check_rejected`: `caller_program_id` access control
use nssa_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput,
read_nssa_inputs,
use lee_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs,
};
use serde::{Deserialize, Serialize};
@@ -78,7 +77,7 @@ fn main() {
instruction,
},
instruction_words,
) = read_nssa_inputs::<FlashSwapInstruction>();
) = read_lee_inputs::<FlashSwapInstruction>();
match instruction {
FlashSwapInstruction::Initiate {
@@ -1,7 +1,7 @@
use nssa_core::{
use lee_core::{
account::AccountWithMetadata,
program::{
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_nssa_inputs,
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs,
},
};
use risc0_zkvm::serde::to_vec;
@@ -20,7 +20,7 @@ fn main() {
instruction: (balance, transfer_program_id),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([sender, receiver]) = <[_; 2]>::try_from(pre_states) else {
return;
@@ -1,5 +1,5 @@
use nssa_core::program::{
AccountPostState, DEFAULT_PROGRAM_ID, ProgramInput, ProgramOutput, read_nssa_inputs,
use lee_core::program::{
AccountPostState, DEFAULT_PROGRAM_ID, ProgramInput, ProgramOutput, read_lee_inputs,
};
type Instruction = ();
@@ -13,7 +13,7 @@ fn main() {
instruction: (),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let post_states = pre_states
.iter()
@@ -1,7 +1,7 @@
use nssa_core::{
use lee_core::{
account::{Account, AccountId, AccountWithMetadata, Data, Nonce},
program::{
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_nssa_inputs,
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs,
},
};
@@ -48,7 +48,7 @@ fn main() {
),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
// Echo own pre_states (attacker's account) unchanged.
let post_states = pre_states
@@ -1,4 +1,4 @@
use nssa_core::program::{ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs};
/// Instruction: (`auth_transfer_id`, `amount`) — both primitive, safe for `risc0_zkvm::serde`.
type Instruction = (ProgramId, u128);
@@ -12,7 +12,7 @@ fn main() {
instruction: (auth_transfer_id, amount),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
// Output empty pre/post states. P2 processes no accounts itself, so the
// authorization check at validated_state_diff.rs:158-182 runs over nothing.
@@ -1,5 +1,5 @@
use nssa_core::program::{
AccountPostState, DEFAULT_PROGRAM_ID, ProgramInput, ProgramOutput, read_nssa_inputs,
use lee_core::program::{
AccountPostState, DEFAULT_PROGRAM_ID, ProgramInput, ProgramOutput, read_lee_inputs,
};
type Instruction = ();
@@ -13,7 +13,7 @@ fn main() {
instruction: (),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let post_states = pre_states
.iter()
+2 -2
View File
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = ();
@@ -11,7 +11,7 @@ fn main() {
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = ();
@@ -11,7 +11,7 @@ fn main() {
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre1, pre2]) = <[_; 2]>::try_from(pre_states) else {
return;
@@ -3,9 +3,9 @@
reason = "This program is intentionally malicious and is expected to have side effects."
)]
use nssa_core::{
use lee_core::{
account::{Account, AccountWithMetadata},
program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs},
program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs},
};
/// Initializes a default account under the ownership of this program.
@@ -70,7 +70,7 @@ fn main() {
instruction: balance_to_move,
},
instruction_data,
) = read_nssa_inputs();
) = read_lee_inputs();
let post_states = match (pre_states.as_slice(), balance_to_move) {
([account_to_claim], 0) => {
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = ();
@@ -11,7 +11,7 @@ fn main() {
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
+2 -2
View File
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = ();
@@ -11,7 +11,7 @@ fn main() {
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let post_states = pre_states
.iter()
@@ -1,5 +1,5 @@
use nssa_core::program::{
AccountPostState, Claim, PdaSeed, ProgramInput, ProgramOutput, read_nssa_inputs,
use lee_core::program::{
AccountPostState, Claim, PdaSeed, ProgramInput, ProgramOutput, read_lee_inputs,
};
type Instruction = PdaSeed;
@@ -13,7 +13,7 @@ fn main() {
instruction: seed,
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,6 +1,5 @@
use nssa_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput,
read_nssa_inputs,
use lee_core::program::{
AccountPostState, ChainedCall, PdaSeed, ProgramId, ProgramInput, ProgramOutput, read_lee_inputs,
};
use risc0_zkvm::serde::to_vec;
@@ -19,7 +18,7 @@ fn main() {
instruction: (seed, amount, auth_transfer_id),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([first, second]) = <[_; 2]>::try_from(pre_states) else {
return;
@@ -13,7 +13,7 @@
//! [prize: u64 LE | `cooldown_ms`: u64 LE | `last_claim_timestamp`: u64 LE].
use clock_core::{CLOCK_01_PROGRAM_ACCOUNT_ID, ClockAccountData};
use nssa_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, Claim, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = ();
@@ -54,7 +54,7 @@ fn main() {
instruction: (),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pinata, winner, clock_pre]) = <[_; 3]>::try_from(pre_states) else {
panic!("Expected exactly 3 input accounts: pinata, winner, clock");
@@ -1,6 +1,6 @@
use nssa_core::program::{
use lee_core::program::{
AccountPostState, ChainedCall, Claim, PdaSeed, ProgramId, ProgramInput, ProgramOutput,
read_nssa_inputs,
read_lee_inputs,
};
use risc0_zkvm::serde::to_vec;
@@ -20,7 +20,7 @@ fn main() {
instruction: (claim_seed, delegated_seed, callee_program_id),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = ();
@@ -11,7 +11,7 @@ fn main() {
..
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,4 +1,4 @@
use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs};
type Instruction = u128;
@@ -11,7 +11,7 @@ fn main() {
instruction: balance,
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([sender_pre, receiver_pre]) = <[_; 2]>::try_from(pre_states) else {
return;
@@ -10,7 +10,7 @@
//! 2 - clock account (read-only, e.g. `CLOCK_01`).
use clock_core::{CLOCK_01_PROGRAM_ACCOUNT_ID, ClockAccountData};
use nssa_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_nssa_inputs};
use lee_core::program::{AccountPostState, ProgramInput, ProgramOutput, read_lee_inputs};
/// (`amount`, `deadline_timestamp`).
type Instruction = (u128, u64);
@@ -24,7 +24,7 @@ fn main() {
instruction: (amount, deadline),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([sender_pre, receiver_pre, clock_pre]) = <[_; 3]>::try_from(pre_states) else {
panic!("Expected exactly 3 input accounts: sender, receiver, clock");
@@ -1,5 +1,5 @@
use nssa_core::program::{
AccountPostState, Claim, PdaSeed, ProgramInput, ProgramOutput, read_nssa_inputs,
use lee_core::program::{
AccountPostState, Claim, PdaSeed, ProgramInput, ProgramOutput, read_lee_inputs,
};
/// Claims two `pre_states` under the same `seed`. Used to exercise the tx-wide
@@ -17,7 +17,7 @@ fn main() {
instruction: seed,
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre_a, pre_b]) = <[_; 2]>::try_from(pre_states) else {
return;
@@ -1,6 +1,6 @@
use nssa_core::program::{
use lee_core::program::{
AccountPostState, BlockValidityWindow, ProgramInput, ProgramOutput, TimestampValidityWindow,
read_nssa_inputs,
read_lee_inputs,
};
type Instruction = (BlockValidityWindow, TimestampValidityWindow);
@@ -14,7 +14,7 @@ fn main() {
instruction: (block_validity_window, timestamp_validity_window),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let Ok([pre]) = <[_; 1]>::try_from(pre_states) else {
return;
@@ -1,6 +1,6 @@
use nssa_core::program::{
use lee_core::program::{
AccountPostState, BlockValidityWindow, ChainedCall, ProgramId, ProgramInput, ProgramOutput,
TimestampValidityWindow, read_nssa_inputs,
TimestampValidityWindow, read_lee_inputs,
};
use risc0_zkvm::serde::to_vec;
@@ -22,7 +22,7 @@ fn main() {
instruction: (block_validity_window, chained_program_id, chained_block_validity_window),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
) = read_lee_inputs::<Instruction>();
let [pre] = <[_; 1]>::try_from(pre_states.clone()).expect("Expected exactly one pre state");
let post = pre.account.clone();