Skip to content

Commit

Permalink
Add return data for process (#188)
Browse files Browse the repository at this point in the history
* add cuda

* bugfix

* replace unwrap with proper error handle in state_storage

* ADD: system contract test.

* ADD: test data for sys-contract debug.

* Add error handle in zk-vm

* MOD: sys contract.

* MOD: init tape.

* MOD: sys contract.

* Deal error handle in executor

* FIX: tape init.

* MOD: debug sys contracts.

* update ntt logic

* MOD: sys contracts.

* remove Drop for OlaStark

* add remark to fri_proof_of_work

* FIX: bytes poseidon.

* ADD: finish_batch.

* error handle progressing

* error handle: use for loop instead of iterator fold

* error handle: mutex lock

* update execute tx and return result

* MOD: StorageQuery add block_timestamp.

* error handling progressing

* error handling progressing

* MOD: StorageQuery add pre_value and init_write type.

* bugfix

* error handling for executor module

* error handle: remove panic in executor module

* error handle progressing

* FIX: callee exe code when init tape.

* error handle

* FIX: addr params.

* Error handle for UpdatesBatch

* FIX: missing StorageQueries.

* error handle progressing

* fmt code

* fix typos

* fix some warnings

* fix bug

* Update system contract json

* Refactor code

* Refactor code

* Save data in tape when tstore, remove it when sccall

* FIX: storage cache.

* refactor code

* remove useless commemnt

---------

Co-authored-by: peinlcy <[email protected]>
Co-authored-by: web3Softcloud <[email protected]>
Co-authored-by: Softcloud <[email protected]>
  • Loading branch information
4 people authored and YancyParker committed Jan 29, 2024
1 parent 9fa8524 commit 4da8442
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assembler/test_data/asm/sys/NonceHolder_asm.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core/src/state/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::crypto::hash::Hasher;
use crate::merkle_tree::log::StorageQuery;
use crate::merkle_tree::log::StorageQuery;
use crate::state::contracts::Contracts;
use std::collections::BTreeMap;

Expand Down
5 changes: 5 additions & 0 deletions executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use core::state::state_storage::StateStorage;
use core::vm::error::ProcessorError;
use core::vm::memory::{MemoryTree, HP_START_ADDR, PSP_START_ADDR};

use core::merkle_tree::log::{StorageLog, StorageQuery};
use core::merkle_tree::log::{StorageLogKind, WitnessStorageLog};
use core::merkle_tree::log::{StorageLog, StorageQuery};
use core::merkle_tree::log::{StorageLogKind, WitnessStorageLog};
use core::merkle_tree::tree::AccountTree;
Expand Down Expand Up @@ -250,6 +252,7 @@ pub struct Process {
impl Process {
pub fn new() -> Self {
Self {
block_timestamp: 0,
block_timestamp: 0,
env_idx: Default::default(),
call_sc_cnt: Default::default(),
Expand Down Expand Up @@ -1906,8 +1909,10 @@ impl Process {

if op1_value.0 == GoldilocksField::ONE {
append_caller_callee_addr(self, self.addr_storage, callee_address, self.addr_storage);
append_caller_callee_addr(self, self.addr_storage, callee_address, self.addr_storage);
} else if op1_value.0 == GoldilocksField::ZERO {
append_caller_callee_addr(self, self.addr_storage, callee_address, callee_address);
append_caller_callee_addr(self, self.addr_storage, callee_address, callee_address);
} else {
return Err(ProcessorError::ParseOpcodeError);
}
Expand Down
19 changes: 19 additions & 0 deletions executor/src/load_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,28 @@ load_ctx_to_tape!(load_tx_context, TxCtxInfo);
// process.tp += GoldilocksField::from_canonical_u64(ctx_addr_len as u64);
// }

// pub fn init_tape(
// process: &mut Process,
// mut calldata: Vec<GoldilocksField>,
// caller_exe_addr: Address,
// callee_addr: Address,
// callee_exe_addr: Address,
// ctx_info: &TxCtxInfo,
// ) {
// let tp_start = load_tx_context(process, ctx_info);
// process.tp = GoldilocksField::from_canonical_u64(tp_start as u64);
// load_tx_calldata(process, &calldata);
// let ctx_addr_len = load_ctx_addr_info(
// process,
// &init_ctx_addr_info(caller_exe_addr, callee_addr, callee_exe_addr),
// );
// process.tp += GoldilocksField::from_canonical_u64(ctx_addr_len as u64);
// }

pub fn init_tape(
process: &mut Process,
calldata: Vec<GoldilocksField>,
calldata: Vec<GoldilocksField>,
caller_exe_addr: Address,
callee_addr: Address,
callee_exe_addr: Address,
Expand Down
11 changes: 11 additions & 0 deletions zk-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ impl OlaVM {
caller_addr,
code_exe_addr,
code_exe_addr,
code_exe_addr,
&self.ctx_info,
);
let mut program = Program::default();
Expand Down Expand Up @@ -441,6 +442,7 @@ impl OlaVM {
}
self.ola_state.txs_trace.insert(env_id, trace);
self.ola_state.storage_queries.append(&mut storage_queries);
self.ola_state.storage_queries.append(&mut storage_queries);
env_idx -= 1;
process.tp = tp;
process.tape = tape_tree;
Expand Down Expand Up @@ -475,4 +477,13 @@ impl OlaVM {
false,
)
}

pub fn finish_batch(&mut self, block_number: u32) -> Result<(), StateError> {
let entry_point_addr = [0, 0, 0, 32769].map(|l| GoldilocksField::from_canonical_u64(l));
let calldata = [block_number as u64, 1, 2190639505]
.iter()
.map(|l| GoldilocksField::from_canonical_u64(*l))
.collect();
self.execute_tx(entry_point_addr, entry_point_addr, calldata, false)
}
}

0 comments on commit 4da8442

Please sign in to comment.