mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-26 14:41:12 +00:00
chore: update to LEZ v0.2.0-rc6
Bump the LEZ dependency from the `lez-core-v0.2.0` tag to `v0.2.0-rc6` across the workspace and all guest manifests (still resolving via the renamed `lee_core`/`lee` packages), and regenerate the lockfiles to match. rc6 moved the clock program out of `nssa` into a separate system-programs crate (gated behind the guest-building `artifacts` feature), so adapt the tests: - Import `ClockAccountData` and `CLOCK_01_PROGRAM_ACCOUNT_ID` from `clock_core` instead of `nssa`, and build clock data via `ClockAccountData::to_bytes()` rather than hand-encoding the Borsh layout. - `V03State::new()` no longer auto-creates the clock account, so AMM tests seed the canonical 1-block clock explicitly before ops that read it. - `advance_clock` now writes the clock account directly via `force_insert_account` (the clock can no longer be ticked with a real transaction), matching how upstream rc6 state-machine tests seed accounts. - Add the `clock_core` dependency to integration_tests/benchmark.
This commit is contained in:
@@ -9,6 +9,7 @@ workspace = true
|
||||
[dependencies]
|
||||
nssa = { workspace = true }
|
||||
nssa_core = { workspace = true, features = ["host", "test_utils"] }
|
||||
clock_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.0-rc6" }
|
||||
amm_core = { workspace = true }
|
||||
token_core = { workspace = true }
|
||||
ata_core = { workspace = true }
|
||||
|
||||
@@ -7,11 +7,11 @@ use amm_core::{
|
||||
PoolDefinition, FEE_TIER_BPS_1, FEE_TIER_BPS_100, FEE_TIER_BPS_30, FEE_TIER_BPS_5,
|
||||
MINIMUM_LIQUIDITY,
|
||||
};
|
||||
use clock_core::{ClockAccountData, CLOCK_01_PROGRAM_ACCOUNT_ID};
|
||||
use nssa::{
|
||||
error::LeeError,
|
||||
program_deployment_transaction::{self, ProgramDeploymentTransaction},
|
||||
public_transaction, PrivateKey, PublicKey, PublicTransaction, V03State,
|
||||
CLOCK_01_PROGRAM_ACCOUNT_ID,
|
||||
};
|
||||
use nssa_core::account::{Account, AccountId, Data, Nonce};
|
||||
use token_core::{TokenDefinition, TokenHolding};
|
||||
@@ -977,7 +977,7 @@ fn deploy_programs(state: &mut V03State) {
|
||||
}
|
||||
|
||||
fn state_for_amm_tests() -> V03State {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(Ids::config(), Accounts::config());
|
||||
state.force_insert_account(Ids::pool_definition(), Accounts::pool_definition_init());
|
||||
@@ -1008,11 +1008,14 @@ fn state_for_amm_tests() -> V03State {
|
||||
state.force_insert_account(Ids::user_lp(), Accounts::user_lp_holding());
|
||||
state.force_insert_account(Ids::vault_a(), Accounts::vault_a_init());
|
||||
state.force_insert_account(Ids::vault_b(), Accounts::vault_b_init());
|
||||
// rc6's `V03State::new()` no longer auto-creates the clock account; seed the canonical
|
||||
// 1-block clock so AMM ops that read it (current-tick refresh, TWAP observations) work.
|
||||
advance_clock(&mut state, 0);
|
||||
state
|
||||
}
|
||||
|
||||
fn state_for_amm_tests_with_new_def() -> V03State {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(Ids::config(), Accounts::config());
|
||||
state.force_insert_account(
|
||||
@@ -1025,6 +1028,9 @@ fn state_for_amm_tests_with_new_def() -> V03State {
|
||||
);
|
||||
state.force_insert_account(Ids::user_a(), Accounts::user_a_holding());
|
||||
state.force_insert_account(Ids::user_b(), Accounts::user_b_holding());
|
||||
// rc6's `V03State::new()` no longer auto-creates the clock account; seed the canonical
|
||||
// 1-block clock so the chained TWAP calls in `new_definition` can read it.
|
||||
advance_clock(&mut state, 0);
|
||||
state
|
||||
}
|
||||
|
||||
@@ -1394,7 +1400,7 @@ fn fungible_total_supply(account: &Account) -> u128 {
|
||||
|
||||
#[test]
|
||||
fn amm_initialize_creates_config_account() {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
|
||||
// Before initialization the config PDA does not exist.
|
||||
@@ -1448,7 +1454,7 @@ fn config_data(state: &V03State) -> amm_core::AmmConfig {
|
||||
}
|
||||
|
||||
fn initialized_amm_state() -> V03State {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
execute_initialize(&mut state);
|
||||
state
|
||||
@@ -1660,21 +1666,26 @@ fn amm_create_price_observations_without_current_tick_account_fails() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Advances the canonical 1-block clock to `timestamp` by submitting a clock transaction, mirroring
|
||||
/// how the sequencer ticks the clock between blocks. `RecordTick` reads this account, so the TWAP
|
||||
/// tests use it to simulate the passage of time between observations.
|
||||
/// Advances the canonical 1-block clock to `timestamp` by writing the clock account directly into
|
||||
/// state. `RecordTick` reads this account (`CLOCK_01_PROGRAM_ACCOUNT_ID`), so the TWAP tests use it
|
||||
/// to simulate the passage of time between observations.
|
||||
///
|
||||
/// rc6 moved the clock program out of `nssa` into the separate system-programs crate (gated behind
|
||||
/// the guest-building `artifacts` feature), so the clock can no longer be ticked by submitting a
|
||||
/// real clock transaction here. Instead we set the account state directly via
|
||||
/// `force_insert_account`, matching how the upstream rc6 state-machine tests seed accounts.
|
||||
#[cfg(test)]
|
||||
fn advance_clock(state: &mut V03State, timestamp: u64) {
|
||||
let message = public_transaction::Message::try_new(
|
||||
nssa::program::Program::clock().id(),
|
||||
nssa::CLOCK_PROGRAM_ACCOUNT_IDS.to_vec(),
|
||||
vec![],
|
||||
let data = ClockAccountData {
|
||||
block_id: 0,
|
||||
timestamp,
|
||||
)
|
||||
.unwrap();
|
||||
let witness_set = public_transaction::WitnessSet::for_message(&message, &[]);
|
||||
let tx = PublicTransaction::new(message, witness_set);
|
||||
state.transition_from_public_transaction(&tx, 0, 0).unwrap();
|
||||
}
|
||||
.to_bytes();
|
||||
let clock_account = Account {
|
||||
data: Data::try_from(data).expect("clock account data fits"),
|
||||
..Account::default()
|
||||
};
|
||||
state.force_insert_account(CLOCK_01_PROGRAM_ACCOUNT_ID, clock_account);
|
||||
}
|
||||
|
||||
/// Calls the TWAP oracle's permissionless `RecordTick` directly (it is not wrapped by the AMM),
|
||||
|
||||
@@ -145,7 +145,7 @@ fn deploy_programs(state: &mut V03State) {
|
||||
}
|
||||
|
||||
fn state_for_ata_tests() -> V03State {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(Ids::token_definition(), Accounts::token_definition_init());
|
||||
state.force_insert_account(Ids::owner_ata(), Accounts::owner_ata_init());
|
||||
@@ -160,7 +160,7 @@ fn state_for_ata_tests_with_precreated_recipient_ata() -> V03State {
|
||||
|
||||
#[test]
|
||||
fn ata_create() {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(Ids::token_definition(), Accounts::token_definition_init());
|
||||
|
||||
@@ -233,7 +233,7 @@ fn ata_create_is_idempotent() {
|
||||
|
||||
#[test]
|
||||
fn ata_create_rejects_definition_owned_by_unexpected_token_program() {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(
|
||||
Ids::token_definition(),
|
||||
@@ -264,7 +264,7 @@ fn ata_create_rejects_definition_owned_by_unexpected_token_program() {
|
||||
|
||||
#[test]
|
||||
fn ata_create_rejects_existing_ata_owned_by_unexpected_token_program() {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(Ids::token_definition(), Accounts::token_definition_init());
|
||||
|
||||
@@ -293,7 +293,7 @@ fn ata_create_rejects_existing_ata_owned_by_unexpected_token_program() {
|
||||
|
||||
#[test]
|
||||
fn ata_create_rejects_existing_ata_with_mismatched_definition() {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(Ids::token_definition(), Accounts::token_definition_init());
|
||||
|
||||
@@ -503,7 +503,7 @@ fn ata_burn() {
|
||||
|
||||
#[test]
|
||||
fn ata_create_from_private_owner() {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(Ids::token_definition(), Accounts::token_definition_init());
|
||||
|
||||
@@ -535,8 +535,8 @@ fn ata_create_from_private_owner() {
|
||||
// Encapsulate a shared secret against the owner's viewing key; the circuit fills the EPK.
|
||||
let shared_secret = SharedSecretKey::encapsulate_deterministic(&owner_vpk, &[0u8; 32], 0).0;
|
||||
|
||||
let ata_program = Program::new(ata_methods::ATA_ELF.to_vec()).unwrap();
|
||||
let token_program = Program::new(token_methods::TOKEN_ELF.to_vec()).unwrap();
|
||||
let ata_program = Program::new(ata_methods::ATA_ELF.to_vec().into()).unwrap();
|
||||
let token_program = Program::new(token_methods::TOKEN_ELF.to_vec().into()).unwrap();
|
||||
let program_with_deps = ProgramWithDependencies::new(
|
||||
ata_program,
|
||||
HashMap::from([(Ids::token_program(), token_program)]),
|
||||
|
||||
@@ -184,7 +184,7 @@ fn deploy_programs(state: &mut V03State) {
|
||||
}
|
||||
|
||||
fn state_for_stablecoin_tests() -> V03State {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(
|
||||
Ids::collateral_definition(),
|
||||
@@ -199,7 +199,7 @@ fn current_nonce(state: &V03State, account_id: AccountId) -> Nonce {
|
||||
}
|
||||
|
||||
fn state_for_stablecoin_repay_tests() -> V03State {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_programs(&mut state);
|
||||
state.force_insert_account(
|
||||
Ids::collateral_definition(),
|
||||
|
||||
@@ -113,7 +113,7 @@ fn deploy_token(state: &mut V03State) {
|
||||
}
|
||||
|
||||
fn state_for_token_tests() -> V03State {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_token(&mut state);
|
||||
state.force_insert_account(Ids::token_definition(), Accounts::token_definition_init());
|
||||
state.force_insert_account(Ids::holder(), Accounts::holder_init());
|
||||
@@ -122,7 +122,7 @@ fn state_for_token_tests() -> V03State {
|
||||
}
|
||||
|
||||
fn state_for_token_tests_without_recipient() -> V03State {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_token(&mut state);
|
||||
state.force_insert_account(Ids::token_definition(), Accounts::token_definition_init());
|
||||
state.force_insert_account(Ids::holder(), Accounts::holder_init());
|
||||
@@ -131,7 +131,7 @@ fn state_for_token_tests_without_recipient() -> V03State {
|
||||
|
||||
#[test]
|
||||
fn token_new_fungible_definition() {
|
||||
let mut state = V03State::new_with_genesis_accounts(&[], vec![], 0);
|
||||
let mut state = V03State::new();
|
||||
deploy_token(&mut state);
|
||||
|
||||
let instruction = token_core::Instruction::NewFungibleDefinition {
|
||||
@@ -643,7 +643,7 @@ impl PrivateKeys {
|
||||
}
|
||||
|
||||
fn token_program() -> Program {
|
||||
Program::new(token_methods::TOKEN_ELF.to_vec()).expect("valid token ELF")
|
||||
Program::new(token_methods::TOKEN_ELF.to_vec().into()).expect("valid token ELF")
|
||||
}
|
||||
|
||||
/// Performs a shielded transfer (public → private) of `amount` tokens from
|
||||
|
||||
Reference in New Issue
Block a user