Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into minor-endtx-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
curryrasul authored Jan 19, 2024
2 parents a134bf6 + 5388d17 commit fd9fa79
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 42 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"zkevm-circuits",
"bus-mapping",
Expand Down
1 change: 1 addition & 0 deletions bus-mapping/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl RWCounter {
}

/// Enum used to differenciate between EVM Stack, Memory and Storage operations.
/// This is also used as the RwTableTag for the RwTable.
#[derive(Debug, Clone, PartialEq, Eq, Copy, EnumIter, Hash)]
pub enum Target {
/// Start is a padding operation.
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mock_prover = []

[build-dependencies]
env = "0.0.0"
ethers = "=2.0.10"
ethers = { version = "=2.0.10", features = ["ethers-solc"] }
ethers-contract-abigen = "=2.0.10"
glob = "0.3.1"
log = "0.4.14"
Expand Down
3 changes: 1 addition & 2 deletions light-client-poc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "light-client-poc"
version = "0.1.0"
edition = "2021"
resolver = "2"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -28,4 +27,4 @@ ahash = "=0.8.6"
ctor = "0.1.22"

[features]
disable-keccak = []
disable-keccak = []
2 changes: 1 addition & 1 deletion mpt-witness-generator/oracle/preimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Preimage(hash common.Hash) ([]byte, error) {
return val, nil
}

// TODO: Maybe we will want to have a seperate preimages for next block's preimages?
// TODO: Maybe we will want to have a separate preimages for next block's preimages?
func Preimages() map[common.Hash][]byte {
return preimages
}
Expand Down
2 changes: 1 addition & 1 deletion mpt-witness-generator/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (s *stateObject) updateTrie(db Database) Trie {
var v []byte
if (value == common.Hash{}) {
//fmt.Println("delete", s.address, key)
// Get absense proof of key in case the deletion needs the sister node.
// Get absence proof of key in case the deletion needs the sister node.

// Note: commented for now because of `ExtNodeDeleted`
oracle.PrefetchStorage(big.NewInt(db.BlockNumber.Int64()+1), s.address, key, trie.GenPossibleShortNodePreimage)
Expand Down
12 changes: 6 additions & 6 deletions mpt-witness-generator/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ func (s *StateDB) deleteStateObject(obj *stateObject) {
}
// Delete the account from the trie
addr := obj.Address()
// Get absense proof of account in case the deletion needs the sister node.
// Get absence proof of account in case the deletion needs the sister node.
oracle.PrefetchAccount(big.NewInt(s.Db.BlockNumber.Int64()+1), addr, trie.GenPossibleShortNodePreimage)
if err := s.trie.TryDelete(addr[:]); err != nil {
s.setError(fmt.Errorf("deleteStateObject (%x) error: %v", addr[:], err))
Expand Down Expand Up @@ -893,11 +893,11 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) {
// If state snapshotting is active, also mark the destruction there.
// Note, we can't do this only at the end of a block because multiple
// transactions within the same block might self destruct and then
// ressurrect an account; but the snapshotter needs both events.
// resurrect an account; but the snapshotter needs both events.
if s.snap != nil {
s.snapDestructs[obj.addrHash] = struct{}{} // We need to maintain account deletions explicitly (will remain set indefinitely)
delete(s.snapAccounts, obj.addrHash) // Clear out any previously updated account data (may be recreated via a ressurrect)
delete(s.snapStorage, obj.addrHash) // Clear out any previously updated storage data (may be recreated via a ressurrect)
delete(s.snapAccounts, obj.addrHash) // Clear out any previously updated account data (may be recreated via a resurrect)
delete(s.snapStorage, obj.addrHash) // Clear out any previously updated storage data (may be recreated via a resurrect)
}
} else {
obj.finalise(true) // Prefetch slots in the background
Expand Down Expand Up @@ -991,7 +991,7 @@ func (s *StateDB) clearJournalAndRefund() {
s.journal = newJournal()
s.refund = 0
}
s.validRevisions = s.validRevisions[:0] // Snapshots can be created without journal entires
s.validRevisions = s.validRevisions[:0] // Snapshots can be created without journal entries
}

// Commit writes the state to the underlying in-memory trie database.
Expand Down Expand Up @@ -1040,7 +1040,7 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) {
}
}*/

// Write the account trie changes, measuing the amount of wasted time
// Write the account trie changes, measuring the amount of wasted time
var start time.Time
if metrics.EnabledExpensive {
start = time.Now()
Expand Down
4 changes: 2 additions & 2 deletions mpt-witness-generator/witness/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ func addBranchAndPlaceholder(proof1, proof2,
Now we want to add a leaf at position n1 n2 n3 n4 n5 m1 where m1 != n6.
The adding algorithm walks through the trie, but it bumps into an extension node where
it should put this leaf. So a new extension node is added at position n1 n2 n3 n4 which only
has one nibble: n5. So at n1 n2 n3 n4 n5 we have a branch now. In this brach, at position m we
has one nibble: n5. So at n1 n2 n3 n4 n5 we have a branch now. In this branch, at position m we
have a leaf, while at position n6 we have another extension node with one extension nibble: n7.
At this position (n7) we have the branch from the original extension node.
When an extension node is inserted because of the added key, C proof will contain this new
extension node and the underlying branch. However, S proof will stop at the old extension node.
This old extension node is not part of the C proof, but we need to ensure that it is in the C trie.
We need to take into accout that in the C trie the old extension node has a shortened extension.
We need to take into account that in the C trie the old extension node has a shortened extension.
The problem is where to store the old extension node. Note that in the above code the new
extension node and the underlying branch rows are prepared. For example, when len2 > len1 we
Expand Down
12 changes: 3 additions & 9 deletions zkevm-circuits/src/circuit_tools/cached_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ impl<'r, 'b, F: Field> CachedRegion<'r, 'b, F> {
cb: &ConstraintBuilder<F, C>,
challenges: &S,
) -> Result<(), Error> {
for (offset, region_id) in self.regions.clone() {
for n in 0..self.regions.len() {
let (offset, region_id) = self.regions[n];
for stored_expression in cb.get_stored_expressions(region_id).iter() {
stored_expression.assign(self, challenges, offset)?;
}
Expand All @@ -76,14 +77,7 @@ impl<'r, 'b, F: Field> CachedRegion<'r, 'b, F> {
pub(crate) fn annotate_columns<C: CellType>(&mut self, cell_columns: &[CellColumn<F, C>]) {
for c in cell_columns {
self.region.name_column(
|| {
format!(
"{:?} {:?}: {:?} queried",
c.cell_type.clone(),
c.index,
c.height
)
},
|| format!("{:?} {:?}: {:?} queried", c.cell_type, c.index, c.height),
c.column,
);
}
Expand Down
21 changes: 11 additions & 10 deletions zkevm-circuits/src/circuit_tools/cell_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ impl<F: Field> Cell<F> {

impl<F: Field> Expr<F> for Cell<F> {
fn expr(&self) -> Expression<F> {
self.expression.as_ref().unwrap().clone()
self.expression.clone().unwrap()
}
}

impl<F: Field> Expr<F> for &Cell<F> {
fn expr(&self) -> Expression<F> {
self.expression.as_ref().unwrap().clone()
self.expression.clone().unwrap()
}
}

Expand Down Expand Up @@ -284,11 +284,14 @@ impl<F: Field, C: CellType> CellManager<F, C> {
permutable: bool,
num_columns: usize,
) {
self.columns.reserve(num_columns);
self.configs.reserve(num_columns);

for _ in 0..num_columns {
// Add a column of the specified type
let config = CellConfig::new(cell_type, phase, permutable);
let col = config.init_column(meta);
let mut cells = Vec::new();
let mut cells = Vec::with_capacity(self.height_limit);
for r in 0..self.height_limit {
query_expression(meta, |meta| {
cells.push(Cell::new(meta, col, self.offset + r));
Expand Down Expand Up @@ -394,13 +397,11 @@ impl<F: Field, C: CellType> CellManager<F, C> {
}

pub(crate) fn get_typed_columns(&self, cell_type: C) -> Vec<CellColumn<F, C>> {
let mut columns = Vec::new();
for column in self.columns.iter() {
if column.cell_type == cell_type {
columns.push(column.clone());
}
}
columns
self.columns
.iter()
.filter(|column| column.cell_type == cell_type)
.cloned()
.collect()
}
}

Expand Down
4 changes: 2 additions & 2 deletions zkevm-circuits/src/circuit_tools/constraint_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ impl<F: Field, C: CellType> ConstraintBuilder<F, C> {
.collect();
// Align the length of values and table
assert!(lookup.table.len() >= values.len());
while values.len() < lookup.table.len() {
values.push(0.expr());
if values.len() < lookup.table.len() {
values.resize(lookup.table.len(), 0.expr());
}
meta.lookup_any(
Box::leak(lookup.description.clone().into_boxed_str()),
Expand Down
12 changes: 6 additions & 6 deletions zkevm-circuits/src/circuit_tools/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ impl<F: Field, C: CellType, MB: MemoryBank<F, C>> Memory<F, C, MB> {
}

pub(crate) fn get_columns(&self) -> Vec<Column<Advice>> {
self.banks.values().fold(Vec::new(), |mut acc, bank| {
acc.extend(bank.columns().iter());
acc
})
self.banks
.values()
.flat_map(|bank| bank.columns())
.collect()
}

pub(crate) fn build_constraints(
Expand Down Expand Up @@ -152,15 +152,15 @@ impl<F: Field, C: CellType> RwBank<F, C> {
self.cur.expr()
}
pub(crate) fn prepend_key(&self, values: &[Expression<F>]) -> Vec<Expression<F>> {
[&[self.cur.expr() + 1.expr()], values].concat().to_vec()
[&[self.cur.expr() + 1.expr()], values].concat()
}

pub(crate) fn prepend_offset(
&self,
values: &[Expression<F>],
offset: Expression<F>,
) -> Vec<Expression<F>> {
[&[self.cur.expr() - offset], values].concat().to_vec()
[&[self.cur.expr() - offset], values].concat()
}
}

Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/evm_circuit/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ pub(crate) enum Lookup<F> {
/// A boolean value to specify if the access record is a read or write.
is_write: Expression<F>,
/// Tag to specify which read-write data to access, see RwTableTag for
/// all tags.
/// all tags. RwTableTag is bus_mapping::operation::Target (PR#1406)
tag: Expression<F>,
/// Values corresponding to the tag.
values: RwValues<F>,
Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/table/rw_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct RwTable {
pub rw_counter: Column<Advice>,
/// Is Write
pub is_write: Column<Advice>,
/// Tag
/// Tag (bus_mapping::operation::Target)
pub tag: Column<Advice>,
/// Key1 (Id)
pub id: Column<Advice>,
Expand Down

0 comments on commit fd9fa79

Please sign in to comment.