Skip to content

Commit

Permalink
main --> 0.3.0 (#138)
Browse files Browse the repository at this point in the history
* Update plonky2 dependencies (#119)

* Update plonky2 dependencies

* Modify changelog

* Charge gas before SLOAD and refactor `insert_accessed_storage_keys` (#117)

* Charge gas before SLOAD and refactor `insert_accessed_storage_keys`

* fmt

* Only store value for cold access

* PR feedback

---------

Co-authored-by: BGluth <gluthb@gmail.com>

* Increased the public interface for `trie_tools` (#123)

- `trie_tools` needs to access a bit of currently private logic.
  Specifically, it needs to be able to process compact bytecode into
  `mpt_tries` directly.
- I think this change is actually reasonable. I can see realistic use
  cases where we don't need to process an entire block trace but instead
  just want to decode some compact bytecode.
- With the current public interface, the caller can only pass in an
  entire block trace to process.

* Mpt trie panic refactor (#118)

* refactor: refactoring mpt_trie to use more Results

* fix: replace anyhow with this-error for mpt_trie

* style: formatting

* fix: fix results

* fix: pr fixes

* fix: fix error message

* fix: format

* fix: fix unusefull return type

* fix: fix formatting

* fix: pr fixes

* fix: pr fixes

* fix: pr fixes

* tests: refactor some tests

---------

Co-authored-by: Vladimir Trifonov <trifonov.vp@gmail.com>

* refactor: remove some reallocations from decoder (#126)

Co-authored-by: Vladimir Trifonov <trifonov.vp@gmail.com>

* Charge cold access cost in *CALL* before accessing state (#124)

* Charge cold access cost in CALL before accessing state

* PR feedback

---------

Co-authored-by: BGluth <gluthb@gmail.com>

* chore: add debug function for better logging in development (#134)

* chore: add debug function for better logging in development

* chore: fix clippy issue

---------

Co-authored-by: Vladimir Trifonov <trifonov.vp@gmail.com>

* Make test_receipt_encoding more meaningful. (#131)

* Make test_receipt_encoding more meaningful.

* Apply comment

* Add a getter for the KERNEL codehash (#136)

* Update CHANGELOG

* Version bump for next release (#137)

* Bumped sub-crate versions for a new release

* Added in missing change log entries

- Other PRs missed updating `CHANGELOG.md`

* feat: swap out the internal U512 inside nibbles (#132)

* feat: swap out the internal U512 inside nibbles

* fix: comment fix

* fix: fix clippy pr issues

* fix: fix clippy issue

* fix: fix pr comments

* docs: update changelog

* fix: update impl_to_nibbles

---------

Co-authored-by: Vladimir Trifonov <trifonov.vp@gmail.com>

* Some clippy fixes (#149)

* MAX fixes for clippy

* fix transmut without annotations

* please the fmt gods

* Remove interpreter-specific preinialization logic from State trait (#139)

* Remove interpreter specific methods from State trait

* Changelog

* Make some more functions constant (#154)

* Make some more functions constant

* Update changelog

* fix(keccak-sponge): properly constrain padding bytes (#158)

* fix(keccak-sponge): properly constrain padding bytes

* fix: block bytes offset

* fix: constrain zero padding bytes

* fix: use collect_vec

* feat: replace is_final_input_len with is_padding_byte

* fix: remove unnecessary iterators

* Update evm_arithmetization/src/keccak_sponge/keccak_sponge_stark.rs

Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>

* Update evm_arithmetization/src/keccak_sponge/keccak_sponge_stark.rs

Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>

* Update evm_arithmetization/src/keccak_sponge/keccak_sponge_stark.rs

Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>

* Update evm_arithmetization/src/keccak_sponge/keccak_sponge_stark.rs

Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>

* Update evm_arithmetization/src/keccak_sponge/keccak_sponge_stark.rs

Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>

* Update evm_arithmetization/src/keccak_sponge/keccak_sponge_stark.rs

Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>

* fix: remove redundant constraint

* docs: define padding byte in comment

---------

Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>

* Reduce verbosity in logs (#160)

* Reduce verbosity in logs

* CHANGELOG

* Add entry for 158 in CHANGELOG

* Bump with latest starky (#161)

* Bump with latest plonky2

* CHANGELOG

* feat: decouple trace_decoder and proof_gen (#163)

Co-authored-by: Vladimir Trifonov <trifonov.vp@gmail.com>

* Simplify withdrawals logic (#168)

* Simplify withdrawals logic

* Update CHANGELOG

* Clippy

* feat: extend trace decoder err info (#148)

* feat: extend trace decoder err info

* fix: fix clippy issue

* feat: swap out the internal U512 inside nibbles (#132)

* feat: swap out the internal U512 inside nibbles

* fix: comment fix

* fix: fix clippy pr issues

* fix: fix clippy issue

* fix: fix pr comments

* docs: update changelog

* fix: update impl_to_nibbles

---------

Co-authored-by: Vladimir Trifonov <trifonov.vp@gmail.com>

* Some clippy fixes (#149)

* MAX fixes for clippy

* fix transmut without annotations

* please the fmt gods

* fix: add pr comments fixes

* fix: add pr comments fix

* fix: add pr comment fix

* docs: update changelog

---------

Co-authored-by: Vladimir Trifonov <trifonov.vp@gmail.com>
Co-authored-by: Ben <bmarsh94@gmail.com>

* Moved `Unreleased` changes to `0.3.0` (#173)

- Also added two missing PRs

---------

Co-authored-by: Hamy Ratoanina <hamy.ratoanina@toposware.com>
Co-authored-by: wborgeaud <williamborgeaud@gmail.com>
Co-authored-by: Vladimir Trifonov <vladimir-trifonov@users.noreply.github.com>
Co-authored-by: Vladimir Trifonov <trifonov.vp@gmail.com>
Co-authored-by: Linda Guiga <101227802+LindaGuiga@users.noreply.github.com>
Co-authored-by: Robin Salen <30937548+Nashtare@users.noreply.github.com>
Co-authored-by: Robin Salen <salenrobin@gmail.com>
Co-authored-by: Ben <bmarsh94@gmail.com>
Co-authored-by: Ayush Shukla <shuklaayush247@gmail.com>
  • Loading branch information
10 people authored Apr 19, 2024
1 parent 21d44e1 commit 88d75ed
Show file tree
Hide file tree
Showing 72 changed files with 1,652 additions and 885 deletions.
30 changes: 28 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,34 @@ 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.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 +44,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 <daniel@lubarov.com>", "William Borgeaud <williamborgeaud@gmail.com>"]
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 88d75ed

Please sign in to comment.