Skip to content

Commit

Permalink
rename table to in_first_table
Browse files Browse the repository at this point in the history
  • Loading branch information
z2trillion committed Aug 21, 2024
1 parent 82fe918 commit ba059ad
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
3 changes: 1 addition & 2 deletions zkevm-circuits/src/copy_circuit/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
copy_circuit::{CopyCircuitConfig, CopyCircuitConfigArgs},
table::{BytecodeTable, CopyTable, RwTable, TxTable},
util::{Challenges, Field, SubCircuit, SubCircuitConfig},
witness::Block,
};
use halo2_proofs::{
circuit::{Layouter, SimpleFloorPlanner},
Expand Down Expand Up @@ -81,7 +80,7 @@ impl<F: Field> Circuit<F> for CopyCircuit<F> {
.external_data
.bytecodes
.values()
.partition(|b| b.table == false);
.partition(|b| b.in_first_table);
config
.0
.bytecode_table
Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/evm_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl<F: Field> Circuit<F> for EvmCircuit<F> {
{
// when enable feature "dual_bytecode", get two sets of bytecodes here.
let (first_bytecodes, second_bytecodes): (Vec<_>, Vec<_>) =
block.bytecodes.values().partition(|b| b.table);
block.bytecodes.values().partition(|b| b.in_first_table);
if !first_bytecodes.is_empty() {
// assign first bytecode_table
config
Expand Down
20 changes: 14 additions & 6 deletions zkevm-circuits/src/witness/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,21 +283,29 @@ impl Block {
log::debug!("start num: {}", self.rws.rw_num(RwTableTag::Start));
}

// TODO: migrate copy circuit and delete this!!!!!
/// as;dlfkjaw;elkrjasd;lkfja;lsfj
/// TODO: migrate copy circuit and delete this!!!!!
pub fn bytecode_map(&self) -> Option<BTreeMap<Word, bool>> {
Some(
self.bytecodes
.values()
.map(|b| (b.hash, b.table == false)) // TODO: did you get the direction correct?
.map(|b| (b.hash, b.in_first_table))
.collect(),
)
}

// This helper returns bytecodes's whether `code_hash` is belong to first bytecode circuit.
// always return true when feature 'dual_bytecode' is disabled.
pub(crate) fn is_first_sub_bytecode_circuit(&self, code_hash: &U256) -> bool {
self.bytecodes.get(code_hash).map_or(true, |b| !b.table)
self.bytecodes.get(code_hash).map_or(true, |b| {
#[cfg(feature = "dual_bytecode")]
{
b.in_first_table
}
#[cfg(not(feature = "dual_bytecode"))]
{
true
}
})
}
}

Expand Down Expand Up @@ -653,7 +661,7 @@ fn get_bytecodes(code_db: &CodeDB) -> BTreeMap<Word, Bytecode> {
.map(|(code_hash, bytes)| {
let hash = Word::from_big_endian(code_hash.as_bytes());
#[cfg(feature = "dual_bytecode")]
let table = if first_set.contains(&bytes.len()) {
let in_first_table = if first_set.contains(&bytes.len()) {
let index = first_set.iter().position(|&x| x == bytes.len()).unwrap();
first_set.remove(index);
true
Expand All @@ -670,7 +678,7 @@ fn get_bytecodes(code_db: &CodeDB) -> BTreeMap<Word, Bytecode> {
hash,
bytes: bytes.clone(),
#[cfg(feature = "dual_bytecode")]
table,
in_first_table,
},
)
})
Expand Down
4 changes: 2 additions & 2 deletions zkevm-circuits/src/witness/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub struct Bytecode {
/// Raw bytes
pub bytes: Vec<u8>,
#[cfg(feature = "dual_bytecode")]
/// as;dlfkjasd;lfkjas
pub table: bool, // TODO make this an enum or usize?
/// This bytecode is in the first bytecode table.
pub in_first_table: bool,
}

impl Bytecode {
Expand Down

0 comments on commit ba059ad

Please sign in to comment.