mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-25 03:11:21 +00:00
refactor validity window with generic
This commit is contained in:
@@ -1,19 +1,14 @@
|
||||
use nssa_core::program::{
|
||||
AccountPostState, BlockId, ProgramInput, ProgramOutput, Timestamp, read_nssa_inputs,
|
||||
AccountPostState, BlockId, ProgramInput, ProgramOutput, ValidityWindow, read_nssa_inputs,
|
||||
};
|
||||
|
||||
type Instruction = (
|
||||
Option<BlockId>,
|
||||
Option<BlockId>,
|
||||
Option<Timestamp>,
|
||||
Option<Timestamp>,
|
||||
);
|
||||
type Instruction = ValidityWindow<BlockId>;
|
||||
|
||||
fn main() {
|
||||
let (
|
||||
ProgramInput {
|
||||
pre_states,
|
||||
instruction: validity_window,
|
||||
instruction: block_validity_window,
|
||||
},
|
||||
instruction_words,
|
||||
) = read_nssa_inputs::<Instruction>();
|
||||
@@ -29,7 +24,6 @@ fn main() {
|
||||
vec![pre],
|
||||
vec![AccountPostState::new(post)],
|
||||
)
|
||||
.try_with_validity_window(validity_window)
|
||||
.unwrap()
|
||||
.with_block_validity_window(block_validity_window)
|
||||
.write();
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
use nssa_core::program::{
|
||||
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, ValidityWindow,
|
||||
AccountPostState, BlockId, ChainedCall, ProgramId, ProgramInput, ProgramOutput, ValidityWindow,
|
||||
read_nssa_inputs,
|
||||
};
|
||||
use risc0_zkvm::serde::to_vec;
|
||||
|
||||
/// A program that sets a validity window on its output and chains to another program with a
|
||||
/// potentially different validity window.
|
||||
/// A program that sets a block validity window on its output and chains to another program with a
|
||||
/// potentially different block validity window.
|
||||
///
|
||||
/// Instruction: (`window`, `chained_program_id`, `chained_window`)
|
||||
/// The initial output uses `window` and chains to `chained_program_id` with `chained_window`.
|
||||
type Instruction = (ValidityWindow, ProgramId, ValidityWindow);
|
||||
type Instruction = (ValidityWindow<BlockId>, ProgramId, ValidityWindow<BlockId>);
|
||||
|
||||
fn main() {
|
||||
let (
|
||||
ProgramInput {
|
||||
pre_states,
|
||||
instruction: (validity_window, chained_program_id, chained_validity_window),
|
||||
instruction: (block_validity_window, chained_program_id, chained_block_validity_window),
|
||||
},
|
||||
instruction_words,
|
||||
) = read_nssa_inputs::<Instruction>();
|
||||
@@ -23,7 +23,7 @@ fn main() {
|
||||
let [pre] = <[_; 1]>::try_from(pre_states.clone()).expect("Expected exactly one pre state");
|
||||
let post = pre.account.clone();
|
||||
|
||||
let chained_instruction = to_vec(&chained_validity_window).unwrap();
|
||||
let chained_instruction = to_vec(&chained_block_validity_window).unwrap();
|
||||
let chained_call = ChainedCall {
|
||||
program_id: chained_program_id,
|
||||
instruction_data: chained_instruction,
|
||||
@@ -36,7 +36,7 @@ fn main() {
|
||||
vec![pre],
|
||||
vec![AccountPostState::new(post)],
|
||||
)
|
||||
.with_validity_window(validity_window)
|
||||
.with_block_validity_window(block_validity_window)
|
||||
.with_chained_calls(vec![chained_call])
|
||||
.write();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user