Skip to content

Commit

Permalink
Merge pull request #182 from 0xPolygonZero/develop
Browse files Browse the repository at this point in the history
Bring back v0.3.0 into main + follow-up `trace_decoder` bump
  • Loading branch information
Nashtare authored Apr 22, 2024
2 parents 4769a2b + e0f1034 commit c95155c
Show file tree
Hide file tree
Showing 72 changed files with 1,705 additions and 924 deletions.
35 changes: 33 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,39 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased]

### Changed

## [0.3.1] - 2024-04-22

### Changed
- Fix withdrawals accesses in state trie ([#176](https://github.com/0xPolygonZero/zk_evm/pull/176))

## [0.3.0] - 2024-04-19

### Changed
- Update plonky2 dependencies ([#119](https://github.com/0xPolygonZero/zk_evm/pull/119))
- Swap out the internal U512 inside nibbles to [u64;5] ([#132](https://github.com/0xPolygonZero/zk_evm/pull/132))
- Charge gas before SLOAD and refactor `insert_accessed_storage_keys` ([#117](https://github.com/0xPolygonZero/zk_evm/pull/117))
- Increased the public interface for `trie_tools` ([#123](https://github.com/0xPolygonZero/zk_evm/pull/123))
- Mpt trie panic refactor ([#118](https://github.com/0xPolygonZero/zk_evm/pull/118))
- refactor: remove some reallocations from decoder ([#126](https://github.com/0xPolygonZero/zk_evm/pull/126))
- Charge cold access cost in *CALL* before accessing state ([#124](https://github.com/0xPolygonZero/zk_evm/pull/124))
- chore: add debug function for better logging in development ([#134](https://github.com/0xPolygonZero/zk_evm/pull/134))
- Make test_receipt_encoding more meaningful. ([#131](https://github.com/0xPolygonZero/zk_evm/pull/131))
- Add a getter for the KERNEL codehash ([#136](https://github.com/0xPolygonZero/zk_evm/pull/136))
- Remove interpreter-specific preinialization logic from State trait ([#139](https://github.com/0xPolygonZero/zk_evm/pull/139))
- Make some more functions constant ([#154](https://github.com/0xPolygonZero/zk_evm/pull/154))
- fix(keccak-sponge): properly constrain padding bytes ([#158](https://github.com/0xPolygonZero/zk_evm/pull/158))
- Reduce verbosity in logs ([#160](https://github.com/0xPolygonZero/zk_evm/pull/160))
- Bump with latest starky ([#161](https://github.com/0xPolygonZero/zk_evm/pull/161))
- Decouple trace_decoder and proof_gen ([#163](https://github.com/0xPolygonZero/zk_evm/pull/163))
- Extend trace decoder err info ([#148](https://github.com/0xPolygonZero/zk_evm/pull/148))
- Add debug function for better public values logging in development ([#134](https://github.com/0xPolygonZero/zk_evm/pull/134))
- Simplify withdrawals logic ([#168](https://github.com/0xPolygonZero/zk_evm/pull/168))

## [0.2.0] - 2024-03-19

### Changed
Expand All @@ -18,8 +49,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Reduce state trie size for dummy payloads ([#88](https://github.com/0xPolygonZero/zk_evm/pull/88))
- Fix post-txn trie debugging output for multi-logs receipts ([#86](https://github.com/0xPolygonZero/zk_evm/pull/86))
- Fixed *most* failing blocks caused by the merged in aggressive pruning changes ([#97](https://github.com/0xPolygonZero/zk_evm/pull/97))
- Fixed trie hash collision issue when constructing storage tries [#75](https://github.com/0xPolygonZero/zk_evm/pull/75)
- Fix interpreter rollback by adding the clock to generation state checkpoints ([#109] https://github.com/0xPolygonZero/zk_evm/pull/109)
- Fixed trie hash collision issue when constructing storage tries ([#75](https://github.com/0xPolygonZero/zk_evm/pull/75))
- Fix interpreter rollback by adding the clock to generation state checkpoints ([#109](https://github.com/0xPolygonZero/zk_evm/pull/109))

## [0.1.1] - 2024-03-01

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ serde_json = "1.0.96"
thiserror = "1.0.49"

# plonky2-related dependencies
plonky2 = "0.2.0"
plonky2 = "0.2.2"
plonky2_maybe_rayon = "0.2.0"
plonky2_util = "0.2.0"
starky = "0.2.1"
starky = "0.4.0"


[workspace.package]
Expand Down
4 changes: 2 additions & 2 deletions evm_arithmetization/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "evm_arithmetization"
description = "Implementation of STARKs for the Ethereum Virtual Machine"
version = "0.1.2"
version = "0.1.3"
authors = ["Daniel Lubarov <[email protected]>", "William Borgeaud <[email protected]>"]
readme = "README.md"
categories = ["cryptography"]
Expand Down Expand Up @@ -41,7 +41,7 @@ tiny-keccak = "2.0.2"
serde_json = { workspace = true }

# Local dependencies
mpt_trie = { version = "0.2.0", path = "../mpt_trie" }
mpt_trie = { version = "0.2.1", path = "../mpt_trie" }

[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = "0.5.0"
Expand Down
45 changes: 22 additions & 23 deletions evm_arithmetization/src/all_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,27 @@ fn ctl_byte_packing<F: Field>() -> CrossTableLookup<F> {
let cpu_packing_looking = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_byte_packing(),
Some(cpu_stark::ctl_filter_byte_packing()),
cpu_stark::ctl_filter_byte_packing(),
);
let cpu_unpacking_looking = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_byte_unpacking(),
Some(cpu_stark::ctl_filter_byte_unpacking()),
cpu_stark::ctl_filter_byte_unpacking(),
);
let cpu_push_packing_looking = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_byte_packing_push(),
Some(cpu_stark::ctl_filter_byte_packing_push()),
cpu_stark::ctl_filter_byte_packing_push(),
);
let cpu_jumptable_read_looking = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_jumptable_read(),
Some(cpu_stark::ctl_filter_syscall_exceptions()),
cpu_stark::ctl_filter_syscall_exceptions(),
);
let byte_packing_looked = TableWithColumns::new(
*Table::BytePacking,
byte_packing_stark::ctl_looked_data(),
Some(byte_packing_stark::ctl_looked_filter()),
byte_packing_stark::ctl_looked_filter(),
);
CrossTableLookup::new(
vec![
Expand All @@ -179,12 +179,12 @@ fn ctl_keccak_inputs<F: Field>() -> CrossTableLookup<F> {
let keccak_sponge_looking = TableWithColumns::new(
*Table::KeccakSponge,
keccak_sponge_stark::ctl_looking_keccak_inputs(),
Some(keccak_sponge_stark::ctl_looking_keccak_filter()),
keccak_sponge_stark::ctl_looking_keccak_filter(),
);
let keccak_looked = TableWithColumns::new(
*Table::Keccak,
keccak_stark::ctl_data_inputs(),
Some(keccak_stark::ctl_filter_inputs()),
keccak_stark::ctl_filter_inputs(),
);
CrossTableLookup::new(vec![keccak_sponge_looking], keccak_looked)
}
Expand All @@ -196,12 +196,12 @@ fn ctl_keccak_outputs<F: Field>() -> CrossTableLookup<F> {
let keccak_sponge_looking = TableWithColumns::new(
*Table::KeccakSponge,
keccak_sponge_stark::ctl_looking_keccak_outputs(),
Some(keccak_sponge_stark::ctl_looking_keccak_filter()),
keccak_sponge_stark::ctl_looking_keccak_filter(),
);
let keccak_looked = TableWithColumns::new(
*Table::Keccak,
keccak_stark::ctl_data_outputs(),
Some(keccak_stark::ctl_filter_outputs()),
keccak_stark::ctl_filter_outputs(),
);
CrossTableLookup::new(vec![keccak_sponge_looking], keccak_looked)
}
Expand All @@ -212,12 +212,12 @@ fn ctl_keccak_sponge<F: Field>() -> CrossTableLookup<F> {
let cpu_looking = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_keccak_sponge(),
Some(cpu_stark::ctl_filter_keccak_sponge()),
cpu_stark::ctl_filter_keccak_sponge(),
);
let keccak_sponge_looked = TableWithColumns::new(
*Table::KeccakSponge,
keccak_sponge_stark::ctl_looked_data(),
Some(keccak_sponge_stark::ctl_looked_filter()),
keccak_sponge_stark::ctl_looked_filter(),
);
CrossTableLookup::new(vec![cpu_looking], keccak_sponge_looked)
}
Expand All @@ -228,19 +228,18 @@ fn ctl_logic<F: Field>() -> CrossTableLookup<F> {
let cpu_looking = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_logic(),
Some(cpu_stark::ctl_filter_logic()),
cpu_stark::ctl_filter_logic(),
);
let mut all_lookers = vec![cpu_looking];
for i in 0..keccak_sponge_stark::num_logic_ctls() {
let keccak_sponge_looking = TableWithColumns::new(
*Table::KeccakSponge,
keccak_sponge_stark::ctl_looking_logic(i),
Some(keccak_sponge_stark::ctl_looking_logic_filter()),
keccak_sponge_stark::ctl_looking_logic_filter(),
);
all_lookers.push(keccak_sponge_looking);
}
let logic_looked =
TableWithColumns::new(*Table::Logic, logic::ctl_data(), Some(logic::ctl_filter()));
let logic_looked = TableWithColumns::new(*Table::Logic, logic::ctl_data(), logic::ctl_filter());
CrossTableLookup::new(all_lookers, logic_looked)
}

Expand All @@ -250,42 +249,42 @@ fn ctl_memory<F: Field>() -> CrossTableLookup<F> {
let cpu_memory_code_read = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_code_memory(),
Some(cpu_stark::ctl_filter_code_memory()),
cpu_stark::ctl_filter_code_memory(),
);
let cpu_memory_gp_ops = (0..NUM_GP_CHANNELS).map(|channel| {
TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_gp_memory(channel),
Some(cpu_stark::ctl_filter_gp_memory(channel)),
cpu_stark::ctl_filter_gp_memory(channel),
)
});
let cpu_push_write_ops = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_partial_memory::<F>(),
Some(cpu_stark::ctl_filter_partial_memory()),
cpu_stark::ctl_filter_partial_memory(),
);
let cpu_set_context_write = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_memory_old_sp_write_set_context::<F>(),
Some(cpu_stark::ctl_filter_set_context()),
cpu_stark::ctl_filter_set_context(),
);
let cpu_set_context_read = TableWithColumns::new(
*Table::Cpu,
cpu_stark::ctl_data_memory_new_sp_read_set_context::<F>(),
Some(cpu_stark::ctl_filter_set_context()),
cpu_stark::ctl_filter_set_context(),
);
let keccak_sponge_reads = (0..KECCAK_RATE_BYTES).map(|i| {
TableWithColumns::new(
*Table::KeccakSponge,
keccak_sponge_stark::ctl_looking_memory(i),
Some(keccak_sponge_stark::ctl_looking_memory_filter(i)),
keccak_sponge_stark::ctl_looking_memory_filter(i),
)
});
let byte_packing_ops = (0..32).map(|i| {
TableWithColumns::new(
*Table::BytePacking,
byte_packing_stark::ctl_looking_memory(i),
Some(byte_packing_stark::ctl_looking_memory_filter(i)),
byte_packing_stark::ctl_looking_memory_filter(i),
)
});
let all_lookers = vec![
Expand All @@ -302,7 +301,7 @@ fn ctl_memory<F: Field>() -> CrossTableLookup<F> {
let memory_looked = TableWithColumns::new(
*Table::Memory,
memory_stark::ctl_data(),
Some(memory_stark::ctl_filter()),
memory_stark::ctl_filter(),
);
CrossTableLookup::new(all_lookers, memory_looked)
}
6 changes: 2 additions & 4 deletions evm_arithmetization/src/arithmetic/arithmetic_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ pub(crate) fn ctl_arithmetic_rows<F: Field>() -> TableWithColumns<F> {
let mut filter_cols = COMBINED_OPS.to_vec();
filter_cols.push((columns::IS_RANGE_CHECK, 0x01));

let filter = Some(Filter::new_simple(Column::sum(
filter_cols.iter().map(|(c, _v)| *c),
)));
let filter = Filter::new_simple(Column::sum(filter_cols.iter().map(|(c, _v)| *c)));

let mut all_combined_cols = COMBINED_OPS.to_vec();
all_combined_cols.push((columns::OPCODE_COL, 0x01));
Expand Down Expand Up @@ -323,7 +321,7 @@ impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for ArithmeticSta
columns: Column::singles(SHARED_COLS).collect(),
table_column: Column::single(RANGE_COUNTER),
frequencies_column: Column::single(RC_FREQUENCIES),
filter_columns: vec![None; NUM_SHARED_COLS],
filter_columns: vec![Default::default(); NUM_SHARED_COLS],
}]
}

Expand Down
8 changes: 4 additions & 4 deletions evm_arithmetization/src/arithmetic/modular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ pub(crate) fn generate_modular_op<F: PrimeField64>(
let (lo, hi) = quot_limbs.split_at_mut(N_LIMBS);

// Verify that the elements are in the expected range.
debug_assert!(lo.iter().all(|&c| c <= u16::max_value() as i64));
debug_assert!(lo.iter().all(|&c| c <= u16::MAX as i64));

// Top half of quot_limbs should be zero.
debug_assert!(hi.iter().all(|&d| d.is_zero()));
Expand All @@ -318,7 +318,7 @@ pub(crate) fn generate_modular_op<F: PrimeField64>(
// it's in the range [0, 2^16 - 1] which will correctly
// range-check.
for c in lo {
*c += u16::max_value() as i64;
*c += u16::MAX as i64;
}
// Store the sign of the quotient after the quotient.
hi[0] = 1;
Expand Down Expand Up @@ -522,7 +522,7 @@ pub(crate) fn submod_constr_poly<P: PackedField>(
let sign = hi[0];
// sign must be 1 (negative) or 0 (positive)
yield_constr.constraint(filter * sign * (sign - P::ONES));
let offset = P::Scalar::from_canonical_u16(u16::max_value());
let offset = P::Scalar::from_canonical_u16(u16::MAX);
for c in lo {
*c -= offset * sign;
}
Expand Down Expand Up @@ -723,7 +723,7 @@ pub(crate) fn submod_constr_poly_ext_circuit<F: RichField + Extendable<D>, const
let t = builder.mul_extension(filter, t);
// sign must be 1 (negative) or 0 (positive)
yield_constr.constraint(builder, t);
let offset = F::from_canonical_u16(u16::max_value());
let offset = F::from_canonical_u16(u16::MAX);
for c in lo {
let t = builder.mul_const_extension(offset, sign);
*c = builder.sub_extension(*c, t);
Expand Down
2 changes: 1 addition & 1 deletion evm_arithmetization/src/byte_packing/byte_packing_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for BytePackingSt
columns: Column::singles(value_bytes(0)..value_bytes(0) + NUM_BYTES).collect(),
table_column: Column::single(RANGE_COUNTER),
frequencies_column: Column::single(RC_FREQUENCIES),
filter_columns: vec![None; NUM_BYTES],
filter_columns: vec![Default::default(); NUM_BYTES],
}]
}

Expand Down
4 changes: 2 additions & 2 deletions evm_arithmetization/src/cpu/cpu_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub(crate) fn ctl_arithmetic_base_rows<F: Field>() -> TableWithColumns<F> {
TableWithColumns::new(
*Table::Cpu,
columns,
Some(Filter::new(
Filter::new(
vec![(Column::single(COL_MAP.op.push_prover_input), col_bit)],
vec![Column::sum([
COL_MAP.op.binary_op,
Expand All @@ -126,7 +126,7 @@ pub(crate) fn ctl_arithmetic_base_rows<F: Field>() -> TableWithColumns<F> {
COL_MAP.op.syscall,
COL_MAP.op.exception,
])],
)),
),
)
}

Expand Down
Loading

0 comments on commit c95155c

Please sign in to comment.