Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Cont dev #210

Closed
wants to merge 28 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cbb0f3c
feat: support continuation
junyu0312 Nov 14, 2023
b1a0d92
refine pre image table assignment
junyu0312 Nov 26, 2023
07c8724
refine post image table
junyu0312 Nov 26, 2023
5d79eda
review 1 fixed
junyu0312 Nov 27, 2023
2da075a
fix
junyu0312 Nov 27, 2023
f2fbe05
update comment
junyu0312 Dec 11, 2023
7530eb2
fix: use F instead of AssignedCell to avoid unwrap
junyu0312 Dec 11, 2023
64fda69
fix: fix termination state and imtable
junyu0312 Dec 11, 2023
2517cc2
fix etable assignment
junyu0312 Dec 12, 2023
dad3058
fix: fix constraints of etable
junyu0312 Dec 12, 2023
d3d0986
refine image table
junyu0312 Dec 12, 2023
3e234ba
refine image table
junyu0312 Dec 12, 2023
29c99b4
fix hardcode
junyu0312 Dec 13, 2023
06f99e4
add transpose for InitializationState
junyu0312 Dec 13, 2023
9febe19
chore: refine image table assignment
junyu0312 Dec 13, 2023
0a6b45d
fmt code
junyu0312 Dec 13, 2023
b54a506
set the number of frame table entry always 2
junyu0312 Dec 14, 2023
09b8638
fix code style
junyu0312 Dec 14, 2023
208b804
fix comment
junyu0312 Dec 14, 2023
6773632
add name for post image table col
junyu0312 Dec 14, 2023
d861066
fix image table assigner
junyu0312 Dec 14, 2023
1fd2066
fix circuit_without_witness
junyu0312 Dec 15, 2023
ce30af3
fix rlp_slice test
junyu0312 Dec 15, 2023
bdfbb8e
fix compiling error
junyu0312 Dec 15, 2023
418274f
fix code style
junyu0312 Dec 18, 2023
e884de6
fix: fix a bug of post image table
junyu0312 Dec 18, 2023
11a01cc
refine etable assignment
junyu0312 Dec 21, 2023
f933ea8
decrease the degree of post init memory lookup
junyu0312 Dec 22, 2023
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
Prev Previous commit
Next Next commit
review 1 fixed
  • Loading branch information
junyu0312 committed Nov 27, 2023
commit 5d79edab771ad60febeef4e01e40fd306f3c612b
13 changes: 3 additions & 10 deletions crates/specs/src/encode/image_table.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use num_bigint::BigUint;
use num_bigint::ToBigUint;

use crate::encode::br_table::BR_TABLE_ENCODE_BOUNDARY;
@@ -22,14 +21,8 @@ impl ImageTableEncoder {
assert!(BR_TABLE_ENCODE_BOUNDARY <= CLASS_SHIFT);
assert!(INIT_MEMORY_ENCODE_BOUNDARY <= CLASS_SHIFT);

let tag = if cfg!(feature = "continuation") && *self == ImageTableEncoder::InitMemory {
// Memory Initialization Lookup with continuation
T::from_bn(&BigUint::zero())
} else {
T::from_bn(&(*self as u64).to_biguint().unwrap())
* T::from_bn(&(1u64.to_biguint().unwrap() << CLASS_SHIFT))
};

tag + data
T::from_bn(&(*self as u64).to_biguint().unwrap())
* T::from_bn(&(1u64.to_biguint().unwrap() << CLASS_SHIFT))
+ data
}
}
18 changes: 9 additions & 9 deletions crates/specs/src/encode/init_memory_table.rs
Original file line number Diff line number Diff line change
@@ -17,24 +17,24 @@ pub fn encode_init_memory_table_entry<T: FromBn>(
eid: T,
value: T,
) -> T {
const LTYPE_SHIFT: u32 = OFFSET_SHIFT + 32;
const LTYPE_SHIFT: u32 = OFFSET_SHIFT + u32::BITS;
const OFFSET_SHIFT: u32 = IS_MUTABLE_SHIFT + 1;
const IS_MUTABLE_SHIFT: u32 = EID_OFFSET_SHIFT + 32;
const IS_MUTABLE_SHIFT: u32 = EID_OFFSET_SHIFT + u32::BITS;
const EID_OFFSET_SHIFT: u32 = VALUE_SHIFT + 64;
const VALUE_SHIFT: u32 = 0;

assert!(LTYPE_SHIFT + 8 <= INIT_MEMORY_ENCODE_BOUNDARY);

let encode = is_mutable * T::from_bn(&(1u64.to_biguint().unwrap() << IS_MUTABLE_SHIFT))
+ eid * T::from_bn(&(1u64.to_biguint().unwrap() << EID_OFFSET_SHIFT))
+ value;

if cfg!(feature = "continuation") {
encode
} else {
ltype * T::from_bn(&(1u64.to_biguint().unwrap() << LTYPE_SHIFT))
+ offset * T::from_bn(&(1u64.to_biguint().unwrap() << OFFSET_SHIFT))
+ is_mutable * T::from_bn(&(1u64.to_biguint().unwrap() << IS_MUTABLE_SHIFT))
+ eid * T::from_bn(&(1u64.to_biguint().unwrap() << EID_OFFSET_SHIFT))
+ value
} else {
is_mutable * T::from_bn(&(1u64.to_biguint().unwrap() << IS_MUTABLE_SHIFT))
+ eid * T::from_bn(&(1u64.to_biguint().unwrap() << EID_OFFSET_SHIFT))
+ value
+ encode
}
}

6 changes: 3 additions & 3 deletions crates/zkwasm/src/circuits/mtable/allocator.rs
Original file line number Diff line number Diff line change
@@ -83,9 +83,9 @@ pub(super) enum MemoryTableCellType {

const BIT_COLUMNS: usize = 3;
const U16_COLUMNS: usize = U32_CELLS.next_multiple_of(2) / 2 + U64_CELLS;
const COMMON_RANGE_COLUMNS: usize = 2;
const UNLIMITED_COLUMNS: usize = if cfg!(feature = "continuation") { 4 } else { 3 };
const U32_CELLS: usize = if cfg!(feature = "continuation") { 9 } else { 6 };
const COMMON_RANGE_COLUMNS: usize = if cfg!(feature = "continuation") { 1 } else { 2 };
const UNLIMITED_COLUMNS: usize = if cfg!(feature = "continuation") { 3 } else { 2 };
const U32_CELLS: usize = if cfg!(feature = "continuation") { 5 } else { 2 };
const U64_CELLS: usize = 1;

#[derive(Debug, Clone)]
4 changes: 2 additions & 2 deletions crates/zkwasm/src/circuits/test_circuit/mod.rs
Original file line number Diff line number Diff line change
@@ -56,9 +56,9 @@ use super::image_table::ImageTableConfig;
use super::post_image_table::PostImageTableConfig;

pub const VAR_COLUMNS: usize = if cfg!(feature = "continuation") {
63
59
} else {
54
51
};

// Reserve a few rows to keep usable rows away from blind rows.