diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62b8e59ed..07f039d25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,9 +53,7 @@ jobs: uses: actions/checkout@v4 - name: Install nightly toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: nightly-2024-02-01 + uses: dtolnay/rust-toolchain@nightly - name: Set up rust cache uses: Swatinem/rust-cache@v2 @@ -80,9 +78,7 @@ jobs: uses: actions/checkout@v4 - name: Install nightly toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: nightly-2024-02-01 + uses: dtolnay/rust-toolchain@nightly - name: Set up rust cache uses: Swatinem/rust-cache@v2 @@ -107,9 +103,7 @@ jobs: uses: actions/checkout@v4 - name: Install nightly toolchain - uses: dtolnay/rust-toolchain@master - with: - toolchain: nightly-2024-02-01 + uses: dtolnay/rust-toolchain@nightly - name: Set up rust cache uses: Swatinem/rust-cache@v2 @@ -134,15 +128,14 @@ jobs: uses: actions/checkout@v4 - name: Install nightly toolchain - uses: dtolnay/rust-toolchain@master + uses: dtolnay/rust-toolchain@nightly with: - toolchain: nightly-2024-02-01 - components: rustfmt, clippy + components: rustfmt, clippy - name: Set up rust cache uses: Swatinem/rust-cache@v2 with: - cache-on-failure: true + cache-on-failure: true - name: Run cargo fmt run: cargo fmt --all --check diff --git a/Cargo.toml b/Cargo.toml index 4b215f56c..52545235f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,21 @@ members = ["mpt_trie", "proof_gen", "trace_decoder", "evm_arithmetization"] resolver = "2" [workspace.dependencies] +bytes = "1.5.0" +enum-as-inner = "0.6.0" ethereum-types = "0.14.1" +hex = "0.4.3" +hex-literal = "0.4.1" +keccak-hash = "0.10.0" log = "0.4.20" -plonky2_evm = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "265d46a96ecfec49a32973f66f8aa811586c5d4a" } +num = "0.4.1" +rlp = "0.5.2" +rlp-derive = "0.1.0" serde = "1.0.166" + +[workspace.package] +edition = "2021" +license = "MIT OR Apache-2.0" +repository = "https://github.com/0xPolygonZero/zk_evm" +homepage = "https://github.com/0xPolygonZero/zk_evm" +keywords = ["cryptography", "SNARK", "PLONK", "FRI", "plonky2", "EVM", "ETHEREUM"] diff --git a/evm_arithmetization/Cargo.toml b/evm_arithmetization/Cargo.toml index 60af3f8ad..324f65b7a 100644 --- a/evm_arithmetization/Cargo.toml +++ b/evm_arithmetization/Cargo.toml @@ -2,27 +2,27 @@ name = "evm_arithmetization" description = "Implementation of STARKs for the Ethereum Virtual Machine" version = "0.1.0" -license = "MIT or Apache-2.0" authors = ["Daniel Lubarov ", "William Borgeaud "] readme = "README.md" -repository = "https://github.com/0xPolygonZero/zk_evm" -keywords = ["EVM", "STARK", "Ethereum"] categories = ["cryptography"] -edition = "2021" +edition.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true +keywords.workspace = true [dependencies] anyhow = "1.0.40" -bytes = "1.4.0" +bytes = { workspace = true } env_logger = "0.10.0" -eth_trie_utils = { git = "https://github.com/0xPolygonZero/eth_trie_utils.git", rev = "7fc3c3f54b3cec9c6fc5ffc5230910bd1cb77f76" } ethereum-types = "0.14.0" -hex = { version = "0.4.3", optional = true } -hex-literal = "0.4.1" +hex = { workspace = true, optional = true } +hex-literal = { workspace = true } itertools = "0.11.0" -keccak-hash = "0.10.0" -log = "0.4.14" +keccak-hash = { workspace = true } +log = { workspace = true } plonky2_maybe_rayon = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "710225c9e0ac5822b2965ce74951cf000bbb8a2c" } -num = "0.4.0" +num = { workspace = true } num-bigint = "0.4.3" once_cell = "1.13.0" pest = "2.1.3" @@ -32,20 +32,23 @@ plonky2_util = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "71 starky = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "710225c9e0ac5822b2965ce74951cf000bbb8a2c" } rand = "0.8.5" rand_chacha = "0.3.1" -rlp = "0.5.1" -rlp-derive = "0.1.0" -serde = { version = "1.0.144", features = ["derive"] } +rlp = { workspace = true } +rlp-derive = { workspace = true } +serde = { workspace = true, features = ["derive"] } static_assertions = "1.1.0" hashbrown = { version = "0.14.0" } tiny-keccak = "2.0.2" serde_json = "1.0" +# Local dependencies +mpt_trie = { version = "0.1.0", path = "../mpt_trie" } + [target.'cfg(not(target_env = "msvc"))'.dependencies] jemallocator = "0.5.0" [dev-dependencies] criterion = "0.5.1" -hex = "0.4.3" +hex = { workspace = true } ripemd = "0.1.3" sha2 = "0.10.6" diff --git a/evm_arithmetization/LICENSE-APACHE b/evm_arithmetization/LICENSE-APACHE deleted file mode 100644 index 1b5ec8b78..000000000 --- a/evm_arithmetization/LICENSE-APACHE +++ /dev/null @@ -1,176 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS diff --git a/evm_arithmetization/LICENSE-MIT b/evm_arithmetization/LICENSE-MIT deleted file mode 100644 index 72dc60d84..000000000 --- a/evm_arithmetization/LICENSE-MIT +++ /dev/null @@ -1,19 +0,0 @@ -The MIT License (MIT) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/evm_arithmetization/src/cpu/kernel/constants/trie_type.rs b/evm_arithmetization/src/cpu/kernel/constants/trie_type.rs index fd89f4100..9821c06f7 100644 --- a/evm_arithmetization/src/cpu/kernel/constants/trie_type.rs +++ b/evm_arithmetization/src/cpu/kernel/constants/trie_type.rs @@ -1,6 +1,6 @@ use core::ops::Deref; -use eth_trie_utils::partial_trie::HashedPartialTrie; +use mpt_trie::partial_trie::HashedPartialTrie; use crate::Node; diff --git a/evm_arithmetization/src/cpu/kernel/interpreter.rs b/evm_arithmetization/src/cpu/kernel/interpreter.rs index 5a47356ec..97a2e4c53 100644 --- a/evm_arithmetization/src/cpu/kernel/interpreter.rs +++ b/evm_arithmetization/src/cpu/kernel/interpreter.rs @@ -5,9 +5,9 @@ use core::ops::Range; use std::collections::{BTreeSet, HashMap}; use anyhow::{anyhow, bail}; -use eth_trie_utils::partial_trie::PartialTrie; use ethereum_types::{BigEndianHash, H160, H256, U256, U512}; use keccak_hash::keccak; +use mpt_trie::partial_trie::PartialTrie; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::field::types::Field; diff --git a/evm_arithmetization/src/cpu/kernel/tests/account_code.rs b/evm_arithmetization/src/cpu/kernel/tests/account_code.rs index 6709b12db..d3ac0c629 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/account_code.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/account_code.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; use anyhow::Result; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H256, U256}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField as F; use plonky2::field::types::Field; use rand::{thread_rng, Rng}; diff --git a/evm_arithmetization/src/cpu/kernel/tests/add11.rs b/evm_arithmetization/src/cpu/kernel/tests/add11.rs index 1c621a1e4..dcd0b0510 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/add11.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/add11.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; use std::str::FromStr; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, Node, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H256}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, Node, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField as F; use crate::cpu::kernel::aggregator::KERNEL; diff --git a/evm_arithmetization/src/cpu/kernel/tests/balance.rs b/evm_arithmetization/src/cpu/kernel/tests/balance.rs index af190ae4c..f64e37f1b 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/balance.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/balance.rs @@ -1,7 +1,7 @@ use anyhow::Result; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H256, U256}; use keccak_hash::keccak; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField as F; use plonky2::field::types::Field; use rand::{thread_rng, Rng}; diff --git a/evm_arithmetization/src/cpu/kernel/tests/mpt/delete.rs b/evm_arithmetization/src/cpu/kernel/tests/mpt/delete.rs index 0be291616..0fb410bef 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/mpt/delete.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/mpt/delete.rs @@ -1,7 +1,7 @@ use anyhow::Result; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{BigEndianHash, H256, U512}; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField as F; use rand::random; diff --git a/evm_arithmetization/src/cpu/kernel/tests/mpt/hash.rs b/evm_arithmetization/src/cpu/kernel/tests/mpt/hash.rs index e9a7ebde8..b85e1dfdd 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/mpt/hash.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/mpt/hash.rs @@ -1,6 +1,6 @@ use anyhow::Result; -use eth_trie_utils::partial_trie::PartialTrie; use ethereum_types::{BigEndianHash, H256}; +use mpt_trie::partial_trie::PartialTrie; use plonky2::field::goldilocks_field::GoldilocksField as F; use crate::cpu::kernel::aggregator::KERNEL; diff --git a/evm_arithmetization/src/cpu/kernel/tests/mpt/insert.rs b/evm_arithmetization/src/cpu/kernel/tests/mpt/insert.rs index 60441b055..ff8173f27 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/mpt/insert.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/mpt/insert.rs @@ -1,7 +1,7 @@ use anyhow::Result; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{BigEndianHash, H256}; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField as F; use crate::cpu::kernel::aggregator::KERNEL; diff --git a/evm_arithmetization/src/cpu/kernel/tests/mpt/load.rs b/evm_arithmetization/src/cpu/kernel/tests/mpt/load.rs index 85c023f09..825f745ab 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/mpt/load.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/mpt/load.rs @@ -1,10 +1,10 @@ use std::str::FromStr; use anyhow::Result; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::HashedPartialTrie; use ethereum_types::{BigEndianHash, H256, U256}; use hex_literal::hex; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::HashedPartialTrie; use plonky2::field::goldilocks_field::GoldilocksField as F; use crate::cpu::kernel::constants::global_metadata::GlobalMetadata; diff --git a/evm_arithmetization/src/cpu/kernel/tests/mpt/mod.rs b/evm_arithmetization/src/cpu/kernel/tests/mpt/mod.rs index e5225ca0e..84f64bb7b 100644 --- a/evm_arithmetization/src/cpu/kernel/tests/mpt/mod.rs +++ b/evm_arithmetization/src/cpu/kernel/tests/mpt/mod.rs @@ -1,6 +1,6 @@ -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::HashedPartialTrie; use ethereum_types::{BigEndianHash, H256, U256}; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::HashedPartialTrie; use crate::generation::mpt::AccountRlp; use crate::Node; diff --git a/evm_arithmetization/src/fixed_recursive_verifier.rs b/evm_arithmetization/src/fixed_recursive_verifier.rs index 6b9835fdf..a60b9e7e3 100644 --- a/evm_arithmetization/src/fixed_recursive_verifier.rs +++ b/evm_arithmetization/src/fixed_recursive_verifier.rs @@ -5,9 +5,9 @@ use std::sync::atomic::AtomicBool; use std::sync::Arc; use anyhow::anyhow; -use eth_trie_utils::partial_trie::{HashedPartialTrie, Node, PartialTrie}; use hashbrown::HashMap; use itertools::{zip_eq, Itertools}; +use mpt_trie::partial_trie::{HashedPartialTrie, Node, PartialTrie}; use plonky2::field::extension::Extendable; use plonky2::fri::FriParams; use plonky2::gates::constant::ConstantGate; diff --git a/evm_arithmetization/src/generation/mod.rs b/evm_arithmetization/src/generation/mod.rs index e856ce4fd..fa26f851b 100644 --- a/evm_arithmetization/src/generation/mod.rs +++ b/evm_arithmetization/src/generation/mod.rs @@ -1,8 +1,8 @@ use std::collections::{BTreeSet, HashMap}; use anyhow::anyhow; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H256, U256}; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::extension::Extendable; use plonky2::field::polynomial::PolynomialValues; use plonky2::field::types::Field; diff --git a/evm_arithmetization/src/generation/mpt.rs b/evm_arithmetization/src/generation/mpt.rs index ee530ddef..79e923068 100644 --- a/evm_arithmetization/src/generation/mpt.rs +++ b/evm_arithmetization/src/generation/mpt.rs @@ -2,10 +2,10 @@ use core::ops::Deref; use std::collections::HashMap; use bytes::Bytes; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H256, U256, U512}; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use rlp::{Decodable, DecoderError, Encodable, PayloadInfo, Rlp, RlpStream}; use rlp_derive::{RlpDecodable, RlpEncodable}; diff --git a/evm_arithmetization/src/generation/trie_extractor.rs b/evm_arithmetization/src/generation/trie_extractor.rs index 66af5361f..6f63f6075 100644 --- a/evm_arithmetization/src/generation/trie_extractor.rs +++ b/evm_arithmetization/src/generation/trie_extractor.rs @@ -3,9 +3,9 @@ use std::collections::HashMap; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, Node, PartialTrie, WrappedNode}; use ethereum_types::{BigEndianHash, H256, U256, U512}; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, Node, PartialTrie, WrappedNode}; use super::mpt::{AccountRlp, LegacyReceiptRlp, LogRlp}; use crate::cpu::kernel::constants::trie_type::PartialTrieType; diff --git a/evm_arithmetization/src/lib.rs b/evm_arithmetization/src/lib.rs index 11f5c7402..b3cdc0e37 100644 --- a/evm_arithmetization/src/lib.rs +++ b/evm_arithmetization/src/lib.rs @@ -1,8 +1,8 @@ //! An implementation of a Type 1 zk-EVM by Polygon Zero. //! //! Following the [zk-EVM classification of V. Buterin](https://vitalik.eth.limo/general/2022/08/04/zkevm.html), -//! the plonky2_evm crate aims at providing an efficient solution for the -//! problem of generating cryptographic proofs of Ethereum-like transactions +//! the evm_arithmetization crate aims at providing an efficient solution for +//! the problem of generating cryptographic proofs of Ethereum-like transactions //! with *full Ethereum capability*. //! //! To this end, the plonky2 zk-EVM is tailored for an AIR-based STARK system @@ -211,10 +211,10 @@ pub mod curve_pairings; pub mod extension_tower; pub mod util; -use eth_trie_utils::partial_trie::HashedPartialTrie; // Set up Jemalloc #[cfg(not(target_env = "msvc"))] use jemallocator::Jemalloc; +use mpt_trie::partial_trie::HashedPartialTrie; #[cfg(not(target_env = "msvc"))] #[global_allocator] @@ -222,7 +222,7 @@ static GLOBAL: Jemalloc = Jemalloc; // Public definitions and re-exports -pub type Node = eth_trie_utils::partial_trie::Node; +pub type Node = mpt_trie::partial_trie::Node; pub use all_stark::AllStark; pub use fixed_recursive_verifier::AllRecursiveCircuits; diff --git a/evm_arithmetization/tests/add11_yml.rs b/evm_arithmetization/tests/add11_yml.rs index f8335598d..772bd4774 100644 --- a/evm_arithmetization/tests/add11_yml.rs +++ b/evm_arithmetization/tests/add11_yml.rs @@ -3,8 +3,6 @@ use std::str::FromStr; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H256}; use evm_arithmetization::generation::mpt::{AccountRlp, LegacyReceiptRlp}; use evm_arithmetization::generation::{GenerationInputs, TrieInputs}; @@ -14,6 +12,8 @@ use evm_arithmetization::verifier::verify_proof; use evm_arithmetization::{AllStark, Node, StarkConfig}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::KeccakGoldilocksConfig; use plonky2::util::timing::TimingTree; diff --git a/evm_arithmetization/tests/basic_smart_contract.rs b/evm_arithmetization/tests/basic_smart_contract.rs index c49d8624e..6f9bfc8d2 100644 --- a/evm_arithmetization/tests/basic_smart_contract.rs +++ b/evm_arithmetization/tests/basic_smart_contract.rs @@ -3,8 +3,6 @@ use std::str::FromStr; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, H256, U256}; use evm_arithmetization::cpu::kernel::opcodes::{get_opcode, get_push_opcode}; use evm_arithmetization::generation::mpt::{AccountRlp, LegacyReceiptRlp}; @@ -15,6 +13,8 @@ use evm_arithmetization::verifier::verify_proof; use evm_arithmetization::{AllStark, Node, StarkConfig}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::KeccakGoldilocksConfig; use plonky2::util::timing::TimingTree; diff --git a/evm_arithmetization/tests/empty_txn_list.rs b/evm_arithmetization/tests/empty_txn_list.rs index cffa3cbf1..1205414f6 100644 --- a/evm_arithmetization/tests/empty_txn_list.rs +++ b/evm_arithmetization/tests/empty_txn_list.rs @@ -3,13 +3,13 @@ use std::collections::HashMap; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{BigEndianHash, H256}; use evm_arithmetization::generation::{GenerationInputs, TrieInputs}; use evm_arithmetization::proof::{BlockHashes, BlockMetadata, PublicValues, TrieRoots}; use evm_arithmetization::{AllRecursiveCircuits, AllStark, Node, StarkConfig}; use keccak_hash::keccak; use log::info; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::PoseidonGoldilocksConfig; use plonky2::util::serialization::{DefaultGateSerializer, DefaultGeneratorSerializer}; diff --git a/evm_arithmetization/tests/erc20.rs b/evm_arithmetization/tests/erc20.rs index c3bda4c64..ef4b22878 100644 --- a/evm_arithmetization/tests/erc20.rs +++ b/evm_arithmetization/tests/erc20.rs @@ -2,8 +2,6 @@ use std::str::FromStr; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H160, H256, U256}; use evm_arithmetization::generation::mpt::{AccountRlp, LegacyReceiptRlp, LogRlp}; use evm_arithmetization::generation::{GenerationInputs, TrieInputs}; @@ -13,6 +11,8 @@ use evm_arithmetization::verifier::verify_proof; use evm_arithmetization::{AllStark, Node, StarkConfig}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::KeccakGoldilocksConfig; use plonky2::util::timing::TimingTree; diff --git a/evm_arithmetization/tests/erc721.rs b/evm_arithmetization/tests/erc721.rs index 2bffb933a..207fa69db 100644 --- a/evm_arithmetization/tests/erc721.rs +++ b/evm_arithmetization/tests/erc721.rs @@ -2,8 +2,6 @@ use std::str::FromStr; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H160, H256, U256}; use evm_arithmetization::generation::mpt::{AccountRlp, LegacyReceiptRlp, LogRlp}; use evm_arithmetization::generation::{GenerationInputs, TrieInputs}; @@ -13,6 +11,8 @@ use evm_arithmetization::verifier::verify_proof; use evm_arithmetization::{AllStark, Node, StarkConfig}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::KeccakGoldilocksConfig; use plonky2::util::timing::TimingTree; diff --git a/evm_arithmetization/tests/log_opcode.rs b/evm_arithmetization/tests/log_opcode.rs index ac56e43ee..56e5bbf6d 100644 --- a/evm_arithmetization/tests/log_opcode.rs +++ b/evm_arithmetization/tests/log_opcode.rs @@ -4,8 +4,6 @@ use std::time::Duration; use bytes::Bytes; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H256, U256}; use evm_arithmetization::generation::mpt::transaction_testing::{ AddressOption, LegacyTransactionRlp, @@ -18,6 +16,8 @@ use evm_arithmetization::verifier::verify_proof; use evm_arithmetization::{AllRecursiveCircuits, AllStark, Node, StarkConfig}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::PoseidonGoldilocksConfig; use plonky2::util::timing::TimingTree; diff --git a/evm_arithmetization/tests/self_balance_gas_cost.rs b/evm_arithmetization/tests/self_balance_gas_cost.rs index b4e555f26..979e43abd 100644 --- a/evm_arithmetization/tests/self_balance_gas_cost.rs +++ b/evm_arithmetization/tests/self_balance_gas_cost.rs @@ -3,8 +3,6 @@ use std::str::FromStr; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, H256, U256}; use evm_arithmetization::generation::mpt::{AccountRlp, LegacyReceiptRlp}; use evm_arithmetization::generation::{GenerationInputs, TrieInputs}; @@ -14,6 +12,8 @@ use evm_arithmetization::verifier::verify_proof; use evm_arithmetization::{AllStark, Node, StarkConfig}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::KeccakGoldilocksConfig; use plonky2::util::timing::TimingTree; diff --git a/evm_arithmetization/tests/selfdestruct.rs b/evm_arithmetization/tests/selfdestruct.rs index 77581f6aa..f48248f69 100644 --- a/evm_arithmetization/tests/selfdestruct.rs +++ b/evm_arithmetization/tests/selfdestruct.rs @@ -2,8 +2,6 @@ use std::str::FromStr; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H256, U256}; use evm_arithmetization::generation::mpt::{AccountRlp, LegacyReceiptRlp}; use evm_arithmetization::generation::{GenerationInputs, TrieInputs}; @@ -13,6 +11,8 @@ use evm_arithmetization::verifier::verify_proof; use evm_arithmetization::{AllStark, Node, StarkConfig}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::KeccakGoldilocksConfig; use plonky2::util::timing::TimingTree; diff --git a/evm_arithmetization/tests/simple_transfer.rs b/evm_arithmetization/tests/simple_transfer.rs index 9a8a47887..3fb3b08f6 100644 --- a/evm_arithmetization/tests/simple_transfer.rs +++ b/evm_arithmetization/tests/simple_transfer.rs @@ -3,8 +3,6 @@ use std::str::FromStr; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, BigEndianHash, H256, U256}; use evm_arithmetization::generation::mpt::{AccountRlp, LegacyReceiptRlp}; use evm_arithmetization::generation::{GenerationInputs, TrieInputs}; @@ -14,6 +12,8 @@ use evm_arithmetization::verifier::verify_proof; use evm_arithmetization::{AllStark, Node, StarkConfig}; use hex_literal::hex; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::KeccakGoldilocksConfig; use plonky2::util::timing::TimingTree; diff --git a/evm_arithmetization/tests/withdrawals.rs b/evm_arithmetization/tests/withdrawals.rs index 35e7cc6ce..28dc6da59 100644 --- a/evm_arithmetization/tests/withdrawals.rs +++ b/evm_arithmetization/tests/withdrawals.rs @@ -2,8 +2,6 @@ use std::collections::HashMap; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV}; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{H160, H256, U256}; use evm_arithmetization::generation::mpt::AccountRlp; use evm_arithmetization::generation::{GenerationInputs, TrieInputs}; @@ -12,6 +10,8 @@ use evm_arithmetization::prover::prove; use evm_arithmetization::verifier::verify_proof; use evm_arithmetization::{AllStark, Node, StarkConfig}; use keccak_hash::keccak; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::plonk::config::PoseidonGoldilocksConfig; use plonky2::util::timing::TimingTree; diff --git a/mpt_trie/Cargo.toml b/mpt_trie/Cargo.toml index 4fe2e7466..8a4c2a41b 100644 --- a/mpt_trie/Cargo.toml +++ b/mpt_trie/Cargo.toml @@ -1,34 +1,32 @@ [package] name = "mpt_trie" description = "Types and utility functions for building/working with partial Ethereum tries." -version = "0.6.0" +version = "0.1.0" authors = ["Polygon Zero "] -edition = "2021" readme = "README.md" -license = "MIT OR Apache-2.0" -homepage = "https://github.com/0xPolygonZero/eth-trie-utils" -repository = "https://github.com/0xPolygonZero/eth-trie-utils" -keywords = ["ethereum", "trie"] -categories = ["cryptography::cryptocurrencies", "data-structures"] +edition.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true exclude = [ "test_data/*" ] [dependencies] -bytes = "1.4.0" -enum-as-inner = "0.6.0" -ethereum-types = "0.14.1" -hex = "0.4.3" -keccak-hash = "0.10.0" +bytes = { workspace = true } +enum-as-inner = { workspace = true } +ethereum-types = { workspace = true } +hex = { workspace = true } +keccak-hash = { workspace = true } parking_lot = { version = "0.12.1", features = ["serde"] } thiserror = "1.0.40" -log = "0.4.17" -num = { version = "0.4.1", optional = true } +log = { workspace = true } +num = { workspace = true, optional = true } num-traits = "0.2.15" uint = "0.9.5" -rlp = "0.5.2" -serde = { version = "1.0.160", features = ["derive", "rc"] } +rlp = { workspace = true } +serde = { workspace = true, features = ["derive", "rc"] } [dev-dependencies] eth_trie = "0.4.0" diff --git a/mpt_trie/LICENSE-APACHE b/mpt_trie/LICENSE-APACHE deleted file mode 100644 index 1e5006dc1..000000000 --- a/mpt_trie/LICENSE-APACHE +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - diff --git a/mpt_trie/LICENSE-MIT b/mpt_trie/LICENSE-MIT deleted file mode 100644 index 86d690b22..000000000 --- a/mpt_trie/LICENSE-MIT +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2022 The Plonky2 Authors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/proof_gen/Cargo.toml b/proof_gen/Cargo.toml index 2e4f8202a..019bcbd9f 100644 --- a/proof_gen/Cargo.toml +++ b/proof_gen/Cargo.toml @@ -3,14 +3,19 @@ name = "proof_gen" description = "Generates block proofs from zero proof IR." version = "0.1.0" authors = ["Polygon Zero "] -edition = "2021" -license = "MIT OR Apache-2.0" +edition.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true +keywords.workspace = true [dependencies] ethereum-types = { workspace = true } log = { workspace = true } paste = "1.0.14" -plonky2 = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "265d46a96ecfec49a32973f66f8aa811586c5d4a" } -plonky2_evm = { workspace = true } -trace_decoder = { path = "../trace_decoder" } +plonky2 = { git = "https://github.com/0xPolygonZero/plonky2.git", rev = "710225c9e0ac5822b2965ce74951cf000bbb8a2c" } serde = { workspace = true } + +# Local dependencies +trace_decoder = { version = "0.1.0", path = "../trace_decoder" } +evm_arithmetization = { version = "0.1.0", path = "../evm_arithmetization" } diff --git a/proof_gen/src/proof_gen.rs b/proof_gen/src/proof_gen.rs index 5175d78fe..6e73839d1 100644 --- a/proof_gen/src/proof_gen.rs +++ b/proof_gen/src/proof_gen.rs @@ -3,8 +3,8 @@ use std::sync::{atomic::AtomicBool, Arc}; +use evm_arithmetization::{AllStark, StarkConfig}; use plonky2::util::timing::TimingTree; -use plonky2_evm::{all_stark::AllStark, config::StarkConfig}; use trace_decoder::types::TxnProofGenIR; use crate::{ diff --git a/proof_gen/src/proof_types.rs b/proof_gen/src/proof_types.rs index f64fc9dcd..acac783a8 100644 --- a/proof_gen/src/proof_types.rs +++ b/proof_gen/src/proof_types.rs @@ -1,7 +1,7 @@ //! This module defines the various proof types used throughout the block proof //! generation process. -use plonky2_evm::proof::PublicValues; +use evm_arithmetization::proof::PublicValues; use serde::{Deserialize, Serialize}; use trace_decoder::types::BlockHeight; diff --git a/proof_gen/src/prover_state.rs b/proof_gen/src/prover_state.rs index 0f3cb99aa..efb3413f4 100644 --- a/proof_gen/src/prover_state.rs +++ b/proof_gen/src/prover_state.rs @@ -5,9 +5,9 @@ use std::ops::Range; +use evm_arithmetization::{AllStark, StarkConfig}; use log::info; use paste::paste; -use plonky2_evm::{all_stark::AllStark, config::StarkConfig}; use crate::constants::*; use crate::types::AllRecursiveCircuits; diff --git a/proof_gen/src/types.rs b/proof_gen/src/types.rs index 52f5d2d43..93df45b33 100644 --- a/proof_gen/src/types.rs +++ b/proof_gen/src/types.rs @@ -11,7 +11,7 @@ pub type PlonkyProofIntern = ProofWithPublicInputs"] version = "0.1.0" -edition = "2021" +edition.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true +keywords.workspace = true [dependencies] -bytes = "1.5.0" +bytes = { workspace = true } ciborium = "0.2.1" ciborium-io = "0.2.1" -enum-as-inner = "0.6.0" +enum-as-inner = { workspace = true } enumn = "0.1.12" -eth_trie_utils = { git = "https://github.com/0xPolygonZero/eth_trie_utils.git", rev = "7fc3c3f54b3cec9c6fc5ffc5230910bd1cb77f76" } ethereum-types = { workspace = true } -hex-literal = "0.4.1" -hex = "0.4.3" -keccak-hash = "0.10.0" +hex = { workspace = true } +hex-literal = { workspace = true } +keccak-hash = { workspace = true } log = { workspace = true } -plonky2_evm = { workspace = true } -thiserror = "1.0.49" -rlp = "0.5.2" -rlp-derive = "0.1.0" +rlp = { workspace = true } +rlp-derive = { workspace = true } serde = { workspace = true } serde_with = "3.4.0" +thiserror = "1.0.49" + +# Local dependencies +mpt_trie = { version = "0.1.0", path = "../mpt_trie" } +evm_arithmetization = { version = "0.1.0", path = "../evm_arithmetization" } [dev-dependencies] pretty_env_logger = "0.5.0" diff --git a/trace_decoder/src/compact/compact_prestate_processing.rs b/trace_decoder/src/compact/compact_prestate_processing.rs index 6af7f356a..f2c189c77 100644 --- a/trace_decoder/src/compact/compact_prestate_processing.rs +++ b/trace_decoder/src/compact/compact_prestate_processing.rs @@ -10,12 +10,12 @@ use std::{ }; use enum_as_inner::EnumAsInner; -use eth_trie_utils::{ +use ethereum_types::{H256, U256}; +use log::trace; +use mpt_trie::{ nibbles::{FromHexPrefixError, Nibbles}, partial_trie::{HashedPartialTrie, PartialTrie}, }; -use ethereum_types::{H256, U256}; -use log::trace; use serde::de::DeserializeOwned; use thiserror::Error; @@ -1425,7 +1425,7 @@ fn get_bytes_from_cursor(cursor: &mut C, cursor_start_pos: u64 #[cfg(test)] mod tests { - use eth_trie_utils::{nibbles::Nibbles, partial_trie::PartialTrie}; + use mpt_trie::{nibbles::Nibbles, partial_trie::PartialTrie}; use super::{key_bytes_to_nibbles, parse_just_to_instructions, Instruction}; use crate::compact::{ diff --git a/trace_decoder/src/compact/compact_to_partial_trie.rs b/trace_decoder/src/compact/compact_to_partial_trie.rs index e19c85999..0d10e3a24 100644 --- a/trace_decoder/src/compact/compact_to_partial_trie.rs +++ b/trace_decoder/src/compact/compact_to_partial_trie.rs @@ -1,11 +1,11 @@ use std::collections::HashMap; -use eth_trie_utils::{ +use evm_arithmetization::generation::mpt::AccountRlp; +use log::trace; +use mpt_trie::{ nibbles::{Nibble, Nibbles}, partial_trie::{HashedPartialTrie, PartialTrie}, }; -use log::trace; -use plonky2_evm::generation::mpt::AccountRlp; use super::compact_prestate_processing::{ AccountNodeCode, AccountNodeData, CompactParsingResult, LeafNodeData, NodeEntry, WitnessEntry, @@ -70,7 +70,7 @@ fn process_branch( ) -> CompactParsingResult<()> { for (i, slot) in branch.iter().enumerate().take(16) { if let Some(child) = slot { - // TODO: Seriously update `eth_trie_utils` to have a better API... + // TODO: Seriously update `mpt_trie` to have a better API... let mut new_k = curr_key; new_k.push_nibble_back(i as Nibble); create_partial_trie_from_compact_node_rec(new_k, child, output)?; diff --git a/trace_decoder/src/compact/complex_test_payloads.rs b/trace_decoder/src/compact/complex_test_payloads.rs index 32d9fb56e..89febd736 100644 --- a/trace_decoder/src/compact/complex_test_payloads.rs +++ b/trace_decoder/src/compact/complex_test_payloads.rs @@ -1,5 +1,5 @@ -use eth_trie_utils::partial_trie::PartialTrie; -use plonky2_evm::generation::mpt::AccountRlp; +use evm_arithmetization::generation::mpt::AccountRlp; +use mpt_trie::partial_trie::PartialTrie; use super::compact_prestate_processing::{ process_compact_prestate, process_compact_prestate_debug, CompactParsingResult, diff --git a/trace_decoder/src/decoding.rs b/trace_decoder/src/decoding.rs index 1e401fd32..4c3f0172a 100644 --- a/trace_decoder/src/decoding.rs +++ b/trace_decoder/src/decoding.rs @@ -4,16 +4,16 @@ use std::{ iter::once, }; -use eth_trie_utils::{ - nibbles::Nibbles, - partial_trie::{HashedPartialTrie, Node, PartialTrie}, - trie_subsets::create_trie_subset, -}; use ethereum_types::{Address, H256, U256}; -use plonky2_evm::{ +use evm_arithmetization::{ generation::{mpt::AccountRlp, GenerationInputs, TrieInputs}, proof::{ExtraBlockData, TrieRoots}, }; +use mpt_trie::{ + nibbles::Nibbles, + partial_trie::{HashedPartialTrie, Node, PartialTrie}, + trie_subsets::create_trie_subset, +}; use thiserror::Error; use crate::{ @@ -188,7 +188,7 @@ impl ProcessedBlockTrace { )?; let txn_k = Nibbles::from_bytes_be(&rlp::encode(&txn_idx)).unwrap(); - // TODO: Replace cast once `eth_trie_utils` supports `into` for `usize... + // TODO: Replace cast once `mpt_trie` supports `into` for `usize... let transactions_trie = create_trie_subset_wrapped(&curr_block_tries.txn, once(txn_k), TrieType::Txn)?; diff --git a/trace_decoder/src/processed_block_trace.rs b/trace_decoder/src/processed_block_trace.rs index 1570bfdd0..fa200df64 100644 --- a/trace_decoder/src/processed_block_trace.rs +++ b/trace_decoder/src/processed_block_trace.rs @@ -2,10 +2,10 @@ use std::collections::{HashMap, HashSet}; use std::fmt::Debug; use std::iter::once; -use eth_trie_utils::nibbles::Nibbles; -use eth_trie_utils::partial_trie::{HashedPartialTrie, PartialTrie}; use ethereum_types::{Address, U256}; -use plonky2_evm::generation::mpt::{AccountRlp, LegacyReceiptRlp}; +use evm_arithmetization::generation::mpt::{AccountRlp, LegacyReceiptRlp}; +use mpt_trie::nibbles::Nibbles; +use mpt_trie::partial_trie::{HashedPartialTrie, PartialTrie}; use crate::compact::compact_prestate_processing::{ process_compact_prestate_debug, PartialTriePreImages, diff --git a/trace_decoder/src/trace_protocol.rs b/trace_decoder/src/trace_protocol.rs index 323dff5e5..b0cbc01bf 100644 --- a/trace_decoder/src/trace_protocol.rs +++ b/trace_decoder/src/trace_protocol.rs @@ -23,8 +23,8 @@ use std::collections::HashMap; -use eth_trie_utils::partial_trie::HashedPartialTrie; use ethereum_types::{Address, U256}; +use mpt_trie::partial_trie::HashedPartialTrie; use serde::{Deserialize, Serialize}; use serde_with::{serde_as, FromInto, TryFromInto}; diff --git a/trace_decoder/src/types.rs b/trace_decoder/src/types.rs index a138abaf2..eeb70a74e 100644 --- a/trace_decoder/src/types.rs +++ b/trace_decoder/src/types.rs @@ -1,9 +1,9 @@ -use eth_trie_utils::nibbles::Nibbles; use ethereum_types::{Address, H256, U256}; -use plonky2_evm::{ +use evm_arithmetization::{ generation::GenerationInputs, proof::{BlockHashes, BlockMetadata}, }; +use mpt_trie::nibbles::Nibbles; use serde::{Deserialize, Serialize}; pub type BlockHeight = u64; diff --git a/trace_decoder/src/utils.rs b/trace_decoder/src/utils.rs index ffb482084..678fcc064 100644 --- a/trace_decoder/src/utils.rs +++ b/trace_decoder/src/utils.rs @@ -1,10 +1,10 @@ -use eth_trie_utils::{ +use ethereum_types::H256; +use keccak_hash::keccak; +use mpt_trie::{ nibbles::Nibbles, partial_trie::{HashedPartialTrie, PartialTrie}, trie_ops::ValOrHash, }; -use ethereum_types::H256; -use keccak_hash::keccak; use crate::types::HashedStorageAddr; @@ -47,7 +47,7 @@ fn print_value_and_hash_nodes_of_trie_common(trie: &HashedPartialTrie) -> Vec H256 { - // TODO: HACK! This fix really needs to be in `eth_trie_utils`... + // TODO: HACK! This fix really needs to be in `mpt_trie`... let mut nib_bytes = h_addr_nibs.bytes_be(); if nib_bytes.len() < 32 { for _ in nib_bytes.len()..32 {