From bbbc8d111e1c661fb2adf46ed48948a3d205fa41 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 2 Nov 2023 21:31:33 -0700 Subject: [PATCH 001/161] setup multiple test bytes --- zkevm-circuits/src/rlp_circuit_fsm.rs | 3 ++ zkevm-circuits/src/rlp_circuit_fsm/test.rs | 43 +++++++++++++++------- zkevm-circuits/src/tx_circuit/test.rs | 2 +- zkevm-circuits/src/witness/tx.rs | 7 ++-- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index ba889b94f5..9da0428acf 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1837,6 +1837,9 @@ impl RlpCircuitConfig { .flat_map(|input| input.gen_sm_witness(challenges)) .collect::>(); + log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows.len(): {:?}", sm_rows.len()); + log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - last_row: {:?}", last_row); + debug_assert!(sm_rows.len() <= last_row); self.rom_table.load(layouter)?; diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index af07e18884..07d9c4af55 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -39,7 +39,7 @@ fn get_tx(is_eip155: bool) -> Transaction { log::debug!("num_unsigned_bytes: {}", unsigned_bytes.len()); log::debug!("num_signed_bytes: {}", signed_bytes.len()); - Transaction::new_from_rlp_bytes(tx_type, signed_bytes, unsigned_bytes) + Transaction::new_from_rlp_bytes(1, tx_type, signed_bytes, unsigned_bytes) } #[test] @@ -109,26 +109,39 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { - let raw_tx_rlp_bytes = hex::decode("02f901e901833c3139842b27f14d86012309ce540083055ca8945f65f7b609678448494de4c87521cdf6cef1e93280b8e4fa558b7100000000000000000000000095ad61b0a150d79219dcf64e1e6cc01f0b64c4ce000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000016a217dedfacdf9c23edb84b57154f26a15848e60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000028cad80bb7cf17e27c4c8f893f7945f65f7b609678448494de4c87521cdf6cef1e932e1a0d2dc2a0881b05440a4908cf506b4871b1f7eaa46ea0c5dfdcda5f52bc17164a4f8599495ad61b0a150d79219dcf64e1e6cc01f0b64c4cef842a0ba03decd934aae936605e9d437c401439ec4cefbad5795e0965100f929fe339ca0b36e2afa1a25492257090107ad99d079032e543c8dd1ffcd44cf14a96d3015ac80a0821193127789b107351f670025dd3b862f5836e5155f627a29741a251e8d28e8a07ea1e82b1bf6f29c5d0f1e4024acdb698086ac40c353704d7d5e301fb916f2e3") + let test_bytes = vec![ + "02f901e901833c3139842b27f14d86012309ce540083055ca8945f65f7b609678448494de4c87521cdf6cef1e93280b8e4fa558b7100000000000000000000000095ad61b0a150d79219dcf64e1e6cc01f0b64c4ce000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000016a217dedfacdf9c23edb84b57154f26a15848e60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000028cad80bb7cf17e27c4c8f893f7945f65f7b609678448494de4c87521cdf6cef1e932e1a0d2dc2a0881b05440a4908cf506b4871b1f7eaa46ea0c5dfdcda5f52bc17164a4f8599495ad61b0a150d79219dcf64e1e6cc01f0b64c4cef842a0ba03decd934aae936605e9d437c401439ec4cefbad5795e0965100f929fe339ca0b36e2afa1a25492257090107ad99d079032e543c8dd1ffcd44cf14a96d3015ac80a0821193127789b107351f670025dd3b862f5836e5155f627a29741a251e8d28e8a07ea1e82b1bf6f29c5d0f1e4024acdb698086ac40c353704d7d5e301fb916f2e3", + "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + ]; + + let mut txs: Vec = vec![]; + for (idx, bytes) in test_bytes.into_iter().enumerate() { + let raw_tx_rlp_bytes = hex::decode(bytes) .expect("decode tx's hex shall not fail"); - let eth_tx = EthTransaction::decode(&Rlp::new(&raw_tx_rlp_bytes)) - .expect("decode tx's rlp bytes shall not fail"); + let eth_tx = EthTransaction::decode(&Rlp::new(&raw_tx_rlp_bytes)) + .expect("decode tx's rlp bytes shall not fail"); - let eth_tx_req: Eip1559TransactionRequest = (ð_tx).into(); - let typed_tx: TypedTransaction = eth_tx_req.into(); - let rlp_unsigned = typed_tx.rlp().to_vec(); + let eth_tx_req: Eip1559TransactionRequest = (ð_tx).into(); + let typed_tx: TypedTransaction = eth_tx_req.into(); + let rlp_unsigned = typed_tx.rlp().to_vec(); + + let tx = Transaction::new_from_rlp_bytes(idx + 1, TxType::Eip1559, raw_tx_rlp_bytes, rlp_unsigned); + + txs.push(tx); + } + + assert!(txs.len() <= 10, "Maximum test cases for Rlp circuit can't exceed 10"); - let tx = Transaction::new_from_rlp_bytes(TxType::Eip1559, raw_tx_rlp_bytes, rlp_unsigned); let rlp_circuit = RlpCircuit:: { - txs: vec![tx], + txs, max_txs: 10, - size: 1000, + size: 2 << 13, _marker: Default::default(), }; - let mock_prover = MockProver::run(14, &rlp_circuit, vec![]); - assert!(mock_prover.is_ok()); + let mock_prover = MockProver::run(16, &rlp_circuit, vec![]); + // assert!(mock_prover.is_ok()); let mock_prover = mock_prover.unwrap(); if let Err(errors) = mock_prover.verify_par() { log::debug!("errors.len() = {}", errors.len()); @@ -139,7 +152,9 @@ fn test_eip1559_tx() { #[test] fn test_eip2930_tx() { - let raw_tx_rlp_bytes = hex::decode("01f8710183018c418502edc2c0dc8307a1209480464c21a0639510142d510c5be486f1bd801cdb87f753258d79d80080c001a0563304e8f2306c3fafed471bee76db83690ec113965c6775a8a94625dcb03774a05bcc59f5737520f7d0dc8b4f967635473e0a58526ce9ddd69c4a2454c9955f12") + let bytes = "01f8710183018c418502edc2c0dc8307a1209480464c21a0639510142d510c5be486f1bd801cdb87f753258d79d80080c001a0563304e8f2306c3fafed471bee76db83690ec113965c6775a8a94625dcb03774a05bcc59f5737520f7d0dc8b4f967635473e0a58526ce9ddd69c4a2454c9955f12"; + + let raw_tx_rlp_bytes = hex::decode(bytes) .expect("decode tx's hex shall not fail"); let eth_tx = EthTransaction::decode(&Rlp::new(&raw_tx_rlp_bytes)) @@ -149,7 +164,7 @@ fn test_eip2930_tx() { let typed_tx: TypedTransaction = eth_tx_req.into(); let rlp_unsigned = typed_tx.rlp().to_vec(); - let tx = Transaction::new_from_rlp_bytes(TxType::Eip2930, raw_tx_rlp_bytes, rlp_unsigned); + let tx = Transaction::new_from_rlp_bytes(1, TxType::Eip2930, raw_tx_rlp_bytes, rlp_unsigned); let rlp_circuit = RlpCircuit:: { txs: vec![tx], max_txs: 10, diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index 946a182ebd..1b45bbf4b1 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -51,7 +51,7 @@ fn build_pre_eip155_tx() -> Transaction { "9cd2288e69623b109e25edc46bc518156498b521e5c162d96e1ab392ff1d9dff" ); - let mut tx = Transaction::new_from_rlp_bytes(PreEip155, signed_bytes, unsigned_bytes); + let mut tx = Transaction::new_from_rlp_bytes(1, PreEip155, signed_bytes, unsigned_bytes); tx.hash = H256(eth_tx_hash); tx.block_number = 1; diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index f02359dbb5..79b375eeca 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -714,12 +714,13 @@ impl Transaction { #[cfg(test)] pub(crate) fn new_from_rlp_bytes( + tx_id: usize, tx_type: TxType, signed_bytes: Vec, unsigned_bytes: Vec, ) -> Self { Self { - id: 1, + id: tx_id, tx_type, rlp_signed: signed_bytes, rlp_unsigned: unsigned_bytes, @@ -757,12 +758,12 @@ impl RlpFsmWitnessGen for Transaction { }; log::debug!( - "{}th tx sign witness rows len = {}", + "tx (id: {}) sign witness rows len = {}", self.id, sign_wit.len() ); log::debug!( - "{}th tx hash witness rows len = {}", + "tx (id: {}) tx hash witness rows len = {}", self.id, hash_wit.len() ); From 14ecc5edf4e37a0313f1bdc93456e9be3b048cca Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 8 Nov 2023 19:23:20 -0800 Subject: [PATCH 002/161] add debug bytes --- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index 07d9c4af55..ab22671030 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,8 +110,10 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ - "02f901e901833c3139842b27f14d86012309ce540083055ca8945f65f7b609678448494de4c87521cdf6cef1e93280b8e4fa558b7100000000000000000000000095ad61b0a150d79219dcf64e1e6cc01f0b64c4ce000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000016a217dedfacdf9c23edb84b57154f26a15848e60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000028cad80bb7cf17e27c4c8f893f7945f65f7b609678448494de4c87521cdf6cef1e932e1a0d2dc2a0881b05440a4908cf506b4871b1f7eaa46ea0c5dfdcda5f52bc17164a4f8599495ad61b0a150d79219dcf64e1e6cc01f0b64c4cef842a0ba03decd934aae936605e9d437c401439ec4cefbad5795e0965100f929fe339ca0b36e2afa1a25492257090107ad99d079032e543c8dd1ffcd44cf14a96d3015ac80a0821193127789b107351f670025dd3b862f5836e5155f627a29741a251e8d28e8a07ea1e82b1bf6f29c5d0f1e4024acdb698086ac40c353704d7d5e301fb916f2e3", - "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", + // "02f901e901833c3139842b27f14d86012309ce540083055ca8945f65f7b609678448494de4c87521cdf6cef1e93280b8e4fa558b7100000000000000000000000095ad61b0a150d79219dcf64e1e6cc01f0b64c4ce000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000016a217dedfacdf9c23edb84b57154f26a15848e60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000028cad80bb7cf17e27c4c8f893f7945f65f7b609678448494de4c87521cdf6cef1e932e1a0d2dc2a0881b05440a4908cf506b4871b1f7eaa46ea0c5dfdcda5f52bc17164a4f8599495ad61b0a150d79219dcf64e1e6cc01f0b64c4cef842a0ba03decd934aae936605e9d437c401439ec4cefbad5795e0965100f929fe339ca0b36e2afa1a25492257090107ad99d079032e543c8dd1ffcd44cf14a96d3015ac80a0821193127789b107351f670025dd3b862f5836e5155f627a29741a251e8d28e8a07ea1e82b1bf6f29c5d0f1e4024acdb698086ac40c353704d7d5e301fb916f2e3", + "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + // "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; let mut txs: Vec = vec![]; From 8579f0bb8b0f906043ef83055a579a02c22fc4c3 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 11 Nov 2023 11:20:00 -0800 Subject: [PATCH 003/161] retrace debug: add ad sk idx --- zkevm-circuits/src/witness/rlp_fsm.rs | 8 ++++++++ zkevm-circuits/src/witness/tx.rs | 3 +++ 2 files changed, 11 insertions(+) diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 3a6b3cf077..26bb3f16b2 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -706,6 +706,14 @@ pub struct RlpTable { pub is_output: bool, /// If current tag's value is None. pub is_none: bool, + /// The index of access list address + /// Corresponding tag is AccessListAddress + pub access_list_idx: u64, + /// The index of the storage key + /// The combination (access_list_idx, storage_key_idx) + /// uniquely identifies a storage key value + /// Corresponding tag is AccessListStorageKey + pub storage_key_idx: u64, } /// State Machine diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 79b375eeca..312c5bf1c1 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -676,6 +676,9 @@ impl Transaction { tag_length, is_output, is_none, + // TX1559_DEBUG + access_list_idx: 0, + storage_key_idx: 0, }, state_machine: StateMachine { state: cur.state, From f9075dab90624ab60da237daf9ed01a9ace46996 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 11 Nov 2023 15:35:15 -0800 Subject: [PATCH 004/161] retrace debug: add access list idx wit --- zkevm-circuits/src/rlp_circuit_fsm.rs | 4 ++++ zkevm-circuits/src/witness/rlp_fsm.rs | 10 +++++++++ zkevm-circuits/src/witness/tx.rs | 30 ++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 9da0428acf..02805f54b2 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1837,9 +1837,13 @@ impl RlpCircuitConfig { .flat_map(|input| input.gen_sm_witness(challenges)) .collect::>(); + // TX1559_DEBUG log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows.len(): {:?}", sm_rows.len()); log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - last_row: {:?}", last_row); + log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", sm_rows); + log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", dt_rows); + debug_assert!(sm_rows.len() <= last_row); self.rom_table.load(layouter)?; diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 26bb3f16b2..aab0cf467a 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -167,6 +167,16 @@ impl Tag { pub fn is_end(&self) -> bool { matches!(self, Self::EndList | Self::EndVector) } + + /// If the tag is AccessListAddress + pub fn is_access_list_address(&self) -> bool { + matches!(self, Self::AccessListAddress) + } + + /// If the tag is AccessListStorageKey + pub fn is_access_list_storage_key(&self) -> bool { + matches!(self, Self::AccessListStorageKey) + } } /// RLP tags diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 312c5bf1c1..3b432fafde 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -406,6 +406,10 @@ impl Transaction { let mut is_none; let mut rlp_tag; let mut lb_len = 0; + // These two variables keep track + // unique identifier of addresses and storage keys included in access list + let mut access_list_idx: u64 = 0; + let mut storage_key_idx: u64 = 0; loop { // default behavior @@ -430,6 +434,18 @@ impl Transaction { assert_eq!(cur.byte_idx, rlp_bytes.len() - 1); is_output = true; rlp_tag = RlpTag::RLC; + } else if cur.depth == 4 { + // end of access list storage keys list + // note: depth alone currently is sufficient to ascertain + // the end of a storage keys list as there's no other nested + // structure at depth 4 specified in EIP standards + storage_key_idx = 0; + } else if cur.depth == 2 { + // end of access list + // note: depth alone currently is sufficient to ascertain + // the end of an access list as there's no other nested + // structure at depth 2 specified in EIP standards + access_list_idx = 0; } else if cur.depth == 0 { // emit GasCost is_output = true; @@ -474,6 +490,15 @@ impl Transaction { // assertions assert!(!cur.tag.is_list()); + // detect start of access list address + if cur.tag.is_access_list_address() { + access_list_idx += 1; + } + // detect start of access list storage key + if cur.tag.is_access_list_storage_key() { + storage_key_idx += 1; + } + // state transitions next.tag_idx = 1; next.tag_length = (byte_value - 0x80) as usize; @@ -676,9 +701,8 @@ impl Transaction { tag_length, is_output, is_none, - // TX1559_DEBUG - access_list_idx: 0, - storage_key_idx: 0, + access_list_idx, + storage_key_idx, }, state_machine: StateMachine { state: cur.state, From 928388df46a463fe098598be91cd4ce2bbe83179 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 11 Nov 2023 17:01:03 -0800 Subject: [PATCH 005/161] add additional witness columns --- zkevm-circuits/src/rlp_circuit_fsm.rs | 4 ++-- zkevm-circuits/src/table.rs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 02805f54b2..aa42107c6d 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1841,8 +1841,8 @@ impl RlpCircuitConfig { log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows.len(): {:?}", sm_rows.len()); log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - last_row: {:?}", last_row); - log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", sm_rows); - log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", dt_rows); + // log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", sm_rows); + // log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", dt_rows); debug_assert!(sm_rows.len() <= last_row); diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 0f0702b5f2..6facccc15f 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -2077,6 +2077,10 @@ pub struct RlpFsmRlpTable { pub is_output: Column, /// Whether or not the current tag's value was nil. pub is_none: Column, + /// Index of access list address + pub access_list_idx: Column, + /// Index of storage key in an access list item + pub storage_key_idx: Column, } impl LookupTable for RlpFsmRlpTable { @@ -2091,6 +2095,8 @@ impl LookupTable for RlpFsmRlpTable { self.tag_length.into(), self.is_output.into(), self.is_none.into(), + self.access_list_idx.into(), + self.storage_key_idx.into(), ] } @@ -2105,6 +2111,8 @@ impl LookupTable for RlpFsmRlpTable { String::from("tag_length"), String::from("is_output"), String::from("is_none"), + String::from("access_list_idx"), + String::from("storage_key_idx"), ] } } @@ -2122,6 +2130,8 @@ impl RlpFsmRlpTable { tag_length: meta.advice_column(), is_output: meta.advice_column(), is_none: meta.advice_column(), + access_list_idx: meta.advice_column(), + storage_key_idx: meta.advice_column(), } } From 6445658895582dd452d1bc410c8f1263e55ba70d Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 11 Nov 2023 17:03:43 -0800 Subject: [PATCH 006/161] add additional witness columns --- zkevm-circuits/src/rlp_circuit_fsm.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index aa42107c6d..f79e4d2055 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1529,6 +1529,18 @@ impl RlpCircuitConfig { row, || Value::known(F::from(witness.rlp_table.is_none as u64)), )?; + region.assign_advice( + || "rlp_table.access_list_idx", + self.rlp_table.access_list_idx, + row, + || Value::known(F::from(witness.rlp_table.access_list_idx as u64)), + )?; + region.assign_advice( + || "rlp_table.storage_key_idx", + self.rlp_table.storage_key_idx, + row, + || Value::known(F::from(witness.rlp_table.storage_key_idx as u64)), + )?; // assign to sm region.assign_advice( From eb7d10258deaf493ad48b81b6255b32244f57cef Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 11 Nov 2023 23:10:45 -0800 Subject: [PATCH 007/161] add constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 47 +++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index f79e4d2055..5e30de1f59 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -275,6 +275,8 @@ pub struct RlpCircuitConfig { depth_check: IsEqualConfig, /// Check for depth == 1 depth_eq_one: IsEqualConfig, + /// Check for depth == 4 + depth_eq_four: IsEqualConfig, /// Check for byte_value == 0 byte_value_is_zero: IsZeroConfig, @@ -385,6 +387,8 @@ impl RlpCircuitConfig { is_tag!(is_tag_begin_vector, BeginVector); is_tag!(is_tag_end_list, EndList); is_tag!(is_tag_end_vector, EndVector); + is_tag!(is_access_list_address, AccessListAddress); + is_tag!(is_access_list_storage_key,AccessListStorageKey); ////////////////////////////////////////////////////////// //////////// data table checks. ////////////////////////// @@ -765,6 +769,12 @@ impl RlpCircuitConfig { |meta| meta.query_advice(depth, Rotation::cur()), |_| 1.expr(), ); + let depth_eq_four = IsEqualChip::configure( + meta, + cmp_enabled, + |meta| meta.query_advice(depth, Rotation::cur()), + |_| 4.expr(), + ); let tx_id_check_in_sm = IsEqualChip::configure( meta, |meta| meta.query_fixed(q_enabled, Rotation::cur()), @@ -1397,6 +1407,31 @@ impl RlpCircuitConfig { ])) }); + meta.create_gate("access list: access_list_idx and storage_key_idx increments", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.condition(is_access_list_address(meta), |cb| { + cb.require_equal( + "al_idx - al_idx::prev = 1", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); + }); + + cb.condition(is_access_list_storage_key(meta), |cb| { + cb.require_equal( + "sk_idx - sk_idx::prev = 1", + meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + ); + }); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + is_decode_tag_start(meta) + ])) + }); + meta.create_gate("sm ends in End state", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1453,6 +1488,7 @@ impl RlpCircuitConfig { tlength_lte_mlength, depth_check, depth_eq_one, + depth_eq_four, byte_value_is_zero, // internal tables @@ -1714,6 +1750,13 @@ impl RlpCircuitConfig { Value::known(F::from(witness.state_machine.depth as u64)), Value::known(F::one()), )?; + let depth_eq_four_chip = IsEqualChip::construct(self.depth_eq_four.clone()); + depth_eq_four_chip.assign( + region, + row, + Value::known(F::from(witness.state_machine.depth as u64)), + Value::known(F::from(4u64)), + )?; let mlength_lte_0x20_chip = ComparatorChip::construct(self.mlength_lte_0x20.clone()); mlength_lte_0x20_chip.assign( @@ -1853,8 +1896,8 @@ impl RlpCircuitConfig { log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows.len(): {:?}", sm_rows.len()); log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - last_row: {:?}", last_row); - // log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", sm_rows); - // log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", dt_rows); + log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", sm_rows); + log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", dt_rows); debug_assert!(sm_rows.len() <= last_row); From 5bf32284f3c0c44e35623ae7031b1c9f2f0d88b4 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 11 Nov 2023 23:14:03 -0800 Subject: [PATCH 008/161] add constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 5e30de1f59..de1afcebb9 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1432,6 +1432,23 @@ impl RlpCircuitConfig { ])) }); + meta.create_gate("access list: clearing access_list_idx and storage_key_idx", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.condition(depth_eq_four.is_equal_expression.expr(), |cb| { + cb.require_equal( + "sk_idx = 0", + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + 0.expr(), + ); + }); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + is_tag_end_vector(meta) + ])) + }); + meta.create_gate("sm ends in End state", |meta| { let mut cb = BaseConstraintBuilder::default(); From 77e69f5ba1659aa65404da9013e72625e48205cf Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 11 Nov 2023 23:26:09 -0800 Subject: [PATCH 009/161] add constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index de1afcebb9..ab76bd3e21 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -275,6 +275,8 @@ pub struct RlpCircuitConfig { depth_check: IsEqualConfig, /// Check for depth == 1 depth_eq_one: IsEqualConfig, + /// CHeck for depth == 2 + depth_eq_two: IsEqualConfig, /// Check for depth == 4 depth_eq_four: IsEqualConfig, /// Check for byte_value == 0 @@ -769,6 +771,12 @@ impl RlpCircuitConfig { |meta| meta.query_advice(depth, Rotation::cur()), |_| 1.expr(), ); + let depth_eq_two = IsEqualChip::configure( + meta, + cmp_enabled, + |meta| meta.query_advice(depth, Rotation::cur()), + |_| 2.expr(), + ); let depth_eq_four = IsEqualChip::configure( meta, cmp_enabled, @@ -1407,6 +1415,7 @@ impl RlpCircuitConfig { ])) }); + // Access List Increments meta.create_gate("access list: access_list_idx and storage_key_idx increments", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1419,6 +1428,11 @@ impl RlpCircuitConfig { }); cb.condition(is_access_list_storage_key(meta), |cb| { + cb.require_equal( + "for same storage key list, al_idx stays the same", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); cb.require_equal( "sk_idx - sk_idx::prev = 1", meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) + 1.expr(), @@ -1432,9 +1446,21 @@ impl RlpCircuitConfig { ])) }); + // Access List Clearing + // note: right now no other nested structures are defined at these depth levels + // hence using depth alone is sufficient to determine clearing conditions. + // however, this might change in the future if more nested structures are introduced at same depth level meta.create_gate("access list: clearing access_list_idx and storage_key_idx", |meta| { let mut cb = BaseConstraintBuilder::default(); + cb.condition(depth_eq_two.is_equal_expression.expr(), |cb| { + cb.require_equal( + "al_idx = 0", + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + 0.expr(), + ); + }); + cb.condition(depth_eq_four.is_equal_expression.expr(), |cb| { cb.require_equal( "sk_idx = 0", @@ -1505,6 +1531,7 @@ impl RlpCircuitConfig { tlength_lte_mlength, depth_check, depth_eq_one, + depth_eq_two, depth_eq_four, byte_value_is_zero, @@ -1767,6 +1794,13 @@ impl RlpCircuitConfig { Value::known(F::from(witness.state_machine.depth as u64)), Value::known(F::one()), )?; + let depth_eq_two_chip = IsEqualChip::construct(self.depth_eq_two.clone()); + depth_eq_two_chip.assign( + region, + row, + Value::known(F::from(witness.state_machine.depth as u64)), + Value::known(F::from(2u64)), + )?; let depth_eq_four_chip = IsEqualChip::construct(self.depth_eq_four.clone()); depth_eq_four_chip.assign( region, From d4e0595eb1136f10ae18de175d10dd2fa9463d1e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 11 Nov 2023 23:30:11 -0800 Subject: [PATCH 010/161] add constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index ab76bd3e21..80441137c7 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1475,6 +1475,28 @@ impl RlpCircuitConfig { ])) }); + // Access List Consistency + meta.create_gate("access list: no access_list_idx and storage_key_idx change", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "al_idx stays the same when no starting or ending conditions present", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); + cb.require_equal( + "sk_idx stays the same when no starting or ending conditions present", + meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()), + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + ); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + not::expr(is_tag_end_vector(meta)), + not::expr(is_decode_tag_start(meta)), + ])) + }); + meta.create_gate("sm ends in End state", |meta| { let mut cb = BaseConstraintBuilder::default(); From 4ace802d388374a1d2f71f57d63340afcb046f03 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 13 Nov 2023 12:06:40 -0800 Subject: [PATCH 011/161] generate correct stack states --- zkevm-circuits/src/witness/rlp_fsm.rs | 40 +++++++++ zkevm-circuits/src/witness/tx.rs | 122 +++++++++++++++++++++++++- 2 files changed, 159 insertions(+), 3 deletions(-) diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index aab0cf467a..6227ad3354 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -609,6 +609,11 @@ impl From for usize { value as usize } } +impl From for u64 { + fn from(value: Format) -> Self { + value as u64 + } +} impl Format { /// The ROM table for format @@ -758,6 +763,27 @@ pub struct StateMachine { pub gas_cost_acc: Value, } +/// Rlp Decoding Table +/// Using simulated stack constraints to make sure all bytes are decoded +#[derive(Clone, Debug)] +pub struct RlpDecodingTable { + // note: a byte-counting idx such as rw_counter is not necessary + // as byte_idx/byte_rev_idx can be used for the purpose + + /// Is Write to decoding stack + pub is_write: bool, + /// Key1 (Id), concat of tx_id, format + pub id: Value, + /// Key2 (Address), in this case depth + pub address: usize, + /// Value + pub value: usize, + /// Value Previous + pub value_prev: usize, + // TX1559_DEBUG + pub note: String, +} + /// Represents the witness in a single row of the RLP circuit. #[derive(Clone, Debug)] pub struct RlpFsmWitnessRow { @@ -765,6 +791,8 @@ pub struct RlpFsmWitnessRow { pub rlp_table: RlpTable, /// The state machine witness. pub state_machine: StateMachine, + /// The rlp decoding table witness + pub rlp_decoding_table: RlpDecodingTable, } /// The RlpFsmWitnessGen trait is implemented by data types who's RLP encoding can @@ -790,3 +818,15 @@ pub(crate) struct SmState { pub(crate) tag_value_acc: Value, pub(crate) tag_bytes_rlc: Value, } + +#[derive(Clone)] +pub(crate) struct RlpStackOp { + pub is_write: bool, + pub id: Value, + pub address: usize, + pub value: usize, + pub value_prev: usize, + + // TX1559_DEBUG + pub note: String, +} \ No newline at end of file diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 3b432fafde..fa871f535c 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -3,7 +3,7 @@ use crate::{ table::TxContextFieldTag, util::{rlc_be_bytes, Challenges}, witness::{ - rlp_fsm::SmState, + rlp_fsm::{SmState, RlpStackOp, RlpDecodingTable}, DataTable, Format, Format::{ L1MsgHash, TxHashEip155, TxHashEip1559, TxHashEip2930, TxHashPreEip155, TxSignEip155, @@ -15,9 +15,9 @@ use crate::{ Tag::{EndList, EndVector}, }, }; -use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}; +use bus_mapping::{circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}, operation::StackOp}; use eth_types::{ - evm_types::gas_utils::tx_data_gas_cost, + evm_types::{gas_utils::tx_data_gas_cost, stack}, geth_types::{TxType, TxType::PreEip155}, sign_types::{ biguint_to_32bytes_le, ct_option_ok_or, get_dummy_tx, recover_pk2, SignData, SECP256K1_Q, @@ -389,12 +389,29 @@ impl Transaction { byte_idx: 0, depth: 0, }; + + // Queue up stack operations + let mut stack_ops: Vec> = vec![]; + // concat tx_id and format as stack identifier + let id = keccak_rand * Value::known(F::from(tx_id)) + Value::known(F::from(format as u64)); // When we are decoding a vector of element type `t`, at the beginning // we actually do not know the next tag is `EndVector` or not. After we // parsed the current tag, if the remaining bytes to decode in this layer // is zero, then the next tag is `EndVector`. let mut cur_rom_row = vec![0]; let mut remaining_bytes = vec![rlp_bytes.len()]; + // initialize stack + stack_ops.push( + RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rlp_bytes.len(), + value_prev: 0, + // TX1559_DEBUG + note: String::from("Initialize"), + } + ); let mut witness_table_idx = 0; // This map keeps track @@ -463,8 +480,25 @@ impl Transaction { if let Some(rem) = remaining_bytes.last_mut() { // read one more byte assert!(*rem >= 1); + + if byte_value <= 0xc0 || byte_value > 0xf7 { + // add stack op on same depth + stack_ops.push( + RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rem.clone() - 1, + value_prev: rem.clone(), + // TX1559_DEBUG + note: String::from(format!("Decoding Start byte read, idx: {}, len: {}", cur.tag_idx, cur.tag_length)), + } + ); + } + *rem -= 1; } + if byte_value < 0x80 { // assertions assert!(!cur.tag.is_list()); @@ -534,9 +568,21 @@ impl Transaction { // current list should be subtracted by // the number of bytes of the new list. assert!(*rem >= num_bytes_of_new_list); + *rem -= num_bytes_of_new_list; } remaining_bytes.push(num_bytes_of_new_list); + stack_ops.push( + RlpStackOp { + is_write: true, + id, + address: cur.depth + 1, + value: num_bytes_of_new_list, + value_prev: 0, + // TX1559_DEBUG + note: String::from("BeginList but byte < 0xf8, next stack state write"), + } + ); next.depth = cur.depth + 1; next.state = DecodeTagStart; } else { @@ -556,6 +602,20 @@ impl Transaction { State::Bytes => { if let Some(rem) = remaining_bytes.last_mut() { assert!(*rem >= 1); + + // add stack op on same depth + stack_ops.push( + RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rem.clone() - 1, + value_prev: rem.clone(), + // TX1559_DEBUG + note: String::from("Bytes, reading regular byte"), + } + ); + *rem -= 1; } if cur.tag_idx < cur.tag_length { @@ -582,6 +642,20 @@ impl Transaction { State::LongBytes => { if let Some(rem) = remaining_bytes.last_mut() { assert!(*rem >= 1); + + // add stack op on same depth + stack_ops.push( + RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rem.clone() - 1, + value_prev: rem.clone(), + // TX1559_DEBUG + note: String::from("Bytes, reading regular long bytes"), + } + ); + *rem -= 1; } @@ -606,6 +680,22 @@ impl Transaction { if let Some(rem) = remaining_bytes.last_mut() { // read one more byte assert!(*rem >= 1); + + // add stack op on same depth + if cur.tag_idx < cur.tag_length { + stack_ops.push( + RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rem.clone() - 1, + value_prev: rem.clone(), + // TX1559_DEBUG + note: String::from("LongList tag_idx < tag_length, read byte"), + } + ); + } + *rem -= 1; } if cur.tag_idx < cur.tag_length { @@ -621,9 +711,21 @@ impl Transaction { } if let Some(rem) = remaining_bytes.last_mut() { assert!(*rem >= lb_len); + *rem -= lb_len; } remaining_bytes.push(lb_len); + stack_ops.push( + RlpStackOp { + is_write: true, + id, + address: cur.depth + 1, + value: lb_len, + value_prev: 0, + // TX1559_DEBUG + note: String::from("LongList Last byte, write next stack state"), + } + ); next.depth = cur.depth + 1; next.state = DecodeTagStart; } @@ -691,6 +793,12 @@ impl Transaction { RlpTag::Null => unreachable!("Null is not used"), }; + // TX1559_DEBUG + if stack_ops.len() < 1 { + stack_ops.push(RlpStackOp { is_write: false, id: Value::known(F::zero()), address: 0, value: 0, value_prev: 0, note: String::from("pad") }); + } + let stack_op = stack_ops.remove(0); + witness.push(RlpFsmWitnessRow { rlp_table: RlpTable { tx_id, @@ -718,6 +826,14 @@ impl Transaction { bytes_rlc, gas_cost_acc, }, + rlp_decoding_table: RlpDecodingTable { + is_write: stack_op.is_write, + id: stack_op.id, + address: stack_op.address, + value: stack_op.value, + value_prev: stack_op.value_prev, + note: stack_op.note, + } }); witness_table_idx += 1; From 72e3ab1eb1f1365302cf5d5338b8fc7806565961 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 13 Nov 2023 13:28:15 -0800 Subject: [PATCH 012/161] correct stack witness generation --- zkevm-circuits/src/witness/tx.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index fa871f535c..dbd0a72d77 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -392,6 +392,7 @@ impl Transaction { // Queue up stack operations let mut stack_ops: Vec> = vec![]; + let mut last_bytes_on_depth: [usize; 4] = [0, 0, 0, 0]; // concat tx_id and format as stack identifier let id = keccak_rand * Value::known(F::from(tx_id)) + Value::known(F::from(format as u64)); // When we are decoding a vector of element type `t`, at the beginning @@ -445,6 +446,22 @@ impl Transaction { .expect("remaining_bytes shall not be empty"), 0 ); + + if remaining_bytes.len() > 0 { + let prev_depth_bytes = remaining_bytes.last().unwrap().clone(); + stack_ops.push( + RlpStackOp { + is_write: true, + id, + address: cur.depth - 1, + value: prev_depth_bytes, + value_prev: last_bytes_on_depth[cur.depth - 1], + // TX1559_DEBUG + note: String::from(format!("Restoring depth level {}", cur.depth - 1)), + } + ) + } + if cur.depth == 1 { assert_eq!(remaining_bytes.len(), 1); assert_eq!(remaining_bytes[0], 0); @@ -452,7 +469,7 @@ impl Transaction { is_output = true; rlp_tag = RlpTag::RLC; } else if cur.depth == 4 { - // end of access list storage keys list + // end of storage keys list // note: depth alone currently is sufficient to ascertain // the end of a storage keys list as there's no other nested // structure at depth 4 specified in EIP standards @@ -568,10 +585,11 @@ impl Transaction { // current list should be subtracted by // the number of bytes of the new list. assert!(*rem >= num_bytes_of_new_list); - + last_bytes_on_depth[cur.depth] = rem.clone() + 1; *rem -= num_bytes_of_new_list; } remaining_bytes.push(num_bytes_of_new_list); + stack_ops.push( RlpStackOp { is_write: true, @@ -711,7 +729,7 @@ impl Transaction { } if let Some(rem) = remaining_bytes.last_mut() { assert!(*rem >= lb_len); - + last_bytes_on_depth[cur.depth] = rem.clone() + 1; *rem -= lb_len; } remaining_bytes.push(lb_len); From ec9cde39b55e523ed189855167d0de6c160c38ef Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 13 Nov 2023 14:36:58 -0800 Subject: [PATCH 013/161] add stack accumulator --- zkevm-circuits/src/witness/rlp_fsm.rs | 5 +++++ zkevm-circuits/src/witness/tx.rs | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 6227ad3354..ed9359a402 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -780,6 +780,11 @@ pub struct RlpDecodingTable { pub value: usize, /// Value Previous pub value_prev: usize, + /// Stack Accumulator + /// accumulates remaining bytes on each depth level (excluding top of stack) + pub stack_acc: Value, + /// Power of rand for stack accumulator on depth level (address) + pub stack_acc_pow_of_rand: Value, // TX1559_DEBUG pub note: String, } diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index dbd0a72d77..ee54082768 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -393,6 +393,15 @@ impl Transaction { // Queue up stack operations let mut stack_ops: Vec> = vec![]; let mut last_bytes_on_depth: [usize; 4] = [0, 0, 0, 0]; + let mut stack_acc = Value::known(F::zero()); + + let mut stack_acc_pow_of_rand: Vec> = vec![]; + let mut pow_of_rand = Value::known(F::one()); + stack_acc_pow_of_rand.push(pow_of_rand.clone()); + for _ in 0..4 { + pow_of_rand = pow_of_rand * keccak_rand; + stack_acc_pow_of_rand.push(pow_of_rand.clone()); + } // concat tx_id and format as stack identifier let id = keccak_rand * Value::known(F::from(tx_id)) + Value::known(F::from(format as u64)); // When we are decoding a vector of element type `t`, at the beginning @@ -449,6 +458,9 @@ impl Transaction { if remaining_bytes.len() > 0 { let prev_depth_bytes = remaining_bytes.last().unwrap().clone(); + stack_acc = stack_acc + - stack_acc_pow_of_rand[cur.depth - 1] + * Value::known(F::from(prev_depth_bytes as u64)); stack_ops.push( RlpStackOp { is_write: true, @@ -586,6 +598,10 @@ impl Transaction { // the number of bytes of the new list. assert!(*rem >= num_bytes_of_new_list); last_bytes_on_depth[cur.depth] = rem.clone() + 1; + stack_acc = stack_acc + + stack_acc_pow_of_rand[cur.depth] + * Value::known(F::from((rem.clone() - num_bytes_of_new_list) as u64)); + *rem -= num_bytes_of_new_list; } remaining_bytes.push(num_bytes_of_new_list); @@ -730,6 +746,10 @@ impl Transaction { if let Some(rem) = remaining_bytes.last_mut() { assert!(*rem >= lb_len); last_bytes_on_depth[cur.depth] = rem.clone() + 1; + stack_acc = stack_acc + + stack_acc_pow_of_rand[cur.depth] + * Value::known(F::from((rem.clone() - lb_len) as u64)); + *rem -= lb_len; } remaining_bytes.push(lb_len); @@ -850,6 +870,8 @@ impl Transaction { address: stack_op.address, value: stack_op.value, value_prev: stack_op.value_prev, + stack_acc: stack_acc.clone(), + stack_acc_pow_of_rand: stack_acc_pow_of_rand[stack_op.address], note: stack_op.note, } }); From 53ad280d612470f373218a44c587ccded0ec91f1 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 13 Nov 2023 14:38:50 -0800 Subject: [PATCH 014/161] fmt --- zkevm-circuits/src/witness/tx.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index ee54082768..20764c3608 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -15,9 +15,9 @@ use crate::{ Tag::{EndList, EndVector}, }, }; -use bus_mapping::{circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}, operation::StackOp}; +use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}; use eth_types::{ - evm_types::{gas_utils::tx_data_gas_cost, stack}, + evm_types::gas_utils::tx_data_gas_cost, geth_types::{TxType, TxType::PreEip155}, sign_types::{ biguint_to_32bytes_le, ct_option_ok_or, get_dummy_tx, recover_pk2, SignData, SECP256K1_Q, From 89f233f24650655409a6e0a45f2c6dc14c2c6363 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 13 Nov 2023 15:52:45 -0800 Subject: [PATCH 015/161] fmt --- zkevm-circuits/src/rlp_circuit_fsm.rs | 162 +++++++++------- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 22 ++- zkevm-circuits/src/witness/rlp_fsm.rs | 7 +- zkevm-circuits/src/witness/tx.rs | 205 +++++++++++---------- 4 files changed, 212 insertions(+), 184 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 80441137c7..9c198b9c01 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -390,7 +390,7 @@ impl RlpCircuitConfig { is_tag!(is_tag_end_list, EndList); is_tag!(is_tag_end_vector, EndVector); is_tag!(is_access_list_address, AccessListAddress); - is_tag!(is_access_list_storage_key,AccessListStorageKey); + is_tag!(is_access_list_storage_key, AccessListStorageKey); ////////////////////////////////////////////////////////// //////////// data table checks. ////////////////////////// @@ -1416,86 +1416,96 @@ impl RlpCircuitConfig { }); // Access List Increments - meta.create_gate("access list: access_list_idx and storage_key_idx increments", |meta| { - let mut cb = BaseConstraintBuilder::default(); + meta.create_gate( + "access list: access_list_idx and storage_key_idx increments", + |meta| { + let mut cb = BaseConstraintBuilder::default(); - cb.condition(is_access_list_address(meta), |cb| { - cb.require_equal( - "al_idx - al_idx::prev = 1", - meta.query_advice(rlp_table.access_list_idx, Rotation::prev()) + 1.expr(), - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - ); - }); + cb.condition(is_access_list_address(meta), |cb| { + cb.require_equal( + "al_idx - al_idx::prev = 1", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); + }); - cb.condition(is_access_list_storage_key(meta), |cb| { - cb.require_equal( - "for same storage key list, al_idx stays the same", - meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - ); - cb.require_equal( - "sk_idx - sk_idx::prev = 1", - meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) + 1.expr(), - meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - ); - }); + cb.condition(is_access_list_storage_key(meta), |cb| { + cb.require_equal( + "for same storage key list, al_idx stays the same", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); + cb.require_equal( + "sk_idx - sk_idx::prev = 1", + meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + ); + }); - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - is_decode_tag_start(meta) - ])) - }); + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + is_decode_tag_start(meta), + ])) + }, + ); // Access List Clearing // note: right now no other nested structures are defined at these depth levels // hence using depth alone is sufficient to determine clearing conditions. - // however, this might change in the future if more nested structures are introduced at same depth level - meta.create_gate("access list: clearing access_list_idx and storage_key_idx", |meta| { - let mut cb = BaseConstraintBuilder::default(); + // however, this might change in the future if more nested structures are introduced at same + // depth level + meta.create_gate( + "access list: clearing access_list_idx and storage_key_idx", + |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.condition(depth_eq_two.is_equal_expression.expr(), |cb| { + cb.require_equal( + "al_idx = 0", + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + 0.expr(), + ); + }); + + cb.condition(depth_eq_four.is_equal_expression.expr(), |cb| { + cb.require_equal( + "sk_idx = 0", + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + 0.expr(), + ); + }); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + is_tag_end_vector(meta), + ])) + }, + ); + + // Access List Consistency + meta.create_gate( + "access list: no access_list_idx and storage_key_idx change", + |meta| { + let mut cb = BaseConstraintBuilder::default(); - cb.condition(depth_eq_two.is_equal_expression.expr(), |cb| { cb.require_equal( - "al_idx = 0", + "al_idx stays the same when no starting or ending conditions present", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - 0.expr(), ); - }); - - cb.condition(depth_eq_four.is_equal_expression.expr(), |cb| { cb.require_equal( - "sk_idx = 0", + "sk_idx stays the same when no starting or ending conditions present", + meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()), meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - 0.expr(), ); - }); - - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - is_tag_end_vector(meta) - ])) - }); - // Access List Consistency - meta.create_gate("access list: no access_list_idx and storage_key_idx change", |meta| { - let mut cb = BaseConstraintBuilder::default(); - - cb.require_equal( - "al_idx stays the same when no starting or ending conditions present", - meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - ); - cb.require_equal( - "sk_idx stays the same when no starting or ending conditions present", - meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()), - meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - ); - - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - not::expr(is_tag_end_vector(meta)), - not::expr(is_decode_tag_start(meta)), - ])) - }); + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + not::expr(is_tag_end_vector(meta)), + not::expr(is_decode_tag_start(meta)), + ])) + }, + ); meta.create_gate("sm ends in End state", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1966,11 +1976,23 @@ impl RlpCircuitConfig { .collect::>(); // TX1559_DEBUG - log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows.len(): {:?}", sm_rows.len()); - log::trace!("=> [Execution Rlp Circuit FSM] RlpCircuitConfig - last_row: {:?}", last_row); + log::trace!( + "=> [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows.len(): {:?}", + sm_rows.len() + ); + log::trace!( + "=> [Execution Rlp Circuit FSM] RlpCircuitConfig - last_row: {:?}", + last_row + ); - log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", sm_rows); - log::trace!("\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", dt_rows); + log::trace!( + "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", + sm_rows + ); + log::trace!( + "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", + dt_rows + ); debug_assert!(sm_rows.len() <= last_row); diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index ab22671030..49812eb789 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,16 +110,15 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ - // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", + "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", // "02f901e901833c3139842b27f14d86012309ce540083055ca8945f65f7b609678448494de4c87521cdf6cef1e93280b8e4fa558b7100000000000000000000000095ad61b0a150d79219dcf64e1e6cc01f0b64c4ce000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000016a217dedfacdf9c23edb84b57154f26a15848e60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000028cad80bb7cf17e27c4c8f893f7945f65f7b609678448494de4c87521cdf6cef1e932e1a0d2dc2a0881b05440a4908cf506b4871b1f7eaa46ea0c5dfdcda5f52bc17164a4f8599495ad61b0a150d79219dcf64e1e6cc01f0b64c4cef842a0ba03decd934aae936605e9d437c401439ec4cefbad5795e0965100f929fe339ca0b36e2afa1a25492257090107ad99d079032e543c8dd1ffcd44cf14a96d3015ac80a0821193127789b107351f670025dd3b862f5836e5155f627a29741a251e8d28e8a07ea1e82b1bf6f29c5d0f1e4024acdb698086ac40c353704d7d5e301fb916f2e3", - "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + // "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", // "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; let mut txs: Vec = vec![]; for (idx, bytes) in test_bytes.into_iter().enumerate() { - let raw_tx_rlp_bytes = hex::decode(bytes) - .expect("decode tx's hex shall not fail"); + let raw_tx_rlp_bytes = hex::decode(bytes).expect("decode tx's hex shall not fail"); let eth_tx = EthTransaction::decode(&Rlp::new(&raw_tx_rlp_bytes)) .expect("decode tx's rlp bytes shall not fail"); @@ -128,12 +127,20 @@ fn test_eip1559_tx() { let typed_tx: TypedTransaction = eth_tx_req.into(); let rlp_unsigned = typed_tx.rlp().to_vec(); - let tx = Transaction::new_from_rlp_bytes(idx + 1, TxType::Eip1559, raw_tx_rlp_bytes, rlp_unsigned); + let tx = Transaction::new_from_rlp_bytes( + idx + 1, + TxType::Eip1559, + raw_tx_rlp_bytes, + rlp_unsigned, + ); txs.push(tx); } - assert!(txs.len() <= 10, "Maximum test cases for Rlp circuit can't exceed 10"); + assert!( + txs.len() <= 10, + "Maximum test cases for Rlp circuit can't exceed 10" + ); let rlp_circuit = RlpCircuit:: { txs, @@ -156,8 +163,7 @@ fn test_eip1559_tx() { fn test_eip2930_tx() { let bytes = "01f8710183018c418502edc2c0dc8307a1209480464c21a0639510142d510c5be486f1bd801cdb87f753258d79d80080c001a0563304e8f2306c3fafed471bee76db83690ec113965c6775a8a94625dcb03774a05bcc59f5737520f7d0dc8b4f967635473e0a58526ce9ddd69c4a2454c9955f12"; - let raw_tx_rlp_bytes = hex::decode(bytes) - .expect("decode tx's hex shall not fail"); + let raw_tx_rlp_bytes = hex::decode(bytes).expect("decode tx's hex shall not fail"); let eth_tx = EthTransaction::decode(&Rlp::new(&raw_tx_rlp_bytes)) .expect("decode tx's rlp bytes shall not fail"); diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index ed9359a402..b0097666a8 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -728,7 +728,7 @@ pub struct RlpTable { /// The combination (access_list_idx, storage_key_idx) /// uniquely identifies a storage key value /// Corresponding tag is AccessListStorageKey - pub storage_key_idx: u64, + pub storage_key_idx: u64, } /// State Machine @@ -767,9 +767,8 @@ pub struct StateMachine { /// Using simulated stack constraints to make sure all bytes are decoded #[derive(Clone, Debug)] pub struct RlpDecodingTable { - // note: a byte-counting idx such as rw_counter is not necessary + // note: a byte-counting idx such as rw_counter is not necessary // as byte_idx/byte_rev_idx can be used for the purpose - /// Is Write to decoding stack pub is_write: bool, /// Key1 (Id), concat of tx_id, format @@ -834,4 +833,4 @@ pub(crate) struct RlpStackOp { // TX1559_DEBUG pub note: String, -} \ No newline at end of file +} diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 20764c3608..394c6ea238 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -3,7 +3,7 @@ use crate::{ table::TxContextFieldTag, util::{rlc_be_bytes, Challenges}, witness::{ - rlp_fsm::{SmState, RlpStackOp, RlpDecodingTable}, + rlp_fsm::{RlpDecodingTable, RlpStackOp, SmState}, DataTable, Format, Format::{ L1MsgHash, TxHashEip155, TxHashEip1559, TxHashEip2930, TxHashPreEip155, TxSignEip155, @@ -411,17 +411,15 @@ impl Transaction { let mut cur_rom_row = vec![0]; let mut remaining_bytes = vec![rlp_bytes.len()]; // initialize stack - stack_ops.push( - RlpStackOp { - is_write: true, - id, - address: cur.depth, - value: rlp_bytes.len(), - value_prev: 0, - // TX1559_DEBUG - note: String::from("Initialize"), - } - ); + stack_ops.push(RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rlp_bytes.len(), + value_prev: 0, + // TX1559_DEBUG + note: String::from("Initialize"), + }); let mut witness_table_idx = 0; // This map keeps track @@ -458,22 +456,23 @@ impl Transaction { if remaining_bytes.len() > 0 { let prev_depth_bytes = remaining_bytes.last().unwrap().clone(); - stack_acc = stack_acc - - stack_acc_pow_of_rand[cur.depth - 1] + stack_acc = stack_acc + - stack_acc_pow_of_rand[cur.depth - 1] * Value::known(F::from(prev_depth_bytes as u64)); - stack_ops.push( - RlpStackOp { - is_write: true, - id, - address: cur.depth - 1, - value: prev_depth_bytes, - value_prev: last_bytes_on_depth[cur.depth - 1], - // TX1559_DEBUG - note: String::from(format!("Restoring depth level {}", cur.depth - 1)), - } - ) + stack_ops.push(RlpStackOp { + is_write: true, + id, + address: cur.depth - 1, + value: prev_depth_bytes, + value_prev: last_bytes_on_depth[cur.depth - 1], + // TX1559_DEBUG + note: String::from(format!( + "Restoring depth level {}", + cur.depth - 1 + )), + }) } - + if cur.depth == 1 { assert_eq!(remaining_bytes.len(), 1); assert_eq!(remaining_bytes[0], 0); @@ -510,21 +509,22 @@ impl Transaction { // read one more byte assert!(*rem >= 1); - if byte_value <= 0xc0 || byte_value > 0xf7 { + if byte_value < 0xc0 || byte_value > 0xf7 { // add stack op on same depth - stack_ops.push( - RlpStackOp { - is_write: true, - id, - address: cur.depth, - value: rem.clone() - 1, - value_prev: rem.clone(), - // TX1559_DEBUG - note: String::from(format!("Decoding Start byte read, idx: {}, len: {}", cur.tag_idx, cur.tag_length)), - } - ); + stack_ops.push(RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rem.clone() - 1, + value_prev: rem.clone(), + // TX1559_DEBUG + note: String::from(format!( + "Decoding Start byte read, idx: {}, len: {}", + cur.tag_idx, cur.tag_length + )), + }); } - + *rem -= 1; } @@ -598,25 +598,27 @@ impl Transaction { // the number of bytes of the new list. assert!(*rem >= num_bytes_of_new_list); last_bytes_on_depth[cur.depth] = rem.clone() + 1; - stack_acc = stack_acc - + stack_acc_pow_of_rand[cur.depth] - * Value::known(F::from((rem.clone() - num_bytes_of_new_list) as u64)); + stack_acc = stack_acc + + stack_acc_pow_of_rand[cur.depth] + * Value::known(F::from( + (rem.clone() - num_bytes_of_new_list) as u64, + )); *rem -= num_bytes_of_new_list; } remaining_bytes.push(num_bytes_of_new_list); - - stack_ops.push( - RlpStackOp { - is_write: true, - id, - address: cur.depth + 1, - value: num_bytes_of_new_list, - value_prev: 0, - // TX1559_DEBUG - note: String::from("BeginList but byte < 0xf8, next stack state write"), - } - ); + + stack_ops.push(RlpStackOp { + is_write: true, + id, + address: cur.depth + 1, + value: num_bytes_of_new_list, + value_prev: 0, + // TX1559_DEBUG + note: String::from( + "BeginList but byte < 0xf8, next stack state write", + ), + }); next.depth = cur.depth + 1; next.state = DecodeTagStart; } else { @@ -638,17 +640,15 @@ impl Transaction { assert!(*rem >= 1); // add stack op on same depth - stack_ops.push( - RlpStackOp { - is_write: true, - id, - address: cur.depth, - value: rem.clone() - 1, - value_prev: rem.clone(), - // TX1559_DEBUG - note: String::from("Bytes, reading regular byte"), - } - ); + stack_ops.push(RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rem.clone() - 1, + value_prev: rem.clone(), + // TX1559_DEBUG + note: String::from("Bytes, reading regular byte"), + }); *rem -= 1; } @@ -678,17 +678,15 @@ impl Transaction { assert!(*rem >= 1); // add stack op on same depth - stack_ops.push( - RlpStackOp { - is_write: true, - id, - address: cur.depth, - value: rem.clone() - 1, - value_prev: rem.clone(), - // TX1559_DEBUG - note: String::from("Bytes, reading regular long bytes"), - } - ); + stack_ops.push(RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rem.clone() - 1, + value_prev: rem.clone(), + // TX1559_DEBUG + note: String::from("Bytes, reading regular long bytes"), + }); *rem -= 1; } @@ -717,17 +715,15 @@ impl Transaction { // add stack op on same depth if cur.tag_idx < cur.tag_length { - stack_ops.push( - RlpStackOp { - is_write: true, - id, - address: cur.depth, - value: rem.clone() - 1, - value_prev: rem.clone(), - // TX1559_DEBUG - note: String::from("LongList tag_idx < tag_length, read byte"), - } - ); + stack_ops.push(RlpStackOp { + is_write: true, + id, + address: cur.depth, + value: rem.clone() - 1, + value_prev: rem.clone(), + // TX1559_DEBUG + note: String::from("LongList tag_idx < tag_length, read byte"), + }); } *rem -= 1; @@ -746,24 +742,22 @@ impl Transaction { if let Some(rem) = remaining_bytes.last_mut() { assert!(*rem >= lb_len); last_bytes_on_depth[cur.depth] = rem.clone() + 1; - stack_acc = stack_acc - + stack_acc_pow_of_rand[cur.depth] + stack_acc = stack_acc + + stack_acc_pow_of_rand[cur.depth] * Value::known(F::from((rem.clone() - lb_len) as u64)); *rem -= lb_len; } remaining_bytes.push(lb_len); - stack_ops.push( - RlpStackOp { - is_write: true, - id, - address: cur.depth + 1, - value: lb_len, - value_prev: 0, - // TX1559_DEBUG - note: String::from("LongList Last byte, write next stack state"), - } - ); + stack_ops.push(RlpStackOp { + is_write: true, + id, + address: cur.depth + 1, + value: lb_len, + value_prev: 0, + // TX1559_DEBUG + note: String::from("LongList Last byte, write next stack state"), + }); next.depth = cur.depth + 1; next.state = DecodeTagStart; } @@ -833,7 +827,14 @@ impl Transaction { // TX1559_DEBUG if stack_ops.len() < 1 { - stack_ops.push(RlpStackOp { is_write: false, id: Value::known(F::zero()), address: 0, value: 0, value_prev: 0, note: String::from("pad") }); + stack_ops.push(RlpStackOp { + is_write: false, + id: Value::known(F::zero()), + address: 0, + value: 0, + value_prev: 0, + note: String::from("pad"), + }); } let stack_op = stack_ops.remove(0); @@ -873,7 +874,7 @@ impl Transaction { stack_acc: stack_acc.clone(), stack_acc_pow_of_rand: stack_acc_pow_of_rand[stack_op.address], note: stack_op.note, - } + }, }); witness_table_idx += 1; From 4ad0eba5c665f08b01bed34e39c9b8e91b3da23e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 13 Nov 2023 16:01:42 -0800 Subject: [PATCH 016/161] remove debug flag --- zkevm-circuits/src/rlp_circuit_fsm.rs | 20 ++++---- zkevm-circuits/src/witness/rlp_fsm.rs | 5 -- zkevm-circuits/src/witness/tx.rs | 72 +++++++-------------------- 3 files changed, 28 insertions(+), 69 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 9c198b9c01..500ceead77 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1645,13 +1645,13 @@ impl RlpCircuitConfig { || "rlp_table.access_list_idx", self.rlp_table.access_list_idx, row, - || Value::known(F::from(witness.rlp_table.access_list_idx as u64)), + || Value::known(F::from(witness.rlp_table.access_list_idx)), )?; region.assign_advice( || "rlp_table.storage_key_idx", self.rlp_table.storage_key_idx, row, - || Value::known(F::from(witness.rlp_table.storage_key_idx as u64)), + || Value::known(F::from(witness.rlp_table.storage_key_idx)), )?; // assign to sm @@ -1985,14 +1985,14 @@ impl RlpCircuitConfig { last_row ); - log::trace!( - "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", - sm_rows - ); - log::trace!( - "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", - dt_rows - ); + // log::trace!( + // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", + // sm_rows + // ); + // log::trace!( + // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", + // dt_rows + // ); debug_assert!(sm_rows.len() <= last_row); diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index b0097666a8..ade800ddb0 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -784,8 +784,6 @@ pub struct RlpDecodingTable { pub stack_acc: Value, /// Power of rand for stack accumulator on depth level (address) pub stack_acc_pow_of_rand: Value, - // TX1559_DEBUG - pub note: String, } /// Represents the witness in a single row of the RLP circuit. @@ -830,7 +828,4 @@ pub(crate) struct RlpStackOp { pub address: usize, pub value: usize, pub value_prev: usize, - - // TX1559_DEBUG - pub note: String, } diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 394c6ea238..1bdd8c0a54 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -397,10 +397,10 @@ impl Transaction { let mut stack_acc_pow_of_rand: Vec> = vec![]; let mut pow_of_rand = Value::known(F::one()); - stack_acc_pow_of_rand.push(pow_of_rand.clone()); + stack_acc_pow_of_rand.push(pow_of_rand); for _ in 0..4 { pow_of_rand = pow_of_rand * keccak_rand; - stack_acc_pow_of_rand.push(pow_of_rand.clone()); + stack_acc_pow_of_rand.push(pow_of_rand); } // concat tx_id and format as stack identifier let id = keccak_rand * Value::known(F::from(tx_id)) + Value::known(F::from(format as u64)); @@ -417,8 +417,6 @@ impl Transaction { address: cur.depth, value: rlp_bytes.len(), value_prev: 0, - // TX1559_DEBUG - note: String::from("Initialize"), }); let mut witness_table_idx = 0; @@ -454,8 +452,8 @@ impl Transaction { 0 ); - if remaining_bytes.len() > 0 { - let prev_depth_bytes = remaining_bytes.last().unwrap().clone(); + if !remaining_bytes.is_empty() { + let prev_depth_bytes = *remaining_bytes.last().unwrap(); stack_acc = stack_acc - stack_acc_pow_of_rand[cur.depth - 1] * Value::known(F::from(prev_depth_bytes as u64)); @@ -465,11 +463,6 @@ impl Transaction { address: cur.depth - 1, value: prev_depth_bytes, value_prev: last_bytes_on_depth[cur.depth - 1], - // TX1559_DEBUG - note: String::from(format!( - "Restoring depth level {}", - cur.depth - 1 - )), }) } @@ -509,19 +502,14 @@ impl Transaction { // read one more byte assert!(*rem >= 1); - if byte_value < 0xc0 || byte_value > 0xf7 { + if !(0xc0..=0xf7).contains(&byte_value) { // add stack op on same depth stack_ops.push(RlpStackOp { is_write: true, id, address: cur.depth, - value: rem.clone() - 1, - value_prev: rem.clone(), - // TX1559_DEBUG - note: String::from(format!( - "Decoding Start byte read, idx: {}, len: {}", - cur.tag_idx, cur.tag_length - )), + value: *rem - 1, + value_prev: *rem, }); } @@ -597,11 +585,11 @@ impl Transaction { // current list should be subtracted by // the number of bytes of the new list. assert!(*rem >= num_bytes_of_new_list); - last_bytes_on_depth[cur.depth] = rem.clone() + 1; + last_bytes_on_depth[cur.depth] = *rem + 1; stack_acc = stack_acc + stack_acc_pow_of_rand[cur.depth] * Value::known(F::from( - (rem.clone() - num_bytes_of_new_list) as u64, + (*rem - num_bytes_of_new_list) as u64, )); *rem -= num_bytes_of_new_list; @@ -614,10 +602,6 @@ impl Transaction { address: cur.depth + 1, value: num_bytes_of_new_list, value_prev: 0, - // TX1559_DEBUG - note: String::from( - "BeginList but byte < 0xf8, next stack state write", - ), }); next.depth = cur.depth + 1; next.state = DecodeTagStart; @@ -644,10 +628,8 @@ impl Transaction { is_write: true, id, address: cur.depth, - value: rem.clone() - 1, - value_prev: rem.clone(), - // TX1559_DEBUG - note: String::from("Bytes, reading regular byte"), + value: *rem - 1, + value_prev: *rem, }); *rem -= 1; @@ -682,10 +664,8 @@ impl Transaction { is_write: true, id, address: cur.depth, - value: rem.clone() - 1, - value_prev: rem.clone(), - // TX1559_DEBUG - note: String::from("Bytes, reading regular long bytes"), + value: *rem - 1, + value_prev: *rem, }); *rem -= 1; @@ -719,10 +699,8 @@ impl Transaction { is_write: true, id, address: cur.depth, - value: rem.clone() - 1, - value_prev: rem.clone(), - // TX1559_DEBUG - note: String::from("LongList tag_idx < tag_length, read byte"), + value: *rem - 1, + value_prev: *rem, }); } @@ -741,10 +719,10 @@ impl Transaction { } if let Some(rem) = remaining_bytes.last_mut() { assert!(*rem >= lb_len); - last_bytes_on_depth[cur.depth] = rem.clone() + 1; + last_bytes_on_depth[cur.depth] = *rem + 1; stack_acc = stack_acc + stack_acc_pow_of_rand[cur.depth] - * Value::known(F::from((rem.clone() - lb_len) as u64)); + * Value::known(F::from((*rem - lb_len) as u64)); *rem -= lb_len; } @@ -755,8 +733,6 @@ impl Transaction { address: cur.depth + 1, value: lb_len, value_prev: 0, - // TX1559_DEBUG - note: String::from("LongList Last byte, write next stack state"), }); next.depth = cur.depth + 1; next.state = DecodeTagStart; @@ -825,17 +801,6 @@ impl Transaction { RlpTag::Null => unreachable!("Null is not used"), }; - // TX1559_DEBUG - if stack_ops.len() < 1 { - stack_ops.push(RlpStackOp { - is_write: false, - id: Value::known(F::zero()), - address: 0, - value: 0, - value_prev: 0, - note: String::from("pad"), - }); - } let stack_op = stack_ops.remove(0); witness.push(RlpFsmWitnessRow { @@ -871,9 +836,8 @@ impl Transaction { address: stack_op.address, value: stack_op.value, value_prev: stack_op.value_prev, - stack_acc: stack_acc.clone(), + stack_acc, stack_acc_pow_of_rand: stack_acc_pow_of_rand[stack_op.address], - note: stack_op.note, }, }); witness_table_idx += 1; From 3f8c63e7744ba3f95e99ffd92e72e61059e64b6e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 13 Nov 2023 16:33:27 -0800 Subject: [PATCH 017/161] correct tx circuit lookup : --- zkevm-circuits/src/tx_circuit.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index a9fa3414ca..9072195dc3 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -1535,6 +1535,8 @@ impl TxCircuitConfig { tag_length, 1.expr(), // is_output = true 0.expr(), // is_none = false + 0.expr(), // access_list_idx + 0.expr(), // storage_key_idx ]; assert_eq!(input_exprs.len(), rlp_table.table_exprs(meta).len()); From 93c0e88d339ab2c404e4d434a0b21729be10342a Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 13 Nov 2023 18:01:32 -0800 Subject: [PATCH 018/161] decoding table --- zkevm-circuits/src/rlp_circuit_fsm.rs | 35 +++++++++++++++++++++++++++ zkevm-circuits/src/tx_circuit.rs | 4 +++ zkevm-circuits/src/witness/rlp_fsm.rs | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 500ceead77..f8d2736b13 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -178,6 +178,41 @@ impl RlpFsmRomTable { } } +/// Data decoding table simulates a stack-like structure for constraining remaining_bytes +#[derive(Clone, Copy, Debug)] +pub struct RlpDecodingTable { + /// Is Write to decoding stack + pub is_write: Column, + /// Key1 (Id), concat of tx_id, format + pub id: Column, + /// Key2 (Address), in this case depth + pub address: Column, + /// Value + pub value: Column, + /// Value Previous + pub value_prev: Column, + /// Stack Accumulator + /// accumulates remaining bytes on each depth level (excluding top of stack) + pub stack_acc: Column, + /// Power of rand for stack accumulator on depth level (address) + pub stack_acc_pow_of_rand: Column, +} + +impl RlpDecodingTable { + /// Construct the decoding table. + pub fn construct(meta: &mut ConstraintSystem) -> Self { + Self { + is_write: meta.advice_column(), + id: meta.advice_column(), + address: meta.advice_column(), + value: meta.advice_column(), + value_prev: meta.advice_column(), + stack_acc: meta.advice_column_in(SecondPhase), + stack_acc_pow_of_rand: meta.advice_column_in(SecondPhase), + } + } +} + /// The RLP Circuit is implemented as a finite state machine. Refer the /// [design doc][doclink] for design decisions and specification details. /// diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 9072195dc3..05f648f6ea 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -1572,6 +1572,8 @@ impl TxCircuitConfig { meta.query_advice(tx_value_length, Rotation::cur()), 1.expr(), // is_output = true is_none, + 0.expr(), // access_list_idx + 0.expr(), // storage_key_idx ] .into_iter() .zip_eq(rlp_table.table_exprs(meta).into_iter()) @@ -1610,6 +1612,8 @@ impl TxCircuitConfig { meta.query_advice(tx_value_length, Rotation::cur()), 1.expr(), // is_output = true is_none, + 0.expr(), // access_list_idx + 0.expr(), // storage_key_idx ] .into_iter() .zip_eq(rlp_table.table_exprs(meta).into_iter()) diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index ade800ddb0..609f76e28d 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -764,7 +764,7 @@ pub struct StateMachine { } /// Rlp Decoding Table -/// Using simulated stack constraints to make sure all bytes are decoded +/// Using simulated stack constraints to make sure all bytes are correctly decoded #[derive(Clone, Debug)] pub struct RlpDecodingTable { // note: a byte-counting idx such as rw_counter is not necessary From 919687c4765450a6e38b17fa49cd1e8856d278ee Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 15 Nov 2023 13:54:59 -0800 Subject: [PATCH 019/161] correct degree --- zkevm-circuits/src/rlp_circuit_fsm.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index f8d2736b13..43a11ff5ce 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1453,7 +1453,7 @@ impl RlpCircuitConfig { // Access List Increments meta.create_gate( "access list: access_list_idx and storage_key_idx increments", - |meta| { + |meta: &mut VirtualCells<'_, F>| { let mut cb = BaseConstraintBuilder::default(); cb.condition(is_access_list_address(meta), |cb| { @@ -1477,10 +1477,7 @@ impl RlpCircuitConfig { ); }); - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - is_decode_tag_start(meta), - ])) + cb.gate(is_decode_tag_start(meta)) }, ); @@ -1510,10 +1507,7 @@ impl RlpCircuitConfig { ); }); - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - is_tag_end_vector(meta), - ])) + cb.gate(is_tag_end_vector(meta)) }, ); @@ -1535,7 +1529,6 @@ impl RlpCircuitConfig { ); cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), not::expr(is_tag_end_vector(meta)), not::expr(is_decode_tag_start(meta)), ])) From ba90c5ef43afc1bc9c3dd5bbd0f967055e7b2b57 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 15 Nov 2023 17:56:02 -0800 Subject: [PATCH 020/161] add decoding table --- zkevm-circuits/src/rlp_circuit_fsm.rs | 18 ++++++++++++++++-- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 4 ++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 43a11ff5ce..c64f777dc4 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -229,6 +229,9 @@ pub struct RlpCircuitConfig { state_bits: BinaryNumberConfig, /// The Rlp table which can be accessed by other circuits. rlp_table: RlpFsmRlpTable, + /// The Rlp decoding table ensuring correct transition of + /// stack constraints on remaining_bytes + rlp_decoding_table: RlpDecodingTable, /// The tag, i.e. what field is being decoded at the current row. tag: Column, /// A utility gadget to compare/query what tag we are at. @@ -334,6 +337,7 @@ impl RlpCircuitConfig { data_table: RlpFsmDataTable, u8_table: U8Table, rlp_table: RlpFsmRlpTable, + rlp_decoding_table: RlpDecodingTable, challenges: &Challenges>, ) -> Self { let (tx_id, format) = (rlp_table.tx_id, rlp_table.format); @@ -1477,7 +1481,10 @@ impl RlpCircuitConfig { ); }); - cb.gate(is_decode_tag_start(meta)) + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + is_decode_tag_start(meta) + ])) }, ); @@ -1507,7 +1514,10 @@ impl RlpCircuitConfig { ); }); - cb.gate(is_tag_end_vector(meta)) + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + is_tag_end_vector(meta) + ])) }, ); @@ -1529,6 +1539,7 @@ impl RlpCircuitConfig { ); cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), not::expr(is_tag_end_vector(meta)), not::expr(is_decode_tag_start(meta)), ])) @@ -1549,6 +1560,7 @@ impl RlpCircuitConfig { state, state_bits, rlp_table, + rlp_decoding_table, tag, tag_bits, tag_next, @@ -2090,6 +2102,7 @@ impl SubCircuitConfig for RlpCircuitConfig { fn new(meta: &mut ConstraintSystem, args: Self::ConfigArgs) -> Self { let data_table = RlpFsmDataTable::construct(meta); let rom_table = RlpFsmRomTable::construct(meta); + let decoding_table = RlpDecodingTable::construct(meta); Self::configure( meta, @@ -2097,6 +2110,7 @@ impl SubCircuitConfig for RlpCircuitConfig { data_table, args.u8_table, args.rlp_table, + decoding_table, &args.challenges, ) } diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index 49812eb789..665e280a28 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,9 +110,9 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ - "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", + // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", // "02f901e901833c3139842b27f14d86012309ce540083055ca8945f65f7b609678448494de4c87521cdf6cef1e93280b8e4fa558b7100000000000000000000000095ad61b0a150d79219dcf64e1e6cc01f0b64c4ce000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000016a217dedfacdf9c23edb84b57154f26a15848e60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000028cad80bb7cf17e27c4c8f893f7945f65f7b609678448494de4c87521cdf6cef1e932e1a0d2dc2a0881b05440a4908cf506b4871b1f7eaa46ea0c5dfdcda5f52bc17164a4f8599495ad61b0a150d79219dcf64e1e6cc01f0b64c4cef842a0ba03decd934aae936605e9d437c401439ec4cefbad5795e0965100f929fe339ca0b36e2afa1a25492257090107ad99d079032e543c8dd1ffcd44cf14a96d3015ac80a0821193127789b107351f670025dd3b862f5836e5155f627a29741a251e8d28e8a07ea1e82b1bf6f29c5d0f1e4024acdb698086ac40c353704d7d5e301fb916f2e3", - // "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", // "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; From 6790cff2922f5d8503288b0ad1bca2f2d28e3a27 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 15 Nov 2023 18:19:04 -0800 Subject: [PATCH 021/161] add decoding table assignment --- zkevm-circuits/src/rlp_circuit_fsm.rs | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index c64f777dc4..d64fcc8463 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1694,6 +1694,50 @@ impl RlpCircuitConfig { || Value::known(F::from(witness.rlp_table.storage_key_idx)), )?; + // assign to rlp decoding table + region.assign_advice( + || "rlp_decoding_table.is_write", + self.rlp_decoding_table.is_write, + row, + || Value::known(F::from(witness.rlp_decoding_table.is_write)), + )?; + region.assign_advice( + || "rlp_decoding_table.id", + self.rlp_decoding_table.id, + row, + || witness.rlp_decoding_table.id, + )?; + region.assign_advice( + || "rlp_decoding_table.address", + self.rlp_decoding_table.address, + row, + || Value::known(F::from(witness.rlp_decoding_table.address as u64)), + )?; + region.assign_advice( + || "rlp_decoding_table.value", + self.rlp_decoding_table.value, + row, + || Value::known(F::from(witness.rlp_decoding_table.value as u64)), + )?; + region.assign_advice( + || "rlp_decoding_table.value_prev", + self.rlp_decoding_table.value_prev, + row, + || Value::known(F::from(witness.rlp_decoding_table.value_prev as u64)), + )?; + region.assign_advice( + || "rlp_decoding_table.stack_acc", + self.rlp_decoding_table.stack_acc, + row, + || witness.rlp_decoding_table.stack_acc, + )?; + region.assign_advice( + || "rlp_decoding_table.stack_acc_pow_of_rand", + self.rlp_decoding_table.stack_acc_pow_of_rand, + row, + || witness.rlp_decoding_table.stack_acc_pow_of_rand, + )?; + // assign to sm region.assign_advice( || "sm.state", From b11496afcf01b8a3aac138d8f49687a0af98aedd Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 15 Nov 2023 20:17:42 -0800 Subject: [PATCH 022/161] reduce degree --- zkevm-circuits/src/rlp_circuit_fsm.rs | 116 +++++++++++++++++++++----- 1 file changed, 95 insertions(+), 21 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index d64fcc8463..1decea6156 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -16,7 +16,7 @@ use crate::{ Block, DataTable, Format, RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTag, RomTableRow, State, State::{DecodeTagStart, End}, Tag, - Tag::{BeginList, EndList, TxType}, + Tag::{BeginList, EndList, TxType, AccessListAddress, AccessListStorageKey, EndVector}, Transaction, }, }; @@ -287,6 +287,11 @@ pub struct RlpCircuitConfig { /// Boolean to reduce the circuit's degree is_same_rlp_instance: Column, + /// Boolean to reduce the circuit's degree + is_new_access_list_address: Column, + /// Boolean to reduce the circuit's degree + is_new_access_list_storage_key: Column, + /// Check for byte_value <= 0x80 byte_value_lte_0x80: ComparatorConfig, /// Check for byte_value >= 0x80 @@ -362,6 +367,8 @@ impl RlpCircuitConfig { is_case3, transit_to_new_rlp_instance, is_same_rlp_instance, + is_new_access_list_address, + is_new_access_list_storage_key, ) = ( meta.fixed_column(), meta.fixed_column(), @@ -381,6 +388,8 @@ impl RlpCircuitConfig { meta.advice_column(), meta.advice_column(), meta.advice_column(), + meta.advice_column(), + meta.advice_column(), ); let tag_value_acc = meta.advice_column_in(SecondPhase); @@ -907,6 +916,27 @@ impl RlpCircuitConfig { ])) }); + + meta.create_gate("booleans for reducing degree (part four)", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "is_new_access_list_address", + meta.query_advice(is_new_access_list_address, Rotation::cur()), + is_access_list_address(meta), + ); + cb.require_equal( + "is_new_access_list_storage_key", + meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), + is_access_list_storage_key(meta), + ); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + is_decode_tag_start(meta), + ])) + }); + debug_assert!(meta.degree() <= 9); let tag_expr = |meta: &mut VirtualCells| meta.query_advice(tag, Rotation::cur()); @@ -1456,11 +1486,13 @@ impl RlpCircuitConfig { // Access List Increments meta.create_gate( - "access list: access_list_idx and storage_key_idx increments", + "access list: access_list_idx increments", |meta: &mut VirtualCells<'_, F>| { let mut cb = BaseConstraintBuilder::default(); - cb.condition(is_access_list_address(meta), |cb| { + cb.condition( + meta.query_advice(is_new_access_list_address, Rotation::cur()), + |cb| { cb.require_equal( "al_idx - al_idx::prev = 1", meta.query_advice(rlp_table.access_list_idx, Rotation::prev()) + 1.expr(), @@ -1468,23 +1500,23 @@ impl RlpCircuitConfig { ); }); - cb.condition(is_access_list_storage_key(meta), |cb| { - cb.require_equal( - "for same storage key list, al_idx stays the same", - meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - ); + cb.condition( + meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), + |cb| { cb.require_equal( - "sk_idx - sk_idx::prev = 1", - meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) + 1.expr(), - meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - ); - }); - - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - is_decode_tag_start(meta) - ])) + "for same storage key list, al_idx stays the same", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); + cb.require_equal( + "sk_idx - sk_idx::prev = 1", + meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + ); + } + ); + + cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }, ); @@ -1540,8 +1572,29 @@ impl RlpCircuitConfig { cb.gate(and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), - not::expr(is_tag_end_vector(meta)), - not::expr(is_decode_tag_start(meta)), + not::expr(is_decode_tag_start(meta)) + ])) + }, + ); + meta.create_gate( + "access list: no access_list_idx and storage_key_idx change", + |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "al_idx stays the same when no starting or ending conditions present", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); + cb.require_equal( + "sk_idx stays the same when no starting or ending conditions present", + meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()), + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + ); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + not::expr(is_tag_end_vector(meta)) ])) }, ); @@ -1589,6 +1642,10 @@ impl RlpCircuitConfig { transit_to_new_rlp_instance, is_same_rlp_instance, + // decoding table checks + is_new_access_list_address, + is_new_access_list_storage_key, + // comparators byte_value_lte_0x80, byte_value_gte_0x80, @@ -1738,6 +1795,23 @@ impl RlpCircuitConfig { || witness.rlp_decoding_table.stack_acc_pow_of_rand, )?; + let is_new_access_list_address = + witness.state_machine.state == DecodeTagStart && witness.state_machine.tag == AccessListAddress; + region.assign_advice( + || "is_new_access_list_address", + self.is_new_access_list_address, + row, + || Value::known(F::from(is_new_access_list_address as u64)), + )?; + let is_new_access_list_storage_key = + witness.state_machine.state == DecodeTagStart && witness.state_machine.tag == AccessListStorageKey; + region.assign_advice( + || "is_new_access_list_storage_key", + self.is_new_access_list_storage_key, + row, + || Value::known(F::from(is_new_access_list_storage_key as u64)), + )?; + // assign to sm region.assign_advice( || "sm.state", From b12e18f783407f2d9876ff0798c700da5c8749d5 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 15 Nov 2023 20:18:03 -0800 Subject: [PATCH 023/161] unnecessary import --- zkevm-circuits/src/rlp_circuit_fsm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 1decea6156..c1b388894f 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -16,7 +16,7 @@ use crate::{ Block, DataTable, Format, RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTag, RomTableRow, State, State::{DecodeTagStart, End}, Tag, - Tag::{BeginList, EndList, TxType, AccessListAddress, AccessListStorageKey, EndVector}, + Tag::{BeginList, EndList, TxType, AccessListAddress, AccessListStorageKey}, Transaction, }, }; From 2b8147cb4090717c9f2667dedae00211608dd412 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 15 Nov 2023 21:17:44 -0800 Subject: [PATCH 024/161] fmt --- zkevm-circuits/src/rlp_circuit_fsm.rs | 42 ++++++++++++++------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index c1b388894f..3e957a8faa 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -16,7 +16,7 @@ use crate::{ Block, DataTable, Format, RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTag, RomTableRow, State, State::{DecodeTagStart, End}, Tag, - Tag::{BeginList, EndList, TxType, AccessListAddress, AccessListStorageKey}, + Tag::{AccessListAddress, AccessListStorageKey, BeginList, EndList, TxType}, Transaction, }, }; @@ -916,7 +916,6 @@ impl RlpCircuitConfig { ])) }); - meta.create_gate("booleans for reducing degree (part four)", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1491,31 +1490,34 @@ impl RlpCircuitConfig { let mut cb = BaseConstraintBuilder::default(); cb.condition( - meta.query_advice(is_new_access_list_address, Rotation::cur()), + meta.query_advice(is_new_access_list_address, Rotation::cur()), |cb| { - cb.require_equal( - "al_idx - al_idx::prev = 1", - meta.query_advice(rlp_table.access_list_idx, Rotation::prev()) + 1.expr(), - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - ); - }); + cb.require_equal( + "al_idx - al_idx::prev = 1", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()) + + 1.expr(), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); + }, + ); cb.condition( meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), |cb| { - cb.require_equal( + cb.require_equal( "for same storage key list, al_idx stays the same", meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), ); cb.require_equal( "sk_idx - sk_idx::prev = 1", - meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) + + 1.expr(), meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), ); - } + }, ); - + cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }, ); @@ -1548,7 +1550,7 @@ impl RlpCircuitConfig { cb.gate(and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), - is_tag_end_vector(meta) + is_tag_end_vector(meta), ])) }, ); @@ -1572,7 +1574,7 @@ impl RlpCircuitConfig { cb.gate(and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), - not::expr(is_decode_tag_start(meta)) + not::expr(is_decode_tag_start(meta)), ])) }, ); @@ -1594,7 +1596,7 @@ impl RlpCircuitConfig { cb.gate(and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), - not::expr(is_tag_end_vector(meta)) + not::expr(is_tag_end_vector(meta)), ])) }, ); @@ -1795,16 +1797,16 @@ impl RlpCircuitConfig { || witness.rlp_decoding_table.stack_acc_pow_of_rand, )?; - let is_new_access_list_address = - witness.state_machine.state == DecodeTagStart && witness.state_machine.tag == AccessListAddress; + let is_new_access_list_address = witness.state_machine.state == DecodeTagStart + && witness.state_machine.tag == AccessListAddress; region.assign_advice( || "is_new_access_list_address", self.is_new_access_list_address, row, || Value::known(F::from(is_new_access_list_address as u64)), )?; - let is_new_access_list_storage_key = - witness.state_machine.state == DecodeTagStart && witness.state_machine.tag == AccessListStorageKey; + let is_new_access_list_storage_key = witness.state_machine.state == DecodeTagStart + && witness.state_machine.tag == AccessListStorageKey; region.assign_advice( || "is_new_access_list_storage_key", self.is_new_access_list_storage_key, From 617bfcc721040c523739aba82ac2ba16d9edac1f Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 15 Nov 2023 22:23:41 -0800 Subject: [PATCH 025/161] fix constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 115 +++++++++++--------------- 1 file changed, 48 insertions(+), 67 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 3e957a8faa..c8b3029ee7 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -16,7 +16,7 @@ use crate::{ Block, DataTable, Format, RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTag, RomTableRow, State, State::{DecodeTagStart, End}, Tag, - Tag::{AccessListAddress, AccessListStorageKey, BeginList, EndList, TxType}, + Tag::{AccessListAddress, AccessListStorageKey, BeginList, EndList, TxType, EndVector}, Transaction, }, }; @@ -25,7 +25,7 @@ use gadgets::{ binary_number::{BinaryNumberChip, BinaryNumberConfig}, comparator::{ComparatorChip, ComparatorConfig, ComparatorInstruction}, is_equal::{IsEqualChip, IsEqualConfig, IsEqualInstruction}, - util::{and, not, select, sum, Expr}, + util::{and, or, not, select, sum, Expr}, }; use halo2_proofs::{ circuit::{Layouter, Region, Value}, @@ -916,26 +916,6 @@ impl RlpCircuitConfig { ])) }); - meta.create_gate("booleans for reducing degree (part four)", |meta| { - let mut cb = BaseConstraintBuilder::default(); - - cb.require_equal( - "is_new_access_list_address", - meta.query_advice(is_new_access_list_address, Rotation::cur()), - is_access_list_address(meta), - ); - cb.require_equal( - "is_new_access_list_storage_key", - meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), - is_access_list_storage_key(meta), - ); - - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - is_decode_tag_start(meta), - ])) - }); - debug_assert!(meta.degree() <= 9); let tag_expr = |meta: &mut VirtualCells| meta.query_advice(tag, Rotation::cur()); @@ -1170,7 +1150,6 @@ impl RlpCircuitConfig { }, ); - // debug_assert!(meta.degree() <= 9); // DecodeTagStart => Bytes meta.create_gate("state transition: DecodeTagStart => Bytes", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1483,6 +1462,37 @@ impl RlpCircuitConfig { ])) }); + meta.create_gate("sm ends in End state", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + constrain_eq!(meta, cb, state, State::End); + + cb.gate(meta.query_fixed(q_last, Rotation::cur())) + }); + + /////////////////////////////////////////////////////////////////// + /////////////////// Rlp Decoding Table Transitions //////////////// + /////////////////////////////////////////////////////////////////// + meta.create_gate("booleans for reducing degree (part four)", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "is_new_access_list_address", + meta.query_advice(is_new_access_list_address, Rotation::cur()), + is_access_list_address(meta), + ); + cb.require_equal( + "is_new_access_list_storage_key", + meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), + is_access_list_storage_key(meta), + ); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + is_decode_tag_start(meta), + ])) + }); + // Access List Increments meta.create_gate( "access list: access_list_idx increments", @@ -1555,59 +1565,28 @@ impl RlpCircuitConfig { }, ); - // Access List Consistency - meta.create_gate( - "access list: no access_list_idx and storage_key_idx change", - |meta| { - let mut cb = BaseConstraintBuilder::default(); - - cb.require_equal( - "al_idx stays the same when no starting or ending conditions present", - meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - ); - cb.require_equal( - "sk_idx stays the same when no starting or ending conditions present", - meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()), - meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - ); + debug_assert!(meta.degree() <= 9); - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - not::expr(is_decode_tag_start(meta)), - ])) - }, - ); + /////////////////////////////////////////////////////////////////// + /////////////////// Rlp Decoding Table Transitions //////////////// + ///////////////////////// (Stack Constraints) ///////////////////// + /////////////////////////////////////////////////////////////////// meta.create_gate( - "access list: no access_list_idx and storage_key_idx change", + "stack constraints", |meta| { let mut cb = BaseConstraintBuilder::default(); cb.require_equal( - "al_idx stays the same when no starting or ending conditions present", - meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + "stack ptr (address) must correspond exactly to depth", + meta.query_advice(depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.address, Rotation::cur()), ); - cb.require_equal( - "sk_idx stays the same when no starting or ending conditions present", - meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()), - meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - ); - - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - not::expr(is_tag_end_vector(meta)), - ])) + + cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }, ); - meta.create_gate("sm ends in End state", |meta| { - let mut cb = BaseConstraintBuilder::default(); - - constrain_eq!(meta, cb, state, State::End); - - cb.gate(meta.query_fixed(q_last, Rotation::cur())) - }); + debug_assert!(meta.degree() <= 9); Self { q_first, @@ -1644,10 +1623,12 @@ impl RlpCircuitConfig { transit_to_new_rlp_instance, is_same_rlp_instance, - // decoding table checks + // access list checks is_new_access_list_address, is_new_access_list_storage_key, + // decoding table checks + // comparators byte_value_lte_0x80, byte_value_gte_0x80, From 51a69ec82304afb5d7c3e22d83741b7dbabd6c00 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 15 Nov 2023 22:44:43 -0800 Subject: [PATCH 026/161] fix constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index c8b3029ee7..cd410d4d86 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1571,11 +1571,32 @@ impl RlpCircuitConfig { /////////////////// Rlp Decoding Table Transitions //////////////// ///////////////////////// (Stack Constraints) ///////////////////// /////////////////////////////////////////////////////////////////// + + // Booleans for comparing stack ptr (address) in decoding table + let stack_ptr_comp: ComparatorConfig = ComparatorChip::configure( + meta, + cmp_enabled, + |meta| meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + |meta| meta.query_advice(rlp_decoding_table.address, Rotation::next()), + u8_table.into(), + ); + + meta.create_gate( "stack constraints", |meta| { let mut cb = BaseConstraintBuilder::default(); + let (ptr_lt, ptr_eq) = stack_ptr_comp.expr(meta, Some(Rotation::cur())); + + cb.condition(ptr_lt, |cb| { + cb.require_equal( + "stack ptr increase", + meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr(), + meta.query_advice(rlp_decoding_table.address, Rotation::next()), + ) + }); + cb.require_equal( "stack ptr (address) must correspond exactly to depth", meta.query_advice(depth, Rotation::cur()), From ab90974e8148d7a82bd517b478cb02238516e65c Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 15 Nov 2023 22:54:26 -0800 Subject: [PATCH 027/161] add stack ptr increase --- zkevm-circuits/src/rlp_circuit_fsm.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index cd410d4d86..966ba0a263 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -324,6 +324,8 @@ pub struct RlpCircuitConfig { depth_eq_four: IsEqualConfig, /// Check for byte_value == 0 byte_value_is_zero: IsZeroConfig, + /// Check for stack ptr change + stack_ptr_comp: ComparatorConfig, /// Internal tables /// Data table @@ -1581,7 +1583,6 @@ impl RlpCircuitConfig { u8_table.into(), ); - meta.create_gate( "stack constraints", |meta| { @@ -1667,6 +1668,7 @@ impl RlpCircuitConfig { depth_eq_two, depth_eq_four, byte_value_is_zero, + stack_ptr_comp, // internal tables data_table, @@ -1816,6 +1818,16 @@ impl RlpCircuitConfig { || Value::known(F::from(is_new_access_list_storage_key as u64)), )?; + if let Some(witness_nxt) = witness_next { + let stack_ptr_comp_chip = ComparatorChip::construct(self.stack_ptr_comp.clone()); + stack_ptr_comp_chip.assign( + region, + row, + F::from(witness.rlp_decoding_table.address as u64), + F::from(witness_nxt.rlp_decoding_table.address as u64), + )?; + } + // assign to sm region.assign_advice( || "sm.state", @@ -1972,7 +1984,6 @@ impl RlpCircuitConfig { F::from(witness.rlp_table.tag_length as u64), F::from(witness.state_machine.max_length as u64), )?; - let depth_check_chip = IsEqualChip::construct(self.depth_check.clone()); depth_check_chip.assign( region, From bc4c07787e93c80a53e7ab8e56a55cf38c037ef2 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 16 Nov 2023 00:19:21 -0800 Subject: [PATCH 028/161] fix constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 39 +++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 966ba0a263..04f07b064c 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1588,23 +1588,51 @@ impl RlpCircuitConfig { |meta| { let mut cb = BaseConstraintBuilder::default(); - let (ptr_lt, ptr_eq) = stack_ptr_comp.expr(meta, Some(Rotation::cur())); + let (ptr_lt, ptr_eq) = stack_ptr_comp.expr(meta, None); - cb.condition(ptr_lt, |cb| { + // Stack PUSH + cb.condition(ptr_lt.clone(), |cb| { cb.require_equal( - "stack ptr increase", + "PUSH: stack ptr increase can only be 1", meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr(), meta.query_advice(rlp_decoding_table.address, Rotation::next()), ) }); + // Stack POP + cb.condition( + and::expr([ + not::expr(ptr_lt), + not::expr(ptr_eq.clone()), + ]), |cb| { + cb.require_equal( + "POP: stack ptr decrease can only be 1", + meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + meta.query_advice(rlp_decoding_table.address, Rotation::next()) + 1.expr(), + ) + }); + + // Stack Update Top + // cb.condition(ptr_eq, |cb| { + // cb.require_equal( + // "At the same depth level, must read 1 byte", + // meta.query_advice(rlp_decoding_table.value, Rotation::next()) + 1.expr(), + // meta.query_advice(rlp_decoding_table.value_prev, Rotation::next()), + // ); + // }); + cb.require_equal( "stack ptr (address) must correspond exactly to depth", meta.query_advice(depth, Rotation::cur()), meta.query_advice(rlp_decoding_table.address, Rotation::cur()), ); - cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) + cb.gate( + and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + not::expr(is_end(meta)), + ]) + ) }, ); @@ -2065,7 +2093,7 @@ impl RlpCircuitConfig { || "q_enable", self.rlp_table.q_enable, row, - || Value::known(F::one()), + || Value::known(F::zero()), )?; region.assign_advice( || "sm.state", @@ -2158,6 +2186,7 @@ impl RlpCircuitConfig { last_row ); + // TX1559_DEBUG // log::trace!( // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", // sm_rows From 2f12efb95a9710c019fb632594a6804bb4aa11fa Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 16 Nov 2023 00:20:42 -0800 Subject: [PATCH 029/161] fmt --- zkevm-circuits/src/rlp_circuit_fsm.rs | 88 +++++++++++++-------------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 04f07b064c..89a528fcf9 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -16,7 +16,7 @@ use crate::{ Block, DataTable, Format, RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTag, RomTableRow, State, State::{DecodeTagStart, End}, Tag, - Tag::{AccessListAddress, AccessListStorageKey, BeginList, EndList, TxType, EndVector}, + Tag::{AccessListAddress, AccessListStorageKey, BeginList, EndList, TxType}, Transaction, }, }; @@ -25,7 +25,7 @@ use gadgets::{ binary_number::{BinaryNumberChip, BinaryNumberConfig}, comparator::{ComparatorChip, ComparatorConfig, ComparatorInstruction}, is_equal::{IsEqualChip, IsEqualConfig, IsEqualInstruction}, - util::{and, or, not, select, sum, Expr}, + util::{and, not, select, sum, Expr}, }; use halo2_proofs::{ circuit::{Layouter, Region, Value}, @@ -1573,7 +1573,7 @@ impl RlpCircuitConfig { /////////////////// Rlp Decoding Table Transitions //////////////// ///////////////////////// (Stack Constraints) ///////////////////// /////////////////////////////////////////////////////////////////// - + // Booleans for comparing stack ptr (address) in decoding table let stack_ptr_comp: ComparatorConfig = ComparatorChip::configure( meta, @@ -1583,58 +1583,52 @@ impl RlpCircuitConfig { u8_table.into(), ); - meta.create_gate( - "stack constraints", - |meta| { - let mut cb = BaseConstraintBuilder::default(); + meta.create_gate("stack constraints", |meta| { + let mut cb = BaseConstraintBuilder::default(); - let (ptr_lt, ptr_eq) = stack_ptr_comp.expr(meta, None); + let (ptr_lt, ptr_eq) = stack_ptr_comp.expr(meta, None); - // Stack PUSH - cb.condition(ptr_lt.clone(), |cb| { - cb.require_equal( - "PUSH: stack ptr increase can only be 1", - meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr(), - meta.query_advice(rlp_decoding_table.address, Rotation::next()), - ) - }); + // Stack PUSH + cb.condition(ptr_lt.clone(), |cb| { + cb.require_equal( + "PUSH: stack ptr increase can only be 1", + meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr(), + meta.query_advice(rlp_decoding_table.address, Rotation::next()), + ) + }); - // Stack POP - cb.condition( - and::expr([ - not::expr(ptr_lt), - not::expr(ptr_eq.clone()), - ]), |cb| { + // Stack POP + cb.condition( + and::expr([not::expr(ptr_lt), not::expr(ptr_eq)]), + |cb| { cb.require_equal( - "POP: stack ptr decrease can only be 1", + "POP: stack ptr decrease can only be 1", meta.query_advice(rlp_decoding_table.address, Rotation::cur()), meta.query_advice(rlp_decoding_table.address, Rotation::next()) + 1.expr(), ) - }); + }, + ); - // Stack Update Top - // cb.condition(ptr_eq, |cb| { - // cb.require_equal( - // "At the same depth level, must read 1 byte", - // meta.query_advice(rlp_decoding_table.value, Rotation::next()) + 1.expr(), - // meta.query_advice(rlp_decoding_table.value_prev, Rotation::next()), - // ); - // }); + // Stack Update Top + // cb.condition(ptr_eq, |cb| { + // cb.require_equal( + // "At the same depth level, must read 1 byte", + // meta.query_advice(rlp_decoding_table.value, Rotation::next()) + 1.expr(), + // meta.query_advice(rlp_decoding_table.value_prev, Rotation::next()), + // ); + // }); - cb.require_equal( - "stack ptr (address) must correspond exactly to depth", - meta.query_advice(depth, Rotation::cur()), - meta.query_advice(rlp_decoding_table.address, Rotation::cur()), - ); - - cb.gate( - and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - not::expr(is_end(meta)), - ]) - ) - }, - ); + cb.require_equal( + "stack ptr (address) must correspond exactly to depth", + meta.query_advice(depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + ); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + not::expr(is_end(meta)), + ])) + }); debug_assert!(meta.degree() <= 9); @@ -1855,7 +1849,7 @@ impl RlpCircuitConfig { F::from(witness_nxt.rlp_decoding_table.address as u64), )?; } - + // assign to sm region.assign_advice( || "sm.state", From 3396e1e6d2569a3493259e67a7bcc45ce7dd26c7 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 16 Nov 2023 07:44:50 -0800 Subject: [PATCH 030/161] add stack op witness --- zkevm-circuits/src/witness/rlp_fsm.rs | 4 ++++ zkevm-circuits/src/witness/tx.rs | 32 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 609f76e28d..283114ee59 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -828,4 +828,8 @@ pub(crate) struct RlpStackOp { pub address: usize, pub value: usize, pub value_prev: usize, + pub is_init: bool, + pub is_push: bool, + pub is_pop: bool, + pub is_update: bool, } diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 1bdd8c0a54..2b9e055142 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -417,6 +417,10 @@ impl Transaction { address: cur.depth, value: rlp_bytes.len(), value_prev: 0, + is_init: true, + is_push: false, + is_pop: false, + is_update: false, }); let mut witness_table_idx = 0; @@ -463,6 +467,10 @@ impl Transaction { address: cur.depth - 1, value: prev_depth_bytes, value_prev: last_bytes_on_depth[cur.depth - 1], + is_init: false, + is_push: false, + is_pop: true, + is_update: false, }) } @@ -510,6 +518,10 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, + is_init: false, + is_push: false, + is_pop: false, + is_update: true, }); } @@ -602,6 +614,10 @@ impl Transaction { address: cur.depth + 1, value: num_bytes_of_new_list, value_prev: 0, + is_init: false, + is_push: true, + is_pop: false, + is_update: false, }); next.depth = cur.depth + 1; next.state = DecodeTagStart; @@ -630,6 +646,10 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, + is_init: false, + is_push: false, + is_pop: false, + is_update: true, }); *rem -= 1; @@ -666,6 +686,10 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, + is_init: false, + is_push: false, + is_pop: false, + is_update: true, }); *rem -= 1; @@ -701,6 +725,10 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, + is_init: false, + is_push: false, + is_pop: false, + is_update: true, }); } @@ -733,6 +761,10 @@ impl Transaction { address: cur.depth + 1, value: lb_len, value_prev: 0, + is_init: false, + is_push: true, + is_pop: false, + is_update: false, }); next.depth = cur.depth + 1; next.state = DecodeTagStart; From 23f94ccae9f858e1855c2acdda63ce0c2dc055cb Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 16 Nov 2023 08:08:20 -0800 Subject: [PATCH 031/161] add stack op witness --- zkevm-circuits/src/rlp_circuit_fsm.rs | 52 ++++++++++++++++++++++----- zkevm-circuits/src/witness/rlp_fsm.rs | 8 +++++ zkevm-circuits/src/witness/tx.rs | 4 +++ 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 89a528fcf9..a7fb73af1d 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -196,6 +196,14 @@ pub struct RlpDecodingTable { pub stack_acc: Column, /// Power of rand for stack accumulator on depth level (address) pub stack_acc_pow_of_rand: Column, + /// Stack Op flag, Init + pub is_stack_init: Column, + /// Stack Op flag, Push + pub is_stack_push: Column, + /// Stack Op flag, Pop + pub is_stack_pop: Column, + /// Stack Op flag, Update + pub is_stack_update: Column, } impl RlpDecodingTable { @@ -209,6 +217,10 @@ impl RlpDecodingTable { value_prev: meta.advice_column(), stack_acc: meta.advice_column_in(SecondPhase), stack_acc_pow_of_rand: meta.advice_column_in(SecondPhase), + is_stack_init: meta.advice_column(), + is_stack_push: meta.advice_column(), + is_stack_pop: meta.advice_column(), + is_stack_update: meta.advice_column(), } } } @@ -1822,6 +1834,30 @@ impl RlpCircuitConfig { row, || witness.rlp_decoding_table.stack_acc_pow_of_rand, )?; + region.assign_advice( + || "rlp_decoding_table.is_stack_init", + self.rlp_decoding_table.is_stack_init, + row, + || Value::known(F::from(witness.rlp_decoding_table.is_stack_init as u64)), + )?; + region.assign_advice( + || "rlp_decoding_table.is_stack_push", + self.rlp_decoding_table.is_stack_push, + row, + || Value::known(F::from(witness.rlp_decoding_table.is_stack_push as u64)), + )?; + region.assign_advice( + || "rlp_decoding_table.is_stack_pop", + self.rlp_decoding_table.is_stack_pop, + row, + || Value::known(F::from(witness.rlp_decoding_table.is_stack_pop as u64)), + )?; + region.assign_advice( + || "rlp_decoding_table.is_stack_update", + self.rlp_decoding_table.is_stack_update, + row, + || Value::known(F::from(witness.rlp_decoding_table.is_stack_update as u64)), + )?; let is_new_access_list_address = witness.state_machine.state == DecodeTagStart && witness.state_machine.tag == AccessListAddress; @@ -2181,14 +2217,14 @@ impl RlpCircuitConfig { ); // TX1559_DEBUG - // log::trace!( - // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", - // sm_rows - // ); - // log::trace!( - // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", - // dt_rows - // ); + log::trace!( + "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", + sm_rows + ); + log::trace!( + "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", + dt_rows + ); debug_assert!(sm_rows.len() <= last_row); diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 283114ee59..ebe8b31499 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -784,6 +784,14 @@ pub struct RlpDecodingTable { pub stack_acc: Value, /// Power of rand for stack accumulator on depth level (address) pub stack_acc_pow_of_rand: Value, + /// Stack Operation Flag, Init + pub is_stack_init: bool, + /// Stack Operation Flag, Push + pub is_stack_push: bool, + /// Stack Operation Flag, Pop + pub is_stack_pop: bool, + /// Stack Operation Flag, Update + pub is_stack_update: bool, } /// Represents the witness in a single row of the RLP circuit. diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 2b9e055142..5d73c3ea6d 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -870,6 +870,10 @@ impl Transaction { value_prev: stack_op.value_prev, stack_acc, stack_acc_pow_of_rand: stack_acc_pow_of_rand[stack_op.address], + is_stack_init: stack_op.is_init, + is_stack_push: stack_op.is_push, + is_stack_pop: stack_op.is_pop, + is_stack_update: stack_op.is_update, }, }); witness_table_idx += 1; From bff1b243886c4a3e6895eec95c464991b9438714 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 16 Nov 2023 08:38:39 -0800 Subject: [PATCH 032/161] add stack constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 157 +++++++++++++++----------- 1 file changed, 93 insertions(+), 64 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index a7fb73af1d..bfb0f6cfd7 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -336,8 +336,6 @@ pub struct RlpCircuitConfig { depth_eq_four: IsEqualConfig, /// Check for byte_value == 0 byte_value_is_zero: IsZeroConfig, - /// Check for stack ptr change - stack_ptr_comp: ComparatorConfig, /// Internal tables /// Data table @@ -1586,60 +1584,102 @@ impl RlpCircuitConfig { ///////////////////////// (Stack Constraints) ///////////////////// /////////////////////////////////////////////////////////////////// - // Booleans for comparing stack ptr (address) in decoding table - let stack_ptr_comp: ComparatorConfig = ComparatorChip::configure( - meta, - cmp_enabled, - |meta| meta.query_advice(rlp_decoding_table.address, Rotation::cur()), - |meta| meta.query_advice(rlp_decoding_table.address, Rotation::next()), - u8_table.into(), - ); - meta.create_gate("stack constraints", |meta| { let mut cb = BaseConstraintBuilder::default(); - let (ptr_lt, ptr_eq) = stack_ptr_comp.expr(meta, None); - - // Stack PUSH - cb.condition(ptr_lt.clone(), |cb| { + // Universal stack constraints + cb.require_equal( + "stack ptr (address) must correspond exactly to depth", + meta.query_advice(depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + ); + cb.condition(not::expr(is_end(meta)), |cb| { cb.require_equal( - "PUSH: stack ptr increase can only be 1", - meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr(), - meta.query_advice(rlp_decoding_table.address, Rotation::next()), - ) + "each row must have a stack operation", + sum::expr([ + meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), + ]), + 1.expr() + ); }); + + cb.require_zero( + "is_stack_init is binary", + meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur()) + * (1.expr() - meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur())) + ); + cb.require_zero( + "is_stack_push is binary", + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()) + * (1.expr() - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur())) + ); + cb.require_zero( + "is_stack_pop is binary", + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()) + * (1.expr() - meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur())) + ); + cb.require_zero( + "is_stack_update is binary", + meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()) + * (1.expr() - meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur())) + ); - // Stack POP + // Stack Init cb.condition( - and::expr([not::expr(ptr_lt), not::expr(ptr_eq)]), + meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur()), |cb| { + cb.require_zero("stack inits at depth 0", meta.query_advice(rlp_decoding_table.address, Rotation::cur())); cb.require_equal( - "POP: stack ptr decrease can only be 1", - meta.query_advice(rlp_decoding_table.address, Rotation::cur()), - meta.query_advice(rlp_decoding_table.address, Rotation::next()) + 1.expr(), - ) - }, + "stack init pushes all remaining_bytes onto depth 0", + meta.query_advice(rlp_decoding_table.value, Rotation::cur()), + meta.query_advice(byte_rev_idx, Rotation::cur()) + ); + } ); - - // Stack Update Top - // cb.condition(ptr_eq, |cb| { - // cb.require_equal( - // "At the same depth level, must read 1 byte", - // meta.query_advice(rlp_decoding_table.value, Rotation::next()) + 1.expr(), - // meta.query_advice(rlp_decoding_table.value_prev, Rotation::next()), - // ); - // }); - - cb.require_equal( - "stack ptr (address) must correspond exactly to depth", - meta.query_advice(depth, Rotation::cur()), - meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + // Stack Push + cb.condition( + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + |cb| { + cb.require_equal( + "PUSH stack operation increases depth", + meta.query_advice(rlp_decoding_table.address, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + ); + } + ); + // Stack Pop + cb.condition( + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), + |cb| { + cb.require_equal( + "POP stack operation decreases depth", + meta.query_advice(rlp_decoding_table.address, Rotation::prev()), + meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr() + ); + } + ); + // Stack Update + cb.condition( + meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), + |cb| { + cb.require_equal( + "UPDATE stack operation doesn't change depth", + meta.query_advice(rlp_decoding_table.address, Rotation::prev()), + meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + ); + cb.require_equal( + "UPDATE stack operation reads 1 byte", + meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + 1.expr(), + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()) + ); + } ); + - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - not::expr(is_end(meta)), - ])) + cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }); debug_assert!(meta.degree() <= 9); @@ -1702,7 +1742,6 @@ impl RlpCircuitConfig { depth_eq_two, depth_eq_four, byte_value_is_zero, - stack_ptr_comp, // internal tables data_table, @@ -1876,16 +1915,6 @@ impl RlpCircuitConfig { || Value::known(F::from(is_new_access_list_storage_key as u64)), )?; - if let Some(witness_nxt) = witness_next { - let stack_ptr_comp_chip = ComparatorChip::construct(self.stack_ptr_comp.clone()); - stack_ptr_comp_chip.assign( - region, - row, - F::from(witness.rlp_decoding_table.address as u64), - F::from(witness_nxt.rlp_decoding_table.address as u64), - )?; - } - // assign to sm region.assign_advice( || "sm.state", @@ -2123,7 +2152,7 @@ impl RlpCircuitConfig { || "q_enable", self.rlp_table.q_enable, row, - || Value::known(F::zero()), + || Value::known(F::one()), )?; region.assign_advice( || "sm.state", @@ -2217,14 +2246,14 @@ impl RlpCircuitConfig { ); // TX1559_DEBUG - log::trace!( - "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", - sm_rows - ); - log::trace!( - "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", - dt_rows - ); + // log::trace!( + // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", + // sm_rows + // ); + // log::trace!( + // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", + // dt_rows + // ); debug_assert!(sm_rows.len() <= last_row); From 306304dbbab12ce39e7217d77de6a1da4495f1f5 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 16 Nov 2023 08:41:38 -0800 Subject: [PATCH 033/161] fmt --- zkevm-circuits/src/rlp_circuit_fsm.rs | 68 +++++++++++++++------------ 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index bfb0f6cfd7..653e666c3e 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1595,89 +1595,95 @@ impl RlpCircuitConfig { ); cb.condition(not::expr(is_end(meta)), |cb| { cb.require_equal( - "each row must have a stack operation", + "each row must have a stack operation", sum::expr([ meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur()), meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), ]), - 1.expr() + 1.expr(), ); }); - + cb.require_zero( - "is_stack_init is binary", + "is_stack_init is binary", meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur()) - * (1.expr() - meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur())) + * (1.expr() + - meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur())), ); cb.require_zero( - "is_stack_push is binary", + "is_stack_push is binary", meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()) - * (1.expr() - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur())) + * (1.expr() + - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur())), ); cb.require_zero( - "is_stack_pop is binary", + "is_stack_pop is binary", meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()) - * (1.expr() - meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur())) + * (1.expr() + - meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur())), ); cb.require_zero( - "is_stack_update is binary", + "is_stack_update is binary", meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()) - * (1.expr() - meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur())) + * (1.expr() + - meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur())), ); // Stack Init cb.condition( - meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur()), |cb| { - cb.require_zero("stack inits at depth 0", meta.query_advice(rlp_decoding_table.address, Rotation::cur())); + cb.require_zero( + "stack inits at depth 0", + meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + ); cb.require_equal( "stack init pushes all remaining_bytes onto depth 0", - meta.query_advice(rlp_decoding_table.value, Rotation::cur()), - meta.query_advice(byte_rev_idx, Rotation::cur()) + meta.query_advice(rlp_decoding_table.value, Rotation::cur()), + meta.query_advice(byte_rev_idx, Rotation::cur()), ); - } + }, ); // Stack Push cb.condition( - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), |cb| { cb.require_equal( "PUSH stack operation increases depth", - meta.query_advice(rlp_decoding_table.address, Rotation::prev()) + 1.expr(), - meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + meta.query_advice(rlp_decoding_table.address, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_decoding_table.address, Rotation::cur()), ); - } + }, ); // Stack Pop cb.condition( - meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), |cb| { cb.require_equal( "POP stack operation decreases depth", - meta.query_advice(rlp_decoding_table.address, Rotation::prev()), - meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr() + meta.query_advice(rlp_decoding_table.address, Rotation::prev()), + meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr(), ); - } + }, ); // Stack Update cb.condition( - meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), |cb| { cb.require_equal( "UPDATE stack operation doesn't change depth", - meta.query_advice(rlp_decoding_table.address, Rotation::prev()), - meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + meta.query_advice(rlp_decoding_table.address, Rotation::prev()), + meta.query_advice(rlp_decoding_table.address, Rotation::cur()), ); cb.require_equal( "UPDATE stack operation reads 1 byte", - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + 1.expr(), - meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()) + meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + 1.expr(), + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), ); - } + }, ); - cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }); From 951ee27577e7e90f207d2d57b54be56cefb3370e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 16 Nov 2023 22:03:56 -0800 Subject: [PATCH 034/161] add stack constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 52 +++++++++++++++++++++++---- zkevm-circuits/src/witness/rlp_fsm.rs | 1 + zkevm-circuits/src/witness/tx.rs | 10 +++++- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 653e666c3e..0a2acc4f2f 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1586,8 +1586,8 @@ impl RlpCircuitConfig { meta.create_gate("stack constraints", |meta| { let mut cb = BaseConstraintBuilder::default(); - - // Universal stack constraints + + // Universal Stack Constraints cb.require_equal( "stack ptr (address) must correspond exactly to depth", meta.query_advice(depth, Rotation::cur()), @@ -1644,8 +1644,14 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.value, Rotation::cur()), meta.query_advice(byte_rev_idx, Rotation::cur()), ); + cb.require_equal( + "stack_acc accumulates depth 0 bytes at 1", + meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + 1.expr() + ) }, ); + // Stack Push cb.condition( meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), @@ -1655,6 +1661,17 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.address, Rotation::prev()) + 1.expr(), meta.query_advice(rlp_decoding_table.address, Rotation::cur()), ); + cb.require_equal( + "stack_acc accumulates next depth level at exponent +1 of challenge", + meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()) * challenges.keccak_input(), + meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + ); + cb.require_equal( + "stack_acc accumulates remaining bytes from previous depth level", + meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) + + (meta.query_advice(rlp_decoding_table.value, Rotation::prev()) - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) - 1.expr()) * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), + meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + ); }, ); // Stack Pop @@ -1666,9 +1683,24 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.address, Rotation::prev()), meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr(), ); + cb.require_zero( + "POP can only happen if there's no more bytes to decode on the higher depth", + meta.query_advice(rlp_decoding_table.value, Rotation::prev()), + ); + cb.require_equal( + "stack_acc accumulates lower depth level at exponent -1 of challenge", + meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), + meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()) * challenges.keccak_input(), + ); + cb.require_equal( + "stack_acc releases remaining bytes from previous depth level", + meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) + - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + ); }, ); - // Stack Update + // Stack Update Top cb.condition( meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), |cb| { @@ -1682,6 +1714,16 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + 1.expr(), meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), ); + cb.require_equal( + "UPDATE doesn't change stack_acc", + meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()), + meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + ); + cb.require_equal( + "stack_acc accumulates same depth level at the same exponent of challenge", + meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), + meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + ); }, ); @@ -2256,10 +2298,6 @@ impl RlpCircuitConfig { // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", // sm_rows // ); - // log::trace!( - // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - dt_rows: {:?}", - // dt_rows - // ); debug_assert!(sm_rows.len() <= last_row); diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index ebe8b31499..d7f41329f0 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -836,6 +836,7 @@ pub(crate) struct RlpStackOp { pub address: usize, pub value: usize, pub value_prev: usize, + pub stack_acc: Value, pub is_init: bool, pub is_push: bool, pub is_pop: bool, diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 5d73c3ea6d..25b0aa748a 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -417,6 +417,7 @@ impl Transaction { address: cur.depth, value: rlp_bytes.len(), value_prev: 0, + stack_acc: Value::known(F::zero()), is_init: true, is_push: false, is_pop: false, @@ -467,6 +468,7 @@ impl Transaction { address: cur.depth - 1, value: prev_depth_bytes, value_prev: last_bytes_on_depth[cur.depth - 1], + stack_acc: stack_acc, is_init: false, is_push: false, is_pop: true, @@ -518,6 +520,7 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, + stack_acc: stack_acc, is_init: false, is_push: false, is_pop: false, @@ -614,6 +617,7 @@ impl Transaction { address: cur.depth + 1, value: num_bytes_of_new_list, value_prev: 0, + stack_acc: stack_acc, is_init: false, is_push: true, is_pop: false, @@ -646,6 +650,7 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, + stack_acc: stack_acc, is_init: false, is_push: false, is_pop: false, @@ -686,6 +691,7 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, + stack_acc: stack_acc, is_init: false, is_push: false, is_pop: false, @@ -725,6 +731,7 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, + stack_acc: stack_acc, is_init: false, is_push: false, is_pop: false, @@ -761,6 +768,7 @@ impl Transaction { address: cur.depth + 1, value: lb_len, value_prev: 0, + stack_acc: stack_acc, is_init: false, is_push: true, is_pop: false, @@ -868,7 +876,7 @@ impl Transaction { address: stack_op.address, value: stack_op.value, value_prev: stack_op.value_prev, - stack_acc, + stack_acc: stack_op.stack_acc, stack_acc_pow_of_rand: stack_acc_pow_of_rand[stack_op.address], is_stack_init: stack_op.is_init, is_stack_push: stack_op.is_push, From d5d28544c05f63137b8abe42f37eb0c974c5b517 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Fri, 17 Nov 2023 17:06:32 -0800 Subject: [PATCH 035/161] add stack end condition --- zkevm-circuits/src/rlp_circuit_fsm.rs | 31 ++++++++++++++++++++-- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 4 +-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 0a2acc4f2f..a16e624446 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -303,6 +303,8 @@ pub struct RlpCircuitConfig { is_new_access_list_address: Column, /// Boolean to reduce the circuit's degree is_new_access_list_storage_key: Column, + /// Decoding table depth check + is_stack_depth_zero: IsZeroConfig, /// Check for byte_value <= 0x80 byte_value_lte_0x80: ComparatorConfig, @@ -1483,7 +1485,7 @@ impl RlpCircuitConfig { }); /////////////////////////////////////////////////////////////////// - /////////////////// Rlp Decoding Table Transitions //////////////// + /////////////////// Access List Constraint Transitions //////////// /////////////////////////////////////////////////////////////////// meta.create_gate("booleans for reducing degree (part four)", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1583,6 +1585,12 @@ impl RlpCircuitConfig { /////////////////// Rlp Decoding Table Transitions //////////////// ///////////////////////// (Stack Constraints) ///////////////////// /////////////////////////////////////////////////////////////////// + let is_stack_depth_zero = IsZeroChip::configure( + meta, + |meta| meta.query_fixed(q_enabled, Rotation::cur()), + rlp_decoding_table.address, + |meta| meta.advice_column(), + ); meta.create_gate("stack constraints", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1674,6 +1682,7 @@ impl RlpCircuitConfig { ); }, ); + // Stack Pop cb.condition( meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), @@ -1700,6 +1709,7 @@ impl RlpCircuitConfig { ); }, ); + // Stack Update Top cb.condition( meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), @@ -1727,6 +1737,20 @@ impl RlpCircuitConfig { }, ); + // End condition. Last step of decoding. + cb.condition( + and::expr([ + is_stack_depth_zero.expr(Rotation::cur())(meta), + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), + ]), + |cb| { + cb.require_zero( + "at the end of decoding, remaining bytes on depth level 0 should be 0.", + meta.query_advice(rlp_decoding_table.value, Rotation::cur()), + ); + } + ); + cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }); @@ -1771,7 +1795,8 @@ impl RlpCircuitConfig { is_new_access_list_address, is_new_access_list_storage_key, - // decoding table checks + // decoding table + is_stack_depth_zero, // comparators byte_value_lte_0x80, @@ -1962,6 +1987,8 @@ impl RlpCircuitConfig { row, || Value::known(F::from(is_new_access_list_storage_key as u64)), )?; + let stack_depth_chip = IsZeroChip::construct(self.is_stack_depth_zero.clone()); + stack_depth_chip.assign(region, row, Value::known(F::from(witness.rlp_decoding_table.address as u64)))?; // assign to sm region.assign_advice( diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index 665e280a28..49812eb789 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,9 +110,9 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ - // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", + "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", // "02f901e901833c3139842b27f14d86012309ce540083055ca8945f65f7b609678448494de4c87521cdf6cef1e93280b8e4fa558b7100000000000000000000000095ad61b0a150d79219dcf64e1e6cc01f0b64c4ce000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000016a217dedfacdf9c23edb84b57154f26a15848e60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000028cad80bb7cf17e27c4c8f893f7945f65f7b609678448494de4c87521cdf6cef1e932e1a0d2dc2a0881b05440a4908cf506b4871b1f7eaa46ea0c5dfdcda5f52bc17164a4f8599495ad61b0a150d79219dcf64e1e6cc01f0b64c4cef842a0ba03decd934aae936605e9d437c401439ec4cefbad5795e0965100f929fe339ca0b36e2afa1a25492257090107ad99d079032e543c8dd1ffcd44cf14a96d3015ac80a0821193127789b107351f670025dd3b862f5836e5155f627a29741a251e8d28e8a07ea1e82b1bf6f29c5d0f1e4024acdb698086ac40c353704d7d5e301fb916f2e3", - "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + // "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", // "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; From a33768907a72578fb1968170f214286f409b2139 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Fri, 17 Nov 2023 17:47:15 -0800 Subject: [PATCH 036/161] fmt --- zkevm-circuits/src/rlp_circuit_fsm.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index a16e624446..f2167f1db0 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1594,7 +1594,7 @@ impl RlpCircuitConfig { meta.create_gate("stack constraints", |meta| { let mut cb = BaseConstraintBuilder::default(); - + // Universal Stack Constraints cb.require_equal( "stack ptr (address) must correspond exactly to depth", @@ -1654,7 +1654,7 @@ impl RlpCircuitConfig { ); cb.require_equal( "stack_acc accumulates depth 0 bytes at 1", - meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), 1.expr() ) }, @@ -1677,7 +1677,10 @@ impl RlpCircuitConfig { cb.require_equal( "stack_acc accumulates remaining bytes from previous depth level", meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) - + (meta.query_advice(rlp_decoding_table.value, Rotation::prev()) - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) - 1.expr()) * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), + + (meta.query_advice(rlp_decoding_table.value, Rotation::prev()) + - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + - 1.expr()) + * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), ); }, @@ -1704,12 +1707,13 @@ impl RlpCircuitConfig { cb.require_equal( "stack_acc releases remaining bytes from previous depth level", meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) - - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), ); }, ); - + // Stack Update Top cb.condition( meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), @@ -1988,7 +1992,11 @@ impl RlpCircuitConfig { || Value::known(F::from(is_new_access_list_storage_key as u64)), )?; let stack_depth_chip = IsZeroChip::construct(self.is_stack_depth_zero.clone()); - stack_depth_chip.assign(region, row, Value::known(F::from(witness.rlp_decoding_table.address as u64)))?; + stack_depth_chip.assign( + region, + row, + Value::known(F::from(witness.rlp_decoding_table.address as u64)), + )?; // assign to sm region.assign_advice( From 22dd5a1a3ed9f2e3ccd7998b6a33c159feabb8be Mon Sep 17 00:00:00 2001 From: darth-cy Date: Fri, 17 Nov 2023 17:49:16 -0800 Subject: [PATCH 037/161] fmt --- zkevm-circuits/src/rlp_circuit_fsm.rs | 16 ---------------- zkevm-circuits/src/witness/tx.rs | 14 +++++++------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index f2167f1db0..100473c87c 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -2318,22 +2318,6 @@ impl RlpCircuitConfig { .flat_map(|input| input.gen_sm_witness(challenges)) .collect::>(); - // TX1559_DEBUG - log::trace!( - "=> [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows.len(): {:?}", - sm_rows.len() - ); - log::trace!( - "=> [Execution Rlp Circuit FSM] RlpCircuitConfig - last_row: {:?}", - last_row - ); - - // TX1559_DEBUG - // log::trace!( - // "\n\n => [Execution Rlp Circuit FSM] RlpCircuitConfig - sm_rows: {:?}", - // sm_rows - // ); - debug_assert!(sm_rows.len() <= last_row); self.rom_table.load(layouter)?; diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 25b0aa748a..55e02a7145 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -468,7 +468,7 @@ impl Transaction { address: cur.depth - 1, value: prev_depth_bytes, value_prev: last_bytes_on_depth[cur.depth - 1], - stack_acc: stack_acc, + stack_acc, is_init: false, is_push: false, is_pop: true, @@ -520,7 +520,7 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, - stack_acc: stack_acc, + stack_acc, is_init: false, is_push: false, is_pop: false, @@ -617,7 +617,7 @@ impl Transaction { address: cur.depth + 1, value: num_bytes_of_new_list, value_prev: 0, - stack_acc: stack_acc, + stack_acc, is_init: false, is_push: true, is_pop: false, @@ -650,7 +650,7 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, - stack_acc: stack_acc, + stack_acc, is_init: false, is_push: false, is_pop: false, @@ -691,7 +691,7 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, - stack_acc: stack_acc, + stack_acc, is_init: false, is_push: false, is_pop: false, @@ -731,7 +731,7 @@ impl Transaction { address: cur.depth, value: *rem - 1, value_prev: *rem, - stack_acc: stack_acc, + stack_acc, is_init: false, is_push: false, is_pop: false, @@ -768,7 +768,7 @@ impl Transaction { address: cur.depth + 1, value: lb_len, value_prev: 0, - stack_acc: stack_acc, + stack_acc, is_init: false, is_push: true, is_pop: false, From 3a82a29a8ee7617843d80b338758fc6285228f62 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Fri, 17 Nov 2023 18:08:44 -0800 Subject: [PATCH 038/161] rename beginlist and endlist --- zkevm-circuits/src/rlp_circuit_fsm.rs | 28 ++--- zkevm-circuits/src/witness/l1_msg.rs | 12 +-- zkevm-circuits/src/witness/rlp_fsm.rs | 144 +++++++++++++------------- zkevm-circuits/src/witness/tx.rs | 6 +- 4 files changed, 95 insertions(+), 95 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 100473c87c..21eb8e7992 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -16,7 +16,7 @@ use crate::{ Block, DataTable, Format, RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTag, RomTableRow, State, State::{DecodeTagStart, End}, Tag, - Tag::{AccessListAddress, AccessListStorageKey, BeginList, EndList, TxType}, + Tag::{AccessListAddress, AccessListStorageKey, BeginObject, EndObject, TxType}, Transaction, }, }; @@ -447,9 +447,9 @@ impl RlpCircuitConfig { }; } - is_tag!(is_tag_begin_list, BeginList); + is_tag!(is_tag_begin_object, BeginObject); is_tag!(is_tag_begin_vector, BeginVector); - is_tag!(is_tag_end_list, EndList); + is_tag!(is_tag_end_object, EndObject); is_tag!(is_tag_end_vector, EndVector); is_tag!(is_access_list_address, AccessListAddress); is_tag!(is_access_list_storage_key, AccessListStorageKey); @@ -873,14 +873,14 @@ impl RlpCircuitConfig { // use sum instead of or because is_tag_* cannot be true at the same time cb.require_equal( - "is_tag_end = is_tag_end_list || is_tag_end_vector", + "is_tag_end = is_tag_end_object || is_tag_end_vector", meta.query_advice(is_tag_end, Rotation::cur()), - sum::expr([is_tag_end_list(meta), is_tag_end_vector(meta)]), + sum::expr([is_tag_end_object(meta), is_tag_end_vector(meta)]), ); cb.require_equal( - "is_tag_begin = is_tag_begin_list || is_tag_begin_vector", + "is_tag_begin = is_tag_begin_object || is_tag_begin_vector", meta.query_advice(is_tag_begin, Rotation::cur()), - sum::expr([is_tag_begin_list(meta), is_tag_begin_vector(meta)]), + sum::expr([is_tag_begin_object(meta), is_tag_begin_vector(meta)]), ); cb.require_equal( "is_case3 = (0xc0 <= byte_value < 0xf8) && (is_tag_end == false)", @@ -987,8 +987,8 @@ impl RlpCircuitConfig { constrain_eq!(meta, cb, tx_id, 1.expr()); constrain_eq!(meta, cb, byte_idx, 1.expr()); cb.require_zero( - "tag == TxType or tag == BeginList", - (tag.expr() - TxType.expr()) * (tag - BeginList.expr()), + "tag == TxType or tag == BeginObject", + (tag.expr() - TxType.expr()) * (tag - BeginObject.expr()), ); cb.gate(meta.query_fixed(q_first, Rotation::cur())) @@ -1082,7 +1082,7 @@ impl RlpCircuitConfig { }, ); - // case 4: tag in [EndList, EndVector] + // case 4: tag in [EndObject, EndVector] let case_4 = is_tag_end_expr(meta); cb.condition( and::expr([case_4.expr(), depth_eq_one.is_equal_expression.expr()]), @@ -1114,9 +1114,9 @@ impl RlpCircuitConfig { update_state!(meta, cb, state, DecodeTagStart); cb.require_zero( - "tag == TxType or tag == BeginList", + "tag == TxType or tag == BeginObject", (tag_next.expr() - TxType.expr()) - * (tag_next.expr() - BeginList.expr()), + * (tag_next.expr() - BeginObject.expr()), ); }, ); @@ -2247,12 +2247,12 @@ impl RlpCircuitConfig { || "sm.tag", self.tag, row, - || Value::known(F::from(usize::from(EndList) as u64)), + || Value::known(F::from(usize::from(EndObject) as u64)), )?; let state_chip = BinaryNumberChip::construct(self.state_bits); state_chip.assign(region, row, &End)?; let tag_chip = BinaryNumberChip::construct(self.tag_bits); - tag_chip.assign(region, row, &EndList)?; + tag_chip.assign(region, row, &EndObject)?; Ok(()) } diff --git a/zkevm-circuits/src/witness/l1_msg.rs b/zkevm-circuits/src/witness/l1_msg.rs index 1eb13bb916..70b5d2e37a 100644 --- a/zkevm-circuits/src/witness/l1_msg.rs +++ b/zkevm-circuits/src/witness/l1_msg.rs @@ -4,7 +4,7 @@ use crate::{ rlp_fsm::{MAX_TAG_LENGTH_OF_LIST, N_BYTES_CALLDATA}, Format::L1MsgHash, RomTableRow, - Tag::{BeginList, Data, EndList, Gas, Nonce, Sender, To, TxType, Value as TxValue}, + Tag::{BeginObject, Data, EndObject, Gas, Nonce, Sender, To, TxType, Value as TxValue}, }, }; use ethers_core::utils::rlp::Encodable; @@ -20,17 +20,17 @@ impl Encodable for L1MsgTx { pub fn rom_table_rows() -> Vec { let rows = vec![ - (TxType, BeginList, 1, vec![1]), - (BeginList, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![2]), + (TxType, BeginObject, 1, vec![1]), + (BeginObject, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![2]), (Nonce, Gas, N_BYTES_U64, vec![3]), (Gas, To, N_BYTES_U64, vec![4]), (To, TxValue, N_BYTES_ACCOUNT_ADDRESS, vec![5]), (TxValue, Data, N_BYTES_WORD, vec![6]), (Data, Sender, N_BYTES_CALLDATA, vec![7]), - (Sender, EndList, N_BYTES_ACCOUNT_ADDRESS, vec![8]), - (EndList, EndList, 0, vec![9]), + (Sender, EndObject, N_BYTES_ACCOUNT_ADDRESS, vec![8]), + (EndObject, EndObject, 0, vec![9]), // used to emit TxGasCostInL1 - (EndList, BeginList, 0, vec![]), + (EndObject, BeginObject, 0, vec![]), ]; rows.into_iter() diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index d7f41329f0..fa5b5968e6 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -54,22 +54,22 @@ impl ValueTagLength for Vec { } } -// return the tag length of the top-level BeginList tag +// return the tag length of the top-level BeginObject tag pub(crate) fn get_rlp_len_tag_length(rlp_bytes: &[u8]) -> u32 { - let begin_list_byte = if rlp_bytes[0] < 0xc0 { + let begin_object_byte = if rlp_bytes[0] < 0xc0 { // it's eip2718 (first byte is transaction type) rlp_bytes[1] } else { rlp_bytes[0] }; - assert!(begin_list_byte >= 0xc0); - if begin_list_byte < 0xf8 { + assert!(begin_object_byte >= 0xc0); + if begin_object_byte < 0xf8 { // list 1 } else { // long_list - (begin_list_byte - 0xf7).into() + (begin_object_byte - 0xf7).into() } } @@ -79,14 +79,14 @@ pub enum Tag { #[default] /// Tag that marks the beginning of a list /// whose value gives the length of bytes of this list. - BeginList = 4, + BeginObject = 4, /// Tag that marks the ending of a list and /// it does not consume any byte. - EndList, - /// Special case of BeginList in which each item's key is + EndObject, + /// Special case of BeginObject in which each item's key is /// an increasing integer starting from 1. BeginVector, - /// Special case of EndList + /// Special case of EndObject EndVector, // Pre EIP-155 @@ -154,18 +154,18 @@ impl Tag { pub fn is_list(&self) -> bool { matches!( self, - Self::BeginList | Self::BeginVector | Self::EndList | Self::EndVector + Self::BeginObject | Self::BeginVector | Self::EndObject | Self::EndVector ) } - /// If the tag is BeginList or BeginVector + /// If the tag is BeginObject or BeginVector pub fn is_begin(&self) -> bool { - matches!(self, Self::BeginList | Self::BeginVector) + matches!(self, Self::BeginObject | Self::BeginVector) } - /// If the tag is EndList or EndVector + /// If the tag is EndObject or EndVector pub fn is_end(&self) -> bool { - matches!(self, Self::EndList | Self::EndVector) + matches!(self, Self::EndObject | Self::EndVector) } /// If the tag is AccessListAddress @@ -222,8 +222,8 @@ use crate::{ TxSignEip1559, TxSignEip2930, TxSignPreEip155, }, Tag::{ - AccessListAddress, AccessListStorageKey, BeginList, BeginVector, ChainId, Data, - EndList, EndVector, Gas, GasPrice, MaxFeePerGas, MaxPriorityFeePerGas, Nonce, SigR, + AccessListAddress, AccessListStorageKey, BeginObject, BeginVector, ChainId, Data, + EndObject, EndVector, Gas, GasPrice, MaxFeePerGas, MaxPriorityFeePerGas, Nonce, SigR, SigS, SigV, To, TxType, Value as TxValue, Zero1, Zero2, }, }, @@ -237,7 +237,7 @@ pub(crate) const N_BYTES_CALLDATA: usize = 1 << 24; fn eip155_tx_sign_rom_table_rows() -> Vec { let rows = vec![ - (BeginList, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![1]), + (BeginObject, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![1]), (Nonce, GasPrice, N_BYTES_U64, vec![2]), (GasPrice, Gas, N_BYTES_WORD, vec![3]), (Gas, To, N_BYTES_U64, vec![4]), @@ -246,10 +246,10 @@ fn eip155_tx_sign_rom_table_rows() -> Vec { (Data, ChainId, N_BYTES_CALLDATA, vec![7]), (ChainId, Zero1, N_BYTES_U64, vec![8]), (Zero1, Zero2, 1, vec![9]), - (Zero2, EndList, 1, vec![10]), - (EndList, EndList, 0, vec![11]), + (Zero2, EndObject, 1, vec![10]), + (EndObject, EndObject, 0, vec![11]), // used to emit TxGasCostInL1 - (EndList, BeginList, 0, vec![]), + (EndObject, BeginObject, 0, vec![]), ]; rows.into_iter() @@ -259,7 +259,7 @@ fn eip155_tx_sign_rom_table_rows() -> Vec { fn eip155_tx_hash_rom_table_rows() -> Vec { let rows = vec![ - (BeginList, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![1]), + (BeginObject, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![1]), (Nonce, GasPrice, N_BYTES_U64, vec![2]), (GasPrice, Gas, N_BYTES_WORD, vec![3]), (Gas, To, N_BYTES_U64, vec![4]), @@ -268,10 +268,10 @@ fn eip155_tx_hash_rom_table_rows() -> Vec { (Data, SigV, N_BYTES_CALLDATA, vec![7]), (SigV, SigR, N_BYTES_U64, vec![8]), (SigR, SigS, N_BYTES_WORD, vec![9]), - (SigS, EndList, N_BYTES_WORD, vec![10]), - (EndList, EndList, 0, vec![11]), + (SigS, EndObject, N_BYTES_WORD, vec![10]), + (EndObject, EndObject, 0, vec![11]), // used to emit TxGasCostInL1 - (EndList, BeginList, 0, vec![]), + (EndObject, BeginObject, 0, vec![]), ]; rows.into_iter() @@ -281,16 +281,16 @@ fn eip155_tx_hash_rom_table_rows() -> Vec { pub fn pre_eip155_tx_sign_rom_table_rows() -> Vec { let rows = vec![ - (BeginList, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![1]), + (BeginObject, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![1]), (Nonce, GasPrice, N_BYTES_U64, vec![2]), (GasPrice, Gas, N_BYTES_WORD, vec![3]), (Gas, To, N_BYTES_U64, vec![4]), (To, TxValue, N_BYTES_ACCOUNT_ADDRESS, vec![5]), (TxValue, Data, N_BYTES_WORD, vec![6]), - (Data, EndList, N_BYTES_CALLDATA, vec![7]), - (EndList, EndList, 0, vec![8]), + (Data, EndObject, N_BYTES_CALLDATA, vec![7]), + (EndObject, EndObject, 0, vec![8]), // used to emit TxGasCostInL1 - (EndList, BeginList, 0, vec![]), + (EndObject, BeginObject, 0, vec![]), ]; rows.into_iter() @@ -300,7 +300,7 @@ pub fn pre_eip155_tx_sign_rom_table_rows() -> Vec { pub fn pre_eip155_tx_hash_rom_table_rows() -> Vec { let rows = vec![ - (BeginList, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![1]), + (BeginObject, Nonce, MAX_TAG_LENGTH_OF_LIST, vec![1]), (Nonce, GasPrice, N_BYTES_U64, vec![2]), (GasPrice, Gas, N_BYTES_WORD, vec![3]), (Gas, To, N_BYTES_U64, vec![4]), @@ -309,10 +309,10 @@ pub fn pre_eip155_tx_hash_rom_table_rows() -> Vec { (Data, SigV, N_BYTES_CALLDATA, vec![7]), (SigV, SigR, N_BYTES_U64, vec![8]), (SigR, SigS, N_BYTES_WORD, vec![9]), - (SigS, EndList, N_BYTES_WORD, vec![10]), - (EndList, EndList, 0, vec![11]), + (SigS, EndObject, N_BYTES_WORD, vec![10]), + (EndObject, EndObject, 0, vec![11]), // used to emit TxGasCostInL1 - (EndList, BeginList, 0, vec![]), + (EndObject, BeginObject, 0, vec![]), ]; rows.into_iter() @@ -322,8 +322,8 @@ pub fn pre_eip155_tx_hash_rom_table_rows() -> Vec { pub fn eip2930_tx_sign_rom_table_rows() -> Vec { let rows = vec![ - (TxType, BeginList, 1, vec![1]), - (BeginList, ChainId, MAX_TAG_LENGTH_OF_LIST, vec![2]), + (TxType, BeginObject, 1, vec![1]), + (BeginObject, ChainId, MAX_TAG_LENGTH_OF_LIST, vec![2]), (ChainId, Nonce, N_BYTES_U64, vec![3]), (Nonce, GasPrice, N_BYTES_U64, vec![4]), (GasPrice, Gas, N_BYTES_WORD, vec![5]), @@ -332,9 +332,9 @@ pub fn eip2930_tx_sign_rom_table_rows() -> Vec { (TxValue, Data, N_BYTES_WORD, vec![8]), (Data, BeginVector, N_BYTES_CALLDATA, vec![9, 10]), (BeginVector, EndVector, MAX_TAG_LENGTH_OF_LIST, vec![20]), // access_list is none - (BeginVector, BeginList, MAX_TAG_LENGTH_OF_LIST, vec![11]), + (BeginVector, BeginObject, MAX_TAG_LENGTH_OF_LIST, vec![11]), ( - BeginList, + BeginObject, AccessListAddress, MAX_TAG_LENGTH_OF_LIST, vec![12], @@ -360,13 +360,13 @@ pub fn eip2930_tx_sign_rom_table_rows() -> Vec { N_BYTES_WORD, vec![15, 16], ), // keep parsing storage_keys - (EndVector, EndList, 0, vec![18, 19]), - (EndList, EndVector, 0, vec![20]), // finished parsing access_list - (EndList, BeginList, 0, vec![11]), // parse another access_list entry - (EndVector, EndList, 0, vec![21]), - (EndList, EndList, 0, vec![22]), + (EndVector, EndObject, 0, vec![18, 19]), + (EndObject, EndVector, 0, vec![20]), // finished parsing access_list + (EndObject, BeginObject, 0, vec![11]), // parse another access_list entry + (EndVector, EndObject, 0, vec![21]), + (EndObject, EndObject, 0, vec![22]), // used to emit TxGasCostInL1 - (EndList, BeginList, 0, vec![]), + (EndObject, BeginObject, 0, vec![]), ]; rows.into_iter() @@ -376,8 +376,8 @@ pub fn eip2930_tx_sign_rom_table_rows() -> Vec { pub fn eip2930_tx_hash_rom_table_rows() -> Vec { let rows = vec![ - (TxType, BeginList, 1, vec![1]), - (BeginList, ChainId, MAX_TAG_LENGTH_OF_LIST, vec![2]), + (TxType, BeginObject, 1, vec![1]), + (BeginObject, ChainId, MAX_TAG_LENGTH_OF_LIST, vec![2]), (ChainId, Nonce, N_BYTES_U64, vec![3]), (Nonce, GasPrice, N_BYTES_U64, vec![4]), (GasPrice, Gas, N_BYTES_WORD, vec![5]), @@ -386,9 +386,9 @@ pub fn eip2930_tx_hash_rom_table_rows() -> Vec { (TxValue, Data, N_BYTES_WORD, vec![8]), (Data, BeginVector, N_BYTES_CALLDATA, vec![9, 10]), (BeginVector, EndVector, MAX_TAG_LENGTH_OF_LIST, vec![20]), // access_list is none - (BeginVector, BeginList, MAX_TAG_LENGTH_OF_LIST, vec![11]), + (BeginVector, BeginObject, MAX_TAG_LENGTH_OF_LIST, vec![11]), ( - BeginList, + BeginObject, AccessListAddress, MAX_TAG_LENGTH_OF_LIST, vec![12], @@ -414,16 +414,16 @@ pub fn eip2930_tx_hash_rom_table_rows() -> Vec { N_BYTES_WORD, vec![15, 16], ), // keep parsing storage_keys - (EndVector, EndList, 0, vec![18, 19]), - (EndList, EndVector, 0, vec![20]), // finished parsing access_list - (EndList, BeginList, 0, vec![11]), // parse another access_list entry + (EndVector, EndObject, 0, vec![18, 19]), + (EndObject, EndVector, 0, vec![20]), // finished parsing access_list + (EndObject, BeginObject, 0, vec![11]), // parse another access_list entry (EndVector, SigV, 0, vec![21]), (SigV, SigR, N_BYTES_U64, vec![22]), (SigR, SigS, N_BYTES_WORD, vec![23]), - (SigS, EndList, N_BYTES_WORD, vec![24]), - (EndList, EndList, 0, vec![25]), + (SigS, EndObject, N_BYTES_WORD, vec![24]), + (EndObject, EndObject, 0, vec![25]), // used to exit TxGasCostInL1 - (EndList, BeginList, 0, vec![]), + (EndObject, BeginObject, 0, vec![]), ]; rows.into_iter() @@ -433,8 +433,8 @@ pub fn eip2930_tx_hash_rom_table_rows() -> Vec { pub fn eip1559_tx_hash_rom_table_rows() -> Vec { let rows = vec![ - (TxType, BeginList, 1, vec![1]), - (BeginList, ChainId, MAX_TAG_LENGTH_OF_LIST, vec![2]), + (TxType, BeginObject, 1, vec![1]), + (BeginObject, ChainId, MAX_TAG_LENGTH_OF_LIST, vec![2]), (ChainId, Nonce, N_BYTES_U64, vec![3]), (Nonce, MaxPriorityFeePerGas, N_BYTES_U64, vec![4]), (MaxPriorityFeePerGas, MaxFeePerGas, N_BYTES_WORD, vec![5]), @@ -444,9 +444,9 @@ pub fn eip1559_tx_hash_rom_table_rows() -> Vec { (TxValue, Data, N_BYTES_WORD, vec![9]), (Data, BeginVector, N_BYTES_CALLDATA, vec![10, 11]), (BeginVector, EndVector, MAX_TAG_LENGTH_OF_LIST, vec![21]), // access_list is none - (BeginVector, BeginList, MAX_TAG_LENGTH_OF_LIST, vec![12]), + (BeginVector, BeginObject, MAX_TAG_LENGTH_OF_LIST, vec![12]), ( - BeginList, + BeginObject, AccessListAddress, MAX_TAG_LENGTH_OF_LIST, vec![13], @@ -472,16 +472,16 @@ pub fn eip1559_tx_hash_rom_table_rows() -> Vec { N_BYTES_WORD, vec![16, 17], ), // keep parsing storage_keys - (EndVector, EndList, 0, vec![19, 20]), - (EndList, EndVector, 0, vec![21]), // finished parsing access_list - (EndList, BeginList, 0, vec![12]), // parse another access_list entry + (EndVector, EndObject, 0, vec![19, 20]), + (EndObject, EndVector, 0, vec![21]), // finished parsing access_list + (EndObject, BeginObject, 0, vec![12]), // parse another access_list entry (EndVector, SigV, 0, vec![22]), (SigV, SigR, N_BYTES_U64, vec![23]), (SigR, SigS, N_BYTES_WORD, vec![24]), - (SigS, EndList, N_BYTES_WORD, vec![25]), - (EndList, EndList, 0, vec![26]), + (SigS, EndObject, N_BYTES_WORD, vec![25]), + (EndObject, EndObject, 0, vec![26]), // used to exit TxGasCostInL1 - (EndList, BeginList, 0, vec![]), + (EndObject, BeginObject, 0, vec![]), ]; rows.into_iter() @@ -491,8 +491,8 @@ pub fn eip1559_tx_hash_rom_table_rows() -> Vec { pub fn eip1559_tx_sign_rom_table_rows() -> Vec { let rows = vec![ - (TxType, BeginList, 1, vec![1]), - (BeginList, ChainId, MAX_TAG_LENGTH_OF_LIST, vec![2]), + (TxType, BeginObject, 1, vec![1]), + (BeginObject, ChainId, MAX_TAG_LENGTH_OF_LIST, vec![2]), (ChainId, Nonce, N_BYTES_U64, vec![3]), (Nonce, MaxPriorityFeePerGas, N_BYTES_U64, vec![4]), (MaxPriorityFeePerGas, MaxFeePerGas, N_BYTES_WORD, vec![5]), @@ -502,9 +502,9 @@ pub fn eip1559_tx_sign_rom_table_rows() -> Vec { (TxValue, Data, N_BYTES_WORD, vec![9]), (Data, BeginVector, N_BYTES_CALLDATA, vec![10, 11]), (BeginVector, EndVector, MAX_TAG_LENGTH_OF_LIST, vec![21]), // access_list is none - (BeginVector, BeginList, MAX_TAG_LENGTH_OF_LIST, vec![12]), + (BeginVector, BeginObject, MAX_TAG_LENGTH_OF_LIST, vec![12]), ( - BeginList, + BeginObject, AccessListAddress, MAX_TAG_LENGTH_OF_LIST, vec![13], @@ -530,13 +530,13 @@ pub fn eip1559_tx_sign_rom_table_rows() -> Vec { N_BYTES_WORD, vec![16, 17], ), // keep parsing storage_keys - (EndVector, EndList, 0, vec![19, 20]), - (EndList, EndVector, 0, vec![21]), // finished parsing access_list - (EndList, BeginList, 0, vec![12]), // parse another access_list entry - (EndVector, EndList, 0, vec![22]), - (EndList, EndList, 0, vec![23]), + (EndVector, EndObject, 0, vec![19, 20]), + (EndObject, EndVector, 0, vec![21]), // finished parsing access_list + (EndObject, BeginObject, 0, vec![12]), // parse another access_list entry + (EndVector, EndObject, 0, vec![22]), + (EndObject, EndObject, 0, vec![23]), // used to emit TxGasCostInL1 - (EndList, BeginList, 0, vec![]), + (EndObject, BeginObject, 0, vec![]), ]; rows.into_iter() diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 55e02a7145..b0ebb51fbb 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -12,7 +12,7 @@ use crate::{ RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTable, RlpTag, State, State::DecodeTagStart, StateMachine, - Tag::{EndList, EndVector}, + Tag::{EndObject, EndVector}, }, }; use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}; @@ -810,7 +810,7 @@ impl Transaction { cur_rom_row = rom_table[row].tag_next_idx.clone(); if next.tag.is_end() { - // Since the EndList or EndVector tag does not read any byte from the data + // Since the EndObject or EndVector tag does not read any byte from the data // table. next.byte_idx = cur.byte_idx; } else { @@ -886,7 +886,7 @@ impl Transaction { }); witness_table_idx += 1; - if cur.tag == EndList && cur.depth == 0 { + if cur.tag == EndObject && cur.depth == 0 { break; } cur = next; From b6046a3792fea0187d3b0968ac38d9a2945e18d3 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Fri, 17 Nov 2023 18:09:18 -0800 Subject: [PATCH 039/161] adjust test case --- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index 49812eb789..c454fec75d 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,10 +110,9 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ - "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", - // "02f901e901833c3139842b27f14d86012309ce540083055ca8945f65f7b609678448494de4c87521cdf6cef1e93280b8e4fa558b7100000000000000000000000095ad61b0a150d79219dcf64e1e6cc01f0b64c4ce000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000016a217dedfacdf9c23edb84b57154f26a15848e60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000028cad80bb7cf17e27c4c8f893f7945f65f7b609678448494de4c87521cdf6cef1e932e1a0d2dc2a0881b05440a4908cf506b4871b1f7eaa46ea0c5dfdcda5f52bc17164a4f8599495ad61b0a150d79219dcf64e1e6cc01f0b64c4cef842a0ba03decd934aae936605e9d437c401439ec4cefbad5795e0965100f929fe339ca0b36e2afa1a25492257090107ad99d079032e543c8dd1ffcd44cf14a96d3015ac80a0821193127789b107351f670025dd3b862f5836e5155f627a29741a251e8d28e8a07ea1e82b1bf6f29c5d0f1e4024acdb698086ac40c353704d7d5e301fb916f2e3", + // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", // "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", - // "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; let mut txs: Vec = vec![]; From eef90a35984d33d6f8d7036c12a8883bb9bb7a0a Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 19 Nov 2023 18:17:28 -0800 Subject: [PATCH 040/161] change address naming to depth --- zkevm-circuits/src/rlp_circuit_fsm.rs | 28 +++++++++++++-------------- zkevm-circuits/src/witness/rlp_fsm.rs | 4 ++-- zkevm-circuits/src/witness/tx.rs | 20 +++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 21eb8e7992..850bd3aea6 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -186,7 +186,7 @@ pub struct RlpDecodingTable { /// Key1 (Id), concat of tx_id, format pub id: Column, /// Key2 (Address), in this case depth - pub address: Column, + pub depth: Column, /// Value pub value: Column, /// Value Previous @@ -212,7 +212,7 @@ impl RlpDecodingTable { Self { is_write: meta.advice_column(), id: meta.advice_column(), - address: meta.advice_column(), + depth: meta.advice_column(), value: meta.advice_column(), value_prev: meta.advice_column(), stack_acc: meta.advice_column_in(SecondPhase), @@ -1588,7 +1588,7 @@ impl RlpCircuitConfig { let is_stack_depth_zero = IsZeroChip::configure( meta, |meta| meta.query_fixed(q_enabled, Rotation::cur()), - rlp_decoding_table.address, + rlp_decoding_table.depth, |meta| meta.advice_column(), ); @@ -1599,7 +1599,7 @@ impl RlpCircuitConfig { cb.require_equal( "stack ptr (address) must correspond exactly to depth", meta.query_advice(depth, Rotation::cur()), - meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), ); cb.condition(not::expr(is_end(meta)), |cb| { cb.require_equal( @@ -1645,7 +1645,7 @@ impl RlpCircuitConfig { |cb| { cb.require_zero( "stack inits at depth 0", - meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), ); cb.require_equal( "stack init pushes all remaining_bytes onto depth 0", @@ -1666,8 +1666,8 @@ impl RlpCircuitConfig { |cb| { cb.require_equal( "PUSH stack operation increases depth", - meta.query_advice(rlp_decoding_table.address, Rotation::prev()) + 1.expr(), - meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), ); cb.require_equal( "stack_acc accumulates next depth level at exponent +1 of challenge", @@ -1692,8 +1692,8 @@ impl RlpCircuitConfig { |cb| { cb.require_equal( "POP stack operation decreases depth", - meta.query_advice(rlp_decoding_table.address, Rotation::prev()), - meta.query_advice(rlp_decoding_table.address, Rotation::cur()) + 1.expr(), + meta.query_advice(rlp_decoding_table.depth, Rotation::prev()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) + 1.expr(), ); cb.require_zero( "POP can only happen if there's no more bytes to decode on the higher depth", @@ -1720,8 +1720,8 @@ impl RlpCircuitConfig { |cb| { cb.require_equal( "UPDATE stack operation doesn't change depth", - meta.query_advice(rlp_decoding_table.address, Rotation::prev()), - meta.query_advice(rlp_decoding_table.address, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::prev()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), ); cb.require_equal( "UPDATE stack operation reads 1 byte", @@ -1922,9 +1922,9 @@ impl RlpCircuitConfig { )?; region.assign_advice( || "rlp_decoding_table.address", - self.rlp_decoding_table.address, + self.rlp_decoding_table.depth, row, - || Value::known(F::from(witness.rlp_decoding_table.address as u64)), + || Value::known(F::from(witness.rlp_decoding_table.depth as u64)), )?; region.assign_advice( || "rlp_decoding_table.value", @@ -1995,7 +1995,7 @@ impl RlpCircuitConfig { stack_depth_chip.assign( region, row, - Value::known(F::from(witness.rlp_decoding_table.address as u64)), + Value::known(F::from(witness.rlp_decoding_table.depth as u64)), )?; // assign to sm diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index fa5b5968e6..cc55ba357a 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -774,7 +774,7 @@ pub struct RlpDecodingTable { /// Key1 (Id), concat of tx_id, format pub id: Value, /// Key2 (Address), in this case depth - pub address: usize, + pub depth: usize, /// Value pub value: usize, /// Value Previous @@ -833,7 +833,7 @@ pub(crate) struct SmState { pub(crate) struct RlpStackOp { pub is_write: bool, pub id: Value, - pub address: usize, + pub depth: usize, pub value: usize, pub value_prev: usize, pub stack_acc: Value, diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index b0ebb51fbb..08b382c162 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -414,7 +414,7 @@ impl Transaction { stack_ops.push(RlpStackOp { is_write: true, id, - address: cur.depth, + depth: cur.depth, value: rlp_bytes.len(), value_prev: 0, stack_acc: Value::known(F::zero()), @@ -465,7 +465,7 @@ impl Transaction { stack_ops.push(RlpStackOp { is_write: true, id, - address: cur.depth - 1, + depth: cur.depth - 1, value: prev_depth_bytes, value_prev: last_bytes_on_depth[cur.depth - 1], stack_acc, @@ -517,7 +517,7 @@ impl Transaction { stack_ops.push(RlpStackOp { is_write: true, id, - address: cur.depth, + depth: cur.depth, value: *rem - 1, value_prev: *rem, stack_acc, @@ -614,7 +614,7 @@ impl Transaction { stack_ops.push(RlpStackOp { is_write: true, id, - address: cur.depth + 1, + depth: cur.depth + 1, value: num_bytes_of_new_list, value_prev: 0, stack_acc, @@ -647,7 +647,7 @@ impl Transaction { stack_ops.push(RlpStackOp { is_write: true, id, - address: cur.depth, + depth: cur.depth, value: *rem - 1, value_prev: *rem, stack_acc, @@ -688,7 +688,7 @@ impl Transaction { stack_ops.push(RlpStackOp { is_write: true, id, - address: cur.depth, + depth: cur.depth, value: *rem - 1, value_prev: *rem, stack_acc, @@ -728,7 +728,7 @@ impl Transaction { stack_ops.push(RlpStackOp { is_write: true, id, - address: cur.depth, + depth: cur.depth, value: *rem - 1, value_prev: *rem, stack_acc, @@ -765,7 +765,7 @@ impl Transaction { stack_ops.push(RlpStackOp { is_write: true, id, - address: cur.depth + 1, + depth: cur.depth + 1, value: lb_len, value_prev: 0, stack_acc, @@ -873,11 +873,11 @@ impl Transaction { rlp_decoding_table: RlpDecodingTable { is_write: stack_op.is_write, id: stack_op.id, - address: stack_op.address, + depth: stack_op.depth, value: stack_op.value, value_prev: stack_op.value_prev, stack_acc: stack_op.stack_acc, - stack_acc_pow_of_rand: stack_acc_pow_of_rand[stack_op.address], + stack_acc_pow_of_rand: stack_acc_pow_of_rand[stack_op.depth], is_stack_init: stack_op.is_init, is_stack_push: stack_op.is_push, is_stack_pop: stack_op.is_pop, From b4dc48f0befd30d1cf872cea2104be64caf5214e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 19 Nov 2023 18:58:43 -0800 Subject: [PATCH 041/161] add instrument booleans --- zkevm-circuits/src/rlp_circuit_fsm.rs | 88 ++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 7 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 850bd3aea6..4c13e85c55 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -16,7 +16,7 @@ use crate::{ Block, DataTable, Format, RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTag, RomTableRow, State, State::{DecodeTagStart, End}, Tag, - Tag::{AccessListAddress, AccessListStorageKey, BeginObject, EndObject, TxType}, + Tag::{AccessListAddress, AccessListStorageKey, BeginObject, EndObject, TxType, EndVector}, Transaction, }, }; @@ -303,6 +303,10 @@ pub struct RlpCircuitConfig { is_new_access_list_address: Column, /// Boolean to reduce the circuit's degree is_new_access_list_storage_key: Column, + /// Boolean to reduce the circuit's degree + is_access_list_address_clear: Column, + /// Boolean to reduce the circuit's degree + is_access_list_storage_key_clear: Column, /// Decoding table depth check is_stack_depth_zero: IsZeroConfig, @@ -383,6 +387,8 @@ impl RlpCircuitConfig { is_same_rlp_instance, is_new_access_list_address, is_new_access_list_storage_key, + is_access_list_address_clear, + is_access_list_storage_key_clear, ) = ( meta.fixed_column(), meta.fixed_column(), @@ -404,6 +410,8 @@ impl RlpCircuitConfig { meta.advice_column(), meta.advice_column(), meta.advice_column(), + meta.advice_column(), + meta.advice_column(), ); let tag_value_acc = meta.advice_column_in(SecondPhase); @@ -1506,6 +1514,25 @@ impl RlpCircuitConfig { is_decode_tag_start(meta), ])) }); + meta.create_gate("boolean for reducing degree (part five)", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "is_access_list_address_clear", + meta.query_advice(is_access_list_address_clear, Rotation::cur()), + depth_eq_two.is_equal_expression.expr(), + ); + cb.require_equal( + "is_access_list_storage_key_clear", + meta.query_advice(is_access_list_storage_key_clear, Rotation::cur()), + depth_eq_four.is_equal_expression.expr(), + ); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + is_tag_end_vector(meta), + ])) + }); // Access List Increments meta.create_gate( @@ -1551,12 +1578,42 @@ impl RlpCircuitConfig { // hence using depth alone is sufficient to determine clearing conditions. // however, this might change in the future if more nested structures are introduced at same // depth level + // 1030_debug + // meta.create_gate( + // "access list: clearing access_list_idx and storage_key_idx", + // |meta| { + // let mut cb = BaseConstraintBuilder::default(); + + // cb.condition(depth_eq_two.is_equal_expression.expr(), |cb| { + // cb.require_equal( + // "al_idx = 0", + // meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + // 0.expr(), + // ); + // }); + + // cb.condition(depth_eq_four.is_equal_expression.expr(), |cb| { + // cb.require_equal( + // "sk_idx = 0", + // meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + // 0.expr(), + // ); + // }); + + // cb.gate(and::expr([ + // meta.query_fixed(q_enabled, Rotation::cur()), + // is_tag_end_vector(meta), + // ])) + // }, + // ); meta.create_gate( "access list: clearing access_list_idx and storage_key_idx", |meta| { let mut cb = BaseConstraintBuilder::default(); - cb.condition(depth_eq_two.is_equal_expression.expr(), |cb| { + cb.condition( + meta.query_advice(is_access_list_address_clear, Rotation::cur()), + |cb| { cb.require_equal( "al_idx = 0", meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), @@ -1564,7 +1621,9 @@ impl RlpCircuitConfig { ); }); - cb.condition(depth_eq_four.is_equal_expression.expr(), |cb| { + cb.condition( + meta.query_advice(is_access_list_storage_key_clear, Rotation::cur()), + |cb| { cb.require_equal( "sk_idx = 0", meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), @@ -1572,10 +1631,7 @@ impl RlpCircuitConfig { ); }); - cb.gate(and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - is_tag_end_vector(meta), - ])) + cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }, ); @@ -1798,6 +1854,8 @@ impl RlpCircuitConfig { // access list checks is_new_access_list_address, is_new_access_list_storage_key, + is_access_list_address_clear, + is_access_list_storage_key_clear, // decoding table is_stack_depth_zero, @@ -1991,6 +2049,22 @@ impl RlpCircuitConfig { row, || Value::known(F::from(is_new_access_list_storage_key as u64)), )?; + let is_access_list_address_clear = witness.state_machine.tag == EndVector + && witness.state_machine.depth == 2; + region.assign_advice( + || "is_access_list_address_clear", + self.is_access_list_address_clear, + row, + || Value::known(F::from(is_access_list_address_clear as u64)), + )?; + let is_access_list_storage_key_clear = witness.state_machine.tag == EndVector + && witness.state_machine.depth == 4; + region.assign_advice( + || "is_access_list_storage_key_clear", + self.is_access_list_storage_key_clear, + row, + || Value::known(F::from(is_access_list_storage_key_clear as u64)), + )?; let stack_depth_chip = IsZeroChip::construct(self.is_stack_depth_zero.clone()); stack_depth_chip.assign( region, From 03b4142cb0a38db8a39bcf147ae49f04dae595d9 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 19 Nov 2023 19:25:12 -0800 Subject: [PATCH 042/161] add consistency constraints for access list --- zkevm-circuits/src/rlp_circuit_fsm.rs | 50 ++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 4c13e85c55..c5b0434804 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1555,11 +1555,11 @@ impl RlpCircuitConfig { cb.condition( meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), |cb| { - cb.require_equal( - "for same storage key list, al_idx stays the same", - meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - ); + // cb.require_equal( + // "for same storage key list, al_idx stays the same", + // meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), + // meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + // ); cb.require_equal( "sk_idx - sk_idx::prev = 1", meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) @@ -1635,6 +1635,46 @@ impl RlpCircuitConfig { }, ); + // Access List Consistency + // When no conditions for access list address or storage key changes are present, these idxs stay the same + meta.create_gate( + "access list: access_list_idx and storage_key_idx don't change when no conditions present", + |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.condition( + and::expr([ + not::expr(meta.query_advice(is_new_access_list_address, Rotation::cur())), + not::expr(meta.query_advice(is_access_list_address_clear, Rotation::cur())), + ]), + |cb| { + cb.require_equal( + "al_idx stays the same", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); + }); + + cb.condition( + and::expr([ + not::expr(meta.query_advice(is_new_access_list_storage_key, Rotation::cur())), + not::expr(meta.query_advice(is_access_list_storage_key_clear, Rotation::cur())), + ]), + |cb| { + cb.require_equal( + "storage_key_idx stays the same", + meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()), + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + ); + }); + + cb.gate(and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + not::expr(meta.query_fixed(q_first, Rotation::cur())), + ])) + }, + ); + debug_assert!(meta.degree() <= 9); /////////////////////////////////////////////////////////////////// From 4b083a3419fcb8bcaa99163881bd7eeb7df47c1f Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 19 Nov 2023 19:33:30 -0800 Subject: [PATCH 043/161] add consistency constraints for access list --- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index c454fec75d..74d0632dbe 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,9 +110,9 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ - // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", + "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", // "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", - "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + // "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; let mut txs: Vec = vec![]; From 426225fb79894db4754679ed53d6f8e145df8bda Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 19 Nov 2023 19:36:44 -0800 Subject: [PATCH 044/161] adjust test --- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index 74d0632dbe..c454fec75d 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,9 +110,9 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ - "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", + // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", // "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", - // "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; let mut txs: Vec = vec![]; From a548910bac59623879cf198ee8e532b0aa544f79 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 19 Nov 2023 20:13:50 -0800 Subject: [PATCH 045/161] remove debug flag --- zkevm-circuits/src/rlp_circuit_fsm.rs | 28 --------------------------- 1 file changed, 28 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index c5b0434804..45479ec46c 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1578,34 +1578,6 @@ impl RlpCircuitConfig { // hence using depth alone is sufficient to determine clearing conditions. // however, this might change in the future if more nested structures are introduced at same // depth level - // 1030_debug - // meta.create_gate( - // "access list: clearing access_list_idx and storage_key_idx", - // |meta| { - // let mut cb = BaseConstraintBuilder::default(); - - // cb.condition(depth_eq_two.is_equal_expression.expr(), |cb| { - // cb.require_equal( - // "al_idx = 0", - // meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - // 0.expr(), - // ); - // }); - - // cb.condition(depth_eq_four.is_equal_expression.expr(), |cb| { - // cb.require_equal( - // "sk_idx = 0", - // meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - // 0.expr(), - // ); - // }); - - // cb.gate(and::expr([ - // meta.query_fixed(q_enabled, Rotation::cur()), - // is_tag_end_vector(meta), - // ])) - // }, - // ); meta.create_gate( "access list: clearing access_list_idx and storage_key_idx", |meta| { From 07bfee15fd11bbcc4d53e4a2506d1fcf65ab5471 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 19 Nov 2023 20:29:01 -0800 Subject: [PATCH 046/161] fmt --- zkevm-circuits/src/rlp_circuit_fsm.rs | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 45479ec46c..dddbbf78d5 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -16,7 +16,7 @@ use crate::{ Block, DataTable, Format, RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTag, RomTableRow, State, State::{DecodeTagStart, End}, Tag, - Tag::{AccessListAddress, AccessListStorageKey, BeginObject, EndObject, TxType, EndVector}, + Tag::{AccessListAddress, AccessListStorageKey, BeginObject, EndObject, EndVector, TxType}, Transaction, }, }; @@ -1584,31 +1584,34 @@ impl RlpCircuitConfig { let mut cb = BaseConstraintBuilder::default(); cb.condition( - meta.query_advice(is_access_list_address_clear, Rotation::cur()), + meta.query_advice(is_access_list_address_clear, Rotation::cur()), |cb| { - cb.require_equal( - "al_idx = 0", - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - 0.expr(), - ); - }); + cb.require_equal( + "al_idx = 0", + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + 0.expr(), + ); + }, + ); cb.condition( - meta.query_advice(is_access_list_storage_key_clear, Rotation::cur()), + meta.query_advice(is_access_list_storage_key_clear, Rotation::cur()), |cb| { - cb.require_equal( - "sk_idx = 0", - meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - 0.expr(), - ); - }); + cb.require_equal( + "sk_idx = 0", + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + 0.expr(), + ); + }, + ); cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }, ); // Access List Consistency - // When no conditions for access list address or storage key changes are present, these idxs stay the same + // When no conditions for access list address or storage key changes are present, these idxs + // stay the same meta.create_gate( "access list: access_list_idx and storage_key_idx don't change when no conditions present", |meta| { @@ -2061,16 +2064,16 @@ impl RlpCircuitConfig { row, || Value::known(F::from(is_new_access_list_storage_key as u64)), )?; - let is_access_list_address_clear = witness.state_machine.tag == EndVector - && witness.state_machine.depth == 2; + let is_access_list_address_clear = + witness.state_machine.tag == EndVector && witness.state_machine.depth == 2; region.assign_advice( || "is_access_list_address_clear", self.is_access_list_address_clear, row, || Value::known(F::from(is_access_list_address_clear as u64)), )?; - let is_access_list_storage_key_clear = witness.state_machine.tag == EndVector - && witness.state_machine.depth == 4; + let is_access_list_storage_key_clear = + witness.state_machine.tag == EndVector && witness.state_machine.depth == 4; region.assign_advice( || "is_access_list_storage_key_clear", self.is_access_list_storage_key_clear, From 33360c0dd83df0cfa07acc4849c5dcf26b7e160d Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 16:21:22 -0800 Subject: [PATCH 047/161] refactor accumulating coeff --- zkevm-circuits/src/witness/tx.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index cd98c3a238..9fc9d6f13f 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -403,13 +403,12 @@ impl Transaction { let mut last_bytes_on_depth: [usize; 4] = [0, 0, 0, 0]; let mut stack_acc = Value::known(F::zero()); - let mut stack_acc_pow_of_rand: Vec> = vec![]; - let mut pow_of_rand = Value::known(F::one()); - stack_acc_pow_of_rand.push(pow_of_rand); - for _ in 0..4 { - pow_of_rand = pow_of_rand * keccak_rand; - stack_acc_pow_of_rand.push(pow_of_rand); - } + let stack_acc_pow_of_rand = std::iter::successors(Some(Value::known(F::one())), |coeff| { + Some(keccak_rand * coeff) + }) + .take(5) + .collect::>>(); + // concat tx_id and format as stack identifier let id = keccak_rand * Value::known(F::from(tx_id)) + Value::known(F::from(format as u64)); // When we are decoding a vector of element type `t`, at the beginning From 87c9cc8d9594b264e5a3db3ba800fac38446e008 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 16:45:57 -0800 Subject: [PATCH 048/161] add stack op enum --- zkevm-circuits/src/rlp_circuit_fsm.rs | 9 ++--- zkevm-circuits/src/witness/rlp_fsm.rs | 18 ++++------ zkevm-circuits/src/witness/tx.rs | 47 ++++++--------------------- 3 files changed, 21 insertions(+), 53 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index dddbbf78d5..ee8be582e9 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -13,6 +13,7 @@ use crate::{ Challenges, SubCircuit, SubCircuitConfig, }, witness::{ + rlp_fsm::StackOp, Block, DataTable, Format, RlpFsmWitnessGen, RlpFsmWitnessRow, RlpTag, RomTableRow, State, State::{DecodeTagStart, End}, Tag, @@ -2027,25 +2028,25 @@ impl RlpCircuitConfig { || "rlp_decoding_table.is_stack_init", self.rlp_decoding_table.is_stack_init, row, - || Value::known(F::from(witness.rlp_decoding_table.is_stack_init as u64)), + || Value::known(F::from(matches!(witness.rlp_decoding_table.stack_op, StackOp::Init) as u64)), )?; region.assign_advice( || "rlp_decoding_table.is_stack_push", self.rlp_decoding_table.is_stack_push, row, - || Value::known(F::from(witness.rlp_decoding_table.is_stack_push as u64)), + || Value::known(F::from(matches!(witness.rlp_decoding_table.stack_op, StackOp::Push) as u64)), )?; region.assign_advice( || "rlp_decoding_table.is_stack_pop", self.rlp_decoding_table.is_stack_pop, row, - || Value::known(F::from(witness.rlp_decoding_table.is_stack_pop as u64)), + || Value::known(F::from(matches!(witness.rlp_decoding_table.stack_op, StackOp::Pop) as u64)), )?; region.assign_advice( || "rlp_decoding_table.is_stack_update", self.rlp_decoding_table.is_stack_update, row, - || Value::known(F::from(witness.rlp_decoding_table.is_stack_update as u64)), + || Value::known(F::from(matches!(witness.rlp_decoding_table.stack_op, StackOp::Update) as u64)), )?; let is_new_access_list_address = witness.state_machine.state == DecodeTagStart diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index cc55ba357a..40c64139ee 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -763,6 +763,9 @@ pub struct StateMachine { pub gas_cost_acc: Value, } +#[derive(Clone, Debug)] +pub enum StackOp { Init, Push, Pop, Update } + /// Rlp Decoding Table /// Using simulated stack constraints to make sure all bytes are correctly decoded #[derive(Clone, Debug)] @@ -784,14 +787,8 @@ pub struct RlpDecodingTable { pub stack_acc: Value, /// Power of rand for stack accumulator on depth level (address) pub stack_acc_pow_of_rand: Value, - /// Stack Operation Flag, Init - pub is_stack_init: bool, - /// Stack Operation Flag, Push - pub is_stack_push: bool, - /// Stack Operation Flag, Pop - pub is_stack_pop: bool, - /// Stack Operation Flag, Update - pub is_stack_update: bool, + /// The stack operation performed at step. + pub stack_op: StackOp, } /// Represents the witness in a single row of the RLP circuit. @@ -837,8 +834,5 @@ pub(crate) struct RlpStackOp { pub value: usize, pub value_prev: usize, pub stack_acc: Value, - pub is_init: bool, - pub is_push: bool, - pub is_pop: bool, - pub is_update: bool, + pub stack_op: StackOp, } diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 9fc9d6f13f..3f4f115733 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -3,7 +3,7 @@ use crate::{ table::TxContextFieldTag, util::{rlc_be_bytes, Challenges}, witness::{ - rlp_fsm::{RlpDecodingTable, RlpStackOp, SmState}, + rlp_fsm::{RlpDecodingTable, RlpStackOp, StackOp, SmState}, DataTable, Format, Format::{ L1MsgHash, TxHashEip155, TxHashEip1559, TxHashEip2930, TxHashPreEip155, TxSignEip155, @@ -425,10 +425,7 @@ impl Transaction { value: rlp_bytes.len(), value_prev: 0, stack_acc: Value::known(F::zero()), - is_init: true, - is_push: false, - is_pop: false, - is_update: false, + stack_op: StackOp::Init, }); let mut witness_table_idx = 0; @@ -476,10 +473,7 @@ impl Transaction { value: prev_depth_bytes, value_prev: last_bytes_on_depth[cur.depth - 1], stack_acc, - is_init: false, - is_push: false, - is_pop: true, - is_update: false, + stack_op: StackOp::Pop, }) } @@ -528,10 +522,7 @@ impl Transaction { value: *rem - 1, value_prev: *rem, stack_acc, - is_init: false, - is_push: false, - is_pop: false, - is_update: true, + stack_op: StackOp::Update, }); } @@ -625,10 +616,7 @@ impl Transaction { value: num_bytes_of_new_list, value_prev: 0, stack_acc, - is_init: false, - is_push: true, - is_pop: false, - is_update: false, + stack_op: StackOp::Push, }); next.depth = cur.depth + 1; next.state = DecodeTagStart; @@ -658,10 +646,7 @@ impl Transaction { value: *rem - 1, value_prev: *rem, stack_acc, - is_init: false, - is_push: false, - is_pop: false, - is_update: true, + stack_op: StackOp::Update, }); *rem -= 1; @@ -699,10 +684,7 @@ impl Transaction { value: *rem - 1, value_prev: *rem, stack_acc, - is_init: false, - is_push: false, - is_pop: false, - is_update: true, + stack_op: StackOp::Update, }); *rem -= 1; @@ -739,10 +721,7 @@ impl Transaction { value: *rem - 1, value_prev: *rem, stack_acc, - is_init: false, - is_push: false, - is_pop: false, - is_update: true, + stack_op: StackOp::Update, }); } @@ -776,10 +755,7 @@ impl Transaction { value: lb_len, value_prev: 0, stack_acc, - is_init: false, - is_push: true, - is_pop: false, - is_update: false, + stack_op: StackOp::Push, }); next.depth = cur.depth + 1; next.state = DecodeTagStart; @@ -885,10 +861,7 @@ impl Transaction { value_prev: stack_op.value_prev, stack_acc: stack_op.stack_acc, stack_acc_pow_of_rand: stack_acc_pow_of_rand[stack_op.depth], - is_stack_init: stack_op.is_init, - is_stack_push: stack_op.is_push, - is_stack_pop: stack_op.is_pop, - is_stack_update: stack_op.is_update, + stack_op: stack_op.stack_op, }, }); witness_table_idx += 1; From 1d92811d2c7e6a33af65a067c8847502ddf070af Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 17:01:18 -0800 Subject: [PATCH 049/161] refactor decoding table witness --- zkevm-circuits/src/rlp_circuit_fsm.rs | 6 ---- zkevm-circuits/src/witness/rlp_fsm.rs | 52 +++++++++++++++++---------- zkevm-circuits/src/witness/tx.rs | 29 ++++++--------- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index ee8be582e9..6020a0b2a5 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1982,12 +1982,6 @@ impl RlpCircuitConfig { )?; // assign to rlp decoding table - region.assign_advice( - || "rlp_decoding_table.is_write", - self.rlp_decoding_table.is_write, - row, - || Value::known(F::from(witness.rlp_decoding_table.is_write)), - )?; region.assign_advice( || "rlp_decoding_table.id", self.rlp_decoding_table.id, diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 40c64139ee..d55a0cd5bd 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -766,21 +766,44 @@ pub struct StateMachine { #[derive(Clone, Debug)] pub enum StackOp { Init, Push, Pop, Update } -/// Rlp Decoding Table -/// Using simulated stack constraints to make sure all bytes are correctly decoded + +// tx1559_debug +// /// Rlp Decoding Table +// /// Using simulated stack constraints to make sure all bytes are correctly decoded +// #[derive(Clone, Debug)] +// pub struct RlpDecodingTable { +// // note: a byte-counting idx such as rw_counter is not necessary +// // as byte_idx/byte_rev_idx can be used for the purpose +// /// Is Write to decoding stack +// pub is_write: bool, +// /// Key1 (Id), concat of tx_id, format +// pub id: Value, +// /// Key2 (Address), in this case depth +// pub depth: usize, +// /// Value +// pub value: usize, +// /// Value Previous +// pub value_prev: usize, +// /// Stack Accumulator +// /// accumulates remaining bytes on each depth level (excluding top of stack) +// pub stack_acc: Value, +// /// Power of rand for stack accumulator on depth level (address) +// pub stack_acc_pow_of_rand: Value, +// /// The stack operation performed at step. +// pub stack_op: StackOp, +// } + +/// Rlp Decoding Witness +/// Using simulated stack constraints to make sure all bytes in nested structure are correctly decoded #[derive(Clone, Debug)] -pub struct RlpDecodingTable { - // note: a byte-counting idx such as rw_counter is not necessary - // as byte_idx/byte_rev_idx can be used for the purpose - /// Is Write to decoding stack - pub is_write: bool, +pub struct RlpStackOp { /// Key1 (Id), concat of tx_id, format pub id: Value, /// Key2 (Address), in this case depth pub depth: usize, /// Value pub value: usize, - /// Value Previous + /// Value Previous pub value_prev: usize, /// Stack Accumulator /// accumulates remaining bytes on each depth level (excluding top of stack) @@ -799,7 +822,7 @@ pub struct RlpFsmWitnessRow { /// The state machine witness. pub state_machine: StateMachine, /// The rlp decoding table witness - pub rlp_decoding_table: RlpDecodingTable, + pub rlp_decoding_table: RlpStackOp, } /// The RlpFsmWitnessGen trait is implemented by data types who's RLP encoding can @@ -826,13 +849,4 @@ pub(crate) struct SmState { pub(crate) tag_bytes_rlc: Value, } -#[derive(Clone)] -pub(crate) struct RlpStackOp { - pub is_write: bool, - pub id: Value, - pub depth: usize, - pub value: usize, - pub value_prev: usize, - pub stack_acc: Value, - pub stack_op: StackOp, -} + diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 3f4f115733..13888b62ac 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -3,7 +3,7 @@ use crate::{ table::TxContextFieldTag, util::{rlc_be_bytes, Challenges}, witness::{ - rlp_fsm::{RlpDecodingTable, RlpStackOp, StackOp, SmState}, + rlp_fsm::{RlpStackOp, StackOp, SmState}, DataTable, Format, Format::{ L1MsgHash, TxHashEip155, TxHashEip1559, TxHashEip2930, TxHashPreEip155, TxSignEip155, @@ -419,12 +419,12 @@ impl Transaction { let mut remaining_bytes = vec![rlp_bytes.len()]; // initialize stack stack_ops.push(RlpStackOp { - is_write: true, id, depth: cur.depth, value: rlp_bytes.len(), value_prev: 0, stack_acc: Value::known(F::zero()), + stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], stack_op: StackOp::Init, }); let mut witness_table_idx = 0; @@ -467,12 +467,12 @@ impl Transaction { - stack_acc_pow_of_rand[cur.depth - 1] * Value::known(F::from(prev_depth_bytes as u64)); stack_ops.push(RlpStackOp { - is_write: true, id, depth: cur.depth - 1, value: prev_depth_bytes, value_prev: last_bytes_on_depth[cur.depth - 1], stack_acc, + stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth - 1], stack_op: StackOp::Pop, }) } @@ -516,12 +516,12 @@ impl Transaction { if !(0xc0..=0xf7).contains(&byte_value) { // add stack op on same depth stack_ops.push(RlpStackOp { - is_write: true, id, depth: cur.depth, value: *rem - 1, value_prev: *rem, stack_acc, + stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], stack_op: StackOp::Update, }); } @@ -610,12 +610,12 @@ impl Transaction { remaining_bytes.push(num_bytes_of_new_list); stack_ops.push(RlpStackOp { - is_write: true, id, depth: cur.depth + 1, value: num_bytes_of_new_list, value_prev: 0, stack_acc, + stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth + 1], stack_op: StackOp::Push, }); next.depth = cur.depth + 1; @@ -640,12 +640,12 @@ impl Transaction { // add stack op on same depth stack_ops.push(RlpStackOp { - is_write: true, id, depth: cur.depth, value: *rem - 1, value_prev: *rem, stack_acc, + stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], stack_op: StackOp::Update, }); @@ -678,12 +678,12 @@ impl Transaction { // add stack op on same depth stack_ops.push(RlpStackOp { - is_write: true, id, depth: cur.depth, value: *rem - 1, value_prev: *rem, stack_acc, + stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], stack_op: StackOp::Update, }); @@ -715,12 +715,12 @@ impl Transaction { // add stack op on same depth if cur.tag_idx < cur.tag_length { stack_ops.push(RlpStackOp { - is_write: true, id, depth: cur.depth, value: *rem - 1, value_prev: *rem, stack_acc, + stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], stack_op: StackOp::Update, }); } @@ -749,12 +749,12 @@ impl Transaction { } remaining_bytes.push(lb_len); stack_ops.push(RlpStackOp { - is_write: true, id, depth: cur.depth + 1, value: lb_len, value_prev: 0, stack_acc, + stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth + 1], stack_op: StackOp::Push, }); next.depth = cur.depth + 1; @@ -853,16 +853,7 @@ impl Transaction { bytes_rlc, gas_cost_acc, }, - rlp_decoding_table: RlpDecodingTable { - is_write: stack_op.is_write, - id: stack_op.id, - depth: stack_op.depth, - value: stack_op.value, - value_prev: stack_op.value_prev, - stack_acc: stack_op.stack_acc, - stack_acc_pow_of_rand: stack_acc_pow_of_rand[stack_op.depth], - stack_op: stack_op.stack_op, - }, + rlp_decoding_table: stack_op, }); witness_table_idx += 1; From 337b49c93d629bffcd50163260e8bc5e6b85a1a2 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 17:21:13 -0800 Subject: [PATCH 050/161] refactor access list indicator columns --- zkevm-circuits/src/rlp_circuit_fsm.rs | 64 ++++++++++++++++++--------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 6020a0b2a5..341718d612 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -301,13 +301,17 @@ pub struct RlpCircuitConfig { is_same_rlp_instance: Column, /// Boolean to reduce the circuit's degree + /// Indicates the start of another new access list item is_new_access_list_address: Column, /// Boolean to reduce the circuit's degree + /// Indicates the start of another new storage key for an access list address is_new_access_list_storage_key: Column, /// Boolean to reduce the circuit's degree - is_access_list_address_clear: Column, + /// Indicates the end of access list + is_access_list_end: Column, /// Boolean to reduce the circuit's degree - is_access_list_storage_key_clear: Column, + /// Indicates the end of storage key list in a particular access list item + is_storage_key_list_end: Column, /// Decoding table depth check is_stack_depth_zero: IsZeroConfig, @@ -388,8 +392,8 @@ impl RlpCircuitConfig { is_same_rlp_instance, is_new_access_list_address, is_new_access_list_storage_key, - is_access_list_address_clear, - is_access_list_storage_key_clear, + is_access_list_end, + is_storage_key_list_end, ) = ( meta.fixed_column(), meta.fixed_column(), @@ -1509,6 +1513,14 @@ impl RlpCircuitConfig { meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), is_access_list_storage_key(meta), ); + cb.require_boolean( + "is_new_access_list_address is boolean", + meta.query_advice(is_new_access_list_address, Rotation::cur()) + ); + cb.require_boolean( + "is_new_access_list_storage_key is boolean", + meta.query_advice(is_new_access_list_storage_key, Rotation::cur()) + ); cb.gate(and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), @@ -1519,15 +1531,23 @@ impl RlpCircuitConfig { let mut cb = BaseConstraintBuilder::default(); cb.require_equal( - "is_access_list_address_clear", - meta.query_advice(is_access_list_address_clear, Rotation::cur()), + "is_access_list_end", + meta.query_advice(is_access_list_end, Rotation::cur()), depth_eq_two.is_equal_expression.expr(), ); cb.require_equal( - "is_access_list_storage_key_clear", - meta.query_advice(is_access_list_storage_key_clear, Rotation::cur()), + "is_storage_key_list_end", + meta.query_advice(is_storage_key_list_end, Rotation::cur()), depth_eq_four.is_equal_expression.expr(), ); + cb.require_boolean( + "is_access_list_end is boolean", + meta.query_advice(is_access_list_end, Rotation::cur()) + ); + cb.require_boolean( + "is_storage_key_list_end is boolean", + meta.query_advice(is_storage_key_list_end, Rotation::cur()) + ); cb.gate(and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), @@ -1585,7 +1605,7 @@ impl RlpCircuitConfig { let mut cb = BaseConstraintBuilder::default(); cb.condition( - meta.query_advice(is_access_list_address_clear, Rotation::cur()), + meta.query_advice(is_access_list_end, Rotation::cur()), |cb| { cb.require_equal( "al_idx = 0", @@ -1596,7 +1616,7 @@ impl RlpCircuitConfig { ); cb.condition( - meta.query_advice(is_access_list_storage_key_clear, Rotation::cur()), + meta.query_advice(is_storage_key_list_end, Rotation::cur()), |cb| { cb.require_equal( "sk_idx = 0", @@ -1621,7 +1641,7 @@ impl RlpCircuitConfig { cb.condition( and::expr([ not::expr(meta.query_advice(is_new_access_list_address, Rotation::cur())), - not::expr(meta.query_advice(is_access_list_address_clear, Rotation::cur())), + not::expr(meta.query_advice(is_access_list_end, Rotation::cur())), ]), |cb| { cb.require_equal( @@ -1634,7 +1654,7 @@ impl RlpCircuitConfig { cb.condition( and::expr([ not::expr(meta.query_advice(is_new_access_list_storage_key, Rotation::cur())), - not::expr(meta.query_advice(is_access_list_storage_key_clear, Rotation::cur())), + not::expr(meta.query_advice(is_storage_key_list_end, Rotation::cur())), ]), |cb| { cb.require_equal( @@ -1870,8 +1890,8 @@ impl RlpCircuitConfig { // access list checks is_new_access_list_address, is_new_access_list_storage_key, - is_access_list_address_clear, - is_access_list_storage_key_clear, + is_access_list_end, + is_storage_key_list_end, // decoding table is_stack_depth_zero, @@ -2059,21 +2079,21 @@ impl RlpCircuitConfig { row, || Value::known(F::from(is_new_access_list_storage_key as u64)), )?; - let is_access_list_address_clear = + let is_access_list_end = witness.state_machine.tag == EndVector && witness.state_machine.depth == 2; region.assign_advice( - || "is_access_list_address_clear", - self.is_access_list_address_clear, + || "is_access_list_end", + self.is_access_list_end, row, - || Value::known(F::from(is_access_list_address_clear as u64)), + || Value::known(F::from(is_access_list_end as u64)), )?; - let is_access_list_storage_key_clear = + let is_storage_key_list_end = witness.state_machine.tag == EndVector && witness.state_machine.depth == 4; region.assign_advice( - || "is_access_list_storage_key_clear", - self.is_access_list_storage_key_clear, + || "is_storage_key_list_end", + self.is_storage_key_list_end, row, - || Value::known(F::from(is_access_list_storage_key_clear as u64)), + || Value::known(F::from(is_storage_key_list_end as u64)), )?; let stack_depth_chip = IsZeroChip::construct(self.is_stack_depth_zero.clone()); stack_depth_chip.assign( From fd60ba1d1aa3949bbb3fb123d8d040336d133957 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 17:22:41 -0800 Subject: [PATCH 051/161] remove auto code --- zkevm-circuits/src/rlp_circuit_fsm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 341718d612..833bc73f71 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1558,7 +1558,7 @@ impl RlpCircuitConfig { // Access List Increments meta.create_gate( "access list: access_list_idx increments", - |meta: &mut VirtualCells<'_, F>| { + |meta| { let mut cb = BaseConstraintBuilder::default(); cb.condition( From c1d1fd76e9d7d92b7f0e277a2516bcce22712fb3 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 17:30:26 -0800 Subject: [PATCH 052/161] refactor syntax --- zkevm-circuits/src/rlp_circuit_fsm.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 833bc73f71..a7ca4eb386 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1607,10 +1607,9 @@ impl RlpCircuitConfig { cb.condition( meta.query_advice(is_access_list_end, Rotation::cur()), |cb| { - cb.require_equal( + cb.require_zero( "al_idx = 0", meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - 0.expr(), ); }, ); @@ -1618,10 +1617,9 @@ impl RlpCircuitConfig { cb.condition( meta.query_advice(is_storage_key_list_end, Rotation::cur()), |cb| { - cb.require_equal( + cb.require_zero( "sk_idx = 0", meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - 0.expr(), ); }, ); From d5d81bcd704db927374c1f4549203a5b8fc9fd4c Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 18:00:48 -0800 Subject: [PATCH 053/161] remove comment --- zkevm-circuits/src/rlp_circuit_fsm.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index a7ca4eb386..7a76ab8afe 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1576,11 +1576,6 @@ impl RlpCircuitConfig { cb.condition( meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), |cb| { - // cb.require_equal( - // "for same storage key list, al_idx stays the same", - // meta.query_advice(rlp_table.access_list_idx, Rotation::prev()), - // meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - // ); cb.require_equal( "sk_idx - sk_idx::prev = 1", meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) From 4b7cb37ac779f2d7668609d6db3b91a5cfc32838 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 18:09:03 -0800 Subject: [PATCH 054/161] add comment --- zkevm-circuits/src/rlp_circuit_fsm.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 7a76ab8afe..cbc7c1dbe3 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1764,6 +1764,8 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) + (meta.query_advice(rlp_decoding_table.value, Rotation::prev()) - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + // 1 byte needs to be subtracted here as the step preceding the PUSH reads one byte from the lower depth + // This byte is already consumed and won't be added to the accumulator - 1.expr()) * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), From a88a3ea84a60863fc94f6d4d5e7826c7d7f2de60 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 18:27:07 -0800 Subject: [PATCH 055/161] add missing constraints --- zkevm-circuits/src/rlp_circuit_fsm.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index cbc7c1dbe3..2ef60352ba 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1741,7 +1741,11 @@ impl RlpCircuitConfig { "stack_acc accumulates depth 0 bytes at 1", meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), 1.expr() - ) + ); + cb.require_zero( + "stack accumulator starts at 0", + meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + ); }, ); @@ -1749,6 +1753,10 @@ impl RlpCircuitConfig { cb.condition( meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), |cb| { + cb.require_zero( + "The higher depth must have 0 bytes.", + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), + ); cb.require_equal( "PUSH stack operation increases depth", meta.query_advice(rlp_decoding_table.depth, Rotation::prev()) + 1.expr(), @@ -1815,6 +1823,11 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + 1.expr(), meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), ); + cb.require_equal( + "UPDATE stack operation doesn't skip bytes", + meta.query_advice(rlp_decoding_table.value, Rotation::prev()), + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), + ); cb.require_equal( "UPDATE doesn't change stack_acc", meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()), From 01a42d2612b8e7b866ed92d9f9712066e5ec4ba2 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 18:31:09 -0800 Subject: [PATCH 056/161] refactor syntax --- zkevm-circuits/src/rlp_circuit_fsm.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 2ef60352ba..87973d6ab1 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1699,29 +1699,21 @@ impl RlpCircuitConfig { ); }); - cb.require_zero( + cb.require_boolean( "is_stack_init is binary", - meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur()) - * (1.expr() - - meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur())), + meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur()), ); - cb.require_zero( + cb.require_boolean( "is_stack_push is binary", - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()) - * (1.expr() - - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur())), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), ); - cb.require_zero( + cb.require_boolean( "is_stack_pop is binary", - meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()) - * (1.expr() - - meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur())), + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), ); - cb.require_zero( + cb.require_boolean( "is_stack_update is binary", - meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()) - * (1.expr() - - meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur())), + meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), ); // Stack Init From b7b9ca10f67db28f9748de00c095e6f7ee7b3acc Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 18:46:59 -0800 Subject: [PATCH 057/161] debug commit --- zkevm-circuits/src/rlp_circuit_fsm.rs | 2 ++ zkevm-circuits/src/witness/rlp_fsm.rs | 27 --------------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 87973d6ab1..b6fac16c69 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -2429,6 +2429,8 @@ impl RlpCircuitConfig { log::debug!("num_sm_rows: {}", sm_rows.len()); log::debug!("num_dt_rows: {}", dt_rows.len()); + log::debug!("=> [Execution RlpCircuitConfig] assign - sm_rows: {:?}", sm_rows); + layouter.assign_region( || "RLP data table region", |mut region| { diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index d55a0cd5bd..d5e3e1d19e 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -766,33 +766,6 @@ pub struct StateMachine { #[derive(Clone, Debug)] pub enum StackOp { Init, Push, Pop, Update } - -// tx1559_debug -// /// Rlp Decoding Table -// /// Using simulated stack constraints to make sure all bytes are correctly decoded -// #[derive(Clone, Debug)] -// pub struct RlpDecodingTable { -// // note: a byte-counting idx such as rw_counter is not necessary -// // as byte_idx/byte_rev_idx can be used for the purpose -// /// Is Write to decoding stack -// pub is_write: bool, -// /// Key1 (Id), concat of tx_id, format -// pub id: Value, -// /// Key2 (Address), in this case depth -// pub depth: usize, -// /// Value -// pub value: usize, -// /// Value Previous -// pub value_prev: usize, -// /// Stack Accumulator -// /// accumulates remaining bytes on each depth level (excluding top of stack) -// pub stack_acc: Value, -// /// Power of rand for stack accumulator on depth level (address) -// pub stack_acc_pow_of_rand: Value, -// /// The stack operation performed at step. -// pub stack_op: StackOp, -// } - /// Rlp Decoding Witness /// Using simulated stack constraints to make sure all bytes in nested structure are correctly decoded #[derive(Clone, Debug)] From 2d5b3dd5783920198f606dae99591219362b428e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 18:50:22 -0800 Subject: [PATCH 058/161] remove debug line --- zkevm-circuits/src/rlp_circuit_fsm.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index b6fac16c69..87973d6ab1 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -2429,8 +2429,6 @@ impl RlpCircuitConfig { log::debug!("num_sm_rows: {}", sm_rows.len()); log::debug!("num_dt_rows: {}", dt_rows.len()); - log::debug!("=> [Execution RlpCircuitConfig] assign - sm_rows: {:?}", sm_rows); - layouter.assign_region( || "RLP data table region", |mut region| { From e6802fd200b87554d9a5fc596db8d1aab10ab117 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 19:20:55 -0800 Subject: [PATCH 059/161] refactor constructor --- zkevm-circuits/src/witness/rlp_fsm.rs | 17 +++++++++++++++++ zkevm-circuits/src/witness/tx.rs | 10 +--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index d5e3e1d19e..264d267029 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -787,6 +787,23 @@ pub struct RlpStackOp { pub stack_op: StackOp, } +impl RlpStackOp { + pub fn init( + id: Value, + value: usize, + ) -> Self { + Self { + id, + depth: 0, + value, + value_prev: 0, + stack_acc: Value::known(F::zero()), + stack_acc_pow_of_rand: Value::known(F::one()), + stack_op: StackOp::Init, + } + } +} + /// Represents the witness in a single row of the RLP circuit. #[derive(Clone, Debug)] pub struct RlpFsmWitnessRow { diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 13888b62ac..9936a837d1 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -418,15 +418,7 @@ impl Transaction { let mut cur_rom_row = vec![0]; let mut remaining_bytes = vec![rlp_bytes.len()]; // initialize stack - stack_ops.push(RlpStackOp { - id, - depth: cur.depth, - value: rlp_bytes.len(), - value_prev: 0, - stack_acc: Value::known(F::zero()), - stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], - stack_op: StackOp::Init, - }); + stack_ops.push(RlpStackOp::init(id, rlp_bytes.len())); let mut witness_table_idx = 0; // This map keeps track From 5062b33e485576fe056d17c71013d62e9f1193c1 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 19:47:49 -0800 Subject: [PATCH 060/161] refactor push constructor --- zkevm-circuits/src/witness/rlp_fsm.rs | 17 +++++++++++++++++ zkevm-circuits/src/witness/tx.rs | 25 +++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 264d267029..44be236f78 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -802,6 +802,23 @@ impl RlpStackOp { stack_op: StackOp::Init, } } + pub fn push( + id: Value, + depth: usize, + value: usize, + stack_acc: Value, + stack_acc_pow_of_rand: Value, + ) -> Self { + Self { + id, + depth, + value, + value_prev: 0, + stack_acc, + stack_acc_pow_of_rand, + stack_op: StackOp::Push, + } + } } /// Represents the witness in a single row of the RLP circuit. diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 9936a837d1..e226c51a88 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -601,15 +601,14 @@ impl Transaction { } remaining_bytes.push(num_bytes_of_new_list); - stack_ops.push(RlpStackOp { + stack_ops.push(RlpStackOp::push( id, - depth: cur.depth + 1, - value: num_bytes_of_new_list, - value_prev: 0, + cur.depth + 1, + num_bytes_of_new_list, stack_acc, - stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth + 1], - stack_op: StackOp::Push, - }); + stack_acc_pow_of_rand[cur.depth + 1] + )); + next.depth = cur.depth + 1; next.state = DecodeTagStart; } else { @@ -740,15 +739,13 @@ impl Transaction { *rem -= lb_len; } remaining_bytes.push(lb_len); - stack_ops.push(RlpStackOp { + stack_ops.push(RlpStackOp::push( id, - depth: cur.depth + 1, - value: lb_len, - value_prev: 0, + cur.depth + 1, + lb_len, stack_acc, - stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth + 1], - stack_op: StackOp::Push, - }); + stack_acc_pow_of_rand[cur.depth + 1] + )); next.depth = cur.depth + 1; next.state = DecodeTagStart; } From 36d5adb6eccac72a3c5d27d96d8126fb632223c5 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 19:51:24 -0800 Subject: [PATCH 061/161] refactor pop constructor --- zkevm-circuits/src/witness/rlp_fsm.rs | 18 ++++++++++++++++++ zkevm-circuits/src/witness/tx.rs | 14 +++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 44be236f78..b9218ad5b0 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -819,6 +819,24 @@ impl RlpStackOp { stack_op: StackOp::Push, } } + pub fn pop( + id: Value, + depth: usize, + value: usize, + value_prev: usize, + stack_acc: Value, + stack_acc_pow_of_rand: Value, + ) -> Self { + Self { + id, + depth, + value, + value_prev, + stack_acc, + stack_acc_pow_of_rand, + stack_op: StackOp::Pop, + } + } } /// Represents the witness in a single row of the RLP circuit. diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index e226c51a88..91e7a8532e 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -458,15 +458,15 @@ impl Transaction { stack_acc = stack_acc - stack_acc_pow_of_rand[cur.depth - 1] * Value::known(F::from(prev_depth_bytes as u64)); - stack_ops.push(RlpStackOp { + + stack_ops.push(RlpStackOp::pop( id, - depth: cur.depth - 1, - value: prev_depth_bytes, - value_prev: last_bytes_on_depth[cur.depth - 1], + cur.depth - 1, + prev_depth_bytes, + last_bytes_on_depth[cur.depth - 1], stack_acc, - stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth - 1], - stack_op: StackOp::Pop, - }) + stack_acc_pow_of_rand[cur.depth - 1], + )); } if cur.depth == 1 { From 18efd55d99e054dbfa87b9b700ccb3fb09a2f18b Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 20:18:32 -0800 Subject: [PATCH 062/161] refactor update --- zkevm-circuits/src/witness/rlp_fsm.rs | 17 ++++++++++ zkevm-circuits/src/witness/tx.rs | 48 +++++++++++---------------- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index b9218ad5b0..c492763ba6 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -837,6 +837,23 @@ impl RlpStackOp { stack_op: StackOp::Pop, } } + pub fn update( + id: Value, + depth: usize, + value: usize, + stack_acc: Value, + stack_acc_pow_of_rand: Value, + ) -> Self { + Self { + id, + depth, + value, + value_prev: value + 1, + stack_acc, + stack_acc_pow_of_rand, + stack_op: StackOp::Update, + } + } } /// Represents the witness in a single row of the RLP circuit. diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 91e7a8532e..435fbcef09 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -507,15 +507,13 @@ impl Transaction { if !(0xc0..=0xf7).contains(&byte_value) { // add stack op on same depth - stack_ops.push(RlpStackOp { + stack_ops.push(RlpStackOp::update( id, - depth: cur.depth, - value: *rem - 1, - value_prev: *rem, + cur.depth, + *rem - 1, stack_acc, - stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], - stack_op: StackOp::Update, - }); + stack_acc_pow_of_rand[cur.depth], + )); } *rem -= 1; @@ -630,15 +628,13 @@ impl Transaction { assert!(*rem >= 1); // add stack op on same depth - stack_ops.push(RlpStackOp { + stack_ops.push(RlpStackOp::update( id, - depth: cur.depth, - value: *rem - 1, - value_prev: *rem, + cur.depth, + *rem - 1, stack_acc, - stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], - stack_op: StackOp::Update, - }); + stack_acc_pow_of_rand[cur.depth], + )); *rem -= 1; } @@ -668,15 +664,13 @@ impl Transaction { assert!(*rem >= 1); // add stack op on same depth - stack_ops.push(RlpStackOp { + stack_ops.push(RlpStackOp::update( id, - depth: cur.depth, - value: *rem - 1, - value_prev: *rem, + cur.depth, + *rem - 1, stack_acc, - stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], - stack_op: StackOp::Update, - }); + stack_acc_pow_of_rand[cur.depth], + )); *rem -= 1; } @@ -705,15 +699,13 @@ impl Transaction { // add stack op on same depth if cur.tag_idx < cur.tag_length { - stack_ops.push(RlpStackOp { + stack_ops.push(RlpStackOp::update( id, - depth: cur.depth, - value: *rem - 1, - value_prev: *rem, + cur.depth, + *rem - 1, stack_acc, - stack_acc_pow_of_rand: stack_acc_pow_of_rand[cur.depth], - stack_op: StackOp::Update, - }); + stack_acc_pow_of_rand[cur.depth], + )); } *rem -= 1; From 153cc38020262ae6898248d9551ca24f4b334aec Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 20:19:13 -0800 Subject: [PATCH 063/161] fmt --- zkevm-circuits/src/rlp_circuit_fsm.rs | 93 +++++++++++++++------------ zkevm-circuits/src/witness/rlp_fsm.rs | 19 +++--- zkevm-circuits/src/witness/tx.rs | 10 +-- 3 files changed, 67 insertions(+), 55 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 87973d6ab1..20be4b9b3b 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1514,12 +1514,12 @@ impl RlpCircuitConfig { is_access_list_storage_key(meta), ); cb.require_boolean( - "is_new_access_list_address is boolean", - meta.query_advice(is_new_access_list_address, Rotation::cur()) + "is_new_access_list_address is boolean", + meta.query_advice(is_new_access_list_address, Rotation::cur()), ); cb.require_boolean( - "is_new_access_list_storage_key is boolean", - meta.query_advice(is_new_access_list_storage_key, Rotation::cur()) + "is_new_access_list_storage_key is boolean", + meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), ); cb.gate(and::expr([ @@ -1541,12 +1541,12 @@ impl RlpCircuitConfig { depth_eq_four.is_equal_expression.expr(), ); cb.require_boolean( - "is_access_list_end is boolean", - meta.query_advice(is_access_list_end, Rotation::cur()) + "is_access_list_end is boolean", + meta.query_advice(is_access_list_end, Rotation::cur()), ); cb.require_boolean( - "is_storage_key_list_end is boolean", - meta.query_advice(is_storage_key_list_end, Rotation::cur()) + "is_storage_key_list_end is boolean", + meta.query_advice(is_storage_key_list_end, Rotation::cur()), ); cb.gate(and::expr([ @@ -1556,38 +1556,33 @@ impl RlpCircuitConfig { }); // Access List Increments - meta.create_gate( - "access list: access_list_idx increments", - |meta| { - let mut cb = BaseConstraintBuilder::default(); + meta.create_gate("access list: access_list_idx increments", |meta| { + let mut cb = BaseConstraintBuilder::default(); - cb.condition( - meta.query_advice(is_new_access_list_address, Rotation::cur()), - |cb| { - cb.require_equal( - "al_idx - al_idx::prev = 1", - meta.query_advice(rlp_table.access_list_idx, Rotation::prev()) - + 1.expr(), - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - ); - }, - ); + cb.condition( + meta.query_advice(is_new_access_list_address, Rotation::cur()), + |cb| { + cb.require_equal( + "al_idx - al_idx::prev = 1", + meta.query_advice(rlp_table.access_list_idx, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + ); + }, + ); - cb.condition( - meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), - |cb| { - cb.require_equal( - "sk_idx - sk_idx::prev = 1", - meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) - + 1.expr(), - meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), - ); - }, - ); + cb.condition( + meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), + |cb| { + cb.require_equal( + "sk_idx - sk_idx::prev = 1", + meta.query_advice(rlp_table.storage_key_idx, Rotation::prev()) + 1.expr(), + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + ); + }, + ); - cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) - }, - ); + cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) + }); // Access List Clearing // note: right now no other nested structures are defined at these depth levels @@ -2042,25 +2037,41 @@ impl RlpCircuitConfig { || "rlp_decoding_table.is_stack_init", self.rlp_decoding_table.is_stack_init, row, - || Value::known(F::from(matches!(witness.rlp_decoding_table.stack_op, StackOp::Init) as u64)), + || { + Value::known(F::from( + matches!(witness.rlp_decoding_table.stack_op, StackOp::Init) as u64, + )) + }, )?; region.assign_advice( || "rlp_decoding_table.is_stack_push", self.rlp_decoding_table.is_stack_push, row, - || Value::known(F::from(matches!(witness.rlp_decoding_table.stack_op, StackOp::Push) as u64)), + || { + Value::known(F::from( + matches!(witness.rlp_decoding_table.stack_op, StackOp::Push) as u64, + )) + }, )?; region.assign_advice( || "rlp_decoding_table.is_stack_pop", self.rlp_decoding_table.is_stack_pop, row, - || Value::known(F::from(matches!(witness.rlp_decoding_table.stack_op, StackOp::Pop) as u64)), + || { + Value::known(F::from( + matches!(witness.rlp_decoding_table.stack_op, StackOp::Pop) as u64, + )) + }, )?; region.assign_advice( || "rlp_decoding_table.is_stack_update", self.rlp_decoding_table.is_stack_update, row, - || Value::known(F::from(matches!(witness.rlp_decoding_table.stack_op, StackOp::Update) as u64)), + || { + Value::known(F::from( + matches!(witness.rlp_decoding_table.stack_op, StackOp::Update) as u64, + )) + }, )?; let is_new_access_list_address = witness.state_machine.state == DecodeTagStart diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index c492763ba6..f7d257f27d 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -764,10 +764,16 @@ pub struct StateMachine { } #[derive(Clone, Debug)] -pub enum StackOp { Init, Push, Pop, Update } +pub enum StackOp { + Init, + Push, + Pop, + Update, +} /// Rlp Decoding Witness -/// Using simulated stack constraints to make sure all bytes in nested structure are correctly decoded +/// Using simulated stack constraints to make sure all bytes in nested structure are correctly +/// decoded #[derive(Clone, Debug)] pub struct RlpStackOp { /// Key1 (Id), concat of tx_id, format @@ -776,7 +782,7 @@ pub struct RlpStackOp { pub depth: usize, /// Value pub value: usize, - /// Value Previous + /// Value Previous pub value_prev: usize, /// Stack Accumulator /// accumulates remaining bytes on each depth level (excluding top of stack) @@ -788,10 +794,7 @@ pub struct RlpStackOp { } impl RlpStackOp { - pub fn init( - id: Value, - value: usize, - ) -> Self { + pub fn init(id: Value, value: usize) -> Self { Self { id, depth: 0, @@ -890,5 +893,3 @@ pub(crate) struct SmState { pub(crate) tag_value_acc: Value, pub(crate) tag_bytes_rlc: Value, } - - diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 435fbcef09..39839350d4 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -3,7 +3,7 @@ use crate::{ table::TxContextFieldTag, util::{rlc_be_bytes, Challenges}, witness::{ - rlp_fsm::{RlpStackOp, StackOp, SmState}, + rlp_fsm::{RlpStackOp, SmState, StackOp}, DataTable, Format, Format::{ L1MsgHash, TxHashEip155, TxHashEip1559, TxHashEip2930, TxHashPreEip155, TxSignEip155, @@ -458,7 +458,7 @@ impl Transaction { stack_acc = stack_acc - stack_acc_pow_of_rand[cur.depth - 1] * Value::known(F::from(prev_depth_bytes as u64)); - + stack_ops.push(RlpStackOp::pop( id, cur.depth - 1, @@ -604,7 +604,7 @@ impl Transaction { cur.depth + 1, num_bytes_of_new_list, stack_acc, - stack_acc_pow_of_rand[cur.depth + 1] + stack_acc_pow_of_rand[cur.depth + 1], )); next.depth = cur.depth + 1; @@ -736,7 +736,7 @@ impl Transaction { cur.depth + 1, lb_len, stack_acc, - stack_acc_pow_of_rand[cur.depth + 1] + stack_acc_pow_of_rand[cur.depth + 1], )); next.depth = cur.depth + 1; next.state = DecodeTagStart; @@ -834,7 +834,7 @@ impl Transaction { bytes_rlc, gas_cost_acc, }, - rlp_decoding_table: stack_op, + rlp_decoding_table: stack_op, }); witness_table_idx += 1; From 050ddae4f1e31d38f3617d78bd5996fc1dcecdb5 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 22 Nov 2023 20:19:54 -0800 Subject: [PATCH 064/161] remove import --- zkevm-circuits/src/witness/tx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 39839350d4..82acb87f10 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -3,7 +3,7 @@ use crate::{ table::TxContextFieldTag, util::{rlc_be_bytes, Challenges}, witness::{ - rlp_fsm::{RlpStackOp, SmState, StackOp}, + rlp_fsm::{RlpStackOp, SmState}, DataTable, Format, Format::{ L1MsgHash, TxHashEip155, TxHashEip1559, TxHashEip2930, TxHashPreEip155, TxSignEip155, From 6436acabf72721fae1dae3431441dc7fdb6d3703 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 29 Nov 2023 15:55:56 -0800 Subject: [PATCH 065/161] debug commit --- zkevm-circuits/src/tx_circuit/test.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index 1b45bbf4b1..2529c6554c 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -134,6 +134,21 @@ fn run( prover.verify_at_rows_par(0..active_row_num, 0..active_row_num) } +// tx1559_debug +#[test] +// #[cfg(feature = "scroll")] +fn tx_circuit_1tx_2max_debug() { + const MAX_TXS: usize = 1; + const MAX_CALLDATA: usize = 320; + + let tx = build_pre_eip155_tx(); + + assert_eq!( + run::(vec![tx], *mock::MOCK_CHAIN_ID, MAX_TXS, MAX_CALLDATA, 0), + Ok(()) + ); +} + #[test] #[cfg(feature = "scroll")] fn tx_circuit_2tx_2max_tx() { From 9f66260b9de257e3cae0991c09bd37a0b977f7f6 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 29 Nov 2023 20:51:56 -0800 Subject: [PATCH 066/161] restore test. fix lookup conditional --- eth-types/src/geth_types.rs | 15 +++++ zkevm-circuits/src/tx_circuit.rs | 85 ++++++++++++++++++++++----- zkevm-circuits/src/tx_circuit/test.rs | 62 ++++++++++++++++--- zkevm-circuits/src/witness/tx.rs | 8 ++- 4 files changed, 145 insertions(+), 25 deletions(-) diff --git a/eth-types/src/geth_types.rs b/eth-types/src/geth_types.rs index e0ee50ead5..2f9a2aaa1a 100644 --- a/eth-types/src/geth_types.rs +++ b/eth-types/src/geth_types.rs @@ -52,11 +52,26 @@ impl TxType { matches!(*self, TxType::L1Msg) } + /// If this type is PreEip155 + pub fn is_pre_eip155(&self) -> bool { + matches!(*self, TxType::PreEip155) + } + /// If this type is Eip155 or not pub fn is_eip155_tx(&self) -> bool { matches!(*self, TxType::Eip155) } + /// If this type is Eip2930 or not + pub fn is_eip2930(&self) -> bool { + matches!(*self, TxType::Eip2930) + } + + /// If this type is Eip1559 or not + pub fn is_eip1559(&self) -> bool { + matches!(*self, TxType::Eip1559) + } + /// Get the type of transaction pub fn get_tx_type(tx: &crate::Transaction) -> Self { match tx.transaction_type { diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 1b11867ff1..49228e1ba7 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -32,7 +32,7 @@ use crate::{ witness, witness::{ rlp_fsm::{Tag, ValueTagLength}, - Format::{L1MsgHash, TxHashEip155, TxHashPreEip155, TxSignEip155, TxSignPreEip155}, + Format::{L1MsgHash, TxHashEip155, TxHashPreEip155, TxSignEip155, TxSignPreEip155, TxSignEip2930, TxSignEip1559, TxHashEip2930, TxHashEip1559}, RlpTag, RlpTag::{GasCost, Len, Null, RLC}, Tag::TxType as RLPTxType, @@ -43,7 +43,7 @@ use bus_mapping::circuit_input_builder::keccak_inputs_sign_verify; use eth_types::{ geth_types::{ TxType, - TxType::{Eip155, L1Msg, PreEip155}, + TxType::{Eip155, L1Msg, PreEip155, Eip2930, Eip1559}, }, sign_types::SignData, Address, Field, ToAddress, ToBigEndian, ToScalar, @@ -144,6 +144,8 @@ pub struct TxCircuitConfig { is_calldata: Column, is_caller_address: Column, is_l1_msg: Column, + is_eip2930: Column, + is_eip1559: Column, is_chain_id: Column, lookup_conditions: HashMap>, @@ -278,6 +280,8 @@ impl SubCircuitConfig for TxCircuitConfig { // booleans to reduce degree let is_l1_msg = meta.advice_column(); + let is_eip2930 = meta.advice_column(); + let is_eip1559 = meta.advice_column(); let is_calldata = meta.advice_column(); let is_caller_address = meta.advice_column(); let is_chain_id = meta.advice_column(); @@ -488,6 +492,8 @@ impl SubCircuitConfig for TxCircuitConfig { usize::from(PreEip155).expr(), usize::from(Eip155).expr(), usize::from(L1Msg).expr(), + usize::from(Eip2930).expr(), + usize::from(Eip1559).expr(), ], ); @@ -612,7 +618,7 @@ impl SubCircuitConfig for TxCircuitConfig { cb.gate(meta.query_fixed(q_enable, Rotation::cur())) }); - meta.create_gate("is_l1_msg", |meta| { + meta.create_gate("distinguish tx type: is_l1_msg, is_eip2930, is_eip1559", |meta| { let mut cb = BaseConstraintBuilder::default(); cb.require_equal( @@ -621,6 +627,18 @@ impl SubCircuitConfig for TxCircuitConfig { tx_type_bits.value_equals(L1Msg, Rotation::cur())(meta), ); + cb.require_equal( + "is_eip2930 = (tx_type == Eip2930)", + meta.query_advice(is_eip2930, Rotation::cur()), + tx_type_bits.value_equals(Eip2930, Rotation::cur())(meta), + ); + + cb.require_equal( + "is_eip1559 = (tx_type == Eip1559)", + meta.query_advice(is_eip1559, Rotation::cur()), + tx_type_bits.value_equals(Eip1559, Rotation::cur())(meta), + ); + cb.gate(meta.query_fixed(q_enable, Rotation::cur())) }); @@ -647,14 +665,21 @@ impl SubCircuitConfig for TxCircuitConfig { let is_tag_in_tx_sign = sum::expr([ is_nonce(meta), - is_gas_price(meta), + and::expr([ + not::expr(meta.query_advice(is_eip1559, Rotation::cur())), + is_gas_price(meta), + ]), is_gas(meta), is_to(meta), is_value(meta), is_data_rlc(meta), and::expr([ meta.query_advice(is_chain_id, Rotation::cur()), - tx_type_bits.value_equals(Eip155, Rotation::cur())(meta), + sum::expr([ + tx_type_bits.value_equals(Eip155, Rotation::cur())(meta), + meta.query_advice(is_eip2930, Rotation::cur()), + meta.query_advice(is_eip1559, Rotation::cur()), + ]) ]), is_sign_length(meta), is_sign_rlc(meta), @@ -680,7 +705,10 @@ impl SubCircuitConfig for TxCircuitConfig { let is_tag_in_tx_hash = sum::expr([ is_nonce(meta), - is_gas_price(meta), + and::expr([ + not::expr(meta.query_advice(is_eip1559, Rotation::cur())), + is_gas_price(meta), + ]), is_gas(meta), is_to(meta), is_value(meta), @@ -770,6 +798,8 @@ impl SubCircuitConfig for TxCircuitConfig { is_calldata, is_chain_id, is_l1_msg, + is_eip2930, + is_eip1559, sv_address, calldata_gas_cost_acc, calldata_rlc, @@ -1367,6 +1397,8 @@ impl SubCircuitConfig for TxCircuitConfig { num_all_txs_acc, total_l1_popped_before, is_l1_msg, + is_eip2930, + is_eip1559, is_chain_id, is_final, calldata_gas_cost_acc, @@ -1401,6 +1433,8 @@ impl TxCircuitConfig { is_calldata: Column, is_chain_id: Column, is_l1_msg_col: Column, + is_eip2930: Column, + is_eip1559: Column, sv_address: Column, calldata_gas_cost_acc: Column, calldata_rlc: Column, @@ -1563,7 +1597,9 @@ impl TxCircuitConfig { let rlp_tag = meta.query_advice(rlp_tag, Rotation::cur()); let is_none = meta.query_advice(is_none, Rotation::cur()); let sign_format = is_pre_eip155(meta) * TxSignPreEip155.expr() - + is_eip155(meta) * TxSignEip155.expr(); + + is_eip155(meta) * TxSignEip155.expr() + + meta.query_advice(is_eip2930, Rotation::cur()) * TxSignEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); // q_enable, tx_id, format, rlp_tag, tag_value, is_output, is_none vec![ @@ -1604,7 +1640,9 @@ impl TxCircuitConfig { let is_none = meta.query_advice(is_none, Rotation::cur()); let hash_format = is_pre_eip155(meta) * TxHashPreEip155.expr() + is_eip155(meta) * TxHashEip155.expr() - + is_l1_msg(meta) * L1MsgHash.expr(); + + is_l1_msg(meta) * L1MsgHash.expr() + + meta.query_advice(is_eip2930, Rotation::cur()) * TxHashEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); vec![ 1.expr(), // q_enable = true @@ -1949,7 +1987,8 @@ impl TxCircuitConfig { ), (BlockNumber, None, Value::known(F::from(tx.block_number))), ]; - + // tx1559_debug + // log::trace!("=> [Execution TxCircuit] assign - fixed_rows: {:?}", fixed_rows); for (tx_tag, rlp_input, tx_value) in fixed_rows { let rlp_tag = rlp_input.clone().map_or(Null, |input| input.tag); let rlp_is_none = rlp_input.clone().map_or(false, |input| input.is_none); @@ -1958,6 +1997,8 @@ impl TxCircuitConfig { .clone() .map_or(zero_rlc, |input| input.be_bytes_rlc); let is_l1_msg = tx.tx_type.is_l1_msg(); + let is_eip2930 = tx.tx_type.is_eip2930(); + let is_eip1559 = tx.tx_type.is_eip1559(); // it's the tx_id of next row let tx_id_next = if tx_tag == BlockNumber { next_tx.map_or(0, |tx| tx.id) @@ -2037,6 +2078,8 @@ impl TxCircuitConfig { F::from((tx_tag == CallerAddress) as u64), ), ] { + // tx1559_debug + // log::trace!("=> [Execution TxCircuit] assign - assign_fixed_rows - anno: {:?}, offset: {:?}", col_anno, offset); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } @@ -2062,7 +2105,6 @@ impl TxCircuitConfig { conditions.insert(LookupCondition::RlpSignTag, { let sign_set = [ Nonce, - GasPrice, Gas, CalleeAddress, TxFieldTag::Value, @@ -2072,14 +2114,14 @@ impl TxCircuitConfig { ]; let is_tag_in_set = sign_set.into_iter().filter(|tag| tx_tag == *tag).count() == 1; let case1 = is_tag_in_set && !is_l1_msg; - let case2 = tx.tx_type.is_eip155_tx() && (tx_tag == ChainID); - F::from((case1 || case2) as u64) + let case2 = !tx.tx_type.is_pre_eip155() && (tx_tag == ChainID); + let case3 = !tx.tx_type.is_eip1559() && (tx_tag == GasPrice); + F::from((case1 || case2 || case3) as u64) }); // 3. lookup to RLP table for hashing (non L1 msg) conditions.insert(LookupCondition::RlpHashTag, { let hash_set = [ Nonce, - GasPrice, Gas, CalleeAddress, TxFieldTag::Value, @@ -2092,7 +2134,9 @@ impl TxCircuitConfig { TxHashRLC, ]; let is_tag_in_set = hash_set.into_iter().filter(|tag| tx_tag == *tag).count() == 1; - F::from((!is_l1_msg && is_tag_in_set) as u64) + let case1 = is_tag_in_set && !is_l1_msg; + let case3 = !tx.tx_type.is_eip1559() && (tx_tag == GasPrice); + F::from((case1 || case3) as u64) }); // 4. lookup to RLP table for hashing (L1 msg) conditions.insert(LookupCondition::L1MsgHash, { @@ -2277,6 +2321,17 @@ impl TxCircuitConfig { self.is_l1_msg, F::from(tx_type.is_l1_msg() as u64), ), + ( + "is_eip2930", + self.is_eip2930, + F::from(tx_type.is_eip2930() as u64), + ), + ( + "is_eip1559", + self.is_eip1559, + F::from(tx_type.is_eip1559() as u64), + ), + ] { region.assign_advice(|| col_anno, col, offset, || Value::known(col_val))?; } @@ -2581,6 +2636,8 @@ impl TxCircuit { // 1. Empty entry region.assign_fixed(|| "q_first", config.q_first, 0, || Value::known(F::one()))?; + // tx1559_debug + // log::trace!("=> [Execution TxCircuit] assign - assign_null_row - offset: {:?}", offset); config.assign_null_row(&mut region, &mut offset)?; // 2. Assign all tx fields except for call data diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index 2529c6554c..75e098eae8 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -1,8 +1,8 @@ #![allow(unused_imports)] use ethers_core::{ - types::{NameOrAddress, Signature, Transaction as EthTransaction, TransactionRequest}, - utils::{keccak256, rlp, rlp::Decodable}, + types::{transaction::eip2718::TypedTransaction, NameOrAddress, Signature, Transaction as EthTransaction, TransactionRequest, Eip1559TransactionRequest}, + utils::{keccak256, rlp::{Decodable, Rlp}}, }; use std::cmp::max; @@ -11,7 +11,7 @@ use crate::{ tx_circuit::{dev::TxCircuitTester, get_sign_data}, util::{log2_ceil, unusable_rows}, }; -use eth_types::{address, evm_types::gas_utils::tx_data_gas_cost, word, H256, U256, U64}; +use eth_types::{address, evm_types::gas_utils::{tx_access_list_gas_cost, tx_data_gas_cost}, word, H256, U256, U64}; use halo2_proofs::{ dev::{MockProver, VerifyFailure}, halo2curves::bn256::Fr, @@ -81,7 +81,7 @@ fn build_l1_msg_tx() -> Transaction { let raw_tx_rlp_bytes = hex::decode("7ef901b60b825dc0941a258d17bf244c4df02d40343a7626a9d321e10580b901848ef1332e000000000000000000000000ea08a65b1829af779261e768d609e59279b510f2000000000000000000000000f2ec6b6206f6208e8f9b394efc1a01c1cbde77750000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000b00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a4232e87480000000000000000000000002b5ad5c4795c026514f8317c7a215e218dccd6cf0000000000000000000000002b5ad5c4795c026514f8317c7a215e218dccd6cf0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000094478cdd110520a8e733e2acf9e543d2c687ea5239") .expect("decode tx's hex shall not fail"); - let eth_tx = EthTransaction::decode(&rlp::Rlp::new(&raw_tx_rlp_bytes)) + let eth_tx = EthTransaction::decode(&Rlp::new(&raw_tx_rlp_bytes)) .expect("decode tx's rlp bytes shall not fail"); let signed_bytes = eth_tx.rlp().to_vec(); @@ -108,6 +108,49 @@ fn build_l1_msg_tx() -> Transaction { tx } +#[cfg(test)] +fn build_eip1559_tx() -> Transaction { + let bytes = "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910"; + let raw_tx_rlp_bytes = hex::decode(bytes).expect("decode tx's hex shall not fail"); + + let eth_tx = EthTransaction::decode(&Rlp::new(&raw_tx_rlp_bytes)) + .expect("decode tx's rlp bytes shall not fail"); + + let eth_tx_req: Eip1559TransactionRequest = (ð_tx).into(); + let typed_tx: TypedTransaction = eth_tx_req.into(); + let rlp_unsigned = typed_tx.rlp().to_vec(); + + let mut tx = Transaction::new_from_rlp_bytes( + 1, + TxType::Eip1559, + raw_tx_rlp_bytes, + rlp_unsigned, + ); + + tx.hash = eth_tx.hash; + tx.block_number = 1; + tx.id = 1; + tx.chain_id = eth_tx.chain_id.unwrap_or(U256::zero()).as_u64(); + tx.nonce = eth_tx.nonce.as_u64(); + tx.value = eth_tx.value; + tx.gas_price = eth_tx.gas_price.unwrap_or(U256::zero()); + tx.gas = eth_tx.gas.as_u64(); + tx.call_data = eth_tx.input.to_vec(); + tx.callee_address = eth_tx.to; + tx.caller_address = eth_tx.from; + tx.is_create = eth_tx.to.is_none(); + tx.call_data_length = tx.call_data.len(); + tx.call_data_gas_cost = tx_data_gas_cost(&tx.call_data); + tx.access_list = eth_tx.access_list.clone().unwrap_or_default(); + tx.access_list_gas_cost = tx_access_list_gas_cost(ð_tx.access_list); + tx.tx_data_gas_cost = tx_data_gas_cost(&tx.rlp_signed); + tx.v = eth_tx.v.as_u64(); + tx.r = eth_tx.r; + tx.s = eth_tx.s; + + tx +} + fn run( txs: Vec, chain_id: u64, @@ -134,14 +177,15 @@ fn run( prover.verify_at_rows_par(0..active_row_num, 0..active_row_num) } -// tx1559_debug + #[test] +// tx1559_debug // #[cfg(feature = "scroll")] -fn tx_circuit_1tx_2max_debug() { - const MAX_TXS: usize = 1; - const MAX_CALLDATA: usize = 320; +fn tx_circuit_1tx_2max_eip1559() { + const MAX_TXS: usize = 2; + const MAX_CALLDATA: usize = 3200; - let tx = build_pre_eip155_tx(); + let tx = build_eip1559_tx(); assert_eq!( run::(vec![tx], *mock::MOCK_CHAIN_ID, MAX_TXS, MAX_CALLDATA, 0), diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 82acb87f10..4bd2023bbe 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -15,14 +15,14 @@ use crate::{ Tag::{EndObject, EndVector}, }, }; -use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}; +use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee, Access}; use eth_types::{ evm_types::gas_utils::{tx_access_list_gas_cost, tx_data_gas_cost}, geth_types::{TxType, TxType::PreEip155}, sign_types::{ biguint_to_32bytes_le, ct_option_ok_or, get_dummy_tx, recover_pk2, SignData, SECP256K1_Q, }, - Address, Error, Field, Signature, ToBigEndian, ToLittleEndian, ToScalar, ToWord, Word, H256, + Address, Error, Field, Signature, ToBigEndian, ToLittleEndian, ToScalar, ToWord, Word, H256, AccessList, }; use ethers_core::{types::TransactionRequest, utils::keccak256}; use halo2_proofs::{ @@ -67,6 +67,8 @@ pub struct Transaction { pub call_data_length: usize, /// The gas cost for transaction call data pub call_data_gas_cost: u64, + /// access list (EIP 2930) + pub access_list: AccessList, /// The gas cost for access list (EIP 2930) pub access_list_gas_cost: u64, /// The gas cost for rlp-encoded bytes of unsigned tx @@ -1003,6 +1005,7 @@ impl From for Transaction { call_data: mock_tx.input.to_vec(), call_data_length: mock_tx.input.len(), call_data_gas_cost: tx_data_gas_cost(&mock_tx.input), + access_list: mock_tx.access_list.clone(), access_list_gas_cost: tx_access_list_gas_cost(&Some(mock_tx.access_list)), tx_data_gas_cost: tx_data_gas_cost(&rlp_signed), chain_id: mock_tx.chain_id, @@ -1055,6 +1058,7 @@ pub(super) fn tx_convert( call_data: tx.input.clone(), call_data_length: tx.input.len(), call_data_gas_cost: tx_data_gas_cost(&tx.input), + access_list: tx.access_list.clone().unwrap_or_default(), access_list_gas_cost: tx_access_list_gas_cost(&tx.access_list), tx_data_gas_cost: tx_gas_cost, chain_id, From af5e424161ee9aad0801eec3f2753ed89687aaf1 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 29 Nov 2023 23:21:36 -0800 Subject: [PATCH 067/161] restore column in tx table --- zkevm-circuits/src/table.rs | 46 +++++++++++++++++++--- zkevm-circuits/src/tx_circuit.rs | 2 - zkevm-circuits/src/witness/tx.rs | 65 ++++++++++++++++++++++++++++++-- 3 files changed, 101 insertions(+), 12 deletions(-) diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 0416bfe155..efcac15e45 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -179,6 +179,21 @@ pub enum TxFieldTag { TxType, /// The block number in which this tx is included. BlockNumber, + /// Max Priority Fee Per Gas (EIP1559) + MaxPriorityFeePerGas, + /// Max Fee Per Gas (EIP1559) + MaxFeePerGas, + /// Value is equal to tx.access_list.len() + AccessListAddressesLen, + /// Value is equal to tx.access_list.iter().map(|al| al.storage_keys.len()).sum() + AccessListStorageKeysLen, + /// RLC of big endian bytes of tx.access_list. + /// Used to make sure that no item in tx.access_list is skipped. + AccessListRLC, + /// AccessListAddress, + AccessListAddress, + /// AccessListStorageKey + AccessListStorageKey, } impl_expr!(TxFieldTag); @@ -204,6 +219,8 @@ pub struct TxTable { pub index: Column, /// Value pub value: Column, + /// Access list address + pub access_list_address: Column, } impl TxTable { @@ -217,6 +234,7 @@ impl TxTable { tag, index: meta.advice_column(), value: meta.advice_column_in(SecondPhase), + access_list_address: meta.advice_column(), } } @@ -253,7 +271,7 @@ impl TxTable { q_enable: Column, advice_columns: &[Column], tag: &Column, - row: &[Value; 4], + row: &[Value; 5], msg: &str, ) -> Result, Error> { let mut value_cell = None; @@ -296,17 +314,18 @@ impl TxTable { self.q_enable, &advice_columns, &self.tag, - &[(); 4].map(|_| Value::known(F::zero())), + &[(); 5].map(|_| Value::known(F::zero())), "all-zero", )?; offset += 1; // Tx Table contains an initial region that has a size parametrized by max_txs - // with all the tx data except for calldata, and then a second + // with all the tx data except for calldata and access list, and then a second // region that has a size parametrized by max_calldata with all - // the tx calldata. This is required to achieve a constant fixed column tag - // regardless of the number of input txs or the calldata size of each tx. - let mut calldata_assignments: Vec<[Value; 4]> = Vec::new(); + // the tx calldata and access list. This is required to achieve a constant fixed column tag + // regardless of the number of input txs or the calldata/access list size of each tx. + let mut calldata_assignments: Vec<[Value; 5]> = Vec::new(); + let mut access_list_assignments: Vec<[Value; 5]> = Vec::new(); // Assign Tx data (all tx fields except for calldata) let padding_txs = (txs.len()..max_txs) .into_iter() @@ -321,6 +340,7 @@ impl TxTable { debug_assert_eq!(i + 1, tx.id); let tx_data = tx.table_assignments_fixed(*challenges); let tx_calldata = tx.table_assignments_dyn(*challenges); + let tx_access_list = tx.table_assignments_access_list_dyn(*challenges); for row in tx_data { tx_value_cells.push(assign_row( &mut region, @@ -334,6 +354,7 @@ impl TxTable { offset += 1; } calldata_assignments.extend(tx_calldata.iter()); + access_list_assignments.extend(tx_access_list.iter()); } // Assign Tx calldata for row in calldata_assignments.into_iter() { @@ -348,6 +369,19 @@ impl TxTable { )?; offset += 1; } + // Assign Tx access_list + for row in access_list_assignments.into_iter() { + assign_row( + &mut region, + offset, + self.q_enable, + &advice_columns, + &self.tag, + &row, + "", + )?; + offset += 1; + } Ok(tx_value_cells) }, ) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 49228e1ba7..874bf96ea2 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -2636,8 +2636,6 @@ impl TxCircuit { // 1. Empty entry region.assign_fixed(|| "q_first", config.q_first, 0, || Value::known(F::one()))?; - // tx1559_debug - // log::trace!("=> [Execution TxCircuit] assign - assign_null_row - offset: {:?}", offset); config.assign_null_row(&mut region, &mut offset)?; // 2. Assign all tx fields except for call data diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 4bd2023bbe..b46ef73862 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -156,7 +156,7 @@ impl Transaction { pub fn table_assignments_fixed( &self, challenges: Challenges>, - ) -> Vec<[Value; 4]> { + ) -> Vec<[Value; 5]> { let tx_hash_be_bytes = keccak256(&self.rlp_signed); let tx_sign_hash_be_bytes = keccak256(&self.rlp_unsigned); @@ -166,6 +166,7 @@ impl Transaction { Value::known(F::from(TxContextFieldTag::Nonce as u64)), Value::known(F::zero()), Value::known(F::from(self.nonce)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), @@ -173,19 +174,23 @@ impl Transaction { Value::known(F::zero()), challenges .evm_word() - .map(|challenge| rlc::value(&self.gas_price.to_le_bytes(), challenge)), + .map(|challenge| rlc::value(&self.gas_price.to_le_bytes(), challenge) + ), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::Gas as u64)), Value::known(F::zero()), Value::known(F::from(self.gas)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::CallerAddress as u64)), Value::known(F::zero()), Value::known(self.caller_address.to_scalar().unwrap()), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), @@ -197,12 +202,14 @@ impl Transaction { .to_scalar() .unwrap(), ), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::IsCreate as u64)), Value::known(F::zero()), Value::known(F::from(self.is_create as u64)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), @@ -210,109 +217,128 @@ impl Transaction { Value::known(F::zero()), challenges .evm_word() - .map(|challenge| rlc::value(&self.value.to_le_bytes(), challenge)), + .map(|challenge| rlc::value(&self.value.to_le_bytes(), challenge) + ), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::CallDataRLC as u64)), Value::known(F::zero()), rlc_be_bytes(&self.call_data, challenges.keccak_input()), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::CallDataLength as u64)), Value::known(F::zero()), Value::known(F::from(self.call_data_length as u64)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::CallDataGasCost as u64)), Value::known(F::zero()), Value::known(F::from(self.call_data_gas_cost)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::AccessListGasCost as u64)), Value::known(F::zero()), Value::known(F::from(self.access_list_gas_cost)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::TxDataGasCost as u64)), Value::known(F::zero()), Value::known(F::from(self.tx_data_gas_cost)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::ChainID as u64)), Value::known(F::zero()), Value::known(F::from(self.chain_id)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::SigV as u64)), Value::known(F::zero()), Value::known(F::from(self.v)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::SigR as u64)), Value::known(F::zero()), rlc_be_bytes(&self.r.to_be_bytes(), challenges.evm_word()), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::SigS as u64)), Value::known(F::zero()), rlc_be_bytes(&self.s.to_be_bytes(), challenges.evm_word()), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::TxSignLength as u64)), Value::known(F::zero()), Value::known(F::from(self.rlp_unsigned.len() as u64)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::TxSignRLC as u64)), Value::known(F::zero()), rlc_be_bytes(&self.rlp_unsigned, challenges.keccak_input()), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::TxSignHash as u64)), Value::known(F::zero()), rlc_be_bytes(&tx_sign_hash_be_bytes, challenges.evm_word()), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::TxHashLength as u64)), Value::known(F::zero()), Value::known(F::from(self.rlp_signed.len() as u64)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::TxHashRLC as u64)), Value::known(F::zero()), rlc_be_bytes(&self.rlp_signed, challenges.keccak_input()), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::TxHash as u64)), Value::known(F::zero()), rlc_be_bytes(&tx_hash_be_bytes, challenges.evm_word()), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::TxType as u64)), Value::known(F::zero()), Value::known(F::from(self.tx_type as u64)), + Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::BlockNumber as u64)), Value::known(F::zero()), Value::known(F::from(self.block_number)), + Value::known(F::zero()), ], ]; @@ -323,7 +349,7 @@ impl Transaction { pub fn table_assignments_dyn( &self, _challenges: Challenges>, - ) -> Vec<[Value; 4]> { + ) -> Vec<[Value; 5]> { self.call_data .iter() .enumerate() @@ -333,11 +359,42 @@ impl Transaction { Value::known(F::from(TxContextFieldTag::CallData as u64)), Value::known(F::from(idx as u64)), Value::known(F::from(*byte as u64)), + Value::known(F::zero()), ] }) .collect() } + /// Assignments for tx table access list + pub fn table_assignments_access_list_dyn( + &self, + challenges: Challenges>, + ) -> Vec<[Value; 5]> { + let mut assignments: Vec<[Value; 5]> = vec![]; + + for (al_idx, al) in self.access_list.0.iter().enumerate() { + assignments.push([ + Value::known(F::from(self.id as u64)), + Value::known(F::from(TxContextFieldTag::AccessListAddress as u64)), + Value::known(F::from((al_idx + 1) as u64)), + Value::known(al.address.to_scalar().unwrap()), + Value::known(al.address.to_scalar().unwrap()), + ]); + + for (sk_idx, sk) in al.storage_keys.iter().enumerate() { + assignments.push([ + Value::known(F::from(self.id as u64)), + Value::known(F::from(TxContextFieldTag::AccessListStorageKey as u64)), + Value::known(F::from(sk_idx as u64)), + rlc_be_bytes(&sk.to_fixed_bytes(), challenges.evm_word()), + Value::known(al.address.to_scalar().unwrap()), + ]); + } + } + + assignments + } + pub(crate) fn gen_rlp_witness( &self, is_hash: bool, From 4eedca884d734989b98303b6f694cebda6623ba2 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 29 Nov 2023 23:34:16 -0800 Subject: [PATCH 068/161] restore access list idx columns: --- zkevm-circuits/src/tx_circuit.rs | 74 ++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 874bf96ea2..b001ccd749 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -190,6 +190,11 @@ pub struct TxCircuitConfig { rlp_table: RlpTable, keccak_table: KeccakTable, + // Access list columns + al_idx: Column, + sk_idx: Column, + sks_acc: Column, + _marker: PhantomData, } @@ -297,6 +302,11 @@ impl SubCircuitConfig for TxCircuitConfig { .map(|condition| (condition, meta.advice_column())) .collect::>>(); + // access list columns + let al_idx = meta.advice_column(); + let sk_idx = meta.advice_column(); + let sks_acc = meta.advice_column(); + // TODO: add lookup to SignVerify table for sv_address let sv_address = meta.advice_column(); meta.enable_equality(tx_table.value); @@ -1411,6 +1421,9 @@ impl SubCircuitConfig for TxCircuitConfig { keccak_table, rlp_table, is_tag_block_num, + al_idx, + sk_idx, + sks_acc, _marker: PhantomData, num_txs, } @@ -2260,6 +2273,67 @@ impl TxCircuitConfig { Ok(()) } + /// Assign access list rows of each tx + fn assign_access_list_rows( + &self, + region: &mut Region<'_, F>, + offset: &mut usize, + tx: &Transaction, + next_tx: Option<&Transaction>, + challenges: &Challenges>, + ) -> Result<(), Error> { + // tx1559_debug + // assign to access_list related columns + let mut gas_cost_acc = 0; + let mut rlc = challenges.keccak_input().map(|_| F::zero()); + for (idx, byte) in tx.call_data.iter().enumerate() { + let is_final = idx == (tx.call_data.len() - 1); + gas_cost_acc += if *byte == 0 { 4 } else { 16 }; + rlc = rlc + .zip(challenges.keccak_input()) + .map(|(rlc, keccak_input)| rlc * keccak_input + F::from(*byte as u64)); + // the tx id of next row + let tx_id_next = if !is_final { + tx.id + } else { + next_tx.map_or(0, |tx| tx.id) + }; + + self.assign_common_part( + region, + *offset, + Some(tx), + tx_id_next, + CallData, + idx as u64, + Value::known(F::from(*byte as u64)), + )?; + + // 1st phase columns + for (col_anno, col, col_val) in [ + ("block_num", self.block_num, F::from(tx.block_number)), + ("rlp_tag", self.rlp_tag, F::from(usize::from(Null) as u64)), + ("is_final", self.is_final, F::from(is_final as u64)), + ( + "gas_cost_acc", + self.calldata_gas_cost_acc, + F::from(gas_cost_acc), + ), + ("byte", self.calldata_byte, F::from(*byte as u64)), + ("is_calldata", self.is_calldata, F::one()), + ] { + region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; + } + + // 2nd phase columns + region.assign_advice(|| "rlc", self.calldata_rlc, *offset, || rlc)?; + + *offset += 1; + } + + Ok(()) + } + // Assigns to common columns in different parts of tx circuit // 1. 1st all zero row // 2. fixed rows of each tx From f839b8a9ada102ed7204594d5f15f6d1c6ec3bc9 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 30 Nov 2023 01:04:02 -0800 Subject: [PATCH 069/161] add access list dynamic assignment --- zkevm-circuits/src/tx_circuit.rs | 161 +++++++++++++++++++++++-------- 1 file changed, 120 insertions(+), 41 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index b001ccd749..85abc83a15 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -45,6 +45,7 @@ use eth_types::{ TxType, TxType::{Eip155, L1Msg, PreEip155, Eip2930, Eip1559}, }, + evm_types::GasCost as GS, sign_types::SignData, Address, Field, ToAddress, ToBigEndian, ToScalar, }; @@ -2284,51 +2285,129 @@ impl TxCircuitConfig { ) -> Result<(), Error> { // tx1559_debug // assign to access_list related columns - let mut gas_cost_acc = 0; - let mut rlc = challenges.keccak_input().map(|_| F::zero()); - for (idx, byte) in tx.call_data.iter().enumerate() { - let is_final = idx == (tx.call_data.len() - 1); - gas_cost_acc += if *byte == 0 { 4 } else { 16 }; - rlc = rlc - .zip(challenges.keccak_input()) - .map(|(rlc, keccak_input)| rlc * keccak_input + F::from(*byte as u64)); - // the tx id of next row - let tx_id_next = if !is_final { - tx.id - } else { - next_tx.map_or(0, |tx| tx.id) - }; - self.assign_common_part( - region, - *offset, - Some(tx), - tx_id_next, - CallData, - idx as u64, - Value::known(F::from(*byte as u64)), - )?; + if tx.access_list.0.len() > 0 { + // initialize gas counting + let mut gas_cost_acc = 0; - // 1st phase columns - for (col_anno, col, col_val) in [ - ("block_num", self.block_num, F::from(tx.block_number)), - ("rlp_tag", self.rlp_tag, F::from(usize::from(Null) as u64)), - ("is_final", self.is_final, F::from(is_final as u64)), - ( - "gas_cost_acc", - self.calldata_gas_cost_acc, - F::from(gas_cost_acc), - ), - ("byte", self.calldata_byte, F::from(*byte as u64)), - ("is_calldata", self.is_calldata, F::one()), - ] { - region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; - } + // idx helper + let mut sks_acc: usize = 0; - // 2nd phase columns - region.assign_advice(|| "rlc", self.calldata_rlc, *offset, || rlc)?; + // row counting for determining when tx_id changes + let total_rows: usize = tx.access_list.0.iter().fold(0, |acc, al| { + acc + 1 + al.storage_keys.len() + }); + let mut curr_row: usize = 0; - *offset += 1; + // initialize access list section rlc + let mut section_rlc = challenges.keccak_input().map(|_| F::zero()); + // depending on prev row, the accumulator advances by different magnitude + let r20 = challenges.keccak_input().map(|f| f.pow(&[20, 0, 0, 0]) ); + let r32 = challenges.keccak_input().map(|f| f.pow(&[32, 0, 0, 0]) ); + + for (al_idx, al) in tx.access_list.0.iter().enumerate() { + curr_row += 1; + + gas_cost_acc += GS::ACCESS_LIST_PER_ADDRESS.as_u64(); + let field_rlc = rlc_be_bytes(&al.address.to_fixed_bytes(), challenges.keccak_input()); + section_rlc = section_rlc * r32 + field_rlc; + + let tx_id_next = if curr_row == total_rows { + next_tx.map_or(0, |tx| tx.id) + } else { + tx.id + }; + + self.assign_common_part( + region, + *offset, + Some(tx), + tx_id_next, + TxFieldTag::AccessListAddress, + al_idx as u64, + Value::known(al.address.to_scalar().unwrap()), + )?; + + // 1st phase columns + for (col_anno, col, col_val) in [ + ("al_idx", self.al_idx, F::from((al_idx + 1) as u64)), + ("sk_idx", self.sk_idx, F::from(0 as u64)), + ("sks_acc", self.sks_acc, F::from(sks_acc as u64)), + + // ("block_num", self.block_num, F::from(tx.block_number)), + // ("rlp_tag", self.rlp_tag, F::from(usize::from(Null) as u64)), + // ("is_final", self.is_final, F::from(is_final as u64)), + // ( + // "gas_cost_acc", + // self.calldata_gas_cost_acc, + // F::from(gas_cost_acc), + // ), + // ("byte", self.calldata_byte, F::from(*byte as u64)), + // ("is_calldata", self.is_calldata, F::one()), + ] { + region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; + } + + // 2nd phase columns + region.assign_advice(|| "rlc", self.calldata_rlc, *offset, || section_rlc)?; + + *offset += 1; + + for (sk_idx, sk) in al.storage_keys.iter().enumerate() { + curr_row += 1; + + sks_acc += 1; + + gas_cost_acc += GS::ACCESS_LIST_PER_STORAGE_KEY.as_u64(); + let field_rlc = rlc_be_bytes(&sk.to_fixed_bytes(), challenges.keccak_input()); + section_rlc = if sk_idx > 0 { + section_rlc * r32 + field_rlc + } else { + section_rlc * r20 + field_rlc + }; + + let tx_id_next = if curr_row == total_rows { + next_tx.map_or(0, |tx| tx.id) + } else { + tx.id + }; + + self.assign_common_part( + region, + *offset, + Some(tx), + tx_id_next, + TxFieldTag::AccessListStorageKey, + sks_acc as u64, + rlc_be_bytes(&sk.to_fixed_bytes(), challenges.evm_word()) + )?; + + // 1st phase columns + for (col_anno, col, col_val) in [ + ("al_idx", self.al_idx, F::from((al_idx + 1) as u64)), + ("sk_idx", self.sk_idx, F::from((sk_idx + 1) as u64)), + ("sks_acc", self.sks_acc, F::from(sks_acc as u64)), + + // ("block_num", self.block_num, F::from(tx.block_number)), + // ("rlp_tag", self.rlp_tag, F::from(usize::from(Null) as u64)), + // ("is_final", self.is_final, F::from(is_final as u64)), + // ( + // "gas_cost_acc", + // self.calldata_gas_cost_acc, + // F::from(gas_cost_acc), + // ), + // ("byte", self.calldata_byte, F::from(*byte as u64)), + // ("is_calldata", self.is_calldata, F::one()), + ] { + region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; + } + + // 2nd phase columns + region.assign_advice(|| "rlc", self.calldata_rlc, *offset, || section_rlc)?; + + *offset += 1; + } + } } Ok(()) From aa4ff2990c5a85f73298688023858f301f0124ad Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 30 Nov 2023 01:36:35 -0800 Subject: [PATCH 070/161] restore dynamic access list assignment --- zkevm-circuits/src/table.rs | 4 ---- zkevm-circuits/src/tx_circuit.rs | 23 +++++++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index efcac15e45..8c506e8ae0 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -183,10 +183,6 @@ pub enum TxFieldTag { MaxPriorityFeePerGas, /// Max Fee Per Gas (EIP1559) MaxFeePerGas, - /// Value is equal to tx.access_list.len() - AccessListAddressesLen, - /// Value is equal to tx.access_list.iter().map(|al| al.storage_keys.len()).sum() - AccessListStorageKeysLen, /// RLC of big endian bytes of tx.access_list. /// Used to make sure that no item in tx.access_list is skipped. AccessListRLC, diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 85abc83a15..6a9ef0c3fe 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -22,6 +22,7 @@ use crate::{ AccessListGasCost, BlockNumber, CallData, CallDataGasCost, CallDataLength, CallDataRLC, CalleeAddress, CallerAddress, ChainID, Gas, GasPrice, IsCreate, Nonce, SigR, SigS, SigV, TxDataGasCost, TxHashLength, TxHashRLC, TxSignHash, TxSignLength, TxSignRLC, + AccessListAddress, AccessListStorageKey, }, TxTable, U16Table, U8Table, }, @@ -361,6 +362,9 @@ impl SubCircuitConfig for TxCircuitConfig { is_tx_tag!(is_hash, TxHash); is_tx_tag!(is_block_num, BlockNumber); is_tx_tag!(is_tx_type, TxType); + is_tx_tag!(is_access_list_address, AccessListAddress); + is_tx_tag!(is_access_list_storage_key, AccessListStorageKey); + let tx_id_unchanged = IsEqualChip::configure( meta, @@ -477,6 +481,8 @@ impl SubCircuitConfig for TxCircuitConfig { (is_hash_rlc(meta), RLC), (is_caller_addr(meta), Tag::Sender.into()), (is_tx_gas_cost(meta), GasCost), + (is_access_list_address(meta), Tag::AccessListAddress.into()), + (is_access_list_storage_key(meta), Tag::AccessListStorageKey.into()), // tx tags which correspond to Null (is_null(meta), Null), (is_create(meta), Null), @@ -2330,12 +2336,13 @@ impl TxCircuitConfig { // 1st phase columns for (col_anno, col, col_val) in [ + ("block_num", self.block_num, F::from(tx.block_number)), ("al_idx", self.al_idx, F::from((al_idx + 1) as u64)), ("sk_idx", self.sk_idx, F::from(0 as u64)), ("sks_acc", self.sks_acc, F::from(sks_acc as u64)), + ("rlp_tag", self.rlp_tag, F::from(usize::from(Tag::AccessListAddress) as u64)), - // ("block_num", self.block_num, F::from(tx.block_number)), - // ("rlp_tag", self.rlp_tag, F::from(usize::from(Null) as u64)), + // ("is_final", self.is_final, F::from(is_final as u64)), // ( // "gas_cost_acc", @@ -2384,12 +2391,13 @@ impl TxCircuitConfig { // 1st phase columns for (col_anno, col, col_val) in [ + ("block_num", self.block_num, F::from(tx.block_number)), ("al_idx", self.al_idx, F::from((al_idx + 1) as u64)), ("sk_idx", self.sk_idx, F::from((sk_idx + 1) as u64)), ("sks_acc", self.sks_acc, F::from(sks_acc as u64)), + ("rlp_tag", self.rlp_tag, F::from(usize::from(Tag::AccessListStorageKey) as u64)), - // ("block_num", self.block_num, F::from(tx.block_number)), - // ("rlp_tag", self.rlp_tag, F::from(usize::from(Null) as u64)), + // ("is_final", self.is_final, F::from(is_final as u64)), // ( // "gas_cost_acc", @@ -2897,6 +2905,13 @@ impl TxCircuit { next_tx, challenges, )?; + config.assign_access_list_rows( + &mut region, + &mut offset, + tx, + next_tx, + challenges, + )?; } assert!(offset <= calldata_last_row, "{offset}, {calldata_last_row}"); // 3.2 pad calldata with zeros From c3ffc6761f4cbc77312b6acbc54dad81afd770e2 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 2 Dec 2023 15:27:13 -0800 Subject: [PATCH 071/161] resolve merge conflict --- bus-mapping/src/evm/opcodes/begin_end_tx.rs | 2 +- go.work.sum | 1 + zkevm-circuits/src/table.rs | 3 --- zkevm-circuits/src/tx_circuit.rs | 6 +++--- zkevm-circuits/src/tx_circuit/test.rs | 2 +- zkevm-circuits/src/witness/tx.rs | 17 +++-------------- 6 files changed, 9 insertions(+), 22 deletions(-) create mode 100644 go.work.sum diff --git a/bus-mapping/src/evm/opcodes/begin_end_tx.rs b/bus-mapping/src/evm/opcodes/begin_end_tx.rs index 0689b03411..60cf53aded 100644 --- a/bus-mapping/src/evm/opcodes/begin_end_tx.rs +++ b/bus-mapping/src/evm/opcodes/begin_end_tx.rs @@ -624,7 +624,7 @@ fn gen_tx_eip2930_ops( state: &mut CircuitInputStateRef, exec_step: &mut ExecStep, ) -> Result<(), Error> { - if !state.tx.tx_type.is_eip2930_tx() { + if !state.tx.tx_type.is_eip2930() { return Ok(()); } diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 0000000000..7ec67a9076 --- /dev/null +++ b/go.work.sum @@ -0,0 +1 @@ +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index a4dc759aae..63516f4c6a 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -187,9 +187,6 @@ pub enum TxFieldTag { MaxPriorityFeePerGas, /// Max Fee Per Gas (EIP1559) MaxFeePerGas, - /// RLC of big endian bytes of tx.access_list. - /// Used to make sure that no item in tx.access_list is skipped. - AccessListRLC, /// AccessListAddress, AccessListAddress, /// AccessListStorageKey diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 2e268598ee..e2639383aa 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -2321,7 +2321,7 @@ impl TxCircuitConfig { // tx1559_debug // assign to access_list related columns - if tx.access_list.0.len() > 0 { + if tx.access_list.as_ref().unwrap().0.len() > 0 { // initialize gas counting let mut gas_cost_acc = 0; @@ -2329,7 +2329,7 @@ impl TxCircuitConfig { let mut sks_acc: usize = 0; // row counting for determining when tx_id changes - let total_rows: usize = tx.access_list.0.iter().fold(0, |acc, al| { + let total_rows: usize = tx.access_list.as_ref().unwrap().0.iter().fold(0, |acc, al| { acc + 1 + al.storage_keys.len() }); let mut curr_row: usize = 0; @@ -2340,7 +2340,7 @@ impl TxCircuitConfig { let r20 = challenges.keccak_input().map(|f| f.pow(&[20, 0, 0, 0]) ); let r32 = challenges.keccak_input().map(|f| f.pow(&[32, 0, 0, 0]) ); - for (al_idx, al) in tx.access_list.0.iter().enumerate() { + for (al_idx, al) in tx.access_list.as_ref().unwrap().0.iter().enumerate() { curr_row += 1; gas_cost_acc += GS::ACCESS_LIST_PER_ADDRESS.as_u64(); diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index 75e098eae8..133b9e6250 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -141,7 +141,7 @@ fn build_eip1559_tx() -> Transaction { tx.is_create = eth_tx.to.is_none(); tx.call_data_length = tx.call_data.len(); tx.call_data_gas_cost = tx_data_gas_cost(&tx.call_data); - tx.access_list = eth_tx.access_list.clone().unwrap_or_default(); + tx.access_list = eth_tx.access_list.clone(); tx.access_list_gas_cost = tx_access_list_gas_cost(ð_tx.access_list); tx.tx_data_gas_cost = tx_data_gas_cost(&tx.rlp_signed); tx.v = eth_tx.v.as_u64(); diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 6707adfd24..ce91021ba1 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -17,7 +17,7 @@ use crate::{ }; use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee, Access}; use eth_types::{ - evm_types::gas_utils::tx_data_gas_cost, + evm_types::gas_utils::{tx_data_gas_cost, tx_access_list_gas_cost}, geth_types::{access_list_size, TxType, TxType::PreEip155}, sign_types::{ biguint_to_32bytes_le, ct_option_ok_or, get_dummy_tx, recover_pk2, SignData, SECP256K1_Q, @@ -71,8 +71,6 @@ pub struct Transaction { pub call_data_length: usize, /// The gas cost for transaction call data pub call_data_gas_cost: u64, - /// access list (EIP 2930) - pub access_list: AccessList, /// The gas cost for access list (EIP 2930) pub access_list_gas_cost: u64, /// The gas cost for rlp-encoded bytes of unsigned tx @@ -250,13 +248,6 @@ impl Transaction { Value::known(F::from(self.call_data_gas_cost)), Value::known(F::zero()), ], - [ - Value::known(F::from(self.id as u64)), - Value::known(F::from(TxContextFieldTag::AccessListGasCost as u64)), - Value::known(F::zero()), - Value::known(F::from(self.access_list_gas_cost)), - Value::known(F::zero()), - ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::TxDataGasCost as u64)), @@ -438,7 +429,7 @@ impl Transaction { ) -> Vec<[Value; 5]> { let mut assignments: Vec<[Value; 5]> = vec![]; - for (al_idx, al) in self.access_list.0.iter().enumerate() { + for (al_idx, al) in self.access_list.as_ref().unwrap().0.iter().enumerate() { assignments.push([ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::AccessListAddress as u64)), @@ -1129,8 +1120,7 @@ impl From for Transaction { call_data: mock_tx.input.to_vec(), call_data_length: mock_tx.input.len(), call_data_gas_cost: tx_data_gas_cost(&mock_tx.input), - access_list: mock_tx.access_list.clone(), - access_list_gas_cost: tx_access_list_gas_cost(&Some(mock_tx.access_list)), + access_list_gas_cost: tx_access_list_gas_cost(&access_list), tx_data_gas_cost: tx_data_gas_cost(&rlp_signed), chain_id: mock_tx.chain_id, rlp_unsigned, @@ -1183,7 +1173,6 @@ pub(super) fn tx_convert( call_data: tx.input.clone(), call_data_length: tx.input.len(), call_data_gas_cost: tx_data_gas_cost(&tx.input), - access_list: tx.access_list.clone().unwrap_or_default(), access_list_gas_cost: tx_access_list_gas_cost(&tx.access_list), tx_data_gas_cost: tx_gas_cost, chain_id, From 3a80d750693e29a32300722ba0f5b02b701d6c54 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 2 Dec 2023 17:16:44 -0800 Subject: [PATCH 072/161] add section denoter for access list --- zkevm-circuits/src/tx_circuit.rs | 125 ++++++++++++++++++------------- 1 file changed, 75 insertions(+), 50 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index e2639383aa..81ec9e939f 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -196,6 +196,8 @@ pub struct TxCircuitConfig { al_idx: Column, sk_idx: Column, sks_acc: Column, + // section denoter for access list, reduces degree + is_access_list: Column, _marker: PhantomData, } @@ -308,6 +310,7 @@ impl SubCircuitConfig for TxCircuitConfig { let al_idx = meta.advice_column(); let sk_idx = meta.advice_column(); let sks_acc = meta.advice_column(); + let is_access_list = meta.advice_column(); // TODO: add lookup to SignVerify table for sv_address let sv_address = meta.advice_column(); @@ -604,6 +607,21 @@ impl SubCircuitConfig for TxCircuitConfig { cb.gate(meta.query_fixed(q_enable, Rotation::cur())) }); + meta.create_gate("is_access_list", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "is_access_lits", + sum::expr([ + is_access_list_address(meta), + is_access_list_storage_key(meta), + ]), + meta.query_advice(is_access_list, Rotation::cur()), + ); + + cb.gate(meta.query_fixed(q_enable, Rotation::cur())) + }); + meta.create_gate("is_caller_address", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -818,6 +836,7 @@ impl SubCircuitConfig for TxCircuitConfig { &lookup_conditions, is_final, is_calldata, + is_access_list, is_chain_id, is_l1_msg, is_eip2930, @@ -1268,39 +1287,59 @@ impl SubCircuitConfig for TxCircuitConfig { ); }); + // on the final call data byte, must transition to another + // calldata section or an access list section for the same tx + + + // tx1559_debug // on the final call data byte, tx_id must change. - cb.condition(is_final_cur.expr(), |cb| { - cb.require_zero( - "tx_id changes at is_final == 1", - tx_id_unchanged.is_equal_expression.clone(), - ); - }); + // cb.condition(is_final_cur.expr(), |cb| { + // cb.require_zero( + // "tx_id changes at is_final == 1", + // tx_id_unchanged.is_equal_expression.clone(), + // ); + // }); + + // tx1559_debug + // cb.condition( + // and::expr([ + // is_final_cur, + // not::expr(tx_id_is_zero.expr(Rotation::next())(meta)), + // ]), + // |cb| { + // let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); + // let gas_cost_next = select::expr(value_next_is_zero, 4.expr(), 16.expr()); + + // cb.require_equal( + // "index' == 0", + // meta.query_advice(tx_table.index, Rotation::next()), + // 0.expr(), + // ); + // cb.require_equal( + // "calldata_gas_cost_acc' == gas_cost_next", + // meta.query_advice(calldata_gas_cost_acc, Rotation::next()), + // gas_cost_next, + // ); + // cb.require_equal( + // "calldata_rlc' == byte'", + // meta.query_advice(calldata_rlc, Rotation::next()), + // meta.query_advice(tx_table.value, Rotation::next()), + // ); + // }, + // ); + cb.condition( and::expr([ - is_final_cur, - not::expr(tx_id_is_zero.expr(Rotation::next())(meta)), + is_final_cur.expr(), + meta.query_advice(is_access_list, Rotation::next()), ]), |cb| { - let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); - let gas_cost_next = select::expr(value_next_is_zero, 4.expr(), 16.expr()); - - cb.require_equal( - "index' == 0", - meta.query_advice(tx_table.index, Rotation::next()), - 0.expr(), - ); - cb.require_equal( - "calldata_gas_cost_acc' == gas_cost_next", - meta.query_advice(calldata_gas_cost_acc, Rotation::next()), - gas_cost_next, - ); - cb.require_equal( - "calldata_rlc' == byte'", - meta.query_advice(calldata_rlc, Rotation::next()), - meta.query_advice(tx_table.value, Rotation::next()), + cb.require_zero( + "tx_id stays the same for access list section at is_final == 1", + tx_id_unchanged.is_equal_expression.clone() - 1.expr(), ); - }, + } ); cb.gate(and::expr(vec![ @@ -1436,6 +1475,7 @@ impl SubCircuitConfig for TxCircuitConfig { al_idx, sk_idx, sks_acc, + is_access_list, _marker: PhantomData, num_txs, } @@ -1456,6 +1496,7 @@ impl TxCircuitConfig { lookup_conditions: &HashMap>, is_final: Column, is_calldata: Column, + is_access_list: Column, is_chain_id: Column, is_l1_msg_col: Column, is_eip2930: Column, @@ -2322,13 +2363,10 @@ impl TxCircuitConfig { // assign to access_list related columns if tx.access_list.as_ref().unwrap().0.len() > 0 { - // initialize gas counting - let mut gas_cost_acc = 0; - - // idx helper + // storage key len accumulator let mut sks_acc: usize = 0; - // row counting for determining when tx_id changes + // row counting for determining when section ends let total_rows: usize = tx.access_list.as_ref().unwrap().0.iter().fold(0, |acc, al| { acc + 1 + al.storage_keys.len() }); @@ -2342,8 +2380,8 @@ impl TxCircuitConfig { for (al_idx, al) in tx.access_list.as_ref().unwrap().0.iter().enumerate() { curr_row += 1; + let is_final = curr_row == total_rows; - gas_cost_acc += GS::ACCESS_LIST_PER_ADDRESS.as_u64(); let field_rlc = rlc_be_bytes(&al.address.to_fixed_bytes(), challenges.keccak_input()); section_rlc = section_rlc * r32 + field_rlc; @@ -2370,16 +2408,10 @@ impl TxCircuitConfig { ("sk_idx", self.sk_idx, F::from(0 as u64)), ("sks_acc", self.sks_acc, F::from(sks_acc as u64)), ("rlp_tag", self.rlp_tag, F::from(usize::from(Tag::AccessListAddress) as u64)), - + ("is_final", self.is_final, F::from(is_final as u64)), + ("is_access_list", self.is_access_list, F::one()), - // ("is_final", self.is_final, F::from(is_final as u64)), - // ( - // "gas_cost_acc", - // self.calldata_gas_cost_acc, - // F::from(gas_cost_acc), - // ), // ("byte", self.calldata_byte, F::from(*byte as u64)), - // ("is_calldata", self.is_calldata, F::one()), ] { region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } @@ -2391,10 +2423,9 @@ impl TxCircuitConfig { for (sk_idx, sk) in al.storage_keys.iter().enumerate() { curr_row += 1; - sks_acc += 1; + let is_final = curr_row == total_rows; - gas_cost_acc += GS::ACCESS_LIST_PER_STORAGE_KEY.as_u64(); let field_rlc = rlc_be_bytes(&sk.to_fixed_bytes(), challenges.keccak_input()); section_rlc = if sk_idx > 0 { section_rlc * r32 + field_rlc @@ -2425,16 +2456,10 @@ impl TxCircuitConfig { ("sk_idx", self.sk_idx, F::from((sk_idx + 1) as u64)), ("sks_acc", self.sks_acc, F::from(sks_acc as u64)), ("rlp_tag", self.rlp_tag, F::from(usize::from(Tag::AccessListStorageKey) as u64)), + ("is_final", self.is_final, F::from(is_final as u64)), + ("is_access_list", self.is_access_list, F::one()), - - // ("is_final", self.is_final, F::from(is_final as u64)), - // ( - // "gas_cost_acc", - // self.calldata_gas_cost_acc, - // F::from(gas_cost_acc), - // ), // ("byte", self.calldata_byte, F::from(*byte as u64)), - // ("is_calldata", self.is_calldata, F::one()), ] { region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } From 008646e86eb01a97016def367efddb6d0ed6ce69 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 2 Dec 2023 17:58:44 -0800 Subject: [PATCH 073/161] add access list rlc helper --- eth-types/src/geth_types.rs | 4 ++-- zkevm-circuits/src/tx_circuit.rs | 39 ++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/eth-types/src/geth_types.rs b/eth-types/src/geth_types.rs index 74c45e4933..23ad2ba0d9 100644 --- a/eth-types/src/geth_types.rs +++ b/eth-types/src/geth_types.rs @@ -9,7 +9,7 @@ use ethers_core::types::{ transaction::eip2718::TypedTransaction, Eip1559TransactionRequest, Eip2930TransactionRequest, NameOrAddress, TransactionRequest, H256, }; -use halo2_proofs::halo2curves::{group::ff::PrimeField, secp256k1::Fq}; +use halo2_proofs::{halo2curves::{group::ff::PrimeField, secp256k1::Fq}, transcript::ChallengeScalar}; use num::Integer; use num_bigint::BigUint; use serde::{Serialize, Serializer}; @@ -432,4 +432,4 @@ pub fn access_list_size(access_list: &Option) -> (u64, u64) { ) }, ) -} +} \ No newline at end of file diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 81ec9e939f..fd5d5fb129 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -48,7 +48,7 @@ use eth_types::{ }, evm_types::GasCost as GS, sign_types::SignData, - Address, Field, ToAddress, ToBigEndian, ToScalar, + Address, Field, ToAddress, ToBigEndian, ToScalar, AccessList, }; use ethers_core::utils::{keccak256, rlp::Encodable}; use gadgets::{ @@ -2066,14 +2066,7 @@ impl TxCircuitConfig { be_bytes_len: 0, be_bytes_rlc: zero_rlc, }), - // TODO: need to check if it's correct with RLP. - rlc_be_bytes( - &tx.access_list - .as_ref() - .map(|access_list| access_list.rlp_bytes()) - .unwrap_or_default(), - keccak_input, - ), + access_list_rlc(&tx.access_list, challenges), ), (BlockNumber, None, Value::known(F::from(tx.block_number))), ]; @@ -3134,3 +3127,31 @@ pub(crate) fn get_sign_data( .collect::, halo2_proofs::plonk::Error>>()?; Ok(signatures) } + +/// Returns the RLC of the access list including addresses and storage keys +pub fn access_list_rlc(access_list: &Option, challenges: &Challenges>) -> Value { + if access_list.is_some() { + let mut section_rlc = challenges.keccak_input().map(|_| F::zero()); + let r20 = challenges.keccak_input().map(|f| f.pow(&[20, 0, 0, 0]) ); + let r32 = challenges.keccak_input().map(|f| f.pow(&[32, 0, 0, 0]) ); + + for al in access_list.as_ref().unwrap().0.iter() { + let field_rlc = rlc_be_bytes(&al.address.to_fixed_bytes(), challenges.keccak_input()); + section_rlc = section_rlc * r32 + field_rlc; + + for (sk_idx, sk) in al.storage_keys.iter().enumerate() { + let field_rlc = rlc_be_bytes(&sk.to_fixed_bytes(), challenges.keccak_input()); + section_rlc = if sk_idx > 0 { + section_rlc * r32 + field_rlc + } else { + section_rlc * r20 + field_rlc + }; + } + } + + section_rlc + } else { + Value::known(F::zero()) + } +} + From e54aefcbea46322c36d6d5350993fc7ee5a9886e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 2 Dec 2023 18:47:27 -0800 Subject: [PATCH 074/161] adjust column and new section init --- zkevm-circuits/src/tx_circuit.rs | 50 ++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index fd5d5fb129..67c8188d7e 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -165,10 +165,11 @@ pub struct TxCircuitConfig { /// An accumulator value used to correctly calculate the calldata gas cost /// for a tx. calldata_gas_cost_acc: Column, - /// An accumulator value used to correctly calculate the RLC(calldata) for a tx. - calldata_rlc: Column, + /// An accumulator value used to correctly calculate the RLC(calldata and access list) for a tx. + /// contains two sections if access list is present on the tx + section_rlc: Column, /// 1st phase column which equals to tx_table.value when is_calldata is true - /// We need this because tx_table.value is a 2nd phase column and is used to get calldata_rlc. + /// We need this because tx_table.value is a 2nd phase column and is used to get section_rlc. /// It's not safe to do RLC on columns of same phase. calldata_byte: Column, @@ -284,7 +285,7 @@ impl SubCircuitConfig for TxCircuitConfig { // columns for accumulating length and gas_cost of call_data let is_final = meta.advice_column(); let calldata_gas_cost_acc = meta.advice_column(); - let calldata_rlc = meta.advice_column_in(SecondPhase); + let section_rlc = meta.advice_column_in(SecondPhase); let calldata_byte = meta.advice_column(); // booleans to reduce degree @@ -843,7 +844,7 @@ impl SubCircuitConfig for TxCircuitConfig { is_eip1559, sv_address, calldata_gas_cost_acc, - calldata_rlc, + section_rlc, tx_table.clone(), keccak_table.clone(), rlp_table, @@ -1241,8 +1242,8 @@ impl SubCircuitConfig for TxCircuitConfig { gas_cost, ); cb.require_equal( - "calldata_rlc == byte", - meta.query_advice(calldata_rlc, Rotation::cur()), + "section_rlc == byte", + meta.query_advice(section_rlc, Rotation::cur()), meta.query_advice(tx_table.value, Rotation::cur()), ); @@ -1280,9 +1281,9 @@ impl SubCircuitConfig for TxCircuitConfig { meta.query_advice(calldata_gas_cost_acc, Rotation::cur()) + gas_cost_next, ); cb.require_equal( - "calldata_rlc' = calldata_rlc * r + byte'", - meta.query_advice(calldata_rlc, Rotation::next()), - meta.query_advice(calldata_rlc, Rotation::cur()) * challenges.keccak_input() + "section_rlc' = section_rlc * r + byte'", + meta.query_advice(section_rlc, Rotation::next()), + meta.query_advice(section_rlc, Rotation::cur()) * challenges.keccak_input() + meta.query_advice(tx_table.value, Rotation::next()), ); }); @@ -1321,14 +1322,16 @@ impl SubCircuitConfig for TxCircuitConfig { // gas_cost_next, // ); // cb.require_equal( - // "calldata_rlc' == byte'", - // meta.query_advice(calldata_rlc, Rotation::next()), + // "section_rlc' == byte'", + // meta.query_advice(section_rlc, Rotation::next()), // meta.query_advice(tx_table.value, Rotation::next()), // ); // }, // ); + // Initialize the dynamic access list assignment section. + // Must follow immediately when the calldata section ends. cb.condition( and::expr([ is_final_cur.expr(), @@ -1339,6 +1342,15 @@ impl SubCircuitConfig for TxCircuitConfig { "tx_id stays the same for access list section at is_final == 1", tx_id_unchanged.is_equal_expression.clone() - 1.expr(), ); + cb.require_equal( + "al_idx starts with 1", + meta.query_advice(al_idx, Rotation::next()), + 1.expr() + ); + cb.require_zero( + "sks_acc starts with 0", + meta.query_advice(sks_acc, Rotation::next()), + ); } ); @@ -1463,7 +1475,7 @@ impl SubCircuitConfig for TxCircuitConfig { is_chain_id, is_final, calldata_gas_cost_acc, - calldata_rlc, + section_rlc, calldata_byte, sv_address, sig_table, @@ -1503,7 +1515,7 @@ impl TxCircuitConfig { is_eip1559: Column, sv_address: Column, calldata_gas_cost_acc: Column, - calldata_rlc: Column, + section_rlc: Column, tx_table: TxTable, keccak_table: KeccakTable, rlp_table: RlpTable, @@ -1588,7 +1600,7 @@ impl TxCircuitConfig { }); meta.lookup_any("lookup CallDataRLC in the calldata part", |meta| { let is_call_data = meta.query_advice(is_calldata, Rotation::cur()); - let calldata_rlc = meta.query_advice(calldata_rlc, Rotation::cur()); + let section_rlc = meta.query_advice(section_rlc, Rotation::cur()); let enable = and::expr([ meta.query_fixed(tx_table.q_enable, Rotation::cur()), is_call_data, @@ -1599,7 +1611,7 @@ impl TxCircuitConfig { let input_exprs = vec![ meta.query_advice(tx_table.tx_id, Rotation::cur()), CallDataRLC.expr(), - calldata_rlc.expr(), + section_rlc.expr(), ]; let table_exprs = vec![ meta.query_advice(tx_table.tx_id, Rotation::cur()), @@ -2335,7 +2347,7 @@ impl TxCircuitConfig { } // 2nd phase columns - region.assign_advice(|| "rlc", self.calldata_rlc, *offset, || rlc)?; + region.assign_advice(|| "rlc", self.section_rlc, *offset, || rlc)?; *offset += 1; } @@ -2410,7 +2422,7 @@ impl TxCircuitConfig { } // 2nd phase columns - region.assign_advice(|| "rlc", self.calldata_rlc, *offset, || section_rlc)?; + region.assign_advice(|| "rlc", self.section_rlc, *offset, || section_rlc)?; *offset += 1; @@ -2458,7 +2470,7 @@ impl TxCircuitConfig { } // 2nd phase columns - region.assign_advice(|| "rlc", self.calldata_rlc, *offset, || section_rlc)?; + region.assign_advice(|| "rlc", self.section_rlc, *offset, || section_rlc)?; *offset += 1; } From ecde4c6f9f99fe87c417c033a2d717da9908d132 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 2 Dec 2023 19:33:25 -0800 Subject: [PATCH 075/161] add boolean instruments, degree fix --- zkevm-circuits/src/tx_circuit.rs | 192 +++++++++++++++++++++++++++++-- 1 file changed, 185 insertions(+), 7 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 67c8188d7e..a219beb31e 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -199,6 +199,9 @@ pub struct TxCircuitConfig { sks_acc: Column, // section denoter for access list, reduces degree is_access_list: Column, + // access list tag denoter, reduces degree + is_access_list_address: Column, + is_access_list_storage_key: Column, _marker: PhantomData, } @@ -312,6 +315,9 @@ impl SubCircuitConfig for TxCircuitConfig { let sk_idx = meta.advice_column(); let sks_acc = meta.advice_column(); let is_access_list = meta.advice_column(); + let is_access_list_address = meta.advice_column(); + let is_access_list_storage_key = meta.advice_column(); + // TODO: add lookup to SignVerify table for sv_address let sv_address = meta.advice_column(); @@ -368,8 +374,8 @@ impl SubCircuitConfig for TxCircuitConfig { is_tx_tag!(is_access_list_addresses_len, AccessListAddressesLen); is_tx_tag!(is_access_list_storage_keys_len, AccessListStorageKeysLen); is_tx_tag!(is_access_list_rlc, AccessListRLC); - is_tx_tag!(is_access_list_address, AccessListAddress); - is_tx_tag!(is_access_list_storage_key, AccessListStorageKey); + is_tx_tag!(is_tag_access_list_address, AccessListAddress); + is_tx_tag!(is_tag_access_list_storage_key, AccessListStorageKey); let tx_id_unchanged = IsEqualChip::configure( @@ -487,8 +493,8 @@ impl SubCircuitConfig for TxCircuitConfig { (is_hash_rlc(meta), RLC), (is_caller_addr(meta), Tag::Sender.into()), (is_tx_gas_cost(meta), GasCost), - (is_access_list_address(meta), Tag::AccessListAddress.into()), - (is_access_list_storage_key(meta), Tag::AccessListStorageKey.into()), + (is_tag_access_list_address(meta), Tag::AccessListAddress.into()), + (is_tag_access_list_storage_key(meta), Tag::AccessListStorageKey.into()), // tx tags which correspond to Null (is_null(meta), Null), (is_create(meta), Null), @@ -612,10 +618,10 @@ impl SubCircuitConfig for TxCircuitConfig { let mut cb = BaseConstraintBuilder::default(); cb.require_equal( - "is_access_lits", + "is_access_list", sum::expr([ - is_access_list_address(meta), - is_access_list_storage_key(meta), + meta.query_advice(is_access_list_address, Rotation::cur()), + meta.query_advice(is_access_list_storage_key, Rotation::cur()), ]), meta.query_advice(is_access_list, Rotation::cur()), ); @@ -623,6 +629,24 @@ impl SubCircuitConfig for TxCircuitConfig { cb.gate(meta.query_fixed(q_enable, Rotation::cur())) }); + meta.create_gate("is_access_list_address and is_access_list_storage_key", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "is_access_list_address", + tag_bits.value_equals(TxFieldTag::AccessListAddress, Rotation::cur())(meta), + meta.query_advice(is_access_list_address, Rotation::cur()), + ); + + cb.require_equal( + "is_access_list_storage_key", + tag_bits.value_equals(TxFieldTag::AccessListStorageKey, Rotation::cur())(meta), + meta.query_advice(is_access_list_storage_key, Rotation::cur()), + ); + + cb.gate(meta.query_fixed(q_enable, Rotation::cur())) + }); + meta.create_gate("is_caller_address", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1361,6 +1385,154 @@ impl SubCircuitConfig for TxCircuitConfig { ])) }); + + //////////////////////////////////////////////////////////////////////// + /////////// Access List Constraints (if available on tx) ///////////// + //////////////////////////////////////////////////////////////////////// + meta.create_gate("tx call data bytes", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + let is_final_cur = meta.query_advice(is_final, Rotation::cur()); + cb.require_boolean("is_final is boolean", is_final_cur.clone()); + + // within same tx, next tag is AccessListAddress + cb.condition( + and::expr([ + not::expr(is_final_cur.clone()), + meta.query_advice(is_access_list_address, Rotation::next()) + ]), + |cb| { + cb.require_equal( + "sks_acc' = sks_acc", + meta.query_advice(sks_acc, Rotation::cur()), + meta.query_advice(sks_acc, Rotation::next()), + ); + cb.require_equal( + "al_idx' = al_idx + 1", + meta.query_advice(al_idx, Rotation::cur()) + 1.expr(), + meta.query_advice(al_idx, Rotation::next()), + ); + }); + + // within same tx, next tag is AccessListStorageKey + cb.condition( + and::expr([ + not::expr(is_final_cur.clone()), + meta.query_advice(is_access_list_storage_key, Rotation::next()) + ]), + |cb| { + cb.require_equal( + "sks_acc' = sks_acc + 1", + meta.query_advice(sks_acc, Rotation::cur()) + 1.expr(), + meta.query_advice(sks_acc, Rotation::next()), + ); + cb.require_equal( + "sk_idx' = sk_idx + 1", + meta.query_advice(sk_idx, Rotation::cur()) + 1.expr(), + meta.query_advice(sk_idx, Rotation::next()), + ); + cb.require_equal( + "al_idx' = al_idx", + meta.query_advice(al_idx, Rotation::cur()), + meta.query_advice(al_idx, Rotation::next()), + ); + cb.require_equal( + "access_list_address' = access_list_address", + meta.query_advice(tx_table.access_list_address, Rotation::cur()), + meta.query_advice(tx_table.access_list_address, Rotation::next()), + ); + }); + + + + + + + + + + // checks for any row, except the final call data byte. + // cb.condition(, |cb| { + // cb.require_equal( + // "index::next == index::cur + 1", + // meta.query_advice(tx_table.index, Rotation::next()), + // meta.query_advice(tx_table.index, Rotation::cur()) + 1.expr(), + // ); + // cb.require_equal( + // "tx_id::next == tx_id::cur", + // tx_id_unchanged.is_equal_expression.clone(), + // 1.expr(), + // ); + + // let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); + // let gas_cost_next = select::expr(value_next_is_zero, 4.expr(), 16.expr()); + // // call data gas cost accumulator check. + // cb.require_equal( + // "calldata_gas_cost_acc::next == calldata_gas_cost::cur + gas_cost_next", + // meta.query_advice(calldata_gas_cost_acc, Rotation::next()), + // meta.query_advice(calldata_gas_cost_acc, Rotation::cur()) + gas_cost_next, + // ); + // cb.require_equal( + // "section_rlc' = section_rlc * r + byte'", + // meta.query_advice(section_rlc, Rotation::next()), + // meta.query_advice(section_rlc, Rotation::cur()) * challenges.keccak_input() + // + meta.query_advice(tx_table.value, Rotation::next()), + // ); + // }); + + // on the final call data byte, must transition to another + // calldata section or an access list section for the same tx + + + + + // tx1559_debug + // on the final call data byte, tx_id must change. + // cb.condition(is_final_cur.expr(), |cb| { + // cb.require_zero( + // "tx_id changes at is_final == 1", + // tx_id_unchanged.is_equal_expression.clone(), + // ); + // }); + + // tx1559_debug + // cb.condition( + // and::expr([ + // is_final_cur, + // not::expr(tx_id_is_zero.expr(Rotation::next())(meta)), + // ]), + // |cb| { + // let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); + // let gas_cost_next = select::expr(value_next_is_zero, 4.expr(), 16.expr()); + + // cb.require_equal( + // "index' == 0", + // meta.query_advice(tx_table.index, Rotation::next()), + // 0.expr(), + // ); + // cb.require_equal( + // "calldata_gas_cost_acc' == gas_cost_next", + // meta.query_advice(calldata_gas_cost_acc, Rotation::next()), + // gas_cost_next, + // ); + // cb.require_equal( + // "section_rlc' == byte'", + // meta.query_advice(section_rlc, Rotation::next()), + // meta.query_advice(tx_table.value, Rotation::next()), + // ); + // }, + // ); + + cb.gate(and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list, Rotation::cur()), + not::expr(tx_id_is_zero.expr(Rotation::cur())(meta)), + ])) + }); + + + + //////////////////////////////////////////////////////////////////////// /////////// SignVerify recover CallerAddress ////////////////////// //////////////////////////////////////////////////////////////////////// @@ -1488,6 +1660,8 @@ impl SubCircuitConfig for TxCircuitConfig { sk_idx, sks_acc, is_access_list, + is_access_list_address, + is_access_list_storage_key, _marker: PhantomData, num_txs, } @@ -2415,6 +2589,8 @@ impl TxCircuitConfig { ("rlp_tag", self.rlp_tag, F::from(usize::from(Tag::AccessListAddress) as u64)), ("is_final", self.is_final, F::from(is_final as u64)), ("is_access_list", self.is_access_list, F::one()), + ("is_access_list_address", self.is_access_list_address, F::one()), + // ("byte", self.calldata_byte, F::from(*byte as u64)), ] { @@ -2463,6 +2639,8 @@ impl TxCircuitConfig { ("rlp_tag", self.rlp_tag, F::from(usize::from(Tag::AccessListStorageKey) as u64)), ("is_final", self.is_final, F::from(is_final as u64)), ("is_access_list", self.is_access_list, F::one()), + ("is_access_list_storage_key", self.is_access_list_storage_key, F::one()), + // ("byte", self.calldata_byte, F::from(*byte as u64)), ] { From a9ff11a262b96f7bcf529aea071d1e1a841871ee Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 2 Dec 2023 20:29:05 -0800 Subject: [PATCH 076/161] add constraints --- zkevm-circuits/src/tx_circuit.rs | 65 +++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index a219beb31e..be276b1aaf 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -1385,16 +1385,48 @@ impl SubCircuitConfig for TxCircuitConfig { ])) }); - //////////////////////////////////////////////////////////////////////// /////////// Access List Constraints (if available on tx) ///////////// //////////////////////////////////////////////////////////////////////// - meta.create_gate("tx call data bytes", |meta| { + meta.create_gate("tx access list", |meta| { let mut cb = BaseConstraintBuilder::default(); let is_final_cur = meta.query_advice(is_final, Rotation::cur()); cb.require_boolean("is_final is boolean", is_final_cur.clone()); + // current tag is AccessListAddress + cb.condition( + and::expr([ + not::expr(is_final_cur.clone()), + meta.query_advice(is_access_list_address, Rotation::cur()) + ]), + |cb| { + cb.require_equal( + "index = al_idx", + meta.query_advice(al_idx, Rotation::cur()), + meta.query_advice(tx_table.index, Rotation::cur()), + ); + cb.require_equal( + "access_list_address = value", + meta.query_advice(tx_table.value, Rotation::cur()), + meta.query_advice(tx_table.access_list_address, Rotation::cur()), + ); + cb.require_zero( + "sk_idx = 0", + meta.query_advice(sk_idx, Rotation::cur()), + ); + }); + + // current tag is AccessListStorageKey + cb.condition( + and::expr([ + not::expr(is_final_cur.clone()), + meta.query_advice(is_access_list_storage_key, Rotation::cur()) + ]), + |cb| { + + }); + // within same tx, next tag is AccessListAddress cb.condition( and::expr([ @@ -1443,14 +1475,6 @@ impl SubCircuitConfig for TxCircuitConfig { ); }); - - - - - - - - // checks for any row, except the final call data byte. // cb.condition(, |cb| { // cb.require_equal( @@ -1483,9 +1507,6 @@ impl SubCircuitConfig for TxCircuitConfig { // on the final call data byte, must transition to another // calldata section or an access list section for the same tx - - - // tx1559_debug // on the final call data byte, tx_id must change. // cb.condition(is_final_cur.expr(), |cb| { @@ -1530,9 +1551,6 @@ impl SubCircuitConfig for TxCircuitConfig { ])) }); - - - //////////////////////////////////////////////////////////////////////// /////////// SignVerify recover CallerAddress ////////////////////// //////////////////////////////////////////////////////////////////////// @@ -2003,6 +2021,7 @@ impl TxCircuitConfig { TxFieldTag::Null, 0, Value::known(F::zero()), + Value::known(F::zero()), )?; let (col_anno, col, col_val) = ("rlp_tag", self.rlp_tag, F::from(usize::from(Null) as u64)); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; @@ -2283,6 +2302,7 @@ impl TxCircuitConfig { tx_tag, 0, tx_value, + Value::known(F::zero()), )?); // 1st phase columns @@ -2502,6 +2522,7 @@ impl TxCircuitConfig { CallData, idx as u64, Value::known(F::from(*byte as u64)), + Value::known(F::zero()), )?; // 1st phase columns @@ -2576,7 +2597,8 @@ impl TxCircuitConfig { Some(tx), tx_id_next, TxFieldTag::AccessListAddress, - al_idx as u64, + (al_idx + 1) as u64, + Value::known(al.address.to_scalar().unwrap()), Value::known(al.address.to_scalar().unwrap()), )?; @@ -2627,7 +2649,8 @@ impl TxCircuitConfig { tx_id_next, TxFieldTag::AccessListStorageKey, sks_acc as u64, - rlc_be_bytes(&sk.to_fixed_bytes(), challenges.evm_word()) + rlc_be_bytes(&sk.to_fixed_bytes(), challenges.evm_word()), + Value::known(al.address.to_scalar().unwrap()), )?; // 1st phase columns @@ -2672,6 +2695,7 @@ impl TxCircuitConfig { tag: TxFieldTag, index: u64, value: Value, + access_list_address: Value, ) -> Result, Error> { let (tx_type, tx_id) = if let Some(tx) = tx { (tx.tx_type, tx.id) @@ -2733,9 +2757,14 @@ impl TxCircuitConfig { ] { region.assign_advice(|| col_anno, col, offset, || Value::known(col_val))?; } + + // additional access_list_address column + region.assign_advice(|| "access_list_address value", self.tx_table.access_list_address, offset, || access_list_address)?; + // 2nd phase columns let tx_value_cell = region.assign_advice(|| "tx_value", self.tx_table.value, offset, || value)?; + Ok(tx_value_cell) } From cfa05b0cb7f50599be16f1693ffdf2840c6eb140 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sat, 2 Dec 2023 20:42:21 -0800 Subject: [PATCH 077/161] add constraints --- zkevm-circuits/src/tx_circuit.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index be276b1aaf..9d7c29d446 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -1424,7 +1424,11 @@ impl SubCircuitConfig for TxCircuitConfig { meta.query_advice(is_access_list_storage_key, Rotation::cur()) ]), |cb| { - + cb.require_equal( + "index = sks_acc", + meta.query_advice(sks_acc, Rotation::cur()), + meta.query_advice(tx_table.index, Rotation::cur()), + ); }); // within same tx, next tag is AccessListAddress From d3d0486baa2cda8bb074f0e8f16a58e45c5d3861 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 3 Dec 2023 20:41:27 -0800 Subject: [PATCH 078/161] add rlp lookup --- zkevm-circuits/src/tx_circuit.rs | 165 ++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 4 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 9d7c29d446..ce07c0ef37 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -202,6 +202,10 @@ pub struct TxCircuitConfig { // access list tag denoter, reduces degree is_access_list_address: Column, is_access_list_storage_key: Column, + // field_rlc holds tag rlc from RLP FSM + // works together with section_rlc to ensure + // no ommittance in access list dynamic section + field_rlc: Column, _marker: PhantomData, } @@ -317,7 +321,7 @@ impl SubCircuitConfig for TxCircuitConfig { let is_access_list = meta.advice_column(); let is_access_list_address = meta.advice_column(); let is_access_list_storage_key = meta.advice_column(); - + let field_rlc = meta.advice_column(); // TODO: add lookup to SignVerify table for sv_address let sv_address = meta.advice_column(); @@ -869,10 +873,15 @@ impl SubCircuitConfig for TxCircuitConfig { sv_address, calldata_gas_cost_acc, section_rlc, + field_rlc, tx_table.clone(), keccak_table.clone(), rlp_table, sig_table, + is_access_list_address, + is_access_list_storage_key, + al_idx, + sk_idx, ); meta.create_gate("tx_gas_cost == 0 for L1 msg", |meta| { @@ -1684,6 +1693,7 @@ impl SubCircuitConfig for TxCircuitConfig { is_access_list, is_access_list_address, is_access_list_storage_key, + field_rlc, _marker: PhantomData, num_txs, } @@ -1712,10 +1722,15 @@ impl TxCircuitConfig { sv_address: Column, calldata_gas_cost_acc: Column, section_rlc: Column, + field_rlc: Column, tx_table: TxTable, keccak_table: KeccakTable, rlp_table: RlpTable, sig_table: SigTable, + is_access_list_address: Column, + is_access_list_storage_key: Column, + al_idx: Column, + sk_idx: Column, ) { macro_rules! is_tx_type { ($var:ident, $type_variant:ident) => { @@ -1937,6 +1952,80 @@ impl TxCircuitConfig { .collect() }); + // tx1559_debug + // lookup access list address in RLP table + // 1. ensure field_rlc is correct + // 2. ensure value of address is correct + // meta.lookup_any("lookup access list address in RLP Table from tx circuit dynamic section", |meta| { + // let enable = and::expr(vec![ + // meta.query_fixed(q_enable, Rotation::cur()), + // meta.query_advice(is_access_list_address, Rotation::cur()), + // ]); + + // // only eip2930 and eip1559 contains an access list + // let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxSignEip2930.expr() + // + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); + // let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxHashEip2930.expr() + // + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); + + // vec![ + // 1.expr(), // q_enable = true + // meta.query_advice(tx_table.tx_id, Rotation::cur()), + // // tx1559_debug + // // hash_format, + // sign_format, + // meta.query_advice(rlp_tag, Rotation::cur()), + // meta.query_advice(tx_table.value, Rotation::cur()), + // meta.query_advice(field_rlc, Rotation::cur()), + // 20.expr(), // 20 bytes for address + // 1.expr(), // is_output = true + // 0.expr(), // is_none = false. must have value + // meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + // meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + // ] + // .into_iter() + // .zip_eq(rlp_table.table_exprs(meta).into_iter()) + // .map(|(arg, table)| (enable.clone() * arg, table)) + // .collect() + // }); + + // tx1559_debug + // lookup access list storage key in RLP table + // 1. ensure field_rlc is correct + // 2. ensure value of storage key is correct + // meta.lookup_any("lookup access list storage key in RLP Table from tx circuit dynamic section", |meta| { + // let enable = and::expr(vec![ + // meta.query_fixed(q_enable, Rotation::cur()), + // meta.query_advice(is_access_list_storage_key, Rotation::cur()), + // ]); + + // // only eip2930 and eip1559 contains an access list + // let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxSignEip2930.expr() + // + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); + // let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxHashEip2930.expr() + // + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); + + // vec![ + // 1.expr(), // q_enable = true + // meta.query_advice(tx_table.tx_id, Rotation::cur()), + // sign_format, + // // tx1559_debug + // // hash_format, + // meta.query_advice(rlp_tag, Rotation::cur()), + // meta.query_advice(tx_table.value, Rotation::cur()), + // meta.query_advice(field_rlc, Rotation::cur()), + // 32.expr(), // 32 bytes for storage keys + // 1.expr(), // is_output = true + // 0.expr(), // is_none = false. must have value + // meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + // meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + // ] + // .into_iter() + // .zip_eq(rlp_table.table_exprs(meta).into_iter()) + // .map(|(arg, table)| (enable.clone() * arg, table)) + // .collect() + // }); + //////////////////////////////////////////////////////////////////// ///////////////// Sig table lookups ////////////////////// ///////////////// ////////////////////////////////////////////////// @@ -2026,6 +2115,8 @@ impl TxCircuitConfig { 0, Value::known(F::zero()), Value::known(F::zero()), + // tx1559_debug + false, )?; let (col_anno, col, col_val) = ("rlp_tag", self.rlp_tag, F::from(usize::from(Null) as u64)); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; @@ -2307,6 +2398,8 @@ impl TxCircuitConfig { 0, tx_value, Value::known(F::zero()), + // tx1559_debug + false, )?); // 1st phase columns @@ -2527,6 +2620,8 @@ impl TxCircuitConfig { idx as u64, Value::known(F::from(*byte as u64)), Value::known(F::zero()), + // tx1559_debug + false, )?; // 1st phase columns @@ -2564,6 +2659,7 @@ impl TxCircuitConfig { challenges: &Challenges>, ) -> Result<(), Error> { // tx1559_debug + let should_print = true; // assign to access_list related columns if tx.access_list.as_ref().unwrap().0.len() > 0 { @@ -2604,6 +2700,7 @@ impl TxCircuitConfig { (al_idx + 1) as u64, Value::known(al.address.to_scalar().unwrap()), Value::known(al.address.to_scalar().unwrap()), + should_print )?; // 1st phase columns @@ -2617,12 +2714,18 @@ impl TxCircuitConfig { ("is_access_list", self.is_access_list, F::one()), ("is_access_list_address", self.is_access_list_address, F::one()), - // ("byte", self.calldata_byte, F::from(*byte as u64)), ] { + // tx1559_debug + log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", col_anno, offset, col_val); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } + // field_rlc to work with section_rlc + // tx1559_debug + log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", "field_rlc", offset, field_rlc.into_field()); + region.assign_advice(|| "field_rlc", self.field_rlc, *offset, || field_rlc)?; + // 2nd phase columns region.assign_advice(|| "rlc", self.section_rlc, *offset, || section_rlc)?; @@ -2655,6 +2758,8 @@ impl TxCircuitConfig { sks_acc as u64, rlc_be_bytes(&sk.to_fixed_bytes(), challenges.evm_word()), Value::known(al.address.to_scalar().unwrap()), + // tx1559_debug + false, )?; // 1st phase columns @@ -2668,12 +2773,14 @@ impl TxCircuitConfig { ("is_access_list", self.is_access_list, F::one()), ("is_access_list_storage_key", self.is_access_list_storage_key, F::one()), - // ("byte", self.calldata_byte, F::from(*byte as u64)), ] { region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } + // field_rlc to work with section_rlc + region.assign_advice(|| "field_rlc", self.field_rlc, *offset, || field_rlc)?; + // 2nd phase columns region.assign_advice(|| "rlc", self.section_rlc, *offset, || section_rlc)?; @@ -2700,6 +2807,8 @@ impl TxCircuitConfig { index: u64, value: Value, access_list_address: Value, + // tx1559_debug + should_print: bool, ) -> Result, Error> { let (tx_type, tx_id) = if let Some(tx) = tx { (tx.tx_type, tx.id) @@ -2733,6 +2842,10 @@ impl TxCircuitConfig { ("q_enable", self.tx_table.q_enable, F::one()), ("tag", self.tx_table.tag, F::from(usize::from(tag) as u64)), ] { + // tx1559_debug + if should_print { + log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", col_anno, offset, col_val); + } region.assign_fixed(|| col_anno, col, offset, || Value::known(col_val))?; } @@ -2757,15 +2870,26 @@ impl TxCircuitConfig { self.is_eip1559, F::from(tx_type.is_eip1559() as u64), ), - ] { + // tx1559_debug + if should_print { + log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", col_anno, offset, col_val); + } region.assign_advice(|| col_anno, col, offset, || Value::known(col_val))?; } // additional access_list_address column + // tx1559_debug + if should_print { + log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", "access_list_address value", offset, access_list_address.into_field()); + } region.assign_advice(|| "access_list_address value", self.tx_table.access_list_address, offset, || access_list_address)?; // 2nd phase columns + // tx1559_debug + if should_print { + log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", "tx_table.value", offset, value.into_field()); + } let tx_value_cell = region.assign_advice(|| "tx_value", self.tx_table.value, offset, || value)?; @@ -3378,3 +3502,36 @@ pub fn access_list_rlc(access_list: &Option, challenges: & } } +// tx1559_debug +// Evaluate an expression using a `CachedRegion` at `offset`. +// pub(crate) fn evaluate_expression( +// expr: &Expression, +// region: &Region<'_, F>, +// offset: usize, +// ) -> Value { +// expr.evaluate( +// &|scalar| Value::known(scalar), +// &|_| unimplemented!("selector column"), +// &|fixed_query| { +// Value::known(region.fi +// region.get_fixed( +// offset, +// fixed_query.column_index(), +// fixed_query.rotation(), +// )) +// }, +// &|advice_query| { +// Value::known(region.get_advice( +// offset, +// advice_query.column_index(), +// advice_query.rotation(), +// )) +// }, +// &|_| unimplemented!("instance column"), +// &|challenge| *region.challenges().indexed()[challenge.index()], +// &|a| -a, +// &|a, b| a + b, +// &|a, b| a * b, +// &|a, scalar| a * Value::known(scalar), +// ) +// } From 4fd060b156acbb7ab253e44237bc9179f3e2df8d Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 3 Dec 2023 21:10:01 -0800 Subject: [PATCH 079/161] add section_rlc starting for access list --- zkevm-circuits/src/tx_circuit.rs | 35 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index ce07c0ef37..a47d73bf4b 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -865,7 +865,8 @@ impl SubCircuitConfig for TxCircuitConfig { &lookup_conditions, is_final, is_calldata, - is_access_list, + // tx1559_debug + // is_access_list, is_chain_id, is_l1_msg, is_eip2930, @@ -873,15 +874,17 @@ impl SubCircuitConfig for TxCircuitConfig { sv_address, calldata_gas_cost_acc, section_rlc, - field_rlc, + // tx1559_debug + // field_rlc, tx_table.clone(), keccak_table.clone(), rlp_table, sig_table, - is_access_list_address, - is_access_list_storage_key, - al_idx, - sk_idx, + // tx1559_debug + // is_access_list_address, + // is_access_list_storage_key, + // al_idx, + // sk_idx, ); meta.create_gate("tx_gas_cost == 0 for L1 msg", |meta| { @@ -1384,6 +1387,11 @@ impl SubCircuitConfig for TxCircuitConfig { "sks_acc starts with 0", meta.query_advice(sks_acc, Rotation::next()), ); + cb.require_equal( + "section_rlc::cur == field_rlc::cur", + meta.query_advice(section_rlc, Rotation::next()), + meta.query_advice(field_rlc, Rotation::next()), + ); } ); @@ -1714,7 +1722,8 @@ impl TxCircuitConfig { lookup_conditions: &HashMap>, is_final: Column, is_calldata: Column, - is_access_list: Column, + // tx1559_debug + // is_access_list: Column, is_chain_id: Column, is_l1_msg_col: Column, is_eip2930: Column, @@ -1722,15 +1731,17 @@ impl TxCircuitConfig { sv_address: Column, calldata_gas_cost_acc: Column, section_rlc: Column, - field_rlc: Column, + // tx1559_debug + // field_rlc: Column, tx_table: TxTable, keccak_table: KeccakTable, rlp_table: RlpTable, sig_table: SigTable, - is_access_list_address: Column, - is_access_list_storage_key: Column, - al_idx: Column, - sk_idx: Column, + // tx1559_debug + // is_access_list_address: Column, + // is_access_list_storage_key: Column, + // al_idx: Column, + // sk_idx: Column, ) { macro_rules! is_tx_type { ($var:ident, $type_variant:ident) => { From 7c4b38ca9ad6dc27c8ba551c81007c65453c326c Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 3 Dec 2023 21:41:14 -0800 Subject: [PATCH 080/161] add section_rlc accumulation --- zkevm-circuits/src/tx_circuit.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index a47d73bf4b..b9303d5aa6 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -1411,6 +1411,12 @@ impl SubCircuitConfig for TxCircuitConfig { let is_final_cur = meta.query_advice(is_final, Rotation::cur()); cb.require_boolean("is_final is boolean", is_final_cur.clone()); + // section_rlc accumulation factor, rand^20 for addresses or rand^32 for storage keys + let r20 = [1, 0, 1, 0, 0].iter() + .fold(1.expr(), |acc: Expression, bit| acc.clone() * acc * if *bit > 0 { challenges.keccak_input() } else { 1.expr() }); + let r32 = [1, 0, 0, 0, 0, 0].iter() + .fold(1.expr(), |acc: Expression, bit| acc.clone() * acc * if *bit > 0 { challenges.keccak_input() } else { 1.expr() }); + // current tag is AccessListAddress cb.condition( and::expr([ @@ -1432,6 +1438,12 @@ impl SubCircuitConfig for TxCircuitConfig { "sk_idx = 0", meta.query_advice(sk_idx, Rotation::cur()), ); + cb.require_equal( + "section_rlc accumulation: r = rand^20, section_rlc' = section_rlc * r + field_rlc'", + meta.query_advice(section_rlc, Rotation::next()), + meta.query_advice(section_rlc, Rotation::cur()) * r20 + + meta.query_advice(field_rlc, Rotation::next()), + ); }); // current tag is AccessListStorageKey @@ -1446,6 +1458,12 @@ impl SubCircuitConfig for TxCircuitConfig { meta.query_advice(sks_acc, Rotation::cur()), meta.query_advice(tx_table.index, Rotation::cur()), ); + cb.require_equal( + "section_rlc accumulation: r = rand^32, section_rlc' = section_rlc * r + field_rlc'", + meta.query_advice(section_rlc, Rotation::next()), + meta.query_advice(section_rlc, Rotation::cur()) * r32 + + meta.query_advice(field_rlc, Rotation::next()), + ); }); // within same tx, next tag is AccessListAddress From 2cf3fb42c83c93501f5e237fe7e7a6e97651c51a Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 3 Dec 2023 21:49:54 -0800 Subject: [PATCH 081/161] recover section constraint --- zkevm-circuits/src/tx_circuit.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index b9303d5aa6..a3f957b276 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -1324,24 +1324,30 @@ impl SubCircuitConfig for TxCircuitConfig { ); }); + // End of calldata bytes transition: // on the final call data byte, must transition to another // calldata section or an access list section for the same tx - - // tx1559_debug - // on the final call data byte, tx_id must change. - // cb.condition(is_final_cur.expr(), |cb| { - // cb.require_zero( - // "tx_id changes at is_final == 1", - // tx_id_unchanged.is_equal_expression.clone(), - // ); - // }); + // on the final call data byte, if there's no access list, tx_id must change. + cb.condition( + and::expr([ + is_final_cur.expr(), + not::expr(meta.query_advice(is_access_list, Rotation::next())), + ]), + |cb| { + cb.require_zero( + "tx_id changes at is_final == 1", + tx_id_unchanged.is_equal_expression.clone(), + ); + } + ); // tx1559_debug // cb.condition( // and::expr([ - // is_final_cur, + // is_final_cur.clone(), // not::expr(tx_id_is_zero.expr(Rotation::next())(meta)), + // not::expr(meta.query_advice(is_access_list, Rotation::next())), // ]), // |cb| { // let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); From 8e50a62d2130cc67c73fbe306c148764bd6880cc Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 3 Dec 2023 22:01:46 -0800 Subject: [PATCH 082/161] look up access list address --- zkevm-circuits/src/tx_circuit.rs | 36 +++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index a3f957b276..86ce9a28a2 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -880,11 +880,12 @@ impl SubCircuitConfig for TxCircuitConfig { keccak_table.clone(), rlp_table, sig_table, + is_access_list, // tx1559_debug // is_access_list_address, // is_access_list_storage_key, - // al_idx, - // sk_idx, + al_idx, + sk_idx, ); meta.create_gate("tx_gas_cost == 0 for L1 msg", |meta| { @@ -1371,7 +1372,6 @@ impl SubCircuitConfig for TxCircuitConfig { // }, // ); - // Initialize the dynamic access list assignment section. // Must follow immediately when the calldata section ends. cb.condition( @@ -1761,11 +1761,12 @@ impl TxCircuitConfig { keccak_table: KeccakTable, rlp_table: RlpTable, sig_table: SigTable, + is_access_list: Column, // tx1559_debug // is_access_list_address: Column, // is_access_list_storage_key: Column, - // al_idx: Column, - // sk_idx: Column, + al_idx: Column, + sk_idx: Column, ) { macro_rules! is_tx_type { ($var:ident, $type_variant:ident) => { @@ -1872,6 +1873,31 @@ impl TxCircuitConfig { .collect() }); + meta.lookup_any("lookup AccessListAddressLen in the TxTable", |meta| { + let enable = and::expr([ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list, Rotation::cur()), + meta.query_advice(is_final, Rotation::cur()), + ]); + + let input_exprs = vec![ + meta.query_advice(tx_table.tx_id, Rotation::cur()), + AccessListAddressesLen.expr(), + meta.query_advice(al_idx, Rotation::cur()), + ]; + let table_exprs = vec![ + meta.query_advice(tx_table.tx_id, Rotation::cur()), + meta.query_fixed(tx_table.tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + ]; + + input_exprs + .into_iter() + .zip(table_exprs.into_iter()) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }); + ///////////////////////////////////////////////////////////////// ///////////////// RLP table lookups ////////////////////// ///////////////// //////////////////////////////////////////////// From 69be6171841949aefb98f31f17464f8e4e82d91a Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 3 Dec 2023 22:05:15 -0800 Subject: [PATCH 083/161] lookup access list storage key len --- zkevm-circuits/src/tx_circuit.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 86ce9a28a2..576e470ac1 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -886,6 +886,7 @@ impl SubCircuitConfig for TxCircuitConfig { // is_access_list_storage_key, al_idx, sk_idx, + sks_acc, ); meta.create_gate("tx_gas_cost == 0 for L1 msg", |meta| { @@ -1767,6 +1768,7 @@ impl TxCircuitConfig { // is_access_list_storage_key: Column, al_idx: Column, sk_idx: Column, + sks_acc: Column, ) { macro_rules! is_tx_type { ($var:ident, $type_variant:ident) => { @@ -1898,6 +1900,31 @@ impl TxCircuitConfig { .collect() }); + meta.lookup_any("lookup AccessListStorageKeysLen in the TxTable", |meta| { + let enable = and::expr([ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list, Rotation::cur()), + meta.query_advice(is_final, Rotation::cur()), + ]); + + let input_exprs = vec![ + meta.query_advice(tx_table.tx_id, Rotation::cur()), + AccessListStorageKeysLen.expr(), + meta.query_advice(sks_acc, Rotation::cur()), + ]; + let table_exprs = vec![ + meta.query_advice(tx_table.tx_id, Rotation::cur()), + meta.query_fixed(tx_table.tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + ]; + + input_exprs + .into_iter() + .zip(table_exprs.into_iter()) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }); + ///////////////////////////////////////////////////////////////// ///////////////// RLP table lookups ////////////////////// ///////////////// //////////////////////////////////////////////// From eabd98bc38f154d5083cb8d0ab3830de16eb314c Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 3 Dec 2023 23:32:05 -0800 Subject: [PATCH 084/161] fmt --- eth-types/src/geth_types.rs | 7 +- zkevm-circuits/src/table.rs | 5 +- zkevm-circuits/src/tx_circuit.rs | 299 +++++++++++++------------- zkevm-circuits/src/tx_circuit/test.rs | 25 ++- zkevm-circuits/src/witness/tx.rs | 10 +- 5 files changed, 177 insertions(+), 169 deletions(-) diff --git a/eth-types/src/geth_types.rs b/eth-types/src/geth_types.rs index 23ad2ba0d9..b28aeaf747 100644 --- a/eth-types/src/geth_types.rs +++ b/eth-types/src/geth_types.rs @@ -9,7 +9,10 @@ use ethers_core::types::{ transaction::eip2718::TypedTransaction, Eip1559TransactionRequest, Eip2930TransactionRequest, NameOrAddress, TransactionRequest, H256, }; -use halo2_proofs::{halo2curves::{group::ff::PrimeField, secp256k1::Fq}, transcript::ChallengeScalar}; +use halo2_proofs::{ + halo2curves::{group::ff::PrimeField, secp256k1::Fq}, + transcript::ChallengeScalar, +}; use num::Integer; use num_bigint::BigUint; use serde::{Serialize, Serializer}; @@ -432,4 +435,4 @@ pub fn access_list_size(access_list: &Option) -> (u64, u64) { ) }, ) -} \ No newline at end of file +} diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 63516f4c6a..5b61dec985 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -319,8 +319,9 @@ impl TxTable { // Tx Table contains an initial region that has a size parametrized by max_txs // with all the tx data except for calldata and access list, and then a second // region that has a size parametrized by max_calldata with all - // the tx calldata and access list. This is required to achieve a constant fixed column tag - // regardless of the number of input txs or the calldata/access list size of each tx. + // the tx calldata and access list. This is required to achieve a constant fixed + // column tag regardless of the number of input txs or the + // calldata/access list size of each tx. let mut calldata_assignments: Vec<[Value; 5]> = Vec::new(); let mut access_list_assignments: Vec<[Value; 5]> = Vec::new(); // Assign Tx data (all tx fields except for calldata) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 576e470ac1..817c3ea137 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -33,7 +33,10 @@ use crate::{ witness, witness::{ rlp_fsm::{Tag, ValueTagLength}, - Format::{L1MsgHash, TxHashEip155, TxHashPreEip155, TxSignEip155, TxSignPreEip155, TxSignEip2930, TxSignEip1559, TxHashEip2930, TxHashEip1559}, + Format::{ + L1MsgHash, TxHashEip155, TxHashEip1559, TxHashEip2930, TxHashPreEip155, TxSignEip155, + TxSignEip1559, TxSignEip2930, TxSignPreEip155, + }, RlpTag, RlpTag::{GasCost, Len, Null, RLC}, Tag::TxType as RLPTxType, @@ -42,13 +45,13 @@ use crate::{ }; use bus_mapping::circuit_input_builder::keccak_inputs_sign_verify; use eth_types::{ + evm_types::GasCost as GS, geth_types::{ access_list_size, TxType, - TxType::{Eip155, L1Msg, PreEip155, Eip2930, Eip1559}, + TxType::{Eip155, Eip1559, Eip2930, L1Msg, PreEip155}, }, - evm_types::GasCost as GS, sign_types::SignData, - Address, Field, ToAddress, ToBigEndian, ToScalar, AccessList, + AccessList, Address, Field, ToAddress, ToBigEndian, ToScalar, }; use ethers_core::utils::{keccak256, rlp::Encodable}; use gadgets::{ @@ -165,8 +168,8 @@ pub struct TxCircuitConfig { /// An accumulator value used to correctly calculate the calldata gas cost /// for a tx. calldata_gas_cost_acc: Column, - /// An accumulator value used to correctly calculate the RLC(calldata and access list) for a tx. - /// contains two sections if access list is present on the tx + /// An accumulator value used to correctly calculate the RLC(calldata and access list) for a + /// tx. contains two sections if access list is present on the tx section_rlc: Column, /// 1st phase column which equals to tx_table.value when is_calldata is true /// We need this because tx_table.value is a 2nd phase column and is used to get section_rlc. @@ -381,7 +384,6 @@ impl SubCircuitConfig for TxCircuitConfig { is_tx_tag!(is_tag_access_list_address, AccessListAddress); is_tx_tag!(is_tag_access_list_storage_key, AccessListStorageKey); - let tx_id_unchanged = IsEqualChip::configure( meta, |meta| meta.query_fixed(q_enable, Rotation::cur()), @@ -497,8 +499,14 @@ impl SubCircuitConfig for TxCircuitConfig { (is_hash_rlc(meta), RLC), (is_caller_addr(meta), Tag::Sender.into()), (is_tx_gas_cost(meta), GasCost), - (is_tag_access_list_address(meta), Tag::AccessListAddress.into()), - (is_tag_access_list_storage_key(meta), Tag::AccessListStorageKey.into()), + ( + is_tag_access_list_address(meta), + Tag::AccessListAddress.into(), + ), + ( + is_tag_access_list_storage_key(meta), + Tag::AccessListStorageKey.into(), + ), // tx tags which correspond to Null (is_null(meta), Null), (is_create(meta), Null), @@ -633,23 +641,26 @@ impl SubCircuitConfig for TxCircuitConfig { cb.gate(meta.query_fixed(q_enable, Rotation::cur())) }); - meta.create_gate("is_access_list_address and is_access_list_storage_key", |meta| { - let mut cb = BaseConstraintBuilder::default(); + meta.create_gate( + "is_access_list_address and is_access_list_storage_key", + |meta| { + let mut cb = BaseConstraintBuilder::default(); - cb.require_equal( - "is_access_list_address", - tag_bits.value_equals(TxFieldTag::AccessListAddress, Rotation::cur())(meta), - meta.query_advice(is_access_list_address, Rotation::cur()), - ); + cb.require_equal( + "is_access_list_address", + tag_bits.value_equals(TxFieldTag::AccessListAddress, Rotation::cur())(meta), + meta.query_advice(is_access_list_address, Rotation::cur()), + ); - cb.require_equal( - "is_access_list_storage_key", - tag_bits.value_equals(TxFieldTag::AccessListStorageKey, Rotation::cur())(meta), - meta.query_advice(is_access_list_storage_key, Rotation::cur()), - ); + cb.require_equal( + "is_access_list_storage_key", + tag_bits.value_equals(TxFieldTag::AccessListStorageKey, Rotation::cur())(meta), + meta.query_advice(is_access_list_storage_key, Rotation::cur()), + ); - cb.gate(meta.query_fixed(q_enable, Rotation::cur())) - }); + cb.gate(meta.query_fixed(q_enable, Rotation::cur())) + }, + ); meta.create_gate("is_caller_address", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -687,29 +698,32 @@ impl SubCircuitConfig for TxCircuitConfig { cb.gate(meta.query_fixed(q_enable, Rotation::cur())) }); - meta.create_gate("distinguish tx type: is_l1_msg, is_eip2930, is_eip1559", |meta| { - let mut cb = BaseConstraintBuilder::default(); + meta.create_gate( + "distinguish tx type: is_l1_msg, is_eip2930, is_eip1559", + |meta| { + let mut cb = BaseConstraintBuilder::default(); - cb.require_equal( - "is_l1_msg = (tx_type == L1Msg)", - meta.query_advice(is_l1_msg, Rotation::cur()), - tx_type_bits.value_equals(L1Msg, Rotation::cur())(meta), - ); + cb.require_equal( + "is_l1_msg = (tx_type == L1Msg)", + meta.query_advice(is_l1_msg, Rotation::cur()), + tx_type_bits.value_equals(L1Msg, Rotation::cur())(meta), + ); - cb.require_equal( - "is_eip2930 = (tx_type == Eip2930)", - meta.query_advice(is_eip2930, Rotation::cur()), - tx_type_bits.value_equals(Eip2930, Rotation::cur())(meta), - ); + cb.require_equal( + "is_eip2930 = (tx_type == Eip2930)", + meta.query_advice(is_eip2930, Rotation::cur()), + tx_type_bits.value_equals(Eip2930, Rotation::cur())(meta), + ); - cb.require_equal( - "is_eip1559 = (tx_type == Eip1559)", - meta.query_advice(is_eip1559, Rotation::cur()), - tx_type_bits.value_equals(Eip1559, Rotation::cur())(meta), - ); + cb.require_equal( + "is_eip1559 = (tx_type == Eip1559)", + meta.query_advice(is_eip1559, Rotation::cur()), + tx_type_bits.value_equals(Eip1559, Rotation::cur())(meta), + ); - cb.gate(meta.query_fixed(q_enable, Rotation::cur())) - }); + cb.gate(meta.query_fixed(q_enable, Rotation::cur())) + }, + ); meta.create_gate("calldata lookup into tx table condition", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -748,7 +762,7 @@ impl SubCircuitConfig for TxCircuitConfig { tx_type_bits.value_equals(Eip155, Rotation::cur())(meta), meta.query_advice(is_eip2930, Rotation::cur()), meta.query_advice(is_eip1559, Rotation::cur()), - ]) + ]), ]), is_sign_length(meta), is_sign_rlc(meta), @@ -1341,7 +1355,7 @@ impl SubCircuitConfig for TxCircuitConfig { "tx_id changes at is_final == 1", tx_id_unchanged.is_equal_expression.clone(), ); - } + }, ); // tx1559_debug @@ -1388,7 +1402,7 @@ impl SubCircuitConfig for TxCircuitConfig { cb.require_equal( "al_idx starts with 1", meta.query_advice(al_idx, Rotation::next()), - 1.expr() + 1.expr(), ); cb.require_zero( "sks_acc starts with 0", @@ -1399,7 +1413,7 @@ impl SubCircuitConfig for TxCircuitConfig { meta.query_advice(section_rlc, Rotation::next()), meta.query_advice(field_rlc, Rotation::next()), ); - } + }, ); cb.gate(and::expr(vec![ @@ -1521,74 +1535,27 @@ impl SubCircuitConfig for TxCircuitConfig { ); }); - // checks for any row, except the final call data byte. - // cb.condition(, |cb| { - // cb.require_equal( - // "index::next == index::cur + 1", - // meta.query_advice(tx_table.index, Rotation::next()), - // meta.query_advice(tx_table.index, Rotation::cur()) + 1.expr(), - // ); - // cb.require_equal( - // "tx_id::next == tx_id::cur", - // tx_id_unchanged.is_equal_expression.clone(), - // 1.expr(), - // ); - - // let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); - // let gas_cost_next = select::expr(value_next_is_zero, 4.expr(), 16.expr()); - // // call data gas cost accumulator check. - // cb.require_equal( - // "calldata_gas_cost_acc::next == calldata_gas_cost::cur + gas_cost_next", - // meta.query_advice(calldata_gas_cost_acc, Rotation::next()), - // meta.query_advice(calldata_gas_cost_acc, Rotation::cur()) + gas_cost_next, - // ); - // cb.require_equal( - // "section_rlc' = section_rlc * r + byte'", - // meta.query_advice(section_rlc, Rotation::next()), - // meta.query_advice(section_rlc, Rotation::cur()) * challenges.keccak_input() - // + meta.query_advice(tx_table.value, Rotation::next()), - // ); - // }); - - // on the final call data byte, must transition to another - // calldata section or an access list section for the same tx - - // tx1559_debug - // on the final call data byte, tx_id must change. - // cb.condition(is_final_cur.expr(), |cb| { - // cb.require_zero( - // "tx_id changes at is_final == 1", - // tx_id_unchanged.is_equal_expression.clone(), - // ); - // }); - - // tx1559_debug - // cb.condition( - // and::expr([ - // is_final_cur, - // not::expr(tx_id_is_zero.expr(Rotation::next())(meta)), - // ]), - // |cb| { - // let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); - // let gas_cost_next = select::expr(value_next_is_zero, 4.expr(), 16.expr()); - - // cb.require_equal( - // "index' == 0", - // meta.query_advice(tx_table.index, Rotation::next()), - // 0.expr(), - // ); - // cb.require_equal( - // "calldata_gas_cost_acc' == gas_cost_next", - // meta.query_advice(calldata_gas_cost_acc, Rotation::next()), - // gas_cost_next, - // ); - // cb.require_equal( - // "section_rlc' == byte'", - // meta.query_advice(section_rlc, Rotation::next()), - // meta.query_advice(tx_table.value, Rotation::next()), - // ); - // }, - // ); + // End conditions for the dynamic access list section, if the dynamic calldata section for the next tx doesn't exist + // For a regular access list section that immediately follows a calldata section, the init idx + // conditions are defined using the tail location of calldata (in the previous constraint block) + cb.condition( + and::expr([ + is_final_cur.clone(), + not::expr(tx_id_is_zero.expr(Rotation::next())(meta)), + meta.query_advice(is_access_list, Rotation::next()), + ]), + |cb| { + cb.require_equal( + "al_idx starts with 1", + meta.query_advice(al_idx, Rotation::next()), + 1.expr() + ); + cb.require_zero( + "sks_acc starts with 0", + meta.query_advice(sks_acc, Rotation::next()), + ); + } + ); cb.gate(and::expr(vec![ meta.query_fixed(q_enable, Rotation::cur()), @@ -2044,17 +2011,18 @@ impl TxCircuitConfig { // lookup access list address in RLP table // 1. ensure field_rlc is correct // 2. ensure value of address is correct - // meta.lookup_any("lookup access list address in RLP Table from tx circuit dynamic section", |meta| { - // let enable = and::expr(vec![ + // meta.lookup_any("lookup access list address in RLP Table from tx circuit dynamic + // section", |meta| { let enable = and::expr(vec![ // meta.query_fixed(q_enable, Rotation::cur()), // meta.query_advice(is_access_list_address, Rotation::cur()), // ]); // // only eip2930 and eip1559 contains an access list - // let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxSignEip2930.expr() - // + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); - // let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxHashEip2930.expr() - // + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); + // let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * + // TxSignEip2930.expr() + meta.query_advice(is_eip1559, Rotation::cur()) * + // TxSignEip1559.expr(); let hash_format = meta.query_advice(is_eip2930, + // Rotation::cur()) * TxHashEip2930.expr() + meta.query_advice(is_eip1559, + // Rotation::cur()) * TxHashEip1559.expr(); // vec![ // 1.expr(), // q_enable = true @@ -2081,17 +2049,18 @@ impl TxCircuitConfig { // lookup access list storage key in RLP table // 1. ensure field_rlc is correct // 2. ensure value of storage key is correct - // meta.lookup_any("lookup access list storage key in RLP Table from tx circuit dynamic section", |meta| { - // let enable = and::expr(vec![ + // meta.lookup_any("lookup access list storage key in RLP Table from tx circuit dynamic + // section", |meta| { let enable = and::expr(vec![ // meta.query_fixed(q_enable, Rotation::cur()), // meta.query_advice(is_access_list_storage_key, Rotation::cur()), // ]); // // only eip2930 and eip1559 contains an access list - // let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxSignEip2930.expr() - // + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); - // let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxHashEip2930.expr() - // + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); + // let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * + // TxSignEip2930.expr() + meta.query_advice(is_eip1559, Rotation::cur()) * + // TxSignEip1559.expr(); let hash_format = meta.query_advice(is_eip2930, + // Rotation::cur()) * TxHashEip2930.expr() + meta.query_advice(is_eip1559, + // Rotation::cur()) * TxHashEip1559.expr(); // vec![ // 1.expr(), // q_enable = true @@ -2553,7 +2522,8 @@ impl TxCircuitConfig { ), ] { // tx1559_debug - // log::trace!("=> [Execution TxCircuit] assign - assign_fixed_rows - anno: {:?}, offset: {:?}", col_anno, offset); + // log::trace!("=> [Execution TxCircuit] assign - assign_fixed_rows - anno: {:?}, + // offset: {:?}", col_anno, offset); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } @@ -2755,22 +2725,27 @@ impl TxCircuitConfig { let mut sks_acc: usize = 0; // row counting for determining when section ends - let total_rows: usize = tx.access_list.as_ref().unwrap().0.iter().fold(0, |acc, al| { - acc + 1 + al.storage_keys.len() - }); + let total_rows: usize = tx + .access_list + .as_ref() + .unwrap() + .0 + .iter() + .fold(0, |acc, al| acc + 1 + al.storage_keys.len()); let mut curr_row: usize = 0; // initialize access list section rlc let mut section_rlc = challenges.keccak_input().map(|_| F::zero()); // depending on prev row, the accumulator advances by different magnitude - let r20 = challenges.keccak_input().map(|f| f.pow(&[20, 0, 0, 0]) ); - let r32 = challenges.keccak_input().map(|f| f.pow(&[32, 0, 0, 0]) ); + let r20 = challenges.keccak_input().map(|f| f.pow(&[20, 0, 0, 0])); + let r32 = challenges.keccak_input().map(|f| f.pow(&[32, 0, 0, 0])); for (al_idx, al) in tx.access_list.as_ref().unwrap().0.iter().enumerate() { curr_row += 1; let is_final = curr_row == total_rows; - let field_rlc = rlc_be_bytes(&al.address.to_fixed_bytes(), challenges.keccak_input()); + let field_rlc = + rlc_be_bytes(&al.address.to_fixed_bytes(), challenges.keccak_input()); section_rlc = section_rlc * r32 + field_rlc; let tx_id_next = if curr_row == total_rows { @@ -2788,7 +2763,7 @@ impl TxCircuitConfig { (al_idx + 1) as u64, Value::known(al.address.to_scalar().unwrap()), Value::known(al.address.to_scalar().unwrap()), - should_print + should_print, )?; // 1st phase columns @@ -2797,11 +2772,18 @@ impl TxCircuitConfig { ("al_idx", self.al_idx, F::from((al_idx + 1) as u64)), ("sk_idx", self.sk_idx, F::from(0 as u64)), ("sks_acc", self.sks_acc, F::from(sks_acc as u64)), - ("rlp_tag", self.rlp_tag, F::from(usize::from(Tag::AccessListAddress) as u64)), + ( + "rlp_tag", + self.rlp_tag, + F::from(usize::from(Tag::AccessListAddress) as u64), + ), ("is_final", self.is_final, F::from(is_final as u64)), ("is_access_list", self.is_access_list, F::one()), - ("is_access_list_address", self.is_access_list_address, F::one()), - + ( + "is_access_list_address", + self.is_access_list_address, + F::one(), + ), // ("byte", self.calldata_byte, F::from(*byte as u64)), ] { // tx1559_debug @@ -2856,14 +2838,26 @@ impl TxCircuitConfig { ("al_idx", self.al_idx, F::from((al_idx + 1) as u64)), ("sk_idx", self.sk_idx, F::from((sk_idx + 1) as u64)), ("sks_acc", self.sks_acc, F::from(sks_acc as u64)), - ("rlp_tag", self.rlp_tag, F::from(usize::from(Tag::AccessListStorageKey) as u64)), + ( + "rlp_tag", + self.rlp_tag, + F::from(usize::from(Tag::AccessListStorageKey) as u64), + ), ("is_final", self.is_final, F::from(is_final as u64)), ("is_access_list", self.is_access_list, F::one()), - ("is_access_list_storage_key", self.is_access_list_storage_key, F::one()), - + ( + "is_access_list_storage_key", + self.is_access_list_storage_key, + F::one(), + ), // ("byte", self.calldata_byte, F::from(*byte as u64)), ] { - region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; + region.assign_advice( + || col_anno, + col, + *offset, + || Value::known(col_val), + )?; } // field_rlc to work with section_rlc @@ -2971,7 +2965,12 @@ impl TxCircuitConfig { if should_print { log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", "access_list_address value", offset, access_list_address.into_field()); } - region.assign_advice(|| "access_list_address value", self.tx_table.access_list_address, offset, || access_list_address)?; + region.assign_advice( + || "access_list_address value", + self.tx_table.access_list_address, + offset, + || access_list_address, + )?; // 2nd phase columns // tx1559_debug @@ -2980,7 +2979,6 @@ impl TxCircuitConfig { } let tx_value_cell = region.assign_advice(|| "tx_value", self.tx_table.value, offset, || value)?; - Ok(tx_value_cell) } @@ -3564,16 +3562,19 @@ pub(crate) fn get_sign_data( } /// Returns the RLC of the access list including addresses and storage keys -pub fn access_list_rlc(access_list: &Option, challenges: &Challenges>) -> Value { +pub fn access_list_rlc( + access_list: &Option, + challenges: &Challenges>, +) -> Value { if access_list.is_some() { let mut section_rlc = challenges.keccak_input().map(|_| F::zero()); - let r20 = challenges.keccak_input().map(|f| f.pow(&[20, 0, 0, 0]) ); - let r32 = challenges.keccak_input().map(|f| f.pow(&[32, 0, 0, 0]) ); - + let r20 = challenges.keccak_input().map(|f| f.pow(&[20, 0, 0, 0])); + let r32 = challenges.keccak_input().map(|f| f.pow(&[32, 0, 0, 0])); + for al in access_list.as_ref().unwrap().0.iter() { let field_rlc = rlc_be_bytes(&al.address.to_fixed_bytes(), challenges.keccak_input()); section_rlc = section_rlc * r32 + field_rlc; - + for (sk_idx, sk) in al.storage_keys.iter().enumerate() { let field_rlc = rlc_be_bytes(&sk.to_fixed_bytes(), challenges.keccak_input()); section_rlc = if sk_idx > 0 { @@ -3583,7 +3584,7 @@ pub fn access_list_rlc(access_list: &Option, challenges: & }; } } - + section_rlc } else { Value::known(F::zero()) diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index 133b9e6250..df2820a93c 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -1,8 +1,14 @@ #![allow(unused_imports)] use ethers_core::{ - types::{transaction::eip2718::TypedTransaction, NameOrAddress, Signature, Transaction as EthTransaction, TransactionRequest, Eip1559TransactionRequest}, - utils::{keccak256, rlp::{Decodable, Rlp}}, + types::{ + transaction::eip2718::TypedTransaction, Eip1559TransactionRequest, NameOrAddress, + Signature, Transaction as EthTransaction, TransactionRequest, + }, + utils::{ + keccak256, + rlp::{Decodable, Rlp}, + }, }; use std::cmp::max; @@ -11,7 +17,11 @@ use crate::{ tx_circuit::{dev::TxCircuitTester, get_sign_data}, util::{log2_ceil, unusable_rows}, }; -use eth_types::{address, evm_types::gas_utils::{tx_access_list_gas_cost, tx_data_gas_cost}, word, H256, U256, U64}; +use eth_types::{ + address, + evm_types::gas_utils::{tx_access_list_gas_cost, tx_data_gas_cost}, + word, H256, U256, U64, +}; use halo2_proofs::{ dev::{MockProver, VerifyFailure}, halo2curves::bn256::Fr, @@ -120,12 +130,8 @@ fn build_eip1559_tx() -> Transaction { let typed_tx: TypedTransaction = eth_tx_req.into(); let rlp_unsigned = typed_tx.rlp().to_vec(); - let mut tx = Transaction::new_from_rlp_bytes( - 1, - TxType::Eip1559, - raw_tx_rlp_bytes, - rlp_unsigned, - ); + let mut tx = + Transaction::new_from_rlp_bytes(1, TxType::Eip1559, raw_tx_rlp_bytes, rlp_unsigned); tx.hash = eth_tx.hash; tx.block_number = 1; @@ -177,7 +183,6 @@ fn run( prover.verify_at_rows_par(0..active_row_num, 0..active_row_num) } - #[test] // tx1559_debug // #[cfg(feature = "scroll")] diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index ce91021ba1..6f5f7b8c42 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -15,9 +15,9 @@ use crate::{ Tag::{EndObject, EndVector}, }, }; -use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee, Access}; +use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, Access, TxL1Fee}; use eth_types::{ - evm_types::gas_utils::{tx_data_gas_cost, tx_access_list_gas_cost}, + evm_types::gas_utils::{tx_access_list_gas_cost, tx_data_gas_cost}, geth_types::{access_list_size, TxType, TxType::PreEip155}, sign_types::{ biguint_to_32bytes_le, ct_option_ok_or, get_dummy_tx, recover_pk2, SignData, SECP256K1_Q, @@ -180,8 +180,7 @@ impl Transaction { Value::known(F::zero()), challenges .evm_word() - .map(|challenge| rlc::value(&self.gas_price.to_le_bytes(), challenge) - ), + .map(|challenge| rlc::value(&self.gas_price.to_le_bytes(), challenge)), Value::known(F::zero()), ], [ @@ -223,8 +222,7 @@ impl Transaction { Value::known(F::zero()), challenges .evm_word() - .map(|challenge| rlc::value(&self.value.to_le_bytes(), challenge) - ), + .map(|challenge| rlc::value(&self.value.to_le_bytes(), challenge)), Value::known(F::zero()), ], [ From 66b7e4653dac898b82716eef1be09bea6a414881 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 3 Dec 2023 23:36:18 -0800 Subject: [PATCH 085/161] fmt clippy --- eth-types/src/geth_types.rs | 5 +---- zkevm-circuits/src/tx_circuit.rs | 15 ++++++--------- zkevm-circuits/src/witness/tx.rs | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/eth-types/src/geth_types.rs b/eth-types/src/geth_types.rs index b28aeaf747..74c45e4933 100644 --- a/eth-types/src/geth_types.rs +++ b/eth-types/src/geth_types.rs @@ -9,10 +9,7 @@ use ethers_core::types::{ transaction::eip2718::TypedTransaction, Eip1559TransactionRequest, Eip2930TransactionRequest, NameOrAddress, TransactionRequest, H256, }; -use halo2_proofs::{ - halo2curves::{group::ff::PrimeField, secp256k1::Fq}, - transcript::ChallengeScalar, -}; +use halo2_proofs::halo2curves::{group::ff::PrimeField, secp256k1::Fq}; use num::Integer; use num_bigint::BigUint; use serde::{Serialize, Serializer}; diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 817c3ea137..ac093bb1c9 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -45,7 +45,6 @@ use crate::{ }; use bus_mapping::circuit_input_builder::keccak_inputs_sign_verify; use eth_types::{ - evm_types::GasCost as GS, geth_types::{ access_list_size, TxType, TxType::{Eip155, Eip1559, Eip2930, L1Msg, PreEip155}, @@ -53,7 +52,7 @@ use eth_types::{ sign_types::SignData, AccessList, Address, Field, ToAddress, ToBigEndian, ToScalar, }; -use ethers_core::utils::{keccak256, rlp::Encodable}; +use ethers_core::utils::keccak256; use gadgets::{ binary_number::{BinaryNumberChip, BinaryNumberConfig}, comparator::{ComparatorChip, ComparatorConfig, ComparatorInstruction}, @@ -899,7 +898,7 @@ impl SubCircuitConfig for TxCircuitConfig { // is_access_list_address, // is_access_list_storage_key, al_idx, - sk_idx, + // sk_idx, sks_acc, ); @@ -1540,7 +1539,7 @@ impl SubCircuitConfig for TxCircuitConfig { // conditions are defined using the tail location of calldata (in the previous constraint block) cb.condition( and::expr([ - is_final_cur.clone(), + is_final_cur, not::expr(tx_id_is_zero.expr(Rotation::next())(meta)), meta.query_advice(is_access_list, Rotation::next()), ]), @@ -1734,7 +1733,7 @@ impl TxCircuitConfig { // is_access_list_address: Column, // is_access_list_storage_key: Column, al_idx: Column, - sk_idx: Column, + // sk_idx: Column, sks_acc: Column, ) { macro_rules! is_tx_type { @@ -2437,8 +2436,6 @@ impl TxCircuitConfig { .clone() .map_or(zero_rlc, |input| input.be_bytes_rlc); let is_l1_msg = tx.tx_type.is_l1_msg(); - let is_eip2930 = tx.tx_type.is_eip2930(); - let is_eip1559 = tx.tx_type.is_eip1559(); // it's the tx_id of next row let tx_id_next = if tx_tag == BlockNumber { next_tx.map_or(0, |tx| tx.id) @@ -2720,7 +2717,7 @@ impl TxCircuitConfig { let should_print = true; // assign to access_list related columns - if tx.access_list.as_ref().unwrap().0.len() > 0 { + if !tx.access_list.as_ref().unwrap().0.is_empty() { // storage key len accumulator let mut sks_acc: usize = 0; @@ -2770,7 +2767,7 @@ impl TxCircuitConfig { for (col_anno, col, col_val) in [ ("block_num", self.block_num, F::from(tx.block_number)), ("al_idx", self.al_idx, F::from((al_idx + 1) as u64)), - ("sk_idx", self.sk_idx, F::from(0 as u64)), + ("sk_idx", self.sk_idx, F::from(0u64)), ("sks_acc", self.sks_acc, F::from(sks_acc as u64)), ( "rlp_tag", diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 6f5f7b8c42..6f67965dd6 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -15,7 +15,7 @@ use crate::{ Tag::{EndObject, EndVector}, }, }; -use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, Access, TxL1Fee}; +use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}; use eth_types::{ evm_types::gas_utils::{tx_access_list_gas_cost, tx_data_gas_cost}, geth_types::{access_list_size, TxType, TxType::PreEip155}, From 1b94185fea21511ea0a8a5ac17dce38cf217ba4e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 3 Dec 2023 23:49:27 -0800 Subject: [PATCH 086/161] remove debug tags --- zkevm-circuits/src/tx_circuit.rs | 103 ++++++++----------------------- 1 file changed, 26 insertions(+), 77 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index ac093bb1c9..c7bd88d49b 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -1891,6 +1891,31 @@ impl TxCircuitConfig { .collect() }); + meta.lookup_any("lookup AccessListRLC in the TxTable", |meta| { + let enable = and::expr([ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list, Rotation::cur()), + meta.query_advice(is_final, Rotation::cur()), + ]); + + let input_exprs = vec![ + meta.query_advice(tx_table.tx_id, Rotation::cur()), + AccessListRLC.expr(), + meta.query_advice(section_rlc, Rotation::cur()), + ]; + let table_exprs = vec![ + meta.query_advice(tx_table.tx_id, Rotation::cur()), + meta.query_fixed(tx_table.tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + ]; + + input_exprs + .into_iter() + .zip(table_exprs.into_iter()) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }); + ///////////////////////////////////////////////////////////////// ///////////////// RLP table lookups ////////////////////// ///////////////// //////////////////////////////////////////////// @@ -2171,8 +2196,6 @@ impl TxCircuitConfig { 0, Value::known(F::zero()), Value::known(F::zero()), - // tx1559_debug - false, )?; let (col_anno, col, col_val) = ("rlp_tag", self.rlp_tag, F::from(usize::from(Null) as u64)); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; @@ -2426,8 +2449,6 @@ impl TxCircuitConfig { ), (BlockNumber, None, Value::known(F::from(tx.block_number))), ]; - // tx1559_debug - // log::trace!("=> [Execution TxCircuit] assign - fixed_rows: {:?}", fixed_rows); for (tx_tag, rlp_input, tx_value) in fixed_rows { let rlp_tag = rlp_input.clone().map_or(Null, |input| input.tag); let rlp_is_none = rlp_input.clone().map_or(false, |input| input.is_none); @@ -2452,8 +2473,6 @@ impl TxCircuitConfig { 0, tx_value, Value::known(F::zero()), - // tx1559_debug - false, )?); // 1st phase columns @@ -2518,9 +2537,6 @@ impl TxCircuitConfig { F::from((tx_tag == CallerAddress) as u64), ), ] { - // tx1559_debug - // log::trace!("=> [Execution TxCircuit] assign - assign_fixed_rows - anno: {:?}, - // offset: {:?}", col_anno, offset); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } @@ -2675,8 +2691,6 @@ impl TxCircuitConfig { idx as u64, Value::known(F::from(*byte as u64)), Value::known(F::zero()), - // tx1559_debug - false, )?; // 1st phase columns @@ -2713,8 +2727,6 @@ impl TxCircuitConfig { next_tx: Option<&Transaction>, challenges: &Challenges>, ) -> Result<(), Error> { - // tx1559_debug - let should_print = true; // assign to access_list related columns if !tx.access_list.as_ref().unwrap().0.is_empty() { @@ -2760,7 +2772,6 @@ impl TxCircuitConfig { (al_idx + 1) as u64, Value::known(al.address.to_scalar().unwrap()), Value::known(al.address.to_scalar().unwrap()), - should_print, )?; // 1st phase columns @@ -2781,16 +2792,10 @@ impl TxCircuitConfig { self.is_access_list_address, F::one(), ), - // ("byte", self.calldata_byte, F::from(*byte as u64)), ] { - // tx1559_debug - log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", col_anno, offset, col_val); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } - // field_rlc to work with section_rlc - // tx1559_debug - log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", "field_rlc", offset, field_rlc.into_field()); region.assign_advice(|| "field_rlc", self.field_rlc, *offset, || field_rlc)?; // 2nd phase columns @@ -2825,8 +2830,6 @@ impl TxCircuitConfig { sks_acc as u64, rlc_be_bytes(&sk.to_fixed_bytes(), challenges.evm_word()), Value::known(al.address.to_scalar().unwrap()), - // tx1559_debug - false, )?; // 1st phase columns @@ -2847,7 +2850,6 @@ impl TxCircuitConfig { self.is_access_list_storage_key, F::one(), ), - // ("byte", self.calldata_byte, F::from(*byte as u64)), ] { region.assign_advice( || col_anno, @@ -2886,8 +2888,6 @@ impl TxCircuitConfig { index: u64, value: Value, access_list_address: Value, - // tx1559_debug - should_print: bool, ) -> Result, Error> { let (tx_type, tx_id) = if let Some(tx) = tx { (tx.tx_type, tx.id) @@ -2921,10 +2921,6 @@ impl TxCircuitConfig { ("q_enable", self.tx_table.q_enable, F::one()), ("tag", self.tx_table.tag, F::from(usize::from(tag) as u64)), ] { - // tx1559_debug - if should_print { - log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", col_anno, offset, col_val); - } region.assign_fixed(|| col_anno, col, offset, || Value::known(col_val))?; } @@ -2950,18 +2946,9 @@ impl TxCircuitConfig { F::from(tx_type.is_eip1559() as u64), ), ] { - // tx1559_debug - if should_print { - log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", col_anno, offset, col_val); - } region.assign_advice(|| col_anno, col, offset, || Value::known(col_val))?; } - // additional access_list_address column - // tx1559_debug - if should_print { - log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", "access_list_address value", offset, access_list_address.into_field()); - } region.assign_advice( || "access_list_address value", self.tx_table.access_list_address, @@ -2970,10 +2957,6 @@ impl TxCircuitConfig { )?; // 2nd phase columns - // tx1559_debug - if should_print { - log::trace!("=> [Execution TxCircuit] assign - assign_access_list_rows - anno: {:?}, offset: {:?}, value: {:?}", "tx_table.value", offset, value.into_field()); - } let tx_value_cell = region.assign_advice(|| "tx_value", self.tx_table.value, offset, || value)?; @@ -3586,38 +3569,4 @@ pub fn access_list_rlc( } else { Value::known(F::zero()) } -} - -// tx1559_debug -// Evaluate an expression using a `CachedRegion` at `offset`. -// pub(crate) fn evaluate_expression( -// expr: &Expression, -// region: &Region<'_, F>, -// offset: usize, -// ) -> Value { -// expr.evaluate( -// &|scalar| Value::known(scalar), -// &|_| unimplemented!("selector column"), -// &|fixed_query| { -// Value::known(region.fi -// region.get_fixed( -// offset, -// fixed_query.column_index(), -// fixed_query.rotation(), -// )) -// }, -// &|advice_query| { -// Value::known(region.get_advice( -// offset, -// advice_query.column_index(), -// advice_query.rotation(), -// )) -// }, -// &|_| unimplemented!("instance column"), -// &|challenge| *region.challenges().indexed()[challenge.index()], -// &|a| -a, -// &|a, b| a + b, -// &|a, b| a * b, -// &|a, scalar| a * Value::known(scalar), -// ) -// } +} \ No newline at end of file From 2d0b6f08bf860a22fb5c36366644fe6717e3420f Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 00:54:06 -0800 Subject: [PATCH 087/161] correct lookup of address and storage keys --- zkevm-circuits/src/rlp_circuit_fsm.rs | 2 + zkevm-circuits/src/table.rs | 10 ++ zkevm-circuits/src/tx_circuit.rs | 210 +++++++++++++++----------- 3 files changed, 137 insertions(+), 85 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 20be4b9b3b..c4acd9a631 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1923,6 +1923,8 @@ impl RlpCircuitConfig { witness: &RlpFsmWitnessRow, witness_next: Option<&RlpFsmWitnessRow>, ) -> Result<(), Error> { + // tx1559_debug + log::trace!("=> [Execution assign_sm_row] witness: {:?}", witness); // assign to selector region.assign_fixed( || "q_enable", diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 5b61dec985..2c0c1dcd18 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -2353,6 +2353,16 @@ impl RlpFsmRlpTable { self.is_none.into(), Value::known(F::from(row.is_none as u64)), ), + ( + "access_list_idx", + self.access_list_idx.into(), + Value::known(F::from(row.access_list_idx as u64)), + ), + ( + "storage_key_idx", + self.storage_key_idx.into(), + Value::known(F::from(row.storage_key_idx as u64)), + ), ]; for cell in cells.into_iter() { diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index c7bd88d49b..99cc3cb627 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -878,8 +878,6 @@ impl SubCircuitConfig for TxCircuitConfig { &lookup_conditions, is_final, is_calldata, - // tx1559_debug - // is_access_list, is_chain_id, is_l1_msg, is_eip2930, @@ -887,18 +885,16 @@ impl SubCircuitConfig for TxCircuitConfig { sv_address, calldata_gas_cost_acc, section_rlc, - // tx1559_debug - // field_rlc, + field_rlc, tx_table.clone(), keccak_table.clone(), rlp_table, sig_table, is_access_list, - // tx1559_debug - // is_access_list_address, - // is_access_list_storage_key, + is_access_list_address, + is_access_list_storage_key, al_idx, - // sk_idx, + sk_idx, sks_acc, ); @@ -1713,8 +1709,6 @@ impl TxCircuitConfig { lookup_conditions: &HashMap>, is_final: Column, is_calldata: Column, - // tx1559_debug - // is_access_list: Column, is_chain_id: Column, is_l1_msg_col: Column, is_eip2930: Column, @@ -1722,18 +1716,16 @@ impl TxCircuitConfig { sv_address: Column, calldata_gas_cost_acc: Column, section_rlc: Column, - // tx1559_debug - // field_rlc: Column, + field_rlc: Column, tx_table: TxTable, keccak_table: KeccakTable, rlp_table: RlpTable, sig_table: SigTable, is_access_list: Column, - // tx1559_debug - // is_access_list_address: Column, - // is_access_list_storage_key: Column, + is_access_list_address: Column, + is_access_list_storage_key: Column, al_idx: Column, - // sk_idx: Column, + sk_idx: Column, sks_acc: Column, ) { macro_rules! is_tx_type { @@ -2031,81 +2023,127 @@ impl TxCircuitConfig { .collect() }); - // tx1559_debug // lookup access list address in RLP table // 1. ensure field_rlc is correct // 2. ensure value of address is correct - // meta.lookup_any("lookup access list address in RLP Table from tx circuit dynamic - // section", |meta| { let enable = and::expr(vec![ - // meta.query_fixed(q_enable, Rotation::cur()), - // meta.query_advice(is_access_list_address, Rotation::cur()), - // ]); - - // // only eip2930 and eip1559 contains an access list - // let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * - // TxSignEip2930.expr() + meta.query_advice(is_eip1559, Rotation::cur()) * - // TxSignEip1559.expr(); let hash_format = meta.query_advice(is_eip2930, - // Rotation::cur()) * TxHashEip2930.expr() + meta.query_advice(is_eip1559, - // Rotation::cur()) * TxHashEip1559.expr(); - - // vec![ - // 1.expr(), // q_enable = true - // meta.query_advice(tx_table.tx_id, Rotation::cur()), - // // tx1559_debug - // // hash_format, - // sign_format, - // meta.query_advice(rlp_tag, Rotation::cur()), - // meta.query_advice(tx_table.value, Rotation::cur()), - // meta.query_advice(field_rlc, Rotation::cur()), - // 20.expr(), // 20 bytes for address - // 1.expr(), // is_output = true - // 0.expr(), // is_none = false. must have value - // meta.query_advice(al_idx, Rotation::cur()), // access_list_idx - // meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx - // ] - // .into_iter() - // .zip_eq(rlp_table.table_exprs(meta).into_iter()) - // .map(|(arg, table)| (enable.clone() * arg, table)) - // .collect() - // }); - - // tx1559_debug + meta.lookup_any("Lookup access list address in RLP Table from tx circuit dynamic section (Signing)", |meta| { + let enable = and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list_address, Rotation::cur()), + ]); + + // only eip2930 and eip1559 contains an access list + let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxSignEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); + + vec![ + 1.expr(), // q_enable = true + meta.query_advice(tx_table.tx_id, Rotation::cur()), + sign_format, + meta.query_advice(rlp_tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + meta.query_advice(field_rlc, Rotation::cur()), + 20.expr(), // 20 bytes for address + 1.expr(), // is_output = true + 0.expr(), // is_none = false. must have value + meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + ] + .into_iter() + .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .map(|(arg, table)| (enable.clone() * arg, table)) + .collect() + }); + + meta.lookup_any("Lookup access list address in RLP Table from tx circuit dynamic section (Hashing)", |meta| { + let enable = and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list_address, Rotation::cur()), + ]); + + // only eip2930 and eip1559 contains an access list + let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxHashEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); + + vec![ + 1.expr(), // q_enable = true + meta.query_advice(tx_table.tx_id, Rotation::cur()), + hash_format, + meta.query_advice(rlp_tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + meta.query_advice(field_rlc, Rotation::cur()), + 20.expr(), // 20 bytes for address + 1.expr(), // is_output = true + 0.expr(), // is_none = false. must have value + meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + ] + .into_iter() + .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .map(|(arg, table)| (enable.clone() * arg, table)) + .collect() + }); + // lookup access list storage key in RLP table // 1. ensure field_rlc is correct // 2. ensure value of storage key is correct - // meta.lookup_any("lookup access list storage key in RLP Table from tx circuit dynamic - // section", |meta| { let enable = and::expr(vec![ - // meta.query_fixed(q_enable, Rotation::cur()), - // meta.query_advice(is_access_list_storage_key, Rotation::cur()), - // ]); - - // // only eip2930 and eip1559 contains an access list - // let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * - // TxSignEip2930.expr() + meta.query_advice(is_eip1559, Rotation::cur()) * - // TxSignEip1559.expr(); let hash_format = meta.query_advice(is_eip2930, - // Rotation::cur()) * TxHashEip2930.expr() + meta.query_advice(is_eip1559, - // Rotation::cur()) * TxHashEip1559.expr(); - - // vec![ - // 1.expr(), // q_enable = true - // meta.query_advice(tx_table.tx_id, Rotation::cur()), - // sign_format, - // // tx1559_debug - // // hash_format, - // meta.query_advice(rlp_tag, Rotation::cur()), - // meta.query_advice(tx_table.value, Rotation::cur()), - // meta.query_advice(field_rlc, Rotation::cur()), - // 32.expr(), // 32 bytes for storage keys - // 1.expr(), // is_output = true - // 0.expr(), // is_none = false. must have value - // meta.query_advice(al_idx, Rotation::cur()), // access_list_idx - // meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx - // ] - // .into_iter() - // .zip_eq(rlp_table.table_exprs(meta).into_iter()) - // .map(|(arg, table)| (enable.clone() * arg, table)) - // .collect() - // }); + meta.lookup_any("Lookup access list storage key in RLP Table from tx circuit dynamic section (Signing)", |meta| { + let enable = and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list_storage_key, Rotation::cur()), + ]); + + // only eip2930 and eip1559 contains an access list + let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxSignEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); + + vec![ + 1.expr(), // q_enable = true + meta.query_advice(tx_table.tx_id, Rotation::cur()), + sign_format, + meta.query_advice(rlp_tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + meta.query_advice(field_rlc, Rotation::cur()), + 32.expr(), // 32 bytes for storage keys + 1.expr(), // is_output = true + 0.expr(), // is_none = false. must have value + meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + ] + .into_iter() + .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .map(|(arg, table)| (enable.clone() * arg, table)) + .collect() + }); + + meta.lookup_any("Lookup access list storage key in RLP Table from tx circuit dynamic section (Hashing)", |meta| { + let enable = and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list_storage_key, Rotation::cur()), + ]); + + // only eip2930 and eip1559 contains an access list + let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxHashEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); + + vec![ + 1.expr(), // q_enable = true + meta.query_advice(tx_table.tx_id, Rotation::cur()), + hash_format, + meta.query_advice(rlp_tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + meta.query_advice(field_rlc, Rotation::cur()), + 32.expr(), // 32 bytes for storage keys + 1.expr(), // is_output = true + 0.expr(), // is_none = false. must have value + meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + ] + .into_iter() + .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .map(|(arg, table)| (enable.clone() * arg, table)) + .collect() + }); //////////////////////////////////////////////////////////////////// ///////////////// Sig table lookups ////////////////////// @@ -2793,6 +2831,8 @@ impl TxCircuitConfig { F::one(), ), ] { + // tx1559_debug + log::trace!("=> [Execution assign_access_list_rows] col_anno: {:?}, offset: {:?}, value: {:?}", col_anno, offset, col_val); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } From 79ed093b67603285cd431eefb74f1f324ea148c8 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 00:55:57 -0800 Subject: [PATCH 088/161] remove debug flag --- zkevm-circuits/src/rlp_circuit_fsm.rs | 2 -- zkevm-circuits/src/tx_circuit.rs | 2 -- 2 files changed, 4 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index c4acd9a631..20be4b9b3b 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1923,8 +1923,6 @@ impl RlpCircuitConfig { witness: &RlpFsmWitnessRow, witness_next: Option<&RlpFsmWitnessRow>, ) -> Result<(), Error> { - // tx1559_debug - log::trace!("=> [Execution assign_sm_row] witness: {:?}", witness); // assign to selector region.assign_fixed( || "q_enable", diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 99cc3cb627..5947426e86 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -2831,8 +2831,6 @@ impl TxCircuitConfig { F::one(), ), ] { - // tx1559_debug - log::trace!("=> [Execution assign_access_list_rows] col_anno: {:?}, offset: {:?}, value: {:?}", col_anno, offset, col_val); region.assign_advice(|| col_anno, col, *offset, || Value::known(col_val))?; } From f7eab8611cb529719d49310eb32faf71d5a5a20a Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 01:32:30 -0800 Subject: [PATCH 089/161] add extra gas fields for 1559 --- zkevm-circuits/src/tx_circuit.rs | 59 +++++++++++++++++++++++---- zkevm-circuits/src/tx_circuit/test.rs | 2 + zkevm-circuits/src/witness/tx.rs | 8 ++++ 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 5947426e86..e76c331a04 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -22,7 +22,7 @@ use crate::{ AccessListAddressesLen, AccessListRLC, AccessListStorageKeysLen, BlockNumber, CallData, CallDataGasCost, CallDataLength, CallDataRLC, CalleeAddress, CallerAddress, ChainID, Gas, GasPrice, IsCreate, Nonce, SigR, SigS, SigV, TxDataGasCost, TxHashLength, - TxHashRLC, TxSignHash, TxSignLength, TxSignRLC, + TxHashRLC, TxSignHash, TxSignLength, TxSignRLC, MaxFeePerGas, MaxPriorityFeePerGas, }, TxTable, U16Table, U8Table, }, @@ -83,7 +83,7 @@ use halo2_proofs::plonk::SecondPhase; use itertools::Itertools; /// Number of rows of one tx occupies in the fixed part of tx table -pub const TX_LEN: usize = 26; +pub const TX_LEN: usize = 28; /// Offset of TxHash tag in the tx table pub const TX_HASH_OFFSET: usize = 21; /// Offset of ChainID tag in the tx table @@ -382,6 +382,8 @@ impl SubCircuitConfig for TxCircuitConfig { is_tx_tag!(is_access_list_rlc, AccessListRLC); is_tx_tag!(is_tag_access_list_address, AccessListAddress); is_tx_tag!(is_tag_access_list_storage_key, AccessListStorageKey); + is_tx_tag!(is_max_fee_per_gas, MaxFeePerGas); + is_tx_tag!(is_max_priority_fee_per_gas, MaxPriorityFeePerGas); let tx_id_unchanged = IsEqualChip::configure( meta, @@ -506,6 +508,14 @@ impl SubCircuitConfig for TxCircuitConfig { is_tag_access_list_storage_key(meta), Tag::AccessListStorageKey.into(), ), + ( + is_max_fee_per_gas(meta), + Tag::MaxFeePerGas.into(), + ), + ( + is_max_priority_fee_per_gas(meta), + Tag::MaxPriorityFeePerGas.into(), + ), // tx tags which correspond to Null (is_null(meta), Null), (is_create(meta), Null), @@ -607,9 +617,6 @@ impl SubCircuitConfig for TxCircuitConfig { cb.gate(meta.query_fixed(q_enable, Rotation::cur())) }); - // TODO: add constraints for AccessListAddressesLen, AccessListStorageKeysLen - // and AccessListRLC. - ////////////////////////////////////////////////////////// ///// Constraints for booleans that reducing degree ///// ////////////////////////////////////////////////////////// @@ -763,6 +770,14 @@ impl SubCircuitConfig for TxCircuitConfig { meta.query_advice(is_eip1559, Rotation::cur()), ]), ]), + and::expr([ + meta.query_advice(is_eip1559, Rotation::cur()), + is_max_fee_per_gas(meta), + ]), + and::expr([ + meta.query_advice(is_eip1559, Rotation::cur()), + is_max_priority_fee_per_gas(meta), + ]), is_sign_length(meta), is_sign_rlc(meta), ]); @@ -801,6 +816,14 @@ impl SubCircuitConfig for TxCircuitConfig { is_sig_s(meta), is_hash_length(meta), is_hash_rlc(meta), + and::expr([ + meta.query_advice(is_eip1559, Rotation::cur()), + is_max_fee_per_gas(meta), + ]), + and::expr([ + meta.query_advice(is_eip1559, Rotation::cur()), + is_max_priority_fee_per_gas(meta), + ]), ]); cb.require_equal( @@ -2485,6 +2508,26 @@ impl TxCircuitConfig { }), access_list_rlc(&tx.access_list, challenges), ), + ( + MaxFeePerGas, + Some(RlpTableInputValue { + tag: Tag::MaxFeePerGas.into(), + is_none: tx.max_fee_per_gas.is_zero(), + be_bytes_len: tx.max_fee_per_gas.tag_length(), + be_bytes_rlc: rlc_be_bytes(&tx.max_fee_per_gas.to_be_bytes(), keccak_input), + }), + rlc_be_bytes(&tx.max_fee_per_gas.to_be_bytes(), evm_word), + ), + ( + MaxPriorityFeePerGas, + Some(RlpTableInputValue { + tag: Tag::MaxPriorityFeePerGas.into(), + is_none: tx.max_priority_fee_per_gas.is_zero(), + be_bytes_len: tx.max_priority_fee_per_gas.tag_length(), + be_bytes_rlc: rlc_be_bytes(&tx.max_priority_fee_per_gas.to_be_bytes(), keccak_input), + }), + rlc_be_bytes(&tx.max_priority_fee_per_gas.to_be_bytes(), evm_word), + ), (BlockNumber, None, Value::known(F::from(tx.block_number))), ]; for (tx_tag, rlp_input, tx_value) in fixed_rows { @@ -2611,7 +2654,8 @@ impl TxCircuitConfig { let case1 = is_tag_in_set && !is_l1_msg; let case2 = !tx.tx_type.is_pre_eip155() && (tx_tag == ChainID); let case3 = !tx.tx_type.is_eip1559() && (tx_tag == GasPrice); - F::from((case1 || case2 || case3) as u64) + let case4 = tx.tx_type.is_eip1559() && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); + F::from((case1 || case2 || case3 || case4) as u64) }); // 3. lookup to RLP table for hashing (non L1 msg) conditions.insert(LookupCondition::RlpHashTag, { @@ -2631,7 +2675,8 @@ impl TxCircuitConfig { let is_tag_in_set = hash_set.into_iter().filter(|tag| tx_tag == *tag).count() == 1; let case1 = is_tag_in_set && !is_l1_msg; let case3 = !tx.tx_type.is_eip1559() && (tx_tag == GasPrice); - F::from((case1 || case3) as u64) + let case4 = tx.tx_type.is_eip1559() && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); + F::from((case1 || case3 || case4) as u64) }); // 4. lookup to RLP table for hashing (L1 msg) conditions.insert(LookupCondition::L1MsgHash, { diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index df2820a93c..3a320e24f4 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -141,6 +141,8 @@ fn build_eip1559_tx() -> Transaction { tx.value = eth_tx.value; tx.gas_price = eth_tx.gas_price.unwrap_or(U256::zero()); tx.gas = eth_tx.gas.as_u64(); + tx.max_fee_per_gas = eth_tx.max_fee_per_gas.unwrap_or(U256::zero()); + tx.max_priority_fee_per_gas = eth_tx.max_priority_fee_per_gas.unwrap_or(U256::zero()); tx.call_data = eth_tx.input.to_vec(); tx.callee_address = eth_tx.to; tx.caller_address = eth_tx.from; diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 6f67965dd6..64b943fb7c 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -57,6 +57,10 @@ pub struct Transaction { pub gas: u64, /// The gas price pub gas_price: Word, + /// Max fee per gas (EIP1559) + pub max_fee_per_gas: Word, + /// Max priority fee per gas (EIP1559) + pub max_priority_fee_per_gas: Word, /// The caller address pub caller_address: Address, /// The callee address @@ -1111,6 +1115,8 @@ impl From for Transaction { nonce: mock_tx.nonce.as_u64(), gas: mock_tx.gas.as_u64(), gas_price: mock_tx.gas_price, + max_fee_per_gas: mock_tx.max_fee_per_gas, + max_priority_fee_per_gas: mock_tx.max_priority_fee_per_gas, caller_address: mock_tx.from.address(), callee_address: mock_tx.to.as_ref().map(|to| to.address()), is_create, @@ -1164,6 +1170,8 @@ pub(super) fn tx_convert( nonce: tx.nonce, gas: tx.gas, gas_price: tx.gas_price, + max_fee_per_gas: if tx.tx_type.is_eip1559() { tx.gas_fee_cap } else { tx.gas_price }, + max_priority_fee_per_gas: if tx.tx_type.is_eip1559() { tx.gas_tip_cap } else { tx.gas_price }, caller_address: tx.from, callee_address, is_create: tx.is_create(), From 3a5021fe58b1bd2dc8e273ca916ad24ccb4ca53d Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 01:33:05 -0800 Subject: [PATCH 090/161] comment --- zkevm-circuits/src/tx_circuit/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index 3a320e24f4..f633ad0385 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -186,7 +186,7 @@ fn run( } #[test] -// tx1559_debug +// tx1559_debug_new_test // #[cfg(feature = "scroll")] fn tx_circuit_1tx_2max_eip1559() { const MAX_TXS: usize = 2; From 241e50c8d9d0e45e3f2e9eef4867a6644b400421 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 01:33:30 -0800 Subject: [PATCH 091/161] fmt --- zkevm-circuits/src/tx_circuit.rs | 250 +++++++++++++++++-------------- zkevm-circuits/src/witness/tx.rs | 12 +- 2 files changed, 144 insertions(+), 118 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index e76c331a04..83d14f0be1 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -21,8 +21,8 @@ use crate::{ TxFieldTag::{ AccessListAddressesLen, AccessListRLC, AccessListStorageKeysLen, BlockNumber, CallData, CallDataGasCost, CallDataLength, CallDataRLC, CalleeAddress, CallerAddress, ChainID, - Gas, GasPrice, IsCreate, Nonce, SigR, SigS, SigV, TxDataGasCost, TxHashLength, - TxHashRLC, TxSignHash, TxSignLength, TxSignRLC, MaxFeePerGas, MaxPriorityFeePerGas, + Gas, GasPrice, IsCreate, MaxFeePerGas, MaxPriorityFeePerGas, Nonce, SigR, SigS, SigV, + TxDataGasCost, TxHashLength, TxHashRLC, TxSignHash, TxSignLength, TxSignRLC, }, TxTable, U16Table, U8Table, }, @@ -508,10 +508,7 @@ impl SubCircuitConfig for TxCircuitConfig { is_tag_access_list_storage_key(meta), Tag::AccessListStorageKey.into(), ), - ( - is_max_fee_per_gas(meta), - Tag::MaxFeePerGas.into(), - ), + (is_max_fee_per_gas(meta), Tag::MaxFeePerGas.into()), ( is_max_priority_fee_per_gas(meta), Tag::MaxPriorityFeePerGas.into(), @@ -2049,124 +2046,140 @@ impl TxCircuitConfig { // lookup access list address in RLP table // 1. ensure field_rlc is correct // 2. ensure value of address is correct - meta.lookup_any("Lookup access list address in RLP Table from tx circuit dynamic section (Signing)", |meta| { - let enable = and::expr(vec![ - meta.query_fixed(q_enable, Rotation::cur()), - meta.query_advice(is_access_list_address, Rotation::cur()), - ]); + meta.lookup_any( + "Lookup access list address in RLP Table from tx circuit dynamic section (Signing)", + |meta| { + let enable = and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list_address, Rotation::cur()), + ]); - // only eip2930 and eip1559 contains an access list - let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxSignEip2930.expr() - + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); - - vec![ - 1.expr(), // q_enable = true - meta.query_advice(tx_table.tx_id, Rotation::cur()), - sign_format, - meta.query_advice(rlp_tag, Rotation::cur()), - meta.query_advice(tx_table.value, Rotation::cur()), - meta.query_advice(field_rlc, Rotation::cur()), - 20.expr(), // 20 bytes for address - 1.expr(), // is_output = true - 0.expr(), // is_none = false. must have value - meta.query_advice(al_idx, Rotation::cur()), // access_list_idx - meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx - ] - .into_iter() - .zip_eq(rlp_table.table_exprs(meta).into_iter()) - .map(|(arg, table)| (enable.clone() * arg, table)) - .collect() - }); + // only eip2930 and eip1559 contains an access list + let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) + * TxSignEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); - meta.lookup_any("Lookup access list address in RLP Table from tx circuit dynamic section (Hashing)", |meta| { - let enable = and::expr(vec![ - meta.query_fixed(q_enable, Rotation::cur()), - meta.query_advice(is_access_list_address, Rotation::cur()), - ]); + vec![ + 1.expr(), // q_enable = true + meta.query_advice(tx_table.tx_id, Rotation::cur()), + sign_format, + meta.query_advice(rlp_tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + meta.query_advice(field_rlc, Rotation::cur()), + 20.expr(), // 20 bytes for address + 1.expr(), // is_output = true + 0.expr(), // is_none = false. must have value + meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + ] + .into_iter() + .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .map(|(arg, table)| (enable.clone() * arg, table)) + .collect() + }, + ); - // only eip2930 and eip1559 contains an access list - let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxHashEip2930.expr() - + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); - - vec![ - 1.expr(), // q_enable = true - meta.query_advice(tx_table.tx_id, Rotation::cur()), - hash_format, - meta.query_advice(rlp_tag, Rotation::cur()), - meta.query_advice(tx_table.value, Rotation::cur()), - meta.query_advice(field_rlc, Rotation::cur()), - 20.expr(), // 20 bytes for address - 1.expr(), // is_output = true - 0.expr(), // is_none = false. must have value - meta.query_advice(al_idx, Rotation::cur()), // access_list_idx - meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx - ] - .into_iter() - .zip_eq(rlp_table.table_exprs(meta).into_iter()) - .map(|(arg, table)| (enable.clone() * arg, table)) - .collect() - }); + meta.lookup_any( + "Lookup access list address in RLP Table from tx circuit dynamic section (Hashing)", + |meta| { + let enable = and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list_address, Rotation::cur()), + ]); + + // only eip2930 and eip1559 contains an access list + let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) + * TxHashEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); + + vec![ + 1.expr(), // q_enable = true + meta.query_advice(tx_table.tx_id, Rotation::cur()), + hash_format, + meta.query_advice(rlp_tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + meta.query_advice(field_rlc, Rotation::cur()), + 20.expr(), // 20 bytes for address + 1.expr(), // is_output = true + 0.expr(), // is_none = false. must have value + meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + ] + .into_iter() + .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .map(|(arg, table)| (enable.clone() * arg, table)) + .collect() + }, + ); // lookup access list storage key in RLP table // 1. ensure field_rlc is correct // 2. ensure value of storage key is correct - meta.lookup_any("Lookup access list storage key in RLP Table from tx circuit dynamic section (Signing)", |meta| { - let enable = and::expr(vec![ - meta.query_fixed(q_enable, Rotation::cur()), - meta.query_advice(is_access_list_storage_key, Rotation::cur()), - ]); + meta.lookup_any( + "Lookup access list storage key in RLP Table from tx circuit dynamic section (Signing)", + |meta| { + let enable = and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list_storage_key, Rotation::cur()), + ]); - // only eip2930 and eip1559 contains an access list - let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxSignEip2930.expr() - + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); + // only eip2930 and eip1559 contains an access list + let sign_format = meta.query_advice(is_eip2930, Rotation::cur()) + * TxSignEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxSignEip1559.expr(); - vec![ - 1.expr(), // q_enable = true - meta.query_advice(tx_table.tx_id, Rotation::cur()), - sign_format, - meta.query_advice(rlp_tag, Rotation::cur()), - meta.query_advice(tx_table.value, Rotation::cur()), - meta.query_advice(field_rlc, Rotation::cur()), - 32.expr(), // 32 bytes for storage keys - 1.expr(), // is_output = true - 0.expr(), // is_none = false. must have value - meta.query_advice(al_idx, Rotation::cur()), // access_list_idx - meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx - ] - .into_iter() - .zip_eq(rlp_table.table_exprs(meta).into_iter()) - .map(|(arg, table)| (enable.clone() * arg, table)) - .collect() - }); + vec![ + 1.expr(), // q_enable = true + meta.query_advice(tx_table.tx_id, Rotation::cur()), + sign_format, + meta.query_advice(rlp_tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + meta.query_advice(field_rlc, Rotation::cur()), + 32.expr(), // 32 bytes for storage keys + 1.expr(), // is_output = true + 0.expr(), // is_none = false. must have value + meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + ] + .into_iter() + .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .map(|(arg, table)| (enable.clone() * arg, table)) + .collect() + }, + ); - meta.lookup_any("Lookup access list storage key in RLP Table from tx circuit dynamic section (Hashing)", |meta| { - let enable = and::expr(vec![ - meta.query_fixed(q_enable, Rotation::cur()), - meta.query_advice(is_access_list_storage_key, Rotation::cur()), - ]); + meta.lookup_any( + "Lookup access list storage key in RLP Table from tx circuit dynamic section (Hashing)", + |meta| { + let enable = and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice(is_access_list_storage_key, Rotation::cur()), + ]); - // only eip2930 and eip1559 contains an access list - let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) * TxHashEip2930.expr() - + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); + // only eip2930 and eip1559 contains an access list + let hash_format = meta.query_advice(is_eip2930, Rotation::cur()) + * TxHashEip2930.expr() + + meta.query_advice(is_eip1559, Rotation::cur()) * TxHashEip1559.expr(); - vec![ - 1.expr(), // q_enable = true - meta.query_advice(tx_table.tx_id, Rotation::cur()), - hash_format, - meta.query_advice(rlp_tag, Rotation::cur()), - meta.query_advice(tx_table.value, Rotation::cur()), - meta.query_advice(field_rlc, Rotation::cur()), - 32.expr(), // 32 bytes for storage keys - 1.expr(), // is_output = true - 0.expr(), // is_none = false. must have value - meta.query_advice(al_idx, Rotation::cur()), // access_list_idx - meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx - ] - .into_iter() - .zip_eq(rlp_table.table_exprs(meta).into_iter()) - .map(|(arg, table)| (enable.clone() * arg, table)) - .collect() - }); + vec![ + 1.expr(), // q_enable = true + meta.query_advice(tx_table.tx_id, Rotation::cur()), + hash_format, + meta.query_advice(rlp_tag, Rotation::cur()), + meta.query_advice(tx_table.value, Rotation::cur()), + meta.query_advice(field_rlc, Rotation::cur()), + 32.expr(), // 32 bytes for storage keys + 1.expr(), // is_output = true + 0.expr(), // is_none = false. must have value + meta.query_advice(al_idx, Rotation::cur()), // access_list_idx + meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx + ] + .into_iter() + .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .map(|(arg, table)| (enable.clone() * arg, table)) + .collect() + }, + ); //////////////////////////////////////////////////////////////////// ///////////////// Sig table lookups ////////////////////// @@ -2524,7 +2537,10 @@ impl TxCircuitConfig { tag: Tag::MaxPriorityFeePerGas.into(), is_none: tx.max_priority_fee_per_gas.is_zero(), be_bytes_len: tx.max_priority_fee_per_gas.tag_length(), - be_bytes_rlc: rlc_be_bytes(&tx.max_priority_fee_per_gas.to_be_bytes(), keccak_input), + be_bytes_rlc: rlc_be_bytes( + &tx.max_priority_fee_per_gas.to_be_bytes(), + keccak_input, + ), }), rlc_be_bytes(&tx.max_priority_fee_per_gas.to_be_bytes(), evm_word), ), @@ -2654,7 +2670,8 @@ impl TxCircuitConfig { let case1 = is_tag_in_set && !is_l1_msg; let case2 = !tx.tx_type.is_pre_eip155() && (tx_tag == ChainID); let case3 = !tx.tx_type.is_eip1559() && (tx_tag == GasPrice); - let case4 = tx.tx_type.is_eip1559() && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); + let case4 = tx.tx_type.is_eip1559() + && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); F::from((case1 || case2 || case3 || case4) as u64) }); // 3. lookup to RLP table for hashing (non L1 msg) @@ -2675,7 +2692,8 @@ impl TxCircuitConfig { let is_tag_in_set = hash_set.into_iter().filter(|tag| tx_tag == *tag).count() == 1; let case1 = is_tag_in_set && !is_l1_msg; let case3 = !tx.tx_type.is_eip1559() && (tx_tag == GasPrice); - let case4 = tx.tx_type.is_eip1559() && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); + let case4 = tx.tx_type.is_eip1559() + && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); F::from((case1 || case3 || case4) as u64) }); // 4. lookup to RLP table for hashing (L1 msg) @@ -3652,4 +3670,4 @@ pub fn access_list_rlc( } else { Value::known(F::zero()) } -} \ No newline at end of file +} diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 64b943fb7c..89ba66632b 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -1170,8 +1170,16 @@ pub(super) fn tx_convert( nonce: tx.nonce, gas: tx.gas, gas_price: tx.gas_price, - max_fee_per_gas: if tx.tx_type.is_eip1559() { tx.gas_fee_cap } else { tx.gas_price }, - max_priority_fee_per_gas: if tx.tx_type.is_eip1559() { tx.gas_tip_cap } else { tx.gas_price }, + max_fee_per_gas: if tx.tx_type.is_eip1559() { + tx.gas_fee_cap + } else { + tx.gas_price + }, + max_priority_fee_per_gas: if tx.tx_type.is_eip1559() { + tx.gas_tip_cap + } else { + tx.gas_price + }, caller_address: tx.from, callee_address, is_create: tx.is_create(), From 93e3e4508979b442819c2ab69496e515a22cd1b9 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 01:34:32 -0800 Subject: [PATCH 092/161] fmt --- zkevm-circuits/src/table.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 2c0c1dcd18..7d58bd34d3 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -2356,12 +2356,12 @@ impl RlpFsmRlpTable { ( "access_list_idx", self.access_list_idx.into(), - Value::known(F::from(row.access_list_idx as u64)), + Value::known(F::from(row.access_list_idx)), ), ( "storage_key_idx", self.storage_key_idx.into(), - Value::known(F::from(row.storage_key_idx as u64)), + Value::known(F::from(row.storage_key_idx)), ), ]; From 5284faff14645a309a3bdbb128d7a815892f83d6 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 01:52:48 -0800 Subject: [PATCH 093/161] add option guard --- zkevm-circuits/src/witness/tx.rs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 89ba66632b..12f722baa6 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -431,23 +431,25 @@ impl Transaction { ) -> Vec<[Value; 5]> { let mut assignments: Vec<[Value; 5]> = vec![]; - for (al_idx, al) in self.access_list.as_ref().unwrap().0.iter().enumerate() { - assignments.push([ - Value::known(F::from(self.id as u64)), - Value::known(F::from(TxContextFieldTag::AccessListAddress as u64)), - Value::known(F::from((al_idx + 1) as u64)), - Value::known(al.address.to_scalar().unwrap()), - Value::known(al.address.to_scalar().unwrap()), - ]); - - for (sk_idx, sk) in al.storage_keys.iter().enumerate() { + if self.access_list.is_some() { + for (al_idx, al) in self.access_list.as_ref().unwrap().0.iter().enumerate() { assignments.push([ Value::known(F::from(self.id as u64)), - Value::known(F::from(TxContextFieldTag::AccessListStorageKey as u64)), - Value::known(F::from(sk_idx as u64)), - rlc_be_bytes(&sk.to_fixed_bytes(), challenges.evm_word()), + Value::known(F::from(TxContextFieldTag::AccessListAddress as u64)), + Value::known(F::from((al_idx + 1) as u64)), + Value::known(al.address.to_scalar().unwrap()), Value::known(al.address.to_scalar().unwrap()), ]); + + for (sk_idx, sk) in al.storage_keys.iter().enumerate() { + assignments.push([ + Value::known(F::from(self.id as u64)), + Value::known(F::from(TxContextFieldTag::AccessListStorageKey as u64)), + Value::known(F::from(sk_idx as u64)), + rlc_be_bytes(&sk.to_fixed_bytes(), challenges.evm_word()), + Value::known(al.address.to_scalar().unwrap()), + ]); + } } } From bd570d79ac922a11ce50d05fe3a11984f4b36050 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 01:57:02 -0800 Subject: [PATCH 094/161] fmt --- zkevm-circuits/src/witness/tx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 12f722baa6..38c50d9a3a 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -440,7 +440,7 @@ impl Transaction { Value::known(al.address.to_scalar().unwrap()), Value::known(al.address.to_scalar().unwrap()), ]); - + for (sk_idx, sk) in al.storage_keys.iter().enumerate() { assignments.push([ Value::known(F::from(self.id as u64)), From e372e36e93fb8d00eef6865b7b5d043ab3b43be7 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 13:57:54 -0800 Subject: [PATCH 095/161] unwrap guard --- zkevm-circuits/src/tx_circuit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 83d14f0be1..359efe25b3 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -2830,7 +2830,7 @@ impl TxCircuitConfig { ) -> Result<(), Error> { // assign to access_list related columns - if !tx.access_list.as_ref().unwrap().0.is_empty() { + if tx.access_list.is_some() { // storage key len accumulator let mut sks_acc: usize = 0; From 62ff8108c661acc81d6af207b27915e8217e8fd4 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 15:15:18 -0800 Subject: [PATCH 096/161] correct witness rows --- zkevm-circuits/src/pi_circuit.rs | 3 +++ zkevm-circuits/src/table.rs | 3 +++ zkevm-circuits/src/witness/tx.rs | 28 ++++++++-------------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/zkevm-circuits/src/pi_circuit.rs b/zkevm-circuits/src/pi_circuit.rs index d9dbcaa35e..637df45f39 100644 --- a/zkevm-circuits/src/pi_circuit.rs +++ b/zkevm-circuits/src/pi_circuit.rs @@ -977,6 +977,9 @@ impl PiCircuitConfig { } } // Copy tx_hashes to tx table + log::trace!("tx_copy_cells: {:?}", tx_copy_cells); + log::trace!("tx_value_cells: {:?}", tx_value_cells); + for (i, tx_hash_cell) in tx_copy_cells.into_iter().enumerate() { region.constrain_equal( tx_hash_cell.cell(), diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 7d58bd34d3..0572b88710 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -394,6 +394,7 @@ impl LookupTable for TxTable { self.tag.into(), self.index.into(), self.value.into(), + self.access_list_address.into(), ] } @@ -404,6 +405,7 @@ impl LookupTable for TxTable { String::from("tag"), String::from("index"), String::from("value"), + String::from("access_list_address"), ] } @@ -414,6 +416,7 @@ impl LookupTable for TxTable { meta.query_fixed(self.tag, Rotation::cur()), meta.query_advice(self.index, Rotation::cur()), meta.query_advice(self.value, Rotation::cur()), + meta.query_advice(self.access_list_address, Rotation::cur()), ] } } diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 38c50d9a3a..18be4f8b0b 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -352,7 +352,6 @@ impl Transaction { Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::AccessListRLC as u64)), Value::known(F::zero()), - // TODO: need to check if it's correct with RLP. rlc_be_bytes( &self .access_list @@ -365,31 +364,20 @@ impl Transaction { ], [ Value::known(F::from(self.id as u64)), - Value::known(F::from(TxContextFieldTag::AccessListAddressesLen as u64)), - Value::known(F::zero()), - Value::known(F::from(access_list_address_size)), + Value::known(F::from(TxContextFieldTag::MaxFeePerGas as u64)), Value::known(F::zero()), - ], - [ - Value::known(F::from(self.id as u64)), - Value::known(F::from(TxContextFieldTag::AccessListStorageKeysLen as u64)), - Value::known(F::zero()), - Value::known(F::from(access_list_storage_key_size)), + challenges + .evm_word() + .map(|challenge| rlc::value(&self.max_fee_per_gas.to_le_bytes(), challenge)), Value::known(F::zero()), ], [ Value::known(F::from(self.id as u64)), - Value::known(F::from(TxContextFieldTag::AccessListRLC as u64)), + Value::known(F::from(TxContextFieldTag::MaxPriorityFeePerGas as u64)), Value::known(F::zero()), - // TODO: need to check if it's correct with RLP. - rlc_be_bytes( - &self - .access_list - .as_ref() - .map(|access_list| access_list.rlp_bytes()) - .unwrap_or_default(), - challenges.keccak_input(), - ), + challenges + .evm_word() + .map(|challenge| rlc::value(&self.max_priority_fee_per_gas.to_le_bytes(), challenge)), Value::known(F::zero()), ], [ From 1a6f37595bb974dd5dbb44f6b5de4b4e3d7656cc Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 15:25:26 -0800 Subject: [PATCH 097/161] fmt --- zkevm-circuits/src/witness/tx.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 18be4f8b0b..066e5c5962 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -375,9 +375,9 @@ impl Transaction { Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::MaxPriorityFeePerGas as u64)), Value::known(F::zero()), - challenges - .evm_word() - .map(|challenge| rlc::value(&self.max_priority_fee_per_gas.to_le_bytes(), challenge)), + challenges.evm_word().map(|challenge| { + rlc::value(&self.max_priority_fee_per_gas.to_le_bytes(), challenge) + }), Value::known(F::zero()), ], [ From 306c5c82079dc4930788ce9f91c573a79e7673d3 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 15:31:26 -0800 Subject: [PATCH 098/161] add comment --- zkevm-circuits/src/tx_circuit.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 359efe25b3..7c826f800f 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -3643,6 +3643,8 @@ pub(crate) fn get_sign_data( } /// Returns the RLC of the access list including addresses and storage keys +/// This function provides an alternative routine to calculate access_list_rlc +/// to ascertain the correctness of assignment in witness generation. pub fn access_list_rlc( access_list: &Option, challenges: &Challenges>, From f8143554fc2311f988fad316672f87fc184b983c Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 16:07:06 -0800 Subject: [PATCH 099/161] add instrument to fix degree --- zkevm-circuits/src/tx_circuit.rs | 82 ++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 7c826f800f..5bcac7ace1 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -151,6 +151,7 @@ pub struct TxCircuitConfig { is_eip2930: Column, is_eip1559: Column, is_chain_id: Column, + is_tx_id_zero: Column, lookup_conditions: HashMap>, /// Columns for computing num_all_txs @@ -302,6 +303,7 @@ impl SubCircuitConfig for TxCircuitConfig { let is_eip2930 = meta.advice_column(); let is_eip1559 = meta.advice_column(); let is_calldata = meta.advice_column(); + let is_tx_id_zero = meta.advice_column(); let is_caller_address = meta.advice_column(); let is_chain_id = meta.advice_column(); let is_tag_block_num = meta.advice_column(); @@ -629,6 +631,18 @@ impl SubCircuitConfig for TxCircuitConfig { cb.gate(meta.query_fixed(q_enable, Rotation::cur())) }); + meta.create_gate("is_tx_id_zero", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "is_tx_id_zero", + tx_id_is_zero.expr(Rotation::cur())(meta), + meta.query_advice(is_tx_id_zero, Rotation::cur()), + ); + + cb.gate(meta.query_fixed(q_enable, Rotation::cur())) + }); + meta.create_gate("is_access_list", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1373,34 +1387,33 @@ impl SubCircuitConfig for TxCircuitConfig { }, ); - // tx1559_debug - // cb.condition( - // and::expr([ - // is_final_cur.clone(), - // not::expr(tx_id_is_zero.expr(Rotation::next())(meta)), - // not::expr(meta.query_advice(is_access_list, Rotation::next())), - // ]), - // |cb| { - // let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); - // let gas_cost_next = select::expr(value_next_is_zero, 4.expr(), 16.expr()); - - // cb.require_equal( - // "index' == 0", - // meta.query_advice(tx_table.index, Rotation::next()), - // 0.expr(), - // ); - // cb.require_equal( - // "calldata_gas_cost_acc' == gas_cost_next", - // meta.query_advice(calldata_gas_cost_acc, Rotation::next()), - // gas_cost_next, - // ); - // cb.require_equal( - // "section_rlc' == byte'", - // meta.query_advice(section_rlc, Rotation::next()), - // meta.query_advice(tx_table.value, Rotation::next()), - // ); - // }, - // ); + cb.condition( + and::expr([ + is_final_cur.clone(), + not::expr(meta.query_advice(is_tx_id_zero, Rotation::next())), + not::expr(meta.query_advice(is_access_list, Rotation::next())), + ]), + |cb| { + let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); + let gas_cost_next = select::expr(value_next_is_zero, 4.expr(), 16.expr()); + + cb.require_equal( + "index' == 0", + meta.query_advice(tx_table.index, Rotation::next()), + 0.expr(), + ); + cb.require_equal( + "calldata_gas_cost_acc' == gas_cost_next", + meta.query_advice(calldata_gas_cost_acc, Rotation::next()), + gas_cost_next, + ); + cb.require_equal( + "section_rlc' == byte'", + meta.query_advice(section_rlc, Rotation::next()), + meta.query_advice(tx_table.value, Rotation::next()), + ); + }, + ); // Initialize the dynamic access list assignment section. // Must follow immediately when the calldata section ends. @@ -1434,7 +1447,7 @@ impl SubCircuitConfig for TxCircuitConfig { cb.gate(and::expr(vec![ meta.query_fixed(q_enable, Rotation::cur()), meta.query_advice(is_calldata, Rotation::cur()), - not::expr(tx_id_is_zero.expr(Rotation::cur())(meta)), + not::expr(meta.query_advice(is_tx_id_zero, Rotation::cur())), ])) }); @@ -1676,6 +1689,7 @@ impl SubCircuitConfig for TxCircuitConfig { value_is_zero, tx_id_unchanged, is_calldata, + is_tx_id_zero, is_caller_address, tx_id_cmp_cum_num_txs, tx_id_gt_prev_cnt, @@ -2612,12 +2626,12 @@ impl TxCircuitConfig { self.sv_address, sign_data.get_addr().to_scalar().unwrap(), ), - // tx_tag related indicator columns ( "is_tag_calldata", self.is_calldata, F::from((tx_tag == CallData) as u64), ), + // tx_tag related indicator columns ( "is_tag_block_num", self.is_tag_block_num, @@ -3046,7 +3060,14 @@ impl TxCircuitConfig { self.is_eip1559, F::from(tx_type.is_eip1559() as u64), ), + ( + "is_tx_id_zero", + self.is_tx_id_zero, + F::from((tx_id == 0) as u64), + ), ] { + // tx1559_debug + log::trace!("=> [assign is_tx_id_zero] col_anno: {:?}, offset: {:?}, val: {:?}", col_anno, offset, col_val); region.assign_advice(|| col_anno, col, offset, || Value::known(col_val))?; } @@ -3110,6 +3131,7 @@ impl TxCircuitConfig { (self.is_final, F::one()), (self.is_calldata, F::one()), (self.calldata_gas_cost_acc, F::zero()), + (self.is_tx_id_zero, F::one()), ] { region.assign_advice(|| "", col, offset, || Value::known(value))?; } From ba0a256decef2a42db833163e6b7786232d0e2d5 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 16:47:44 -0800 Subject: [PATCH 100/161] fix rlp lookup --- tx_circuit_l1_msg_tx | 422 ++++++++++++++++++++++++++ zkevm-circuits/src/tx_circuit.rs | 12 +- zkevm-circuits/src/tx_circuit/test.rs | 3 +- 3 files changed, 429 insertions(+), 8 deletions(-) create mode 100644 tx_circuit_l1_msg_tx diff --git a/tx_circuit_l1_msg_tx b/tx_circuit_l1_msg_tx new file mode 100644 index 0000000000..aaa559815f --- /dev/null +++ b/tx_circuit_l1_msg_tx @@ -0,0 +1,422 @@ + Blocking waiting for file lock on build directory + Compiling zkevm-circuits v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/zkevm-circuits) +warning: unused imports: `mpt_circuit::MptCircuit`, `util::SubCircuit`, `witness::block_convert` + --> zkevm-circuits/src/evm_circuit/execution/callop.rs:1153:9 + | +1153 | mpt_circuit::MptCircuit, test_util::CircuitTestBuilder, util::SubCircuit, + | ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +1154 | witness::block_convert, + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default + +warning: unused import: `mock::BlockData` + --> zkevm-circuits/src/evm_circuit/execution/callop.rs:1156:62 + | +1156 | use bus_mapping::{circuit_input_builder::CircuitsParams, mock::BlockData}; + | ^^^^^^^^^^^^^^^ + +warning: unused import: `GethData` + --> zkevm-circuits/src/evm_circuit/execution/callop.rs:1160:31 + | +1160 | geth_types::{Account, GethData}, + | ^^^^^^^^ + +warning: unused imports: `dev::MockProver`, `halo2curves::bn256::Fr` + --> zkevm-circuits/src/evm_circuit/execution/callop.rs:1163:24 + | +1163 | use halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr}; + | ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ + + Compiling integration-tests v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/integration-tests) + Compiling aggregator v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/aggregator) + Compiling prover v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/prover) + Compiling circuit-benchmarks v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/circuit-benchmarks) + Compiling testool v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/testool) +warning: variable does not need to be mutable + --> testool/src/statetest/executor.rs:560:13 + | +560 | let (_, mut trace_config, post) = into_traceconfig(st.clone()); + | ----^^^^^^^^^^^^ + | | + | help: remove this `mut` + | + = note: `#[warn(unused_mut)]` on by default + +warning: `testool` (bin "testool" test) generated 1 warning (run `cargo fix --bin "testool" --tests` to apply 1 suggestion) +warning: `zkevm-circuits` (lib test) generated 4 warnings (run `cargo fix --lib -p zkevm-circuits --tests` to apply 4 suggestions) + Finished test [unoptimized + debuginfo] target(s) in 54.70s + Running unittests src/lib.rs (target/debug/deps/aggregator-b8ca1009cd7be173) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/bus_mapping-be22080c86aded88) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 66 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/circuit_benchmarks-7a2a8e48926146f4) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/eth_types-39dc8ee3cf4846e6) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 19 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/external_tracer-6f36029a05644959) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/gadgets-d1febf07fa5bed2a) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 10 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/geth_utils-4759d6976c1ac707) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/integration_tests-136bc6136abc225e) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + + Running unittests src/bin/gen_blockchain_data.rs (target/debug/deps/gen_blockchain_data-259f9014d2198487) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + + Running tests/circuit_input_builder.rs (target/debug/deps/circuit_input_builder-0b95a3d634ec7a80) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + + Running tests/circuits.rs (target/debug/deps/circuits-1a289e0d2b0edc87) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 80 filtered out; finished in 0.00s + + Running tests/mainnet.rs (target/debug/deps/mainnet-f46ad174707ca7e4) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out; finished in 0.00s + + Running tests/rpc.rs (target/debug/deps/rpc-030b30ceb12bd315) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/keccak256-fb7849d1c3ab5b6f) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/mock-a8b180075292ccc2) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/mpt_zktrie-1cad4ab933ec3e66) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 3 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/prover-ee0a88654eff2942) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s + + Running unittests src/main.rs (target/debug/deps/testool-0b06b9af4140306a) + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 14 filtered out; finished in 0.00s + + Running unittests src/lib.rs (target/debug/deps/zkevm_circuits-68f918ed565bb50a) + +running 1 test +[2023-12-05T00:46:49Z INFO zkevm_circuits::tx_circuit] TxCircuit::new(max_txs = 4, max_calldata = 400, chain_id = 1338) +[2023-12-05T00:46:49Z DEBUG zkevm_circuits::sig_circuit::utils] ecdsa chip uses 57 advice columns for 128 signatures +[2023-12-05T00:46:49Z DEBUG zkevm_circuits::sig_circuit::utils] ecdsa chip uses 8 lookup advice columns for 128 signatures +[2023-12-05T00:46:49Z INFO zkevm_circuits::sig_circuit] configuring ECDSA chip with multiple phases +[2023-12-05T00:46:49Z INFO zkevm_circuits::tx_circuit] after tx_circuit, meta.degree: 9 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 1) sign witness rows len = 0 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 1) tx hash witness rows len = 444 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 2) sign witness rows len = 29 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 2) tx hash witness rows len = 97 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 3) sign witness rows len = 29 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 3) tx hash witness rows len = 97 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 4) sign witness rows len = 29 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 4) tx hash witness rows len = 97 +[2023-12-05T00:46:56Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "RLP dev table" row_count: 73 +[2023-12-05T00:46:56Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "RLP dev table", idx 1 start 0 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] block_nums: {1} +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] num_all_txs: {1: 12} +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] [block_num: 1, num_txs: 1, cum_num_txs: 1] tx_id: 0, num_all_txs_acc: 12 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 1, num_all_txs_acc: 1 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 2, num_all_txs_acc: 2 +[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 3, num_all_txs_acc: 3 +[2023-12-05T00:46:57Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "tx table aux" row_count: 513 +[2023-12-05T00:46:57Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "tx table aux", idx 3 start 0 +[2023-12-05T00:46:57Z DEBUG zkevm_circuits::tx_circuit] [block_num: 1, num_txs: 1, cum_num_txs: 1] tx_id: 0, num_all_txs_acc: 12 +[2023-12-05T00:46:57Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 1, num_all_txs_acc: 1 +[2023-12-05T00:46:57Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 2, num_all_txs_acc: 2 +[2023-12-05T00:46:57Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 3, num_all_txs_acc: 3 +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } + reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } + reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished data decomposition +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } + reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } + reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished data decomposition +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } + reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } + reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished data decomposition +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } + reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } + reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished data decomposition +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 + input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 + input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } + reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 + input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } + reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } +[2023-12-05T00:47:12Z INFO zkevm_circuits::sig_circuit] before proceeding to the next phase +Context "ECDSA context" used 2 advice columns and 1844697 total advice cells in phase 0 +Special lookup advice cells: optimal columns: 1, total 253104 cells used in phase 0. +Fixed columns: 1, Total fixed cells: 8032 +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished sign verify +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished sign verify +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished sign verify +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished sign verify +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] keccak lookup +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] keccak lookup +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] keccak lookup +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] keccak lookup +[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup +[2023-12-05T00:47:12Z INFO zkevm_circuits::sig_circuit] total number of lookup cells: 0 +Context "ECDSA context" used 2 advice columns and 1844697 total advice cells in phase 0 +Special lookup advice cells: optimal columns: 1, total 253104 cells used in phase 0. +Context "ECDSA context" used 1 advice columns and 2324 total advice cells in phase 1 +Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 1. +Fixed columns: 1, Total fixed cells: 8032 +[2023-12-05T00:47:12Z INFO halo2_proofs::dev] MockProver synthesize took 20.166517083s +[2023-12-05T00:47:17Z DEBUG halo2_proofs::dev] regions.len() = 9 +test tx_circuit::test::tx_circuit_l1_msg_tx ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 597 filtered out; finished in 44.04s + diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 5bcac7ace1..da184be65c 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -2682,8 +2682,8 @@ impl TxCircuitConfig { ]; let is_tag_in_set = sign_set.into_iter().filter(|tag| tx_tag == *tag).count() == 1; let case1 = is_tag_in_set && !is_l1_msg; - let case2 = !tx.tx_type.is_pre_eip155() && (tx_tag == ChainID); - let case3 = !tx.tx_type.is_eip1559() && (tx_tag == GasPrice); + let case2 = !tx.tx_type.is_pre_eip155() && !is_l1_msg && (tx_tag == ChainID); + let case3 = !tx.tx_type.is_eip1559() && !is_l1_msg && (tx_tag == GasPrice); let case4 = tx.tx_type.is_eip1559() && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); F::from((case1 || case2 || case3 || case4) as u64) @@ -2705,10 +2705,10 @@ impl TxCircuitConfig { ]; let is_tag_in_set = hash_set.into_iter().filter(|tag| tx_tag == *tag).count() == 1; let case1 = is_tag_in_set && !is_l1_msg; - let case3 = !tx.tx_type.is_eip1559() && (tx_tag == GasPrice); - let case4 = tx.tx_type.is_eip1559() + let case2 = !tx.tx_type.is_eip1559() && !is_l1_msg && (tx_tag == GasPrice); + let case3 = tx.tx_type.is_eip1559() && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); - F::from((case1 || case3 || case4) as u64) + F::from((case1 || case2 || case3) as u64) }); // 4. lookup to RLP table for hashing (L1 msg) conditions.insert(LookupCondition::L1MsgHash, { @@ -3066,8 +3066,6 @@ impl TxCircuitConfig { F::from((tx_id == 0) as u64), ), ] { - // tx1559_debug - log::trace!("=> [assign is_tx_id_zero] col_anno: {:?}, offset: {:?}, val: {:?}", col_anno, offset, col_val); region.assign_advice(|| col_anno, col, offset, || Value::known(col_val))?; } diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index f633ad0385..2d5bbc196e 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -271,7 +271,8 @@ fn tx_circuit_1tx_2max_tx() { } #[test] -#[cfg(feature = "scroll")] +// tx1559_debug +// #[cfg(feature = "scroll")] fn tx_circuit_l1_msg_tx() { const MAX_TXS: usize = 4; const MAX_CALLDATA: usize = 400; From 6c94f8b535627361e78708e193492ee9f70fa70d Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 16:47:54 -0800 Subject: [PATCH 101/161] remove debug tag --- zkevm-circuits/src/tx_circuit/test.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index 2d5bbc196e..f633ad0385 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -271,8 +271,7 @@ fn tx_circuit_1tx_2max_tx() { } #[test] -// tx1559_debug -// #[cfg(feature = "scroll")] +#[cfg(feature = "scroll")] fn tx_circuit_l1_msg_tx() { const MAX_TXS: usize = 4; const MAX_CALLDATA: usize = 400; From ba9fa62ceb47d009bb1db206cf3510b32d5f9121 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 16:48:03 -0800 Subject: [PATCH 102/161] remove debug tag --- zkevm-circuits/src/tx_circuit/test.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index f633ad0385..7be8c9a543 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -186,8 +186,7 @@ fn run( } #[test] -// tx1559_debug_new_test -// #[cfg(feature = "scroll")] +#[cfg(feature = "scroll")] fn tx_circuit_1tx_2max_eip1559() { const MAX_TXS: usize = 2; const MAX_CALLDATA: usize = 3200; From 54f5195395c3695bfb930da50f965e78d547eb0c Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 17:00:05 -0800 Subject: [PATCH 103/161] style fmt --- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index c454fec75d..c784f15cb6 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -115,26 +115,27 @@ fn test_eip1559_tx() { "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; - let mut txs: Vec = vec![]; - for (idx, bytes) in test_bytes.into_iter().enumerate() { - let raw_tx_rlp_bytes = hex::decode(bytes).expect("decode tx's hex shall not fail"); - - let eth_tx = EthTransaction::decode(&Rlp::new(&raw_tx_rlp_bytes)) - .expect("decode tx's rlp bytes shall not fail"); - - let eth_tx_req: Eip1559TransactionRequest = (ð_tx).into(); - let typed_tx: TypedTransaction = eth_tx_req.into(); - let rlp_unsigned = typed_tx.rlp().to_vec(); - - let tx = Transaction::new_from_rlp_bytes( - idx + 1, - TxType::Eip1559, - raw_tx_rlp_bytes, - rlp_unsigned, - ); - - txs.push(tx); - } + let txs = test_bytes + .into_iter() + .enumerate() + .map(|(idx, bytes)| { + let raw_tx_rlp_bytes = hex::decode(bytes).expect("decode tx's hex shall not fail"); + + let eth_tx = EthTransaction::decode(&Rlp::new(&raw_tx_rlp_bytes)) + .expect("decode tx's rlp bytes shall not fail"); + + let eth_tx_req: Eip1559TransactionRequest = (ð_tx).into(); + let typed_tx: TypedTransaction = eth_tx_req.into(); + let rlp_unsigned = typed_tx.rlp().to_vec(); + + Transaction::new_from_rlp_bytes( + idx + 1, + TxType::Eip1559, + raw_tx_rlp_bytes, + rlp_unsigned, + ) + }) + .collect::>(); assert!( txs.len() <= 10, From 2ef2c5ac834e3ceaded012f601cca0a08dd97ec2 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 4 Dec 2023 18:02:44 -0800 Subject: [PATCH 104/161] adjust section transition --- zkevm-circuits/src/tx_circuit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index da184be65c..0e81404c85 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -1391,7 +1391,7 @@ impl SubCircuitConfig for TxCircuitConfig { and::expr([ is_final_cur.clone(), not::expr(meta.query_advice(is_tx_id_zero, Rotation::next())), - not::expr(meta.query_advice(is_access_list, Rotation::next())), + meta.query_advice(is_calldata, Rotation::next()), ]), |cb| { let value_next_is_zero = value_is_zero.expr(Rotation::next())(meta); From 9cb52714493a9a1929207e43f66f2e2ebb5aefe6 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 14:57:37 -0800 Subject: [PATCH 105/161] cargo --- Cargo.lock | 1237 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 744 insertions(+), 493 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e131d307eb..bef6eace67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,8 +45,8 @@ dependencies = [ "ark-std 0.3.0", "env_logger", "eth-types", - "ethers-core", - "halo2_proofs", + "ethers-core 2.0.7", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "hex", "itertools 0.11.0", "log", @@ -60,29 +60,30 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if 1.0.0", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] [[package]] name = "alloy-rlp" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f938f00332d63a5b0ac687bd6f46d03884638948921d9f8b50c59563d421ae25" +checksum = "cc0fac0fc16baf1f63f78b47c3d24718f3619b0714076f6a02957d808d52cbef" dependencies = [ "arrayvec", "bytes", @@ -270,13 +271,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] @@ -354,9 +355,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -402,9 +403,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "bitvec" @@ -475,9 +476,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bus-mapping" @@ -486,11 +487,11 @@ dependencies = [ "ctor", "env_logger", "eth-types", - "ethers-core", + "ethers-core 2.0.7", "ethers-providers", "ethers-signers", "gadgets", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "hex", "itertools 0.11.0", "lazy_static", @@ -525,9 +526,9 @@ checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -570,22 +571,22 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" +checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" dependencies = [ "serde", ] [[package]] name = "cargo_metadata" -version = "0.15.4" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", - "semver 1.0.18", + "semver 1.0.20", "serde", "serde_json", "thiserror", @@ -599,11 +600,10 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "0f8e7c90afad890484a21653d08b6e209ae34770fb5ee298f9c699fcc1e5c856" dependencies = [ - "jobserver", "libc", ] @@ -621,9 +621,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.30" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", @@ -653,7 +653,7 @@ dependencies = [ "eth-types", "ethers", "ethers-signers", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "itertools 0.11.0", "keccak256", "log", @@ -786,7 +786,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bech32", "bs58", "digest 0.10.7", @@ -823,6 +823,19 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed3d0b5ff30645a68f35ece8cea4556ca14ef8a1651455f789a099a0513532a6" +[[package]] +name = "const-hex" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5104de16b218eddf8e34ffe2f86f74bfa4e61e95a1b89732fccf6325efd0557" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "hex", + "proptest", + "serde", +] + [[package]] name = "const-oid" version = "0.9.5" @@ -901,9 +914,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -1040,9 +1053,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "28f85c3514d2a6e64160359b45a3918c3b4178bcbf4ae5d03ab2d02e521c479a" dependencies = [ "generic-array", "rand_core", @@ -1062,9 +1075,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626ae34994d3d8d668f4269922248239db4ae42d538b14c398b74a52208e8086" +checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" dependencies = [ "csv-core", "itoa", @@ -1074,9 +1087,9 @@ dependencies = [ [[package]] name = "csv-core" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" dependencies = [ "memchr", ] @@ -1197,9 +1210,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] [[package]] name = "derivative" @@ -1277,6 +1293,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + [[package]] name = "dirs-next" version = "2.0.0" @@ -1287,6 +1312,18 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + [[package]] name = "dirs-sys-next" version = "0.1.2" @@ -1351,7 +1388,7 @@ checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ "der 0.7.8", "digest 0.10.7", - "elliptic-curve 0.13.5", + "elliptic-curve 0.13.6", "rfc6979 0.4.0", "signature 2.1.0", "spki", @@ -1384,12 +1421,12 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.5" +version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" dependencies = [ "base16ct 0.2.0", - "crypto-bigint 0.5.3", + "crypto-bigint 0.5.4", "digest 0.10.7", "ff 0.13.0", "generic-array", @@ -1427,11 +1464,11 @@ dependencies = [ [[package]] name = "enr" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf56acd72bb22d2824e66ae8e9e5ada4d0de17a69c7fd35569dde2ada8ec9116" +checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" dependencies = [ - "base64 0.13.1", + "base64 0.21.5", "bytes", "hex", "k256 0.13.1", @@ -1451,14 +1488,14 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -1475,25 +1512,14 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" dependencies = [ - "errno-dragonfly", "libc", "windows-sys", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "eth-keystore" version = "0.5.0" @@ -1520,9 +1546,9 @@ dependencies = [ name = "eth-types" version = "0.1.0" dependencies = [ - "ethers-core", + "ethers-core 2.0.7", "ethers-signers", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "hex", "itertools 0.11.0", "lazy_static", @@ -1591,27 +1617,27 @@ dependencies = [ [[package]] name = "ethers" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a58ce802c65cf3d0756dee5a61094a92cde53c1583b246e9ee5b37226c7fc15" +checksum = "1a5344eea9b20effb5efeaad29418215c4d27017639fd1f908260f59cbbd226e" dependencies = [ "ethers-addressbook", "ethers-contract", - "ethers-core", + "ethers-core 2.0.11", "ethers-etherscan", "ethers-middleware", "ethers-providers", "ethers-signers", - "ethers-solc 2.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "ethers-solc", ] [[package]] name = "ethers-addressbook" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b856b7b8ff5c961093cb8efe151fbcce724b451941ce20781de11a531ccd578" +checksum = "8c405f24ea3a517899ba7985385c43dc4a7eb1209af3b1e0a1a32d7dcc7f8d09" dependencies = [ - "ethers-core", + "ethers-core 2.0.11", "once_cell", "serde", "serde_json", @@ -1619,16 +1645,16 @@ dependencies = [ [[package]] name = "ethers-contract" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e066a0d9cfc70c454672bf16bb433b0243427420076dc5b2f49c448fb5a10628" +checksum = "0111ead599d17a7bff6985fd5756f39ca7033edc79a31b23026a8d5d64fa95cd" dependencies = [ + "const-hex", "ethers-contract-abigen", "ethers-contract-derive", - "ethers-core", + "ethers-core 2.0.11", "ethers-providers", "futures-util", - "hex", "once_cell", "pin-project", "serde", @@ -1638,16 +1664,16 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c113e3e86b6bc16d98484b2c3bb2d01d6fed9f489fe2e592e5cc87c3024d616b" +checksum = "51258120c6b47ea9d9bec0d90f9e8af71c977fbefbef8213c91bfed385fe45eb" dependencies = [ "Inflector", + "const-hex", "dunce", - "ethers-core", + "ethers-core 2.0.11", "ethers-etherscan", "eyre", - "hex", "prettyplease", "proc-macro2", "quote", @@ -1655,25 +1681,25 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.32", - "toml 0.7.8", + "syn 2.0.39", + "toml 0.8.8", "walkdir", ] [[package]] name = "ethers-contract-derive" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3fb5adee25701c79ec58fcf2c63594cd8829bc9ad6037ff862d5a111101ed2" +checksum = "936e7a0f1197cee2b62dc89f63eff3201dbf87c283ff7e18d86d38f83b845483" dependencies = [ "Inflector", + "const-hex", "ethers-contract-abigen", - "ethers-core", - "hex", + "ethers-core 2.0.11", "proc-macro2", "quote", "serde_json", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] @@ -1683,22 +1709,49 @@ source = "git+https://github.com/scroll-tech/ethers-rs.git?branch=v2.0.7#e32dfd6 dependencies = [ "arrayvec", "bytes", - "cargo_metadata", "chrono", - "elliptic-curve 0.13.5", + "elliptic-curve 0.13.6", "ethabi", "generic-array", "hex", "k256 0.13.1", "num_enum 0.6.1", - "once_cell", "open-fastrlp", "rand", "rlp", "serde", "serde_json", "strum 0.24.1", - "syn 2.0.32", + "tempfile", + "thiserror", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "ethers-core" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f03e0bdc216eeb9e355b90cf610ef6c5bb8aca631f97b5ae9980ce34ea7878d" +dependencies = [ + "arrayvec", + "bytes", + "cargo_metadata", + "chrono", + "const-hex", + "elliptic-curve 0.13.6", + "ethabi", + "generic-array", + "k256 0.13.1", + "num_enum 0.7.1", + "once_cell", + "open-fastrlp", + "rand", + "rlp", + "serde", + "serde_json", + "strum 0.25.0", + "syn 2.0.39", "tempfile", "thiserror", "tiny-keccak", @@ -1707,13 +1760,15 @@ dependencies = [ [[package]] name = "ethers-etherscan" -version = "2.0.7" -source = "git+https://github.com/scroll-tech/ethers-rs.git?branch=v2.0.7#e32dfd62e7cdec31160b91c5a646883594a586ba" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abbac2c890bdbe0f1b8e549a53b00e2c4c1de86bb077c1094d1f38cdf9381a56" dependencies = [ - "ethers-core", - "ethers-solc 2.0.7 (git+https://github.com/scroll-tech/ethers-rs.git?branch=v2.0.7)", + "chrono", + "ethers-core 2.0.11", + "ethers-solc", "reqwest", - "semver 1.0.18", + "semver 1.0.20", "serde", "serde_json", "thiserror", @@ -1722,14 +1777,14 @@ dependencies = [ [[package]] name = "ethers-middleware" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740f4a773c19dd6d6a68c8c2e0996c096488d38997d524e21dc612c55da3bd24" +checksum = "681ece6eb1d10f7cf4f873059a77c04ff1de4f35c63dd7bccde8f438374fcb93" dependencies = [ "async-trait", "auto_impl", "ethers-contract", - "ethers-core", + "ethers-core 2.0.11", "ethers-etherscan", "ethers-providers", "ethers-signers", @@ -1749,24 +1804,25 @@ dependencies = [ [[package]] name = "ethers-providers" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56b498fd2a6c019d023e43e83488cd1fb0721f299055975aa6bac8dbf1e95f2c" +checksum = "25d6c0c9455d93d4990c06e049abf9b30daf148cf461ee939c11d88907c60816" dependencies = [ "async-trait", "auto_impl", - "base64 0.21.4", + "base64 0.21.5", "bytes", + "const-hex", "enr", - "ethers-core", + "ethers-core 2.0.11", "futures-channel", "futures-core", "futures-timer", "futures-util", "hashers", - "hex", "http", "instant", + "jsonwebtoken", "once_cell", "pin-project", "reqwest", @@ -1786,17 +1842,17 @@ dependencies = [ [[package]] name = "ethers-signers" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c4b7e15f212fa7cc2e1251868320221d4ff77a3d48068e69f47ce1c491df2d" +checksum = "0cb1b714e227bbd2d8c53528adb580b203009728b17d0d0e4119353aa9bc5532" dependencies = [ "async-trait", "coins-bip32", "coins-bip39", - "elliptic-curve 0.13.5", + "const-hex", + "elliptic-curve 0.13.6", "eth-keystore", - "ethers-core", - "hex", + "ethers-core 2.0.11", "rand", "sha2", "thiserror", @@ -1805,15 +1861,16 @@ dependencies = [ [[package]] name = "ethers-solc" -version = "2.0.7" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a81c89f121595cf8959e746045bb8b25a6a38d72588561e1a3b7992fc213f674" +checksum = "a64f710586d147864cff66540a6d64518b9ff37d73ef827fee430538265b595f" dependencies = [ "cfg-if 1.0.0", + "const-hex", + "dirs", "dunce", - "ethers-core", + "ethers-core 2.0.11", "glob", - "hex", "home", "md-5", "num_cpus", @@ -1821,7 +1878,7 @@ dependencies = [ "path-slash", "rayon", "regex", - "semver 1.0.18", + "semver 1.0.20", "serde", "serde_json", "solang-parser", @@ -1834,35 +1891,6 @@ dependencies = [ "yansi", ] -[[package]] -name = "ethers-solc" -version = "2.0.7" -source = "git+https://github.com/scroll-tech/ethers-rs.git?branch=v2.0.7#e32dfd62e7cdec31160b91c5a646883594a586ba" -dependencies = [ - "cfg-if 1.0.0", - "dunce", - "ethers-core", - "glob", - "hex", - "home", - "md-5", - "num_cpus", - "once_cell", - "path-slash", - "rayon", - "regex", - "semver 1.0.18", - "serde", - "serde_json", - "solang-parser", - "thiserror", - "tiny-keccak", - "tokio", - "tracing", - "walkdir", - "yansi", -] - [[package]] name = "external-tracer" version = "0.1.0" @@ -1886,9 +1914,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fastrlp" @@ -1903,9 +1931,9 @@ dependencies = [ [[package]] name = "fdeflate" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +checksum = "64d6dafc854908ff5da46ff3f8f473c6984119a2876a383a860246dd7841a868" dependencies = [ "simd-adler32", ] @@ -1927,6 +1955,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ + "bitvec", "rand_core", "subtle", ] @@ -1951,9 +1980,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -2059,9 +2088,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -2074,9 +2103,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -2084,15 +2113,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -2101,9 +2130,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-locks" @@ -2117,26 +2146,26 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-timer" @@ -2150,9 +2179,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -2180,7 +2209,7 @@ name = "gadgets" version = "0.1.0" dependencies = [ "eth-types", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "rand", "rand_xorshift", "sha3 0.10.8", @@ -2209,9 +2238,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if 1.0.0", "libc", @@ -2335,7 +2364,7 @@ version = "0.2.2" source = "git+https://github.com/scroll-tech/halo2-lib?tag=v0.1.5#70588177930400361c731659b15b2ab3f29f7784" dependencies = [ "ff 0.12.1", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "itertools 0.10.5", "num-bigint", "num-integer", @@ -2366,9 +2395,9 @@ dependencies = [ [[package]] name = "halo2-gate-generator" version = "0.1.0" -source = "git+https://github.com/scroll-tech/halo2gategen.git#35b137de2f71c37dfbd236842b868013c46739d1" +source = "git+https://github.com/scroll-tech/halo2gategen#8ccf462e1eff4ed0e602d7ba19771b2c53dee0e3" dependencies = [ - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=v1.0)", "lazy_static", "num-bigint", "rand", @@ -2384,8 +2413,8 @@ name = "halo2-mpt-circuits" version = "0.1.0" source = "git+https://github.com/scroll-tech/mpt-circuit.git?tag=v0.7.0#578c210ceb88d3c143ee2a013ad836d19285d9c1" dependencies = [ - "ethers-core", - "halo2_proofs", + "ethers-core 2.0.7", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "hex", "itertools 0.10.5", "lazy_static", @@ -2404,14 +2433,14 @@ dependencies = [ [[package]] name = "halo2_gadgets" version = "0.2.0" -source = "git+https://github.com/scroll-tech/halo2.git?branch=develop#5b9a3d71a325a9ecbad164aba90a7f6a8550a015" +source = "git+https://github.com/scroll-tech/halo2.git?branch=develop#8deec9924f598c85eb5ec1044199c78ef455c866" dependencies = [ "arrayvec", "bitvec", - "ff 0.12.1", - "group 0.12.1", - "halo2_proofs", - "halo2curves", + "ff 0.13.0", + "group 0.13.0", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", + "halo2curves 0.3.2", "lazy_static", "rand", "subtle", @@ -2421,20 +2450,20 @@ dependencies = [ [[package]] name = "halo2_proofs" version = "0.2.0" -source = "git+https://github.com/scroll-tech/halo2.git?branch=develop#5b9a3d71a325a9ecbad164aba90a7f6a8550a015" +source = "git+https://github.com/scroll-tech/halo2.git?branch=develop#8deec9924f598c85eb5ec1044199c78ef455c866" dependencies = [ "ark-std 0.3.0", "blake2b_simd", "cfg-if 0.1.10", "crossbeam", - "ff 0.12.1", - "group 0.12.1", - "halo2curves", + "ff 0.13.0", + "group 0.13.0", + "halo2curves 0.1.0", "log", "num-bigint", "num-integer", "plotters", - "poseidon", + "poseidon 0.2.0 (git+https://github.com/scroll-tech/poseidon.git?branch=main)", "rand_core", "rayon", "sha3 0.9.1", @@ -2443,6 +2472,51 @@ dependencies = [ "tracing", ] +[[package]] +name = "halo2_proofs" +version = "0.2.0" +source = "git+https://github.com/scroll-tech/halo2.git?branch=v1.0#04d8dc09bd4df542feccac85e34dff4b38a467d3" +dependencies = [ + "ark-std 0.3.0", + "blake2b_simd", + "cfg-if 0.1.10", + "crossbeam", + "ff 0.13.0", + "group 0.13.0", + "halo2curves 0.1.0", + "log", + "num-bigint", + "num-integer", + "poseidon 0.2.0 (git+https://github.com/scroll-tech/poseidon.git?branch=main)", + "rand_core", + "rayon", + "sha3 0.9.1", + "subtle", + "tracing", +] + +[[package]] +name = "halo2curves" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6b1142bd1059aacde1b477e0c80c142910f1ceae67fc619311d6a17428007ab" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "lazy_static", + "num-bigint", + "num-traits", + "pasta_curves 0.5.1", + "paste", + "rand", + "rand_core", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + [[package]] name = "halo2curves" version = "0.3.1" @@ -2453,7 +2527,7 @@ dependencies = [ "lazy_static", "num-bigint", "num-traits", - "pasta_curves", + "pasta_curves 0.4.1", "paste", "rand", "rand_core", @@ -2462,11 +2536,29 @@ dependencies = [ "subtle", ] +[[package]] +name = "halo2curves" +version = "0.3.2" +source = "git+https://github.com/privacy-scaling-explorations/halo2curves?tag=0.3.2#9f5c50810bbefe779ee5cf1d852b2fe85dc35d5e" +dependencies = [ + "ff 0.13.0", + "group 0.13.0", + "lazy_static", + "num-bigint", + "num-traits", + "pasta_curves 0.5.1", + "paste", + "rand", + "rand_core", + "static_assertions", + "subtle", +] + [[package]] name = "handlebars" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" +checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" dependencies = [ "log", "pest", @@ -2493,9 +2585,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "hashers" @@ -2523,9 +2615,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -2559,9 +2651,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -2614,7 +2706,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -2623,9 +2715,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -2637,16 +2729,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -2745,12 +2837,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.2", ] [[package]] @@ -2779,7 +2871,7 @@ dependencies = [ "env_logger", "eth-types", "ethers", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "hex", "lazy_static", "log", @@ -2799,9 +2891,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" @@ -2809,7 +2901,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "rustix", "windows-sys", ] @@ -2838,15 +2930,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" -[[package]] -name = "jobserver" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" -dependencies = [ - "libc", -] - [[package]] name = "jpeg-decoder" version = "0.3.0" @@ -2855,13 +2938,27 @@ checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +dependencies = [ + "base64 0.21.5", + "pem", + "ring 0.16.20", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "k256" version = "0.11.6" @@ -2883,7 +2980,7 @@ checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if 1.0.0", "ecdsa 0.16.8", - "elliptic-curve 0.13.5", + "elliptic-curve 0.13.6", "once_cell", "sha2", "signature 2.1.0", @@ -2904,7 +3001,7 @@ version = "0.1.0" dependencies = [ "env_logger", "eth-types", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "itertools 0.11.0", "lazy_static", "log", @@ -2917,9 +3014,9 @@ dependencies = [ [[package]] name = "lalrpop" -version = "0.19.12" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1cbf952127589f2851ab2046af368fd20645491bb4b376f04b7f94d7a9837b" +checksum = "da4081d44f4611b66c6dd725e6de3169f9f63905421e8626fcb86b6a898998b8" dependencies = [ "ascii-canvas", "bit-set", @@ -2930,7 +3027,7 @@ dependencies = [ "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.6.29", + "regex-syntax 0.7.5", "string_cache", "term", "tiny-keccak", @@ -2939,9 +3036,9 @@ dependencies = [ [[package]] name = "lalrpop-util" -version = "0.19.12" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3c48237b9604c5a4702de6b824e02006c3214327564636aef27c1028a8fa0ed" +checksum = "3f35c735096c0293d313e8f2a641627472b83d01b937177fe76e5e2708d31e0d" [[package]] name = "lazy_static" @@ -2949,20 +3046,20 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" dependencies = [ - "spin", + "spin 0.5.2", ] [[package]] name = "libc" -version = "0.2.147" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libloading" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d580318f95776505201b28cf98eb1fa5e4be3b689633ba6a3e6cd880ff22d8cb" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" dependencies = [ "cfg-if 1.0.0", "windows-sys", @@ -2970,9 +3067,20 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall", +] [[package]] name = "linked-hash-map" @@ -2982,15 +3090,15 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -3030,18 +3138,19 @@ dependencies = [ [[package]] name = "md-5" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ + "cfg-if 1.0.0", "digest 0.10.7", ] [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memoffset" @@ -3070,9 +3179,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi", @@ -3085,7 +3194,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/misc-precompiled-circuit.git?tag=v0.1.0#f647341f9951f5c2399035728d4f6765564e2e02" dependencies = [ "halo2-gate-generator", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "lazy_static", "num-bigint", "rand", @@ -3101,7 +3210,7 @@ name = "mock" version = "0.1.0" dependencies = [ "eth-types", - "ethers-core", + "ethers-core 2.0.7", "ethers-signers", "external-tracer", "itertools 0.11.0", @@ -3118,7 +3227,7 @@ dependencies = [ "env_logger", "eth-types", "halo2-mpt-circuits", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "hex", "lazy_static", "log", @@ -3205,9 +3314,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", "libm", @@ -3219,7 +3328,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.3", "libc", ] @@ -3241,6 +3350,15 @@ dependencies = [ "num_enum_derive 0.6.1", ] +[[package]] +name = "num_enum" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" +dependencies = [ + "num_enum_derive 0.7.1", +] + [[package]] name = "num_enum_derive" version = "0.5.11" @@ -3262,7 +3380,19 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", ] [[package]] @@ -3317,11 +3447,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "os_str_bytes" -version = "6.5.1" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "parity-scale-codec" @@ -3361,13 +3497,13 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.3.5", + "redox_syscall", "smallvec", "windows-targets", ] @@ -3398,6 +3534,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "pasta_curves" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "lazy_static", + "rand", + "static_assertions", + "subtle", +] + [[package]] name = "paste" version = "1.0.14" @@ -3422,11 +3573,11 @@ dependencies = [ [[package]] name = "pathfinder_simd" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39fe46acc5503595e5949c17b818714d26fdf9b4920eacf3b2947f0199f4a6ff" +checksum = "0444332826c70dc47be74a7c6a5fc44e23a7905ad6858d4162b658320455ef93" dependencies = [ - "rustc_version 0.3.3", + "rustc_version 0.4.0", ] [[package]] @@ -3451,6 +3602,15 @@ dependencies = [ "hmac", ] +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -3459,9 +3619,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.3" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ "memchr", "thiserror", @@ -3470,9 +3630,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.3" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" dependencies = [ "pest", "pest_generator", @@ -3480,22 +3640,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.3" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] name = "pest_meta" -version = "2.7.3" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" dependencies = [ "once_cell", "pest", @@ -3509,7 +3669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.0", + "indexmap 2.1.0", ] [[package]] @@ -3552,7 +3712,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] @@ -3590,7 +3750,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] @@ -3680,13 +3840,22 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "poseidon" +version = "0.2.0" +source = "git+https://github.com/scroll-tech/poseidon.git?branch=main#5787dd3d2ce7a9e9601a035c396ac0c03449b54d" +dependencies = [ + "halo2curves 0.1.0", + "subtle", +] + [[package]] name = "poseidon" version = "0.2.0" source = "git+https://github.com/scroll-tech/poseidon.git?branch=scroll-dev-0220#2fb4a2385bada39b50dce12fe50cb80d2fd33476" dependencies = [ "group 0.12.1", - "halo2curves", + "halo2curves 0.3.1", "subtle", ] @@ -3696,7 +3865,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=scroll-dev-0901#69524f42bdc55c581088c2fe64c2ab9a2921146b" dependencies = [ "bitvec", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "lazy_static", "log", "rand", @@ -3704,6 +3873,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -3733,7 +3908,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] @@ -3752,9 +3927,9 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", @@ -3771,7 +3946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", ] [[package]] @@ -3806,27 +3981,26 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "proptest" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e35c06b98bf36aba164cc17cb25f7e232f5c4aeea73baa14b8a9f0d92dbfa65" +checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ - "bitflags 1.3.2", - "byteorder", + "bitflags 2.4.1", "lazy_static", "num-traits", "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.6.29", + "regex-syntax 0.8.2", "unarray", ] @@ -3842,9 +4016,9 @@ dependencies = [ "chrono", "dotenvy", "eth-types", - "ethers-core", + "ethers-core 2.0.7", "git-version", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "hex", "itertools 0.11.0", "log", @@ -3929,9 +4103,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -3939,87 +4113,76 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall 0.2.16", + "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.9.5" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.5", + "regex-syntax 0.8.2", ] [[package]] name = "regex-syntax" -version = "0.6.29" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.20" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "encoding_rs", "futures-core", @@ -4041,6 +4204,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-rustls", "tower-service", @@ -4048,7 +4212,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.25.2", + "webpki-roots", "winreg", ] @@ -4151,12 +4315,26 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", + "spin 0.5.2", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -4190,9 +4368,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95294d6e3a6192f3aabf91c38f56505a625aa495533442744185a36d75a790c4" +checksum = "724fd11728a3804e9944b14cab63825024c40bf42f8af87c8b5d97c4bbacf426" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -4200,6 +4378,7 @@ dependencies = [ "bytes", "fastrlp", "num-bigint", + "num-traits", "parity-scale-codec", "primitive-types", "proptest", @@ -4250,16 +4429,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.18", + "semver 1.0.20", ] [[package]] name = "rustix" -version = "0.38.13" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", @@ -4268,43 +4447,33 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring", - "rustls-webpki 0.101.5", + "ring 0.17.5", + "rustls-webpki", "sct", ] [[package]] name = "rustls-pemfile" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" -dependencies = [ - "base64 0.21.4", -] - -[[package]] -name = "rustls-webpki" -version = "0.100.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "ring", - "untrusted", + "base64 0.21.5", ] [[package]] name = "rustls-webpki" -version = "0.101.5" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring", - "untrusted", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -4339,9 +4508,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "cfg-if 1.0.0", "derive_more", @@ -4351,9 +4520,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -4381,12 +4550,12 @@ dependencies = [ [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring", - "untrusted", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -4463,9 +4632,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" dependencies = [ "serde", ] @@ -4493,13 +4662,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + [[package]] name = "serde_cbor" version = "0.11.2" @@ -4512,20 +4690,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.106" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -4534,9 +4712,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -4587,9 +4765,9 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -4598,9 +4776,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -4655,6 +4833,18 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -4672,9 +4862,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "smol_str" @@ -4700,7 +4890,7 @@ dependencies = [ "num-bigint", "num-integer", "num-traits", - "poseidon", + "poseidon 0.2.0 (git+https://github.com/scroll-tech/poseidon.git?branch=scroll-dev-0220)", "rand", "revm", "rlp", @@ -4734,9 +4924,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -4744,9 +4934,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys", @@ -4754,11 +4944,11 @@ dependencies = [ [[package]] name = "solang-parser" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a94494913728908efa7a25a2dd2e4f037e714897985c24273c40596638ed909" +checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" dependencies = [ - "itertools 0.10.5", + "itertools 0.11.0", "lalrpop", "lalrpop-util", "phf", @@ -4772,6 +4962,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "spki" version = "0.7.2" @@ -4840,6 +5036,9 @@ name = "strum" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros 0.25.3", +] [[package]] name = "strum_macros" @@ -4864,7 +5063,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] @@ -4888,16 +5087,16 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "svm-rs" -version = "0.2.23" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a04fc4f5cd35c700153b233f5575ccb3237e0f941fa5049d9e98254d10bf2fe" +checksum = "20689c7d03b6461b502d0b95d6c24874c7d24dea2688af80486a130a06af3b07" dependencies = [ + "dirs", "fs2", "hex", - "home", "once_cell", "reqwest", - "semver 1.0.18", + "semver 1.0.20", "serde", "serde_json", "sha2", @@ -4919,15 +5118,36 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.32" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tabbycat" version = "0.1.2" @@ -4947,13 +5167,13 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if 1.0.0", "fastrand", - "redox_syscall 0.3.5", + "redox_syscall", "rustix", "windows-sys", ] @@ -4971,9 +5191,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] @@ -4988,11 +5208,11 @@ dependencies = [ "ctor", "env_logger", "eth-types", - "ethers-core", + "ethers-core 2.0.7", "ethers-signers", "external-tracer", "glob", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "handlebars", "hex", "itertools 0.11.0", @@ -5034,51 +5254,62 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.48" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] name = "thread-id" -version = "4.2.0" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79474f573561cdc4871a0de34a51c92f7f5a56039113fbb5b9c9f96bdb756669" +checksum = "f0ec81c46e9eb50deaa257be2f148adf052d1fb7701cfd55ccfab2525280b70b" dependencies = [ "libc", - "redox_syscall 0.2.16", "winapi", ] [[package]] name = "time" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ "deranged", + "itoa", + "powerfmt", "serde", "time-core", + "time-macros", ] [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +dependencies = [ + "time-core", +] [[package]] name = "tiny-keccak" @@ -5116,9 +5347,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -5126,20 +5357,20 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2 0.5.4", + "socket2 0.5.5", "tokio-macros", "windows-sys", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] @@ -5154,9 +5385,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.19.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec509ac96e9a0c43427c74f003127d953a265737636129424288d27cb5c4b12c" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", @@ -5164,14 +5395,14 @@ dependencies = [ "tokio", "tokio-rustls", "tungstenite", - "webpki-roots 0.23.1", + "webpki-roots", ] [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -5192,21 +5423,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.8" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.21.0", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -5217,7 +5448,18 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.1.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +dependencies = [ + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -5232,11 +5474,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -5244,20 +5485,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] @@ -5286,9 +5527,9 @@ checksum = "375812fa44dab6df41c195cd2f7fecb488f6c09fbaafb62807488cefab642bff" [[package]] name = "tungstenite" -version = "0.19.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15fba1a6d6bb030745759a9a2a588bfe8490fc8b4751a277db3a0be1c9ebbf67" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ "byteorder", "bytes", @@ -5302,14 +5543,13 @@ dependencies = [ "thiserror", "url", "utf-8", - "webpki", ] [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" @@ -5343,9 +5583,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -5358,9 +5598,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -5374,6 +5614,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.4.1" @@ -5446,9 +5692,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -5456,24 +5702,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -5483,9 +5729,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5493,52 +5739,33 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.2", -] - [[package]] name = "webpki-roots" version = "0.25.2" @@ -5569,9 +5796,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -5583,10 +5810,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets", ] @@ -5659,9 +5886,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" dependencies = [ "memchr", ] @@ -5740,6 +5967,26 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "zerocopy" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "zeroize" version = "1.6.0" @@ -5757,7 +6004,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.39", ] [[package]] @@ -5792,13 +6039,13 @@ dependencies = [ "either", "env_logger", "eth-types", - "ethers-core", + "ethers-core 2.0.7", "ethers-signers", "gadgets", "halo2-base", "halo2-ecc", "halo2_gadgets", - "halo2_proofs", + "halo2_proofs 0.2.0 (git+https://github.com/scroll-tech/halo2.git?branch=develop)", "hex", "itertools 0.11.0", "keccak256", @@ -5830,7 +6077,7 @@ dependencies = [ [[package]] name = "zktrie" version = "0.2.0" -source = "git+https://github.com/scroll-tech/zktrie.git?branch=v0.7#e5071cbd7097c7b65916654d581a510fff9d285c" +source = "git+https://github.com/scroll-tech/zktrie.git?branch=v0.7#a12f2f262ad3e82301e39ecdf9bfe235befc7074" dependencies = [ "gobuild", ] @@ -5856,11 +6103,15 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" +version = "2.0.9+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" dependencies = [ "cc", - "libc", "pkg-config", ] + +[[patch.unused]] +name = "ethers-etherscan" +version = "2.0.7" +source = "git+https://github.com/scroll-tech/ethers-rs.git?branch=v2.0.7#e32dfd62e7cdec31160b91c5a646883594a586ba" From 299be6dc409d6b7b349452ad6ee3a7ea4acb7be3 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 15:08:00 -0800 Subject: [PATCH 106/161] clip cargo lock --- Cargo_resolve.lock => Cargo.lock | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Cargo_resolve.lock => Cargo.lock (100%) diff --git a/Cargo_resolve.lock b/Cargo.lock similarity index 100% rename from Cargo_resolve.lock rename to Cargo.lock From 51943245b0f8f0c2652b598e03567db5d3bdb92e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 16:31:06 -0800 Subject: [PATCH 107/161] correct merge --- tx_circuit_l1_msg_tx | 352 ++++++++++++-------------- zkevm-circuits/src/tx_circuit/test.rs | 3 +- zkevm-circuits/src/witness/rlp_fsm.rs | 14 +- 3 files changed, 168 insertions(+), 201 deletions(-) diff --git a/tx_circuit_l1_msg_tx b/tx_circuit_l1_msg_tx index aaa559815f..b3bcea680a 100644 --- a/tx_circuit_l1_msg_tx +++ b/tx_circuit_l1_msg_tx @@ -1,422 +1,384 @@ - Blocking waiting for file lock on build directory Compiling zkevm-circuits v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/zkevm-circuits) -warning: unused imports: `mpt_circuit::MptCircuit`, `util::SubCircuit`, `witness::block_convert` - --> zkevm-circuits/src/evm_circuit/execution/callop.rs:1153:9 - | -1153 | mpt_circuit::MptCircuit, test_util::CircuitTestBuilder, util::SubCircuit, - | ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ -1154 | witness::block_convert, - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(unused_imports)]` on by default - -warning: unused import: `mock::BlockData` - --> zkevm-circuits/src/evm_circuit/execution/callop.rs:1156:62 - | -1156 | use bus_mapping::{circuit_input_builder::CircuitsParams, mock::BlockData}; - | ^^^^^^^^^^^^^^^ - -warning: unused import: `GethData` - --> zkevm-circuits/src/evm_circuit/execution/callop.rs:1160:31 - | -1160 | geth_types::{Account, GethData}, - | ^^^^^^^^ - -warning: unused imports: `dev::MockProver`, `halo2curves::bn256::Fr` - --> zkevm-circuits/src/evm_circuit/execution/callop.rs:1163:24 - | -1163 | use halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr}; - | ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ - Compiling integration-tests v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/integration-tests) Compiling aggregator v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/aggregator) - Compiling prover v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/prover) - Compiling circuit-benchmarks v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/circuit-benchmarks) Compiling testool v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/testool) -warning: variable does not need to be mutable - --> testool/src/statetest/executor.rs:560:13 - | -560 | let (_, mut trace_config, post) = into_traceconfig(st.clone()); - | ----^^^^^^^^^^^^ - | | - | help: remove this `mut` - | - = note: `#[warn(unused_mut)]` on by default - -warning: `testool` (bin "testool" test) generated 1 warning (run `cargo fix --bin "testool" --tests` to apply 1 suggestion) -warning: `zkevm-circuits` (lib test) generated 4 warnings (run `cargo fix --lib -p zkevm-circuits --tests` to apply 4 suggestions) - Finished test [unoptimized + debuginfo] target(s) in 54.70s - Running unittests src/lib.rs (target/debug/deps/aggregator-b8ca1009cd7be173) + Compiling circuit-benchmarks v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/circuit-benchmarks) + Compiling prover v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/prover) + Finished test [unoptimized + debuginfo] target(s) in 20.57s + Running unittests src/lib.rs (target/debug/deps/aggregator-e8b63b89b16abded) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/bus_mapping-be22080c86aded88) + Running unittests src/lib.rs (target/debug/deps/bus_mapping-9f5990d50441f09f) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 66 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/circuit_benchmarks-7a2a8e48926146f4) + Running unittests src/lib.rs (target/debug/deps/circuit_benchmarks-4c812cdb7d543074) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/eth_types-39dc8ee3cf4846e6) + Running unittests src/lib.rs (target/debug/deps/eth_types-eb574e315b0552b7) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 19 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/external_tracer-6f36029a05644959) + Running unittests src/lib.rs (target/debug/deps/external_tracer-ae661242e5abdc52) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/gadgets-d1febf07fa5bed2a) + Running unittests src/lib.rs (target/debug/deps/gadgets-00c2563f71ffbdc4) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 10 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/geth_utils-4759d6976c1ac707) + Running unittests src/lib.rs (target/debug/deps/geth_utils-996f6cbe833b634e) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/integration_tests-136bc6136abc225e) + Running unittests src/lib.rs (target/debug/deps/integration_tests-aea04512f7a9dcff) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running unittests src/bin/gen_blockchain_data.rs (target/debug/deps/gen_blockchain_data-259f9014d2198487) + Running unittests src/bin/gen_blockchain_data.rs (target/debug/deps/gen_blockchain_data-b91ad367da5a19b1) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running tests/circuit_input_builder.rs (target/debug/deps/circuit_input_builder-0b95a3d634ec7a80) + Running tests/circuit_input_builder.rs (target/debug/deps/circuit_input_builder-4c747264b93f3b0e) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running tests/circuits.rs (target/debug/deps/circuits-1a289e0d2b0edc87) + Running tests/circuits.rs (target/debug/deps/circuits-1c55db415717ddd2) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 80 filtered out; finished in 0.00s - Running tests/mainnet.rs (target/debug/deps/mainnet-f46ad174707ca7e4) + Running tests/mainnet.rs (target/debug/deps/mainnet-9120419924683559) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out; finished in 0.00s - Running tests/rpc.rs (target/debug/deps/rpc-030b30ceb12bd315) + Running tests/rpc.rs (target/debug/deps/rpc-c1ec81e2e4e9e5ad) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/keccak256-fb7849d1c3ab5b6f) + Running unittests src/lib.rs (target/debug/deps/keccak256-24246c5b10dcbeea) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/mock-a8b180075292ccc2) + Running unittests src/lib.rs (target/debug/deps/mock-5a1dc49cf482187c) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/mpt_zktrie-1cad4ab933ec3e66) + Running unittests src/lib.rs (target/debug/deps/mpt_zktrie-a8af5664cc7450ce) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 3 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/prover-ee0a88654eff2942) + Running unittests src/lib.rs (target/debug/deps/prover-9a62517258415202) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s - Running unittests src/main.rs (target/debug/deps/testool-0b06b9af4140306a) + Running unittests src/main.rs (target/debug/deps/testool-5a6f52fc32a95bf6) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 14 filtered out; finished in 0.00s - Running unittests src/lib.rs (target/debug/deps/zkevm_circuits-68f918ed565bb50a) + Running unittests src/lib.rs (target/debug/deps/zkevm_circuits-5d2aa0dfb773fa9e) running 1 test -[2023-12-05T00:46:49Z INFO zkevm_circuits::tx_circuit] TxCircuit::new(max_txs = 4, max_calldata = 400, chain_id = 1338) -[2023-12-05T00:46:49Z DEBUG zkevm_circuits::sig_circuit::utils] ecdsa chip uses 57 advice columns for 128 signatures -[2023-12-05T00:46:49Z DEBUG zkevm_circuits::sig_circuit::utils] ecdsa chip uses 8 lookup advice columns for 128 signatures -[2023-12-05T00:46:49Z INFO zkevm_circuits::sig_circuit] configuring ECDSA chip with multiple phases -[2023-12-05T00:46:49Z INFO zkevm_circuits::tx_circuit] after tx_circuit, meta.degree: 9 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 1) sign witness rows len = 0 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 1) tx hash witness rows len = 444 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 2) sign witness rows len = 29 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 2) tx hash witness rows len = 97 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 3) sign witness rows len = 29 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 3) tx hash witness rows len = 97 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 4) sign witness rows len = 29 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::witness::tx] tx (id: 4) tx hash witness rows len = 97 -[2023-12-05T00:46:56Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "RLP dev table" row_count: 73 -[2023-12-05T00:46:56Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "RLP dev table", idx 1 start 0 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] block_nums: {1} -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] num_all_txs: {1: 12} -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] [block_num: 1, num_txs: 1, cum_num_txs: 1] tx_id: 0, num_all_txs_acc: 12 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 1, num_all_txs_acc: 1 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 2, num_all_txs_acc: 2 -[2023-12-05T00:46:56Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 3, num_all_txs_acc: 3 -[2023-12-05T00:46:57Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "tx table aux" row_count: 513 -[2023-12-05T00:46:57Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "tx table aux", idx 3 start 0 -[2023-12-05T00:46:57Z DEBUG zkevm_circuits::tx_circuit] [block_num: 1, num_txs: 1, cum_num_txs: 1] tx_id: 0, num_all_txs_acc: 12 -[2023-12-05T00:46:57Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 1, num_all_txs_acc: 1 -[2023-12-05T00:46:57Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 2, num_all_txs_acc: 2 -[2023-12-05T00:46:57Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 3, num_all_txs_acc: 3 -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:41Z INFO zkevm_circuits::tx_circuit] TxCircuit::new(max_txs = 4, max_calldata = 400, chain_id = 1338) +[2023-12-07T00:28:41Z DEBUG zkevm_circuits::sig_circuit::utils] ecdsa chip uses 57 advice columns for 128 signatures +[2023-12-07T00:28:41Z DEBUG zkevm_circuits::sig_circuit::utils] ecdsa chip uses 8 lookup advice columns for 128 signatures +[2023-12-07T00:28:41Z INFO zkevm_circuits::sig_circuit] configuring ECDSA chip with multiple phases +[2023-12-07T00:28:41Z INFO zkevm_circuits::tx_circuit] after tx_circuit, meta.degree: 9 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 1) sign witness rows len = 0 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 1) tx hash witness rows len = 444 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 2) sign witness rows len = 29 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 2) tx hash witness rows len = 97 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 3) sign witness rows len = 29 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 3) tx hash witness rows len = 97 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 4) sign witness rows len = 29 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 4) tx hash witness rows len = 97 +[2023-12-07T00:28:51Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "RLP dev table" row_count: 73 +[2023-12-07T00:28:51Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "RLP dev table", idx 1 start 0 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] block_nums: {1} +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] num_all_txs: {1: 12} +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 1, num_txs: 1, cum_num_txs: 1] tx_id: 0, num_all_txs_acc: 12 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 1, num_all_txs_acc: 1 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 2, num_all_txs_acc: 2 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 3, num_all_txs_acc: 3 +[2023-12-07T00:28:51Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "tx table aux" row_count: 513 +[2023-12-07T00:28:51Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "tx table aux", idx 3 start 0 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 1, num_txs: 1, cum_num_txs: 1] tx_id: 0, num_all_txs_acc: 12 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 1, num_all_txs_acc: 1 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 2, num_all_txs_acc: 2 +[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 3, num_all_txs_acc: 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished data decomposition -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished data decomposition +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished data decomposition -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished data decomposition +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished data decomposition -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished data decomposition +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished data decomposition -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished data decomposition +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 1 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 2 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] limb 3 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } -[2023-12-05T00:47:12Z INFO zkevm_circuits::sig_circuit] before proceeding to the next phase +[2023-12-07T00:28:59Z INFO zkevm_circuits::sig_circuit] before proceeding to the next phase Context "ECDSA context" used 2 advice columns and 1844697 total advice cells in phase 0 Special lookup advice cells: optimal columns: 1, total 253104 cells used in phase 0. Fixed columns: 1, Total fixed cells: 8032 -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished sign verify -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished sign verify -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished sign verify -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished sign verify -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] keccak lookup -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] keccak lookup -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] keccak lookup -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] keccak lookup -[2023-12-05T00:47:12Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup -[2023-12-05T00:47:12Z INFO zkevm_circuits::sig_circuit] total number of lookup cells: 0 +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished sign verify +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished sign verify +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished sign verify +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished sign verify +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] keccak lookup +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] keccak lookup +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] keccak lookup +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] keccak lookup +[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup +[2023-12-07T00:28:59Z INFO zkevm_circuits::sig_circuit] total number of lookup cells: 0 Context "ECDSA context" used 2 advice columns and 1844697 total advice cells in phase 0 Special lookup advice cells: optimal columns: 1, total 253104 cells used in phase 0. Context "ECDSA context" used 1 advice columns and 2324 total advice cells in phase 1 Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 1. Fixed columns: 1, Total fixed cells: 8032 -[2023-12-05T00:47:12Z INFO halo2_proofs::dev] MockProver synthesize took 20.166517083s -[2023-12-05T00:47:17Z DEBUG halo2_proofs::dev] regions.len() = 9 +[2023-12-07T00:28:59Z INFO halo2_proofs::dev] MockProver synthesize took 11.163444334s +test tx_circuit::test::tx_circuit_l1_msg_tx has been running for over 60 seconds +[2023-12-07T00:29:44Z INFO halo2_proofs::dev] num of denominators: 3223 / 159383552 +[2023-12-07T00:30:34Z INFO halo2_proofs::dev] num of denominators: 0 / 13631488 +[2023-12-07T00:30:37Z DEBUG halo2_proofs::dev] regions.len() = 9 test tx_circuit::test::tx_circuit_l1_msg_tx ... ok -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 597 filtered out; finished in 44.04s +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 596 filtered out; finished in 131.65s diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index d9a267fbe5..2c50acf3dc 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -271,7 +271,8 @@ fn tx_circuit_1tx_2max_tx() { } #[test] -#[cfg(feature = "scroll")] +// tx1559_debug +// #[cfg(feature = "scroll")] fn tx_circuit_l1_msg_tx() { const MAX_TXS: usize = 4; const MAX_CALLDATA: usize = 400; diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index a712f7c24d..ce74c5ef6c 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -1,6 +1,10 @@ use eth_types::{Address, Field, H160, U256}; use gadgets::{impl_expr, util::Expr}; -use halo2_proofs::{circuit::Value, plonk::Expression}; +use halo2_proofs::{ + circuit::Value, + plonk::Expression, + halo2curves::ff::PrimeField, +}; use strum_macros::EnumIter; use crate::util::Challenges; @@ -775,7 +779,7 @@ pub enum StackOp { /// Using simulated stack constraints to make sure all bytes in nested structure are correctly /// decoded #[derive(Clone, Debug)] -pub struct RlpStackOp { +pub struct RlpStackOp { /// Key1 (Id), concat of tx_id, format pub id: Value, /// Key2 (Address), in this case depth @@ -793,15 +797,15 @@ pub struct RlpStackOp { pub stack_op: StackOp, } -impl RlpStackOp { +impl RlpStackOp { pub fn init(id: Value, value: usize) -> Self { Self { id, depth: 0, value, value_prev: 0, - stack_acc: Value::known(F::zero()), - stack_acc_pow_of_rand: Value::known(F::one()), + stack_acc: Value::known(F::ZERO), + stack_acc_pow_of_rand: Value::known(F::ONE), stack_op: StackOp::Init, } } From 27bbf4d5631263cbd5d0cdeb80be631e19a29369 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 16:47:53 -0800 Subject: [PATCH 108/161] debug commit --- zkevm-circuits/src/tx_circuit/test.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index 2c50acf3dc..a29a20d8db 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -187,7 +187,8 @@ fn run( } #[test] -#[cfg(feature = "scroll")] +// tx1559_debug +// #[cfg(feature = "scroll")] fn tx_circuit_1tx_2max_eip1559() { const MAX_TXS: usize = 2; const MAX_CALLDATA: usize = 3200; @@ -195,7 +196,7 @@ fn tx_circuit_1tx_2max_eip1559() { let tx = build_eip1559_tx(); assert_eq!( - run::(vec![tx], *mock::MOCK_CHAIN_ID, MAX_TXS, MAX_CALLDATA, 0), + run::(vec![tx], mock::MOCK_CHAIN_ID, MAX_TXS, MAX_CALLDATA, 0), Ok(()) ); } @@ -271,8 +272,7 @@ fn tx_circuit_1tx_2max_tx() { } #[test] -// tx1559_debug -// #[cfg(feature = "scroll")] +#[cfg(feature = "scroll")] fn tx_circuit_l1_msg_tx() { const MAX_TXS: usize = 4; const MAX_CALLDATA: usize = 400; From a0fb39d1f2f1360e79ba856dec78fa13a9c93dbd Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 16:56:05 -0800 Subject: [PATCH 109/161] uncomment test --- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index 186f36f8a5..06dc403291 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,8 +110,11 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ - // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", - // "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + // empty access list + "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", + // same as third test but with abridged access list + "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + // unabridged access list "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; From 3f3fec7c82def52972a310ca8456231148981c89 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 16:56:55 -0800 Subject: [PATCH 110/161] correct fn name --- eth-types/src/geth_types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth-types/src/geth_types.rs b/eth-types/src/geth_types.rs index 74c45e4933..3b04cf0a40 100644 --- a/eth-types/src/geth_types.rs +++ b/eth-types/src/geth_types.rs @@ -58,7 +58,7 @@ impl TxType { } /// If this type is EIP155 or not - pub fn is_eip155_tx(&self) -> bool { + pub fn is_eip155(&self) -> bool { matches!(*self, TxType::Eip155) } From 19f2b36b0425d3b6d120ac83dbe5ae0f0acb87af Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 16:57:10 -0800 Subject: [PATCH 111/161] remove output --- tx_circuit_l1_msg_tx | 384 ------------------------------------------- 1 file changed, 384 deletions(-) delete mode 100644 tx_circuit_l1_msg_tx diff --git a/tx_circuit_l1_msg_tx b/tx_circuit_l1_msg_tx deleted file mode 100644 index b3bcea680a..0000000000 --- a/tx_circuit_l1_msg_tx +++ /dev/null @@ -1,384 +0,0 @@ - Compiling zkevm-circuits v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/zkevm-circuits) - Compiling integration-tests v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/integration-tests) - Compiling aggregator v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/aggregator) - Compiling testool v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/testool) - Compiling circuit-benchmarks v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/circuit-benchmarks) - Compiling prover v0.1.0 (/Users/raymondgao/Desktop/zkevm-circuits-work/prover) - Finished test [unoptimized + debuginfo] target(s) in 20.57s - Running unittests src/lib.rs (target/debug/deps/aggregator-e8b63b89b16abded) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/bus_mapping-9f5990d50441f09f) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 66 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/circuit_benchmarks-4c812cdb7d543074) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/eth_types-eb574e315b0552b7) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 19 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/external_tracer-ae661242e5abdc52) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/gadgets-00c2563f71ffbdc4) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 10 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/geth_utils-996f6cbe833b634e) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/integration_tests-aea04512f7a9dcff) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - - Running unittests src/bin/gen_blockchain_data.rs (target/debug/deps/gen_blockchain_data-b91ad367da5a19b1) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - - Running tests/circuit_input_builder.rs (target/debug/deps/circuit_input_builder-4c747264b93f3b0e) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - - Running tests/circuits.rs (target/debug/deps/circuits-1c55db415717ddd2) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 80 filtered out; finished in 0.00s - - Running tests/mainnet.rs (target/debug/deps/mainnet-9120419924683559) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out; finished in 0.00s - - Running tests/rpc.rs (target/debug/deps/rpc-c1ec81e2e4e9e5ad) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/keccak256-24246c5b10dcbeea) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/mock-5a1dc49cf482187c) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/mpt_zktrie-a8af5664cc7450ce) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 3 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/prover-9a62517258415202) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s - - Running unittests src/main.rs (target/debug/deps/testool-5a6f52fc32a95bf6) - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 14 filtered out; finished in 0.00s - - Running unittests src/lib.rs (target/debug/deps/zkevm_circuits-5d2aa0dfb773fa9e) - -running 1 test -[2023-12-07T00:28:41Z INFO zkevm_circuits::tx_circuit] TxCircuit::new(max_txs = 4, max_calldata = 400, chain_id = 1338) -[2023-12-07T00:28:41Z DEBUG zkevm_circuits::sig_circuit::utils] ecdsa chip uses 57 advice columns for 128 signatures -[2023-12-07T00:28:41Z DEBUG zkevm_circuits::sig_circuit::utils] ecdsa chip uses 8 lookup advice columns for 128 signatures -[2023-12-07T00:28:41Z INFO zkevm_circuits::sig_circuit] configuring ECDSA chip with multiple phases -[2023-12-07T00:28:41Z INFO zkevm_circuits::tx_circuit] after tx_circuit, meta.degree: 9 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 1) sign witness rows len = 0 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 1) tx hash witness rows len = 444 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 2) sign witness rows len = 29 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 2) tx hash witness rows len = 97 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 3) sign witness rows len = 29 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 3) tx hash witness rows len = 97 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 4) sign witness rows len = 29 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::witness::tx] tx (id: 4) tx hash witness rows len = 97 -[2023-12-07T00:28:51Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "RLP dev table" row_count: 73 -[2023-12-07T00:28:51Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "RLP dev table", idx 1 start 0 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] block_nums: {1} -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] num_all_txs: {1: 12} -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 1, num_txs: 1, cum_num_txs: 1] tx_id: 0, num_all_txs_acc: 12 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 1, num_all_txs_acc: 1 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 2, num_all_txs_acc: 2 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 3, num_all_txs_acc: 3 -[2023-12-07T00:28:51Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "tx table aux" row_count: 513 -[2023-12-07T00:28:51Z DEBUG halo2_proofs::circuit::floor_planner::single_pass] region "tx table aux", idx 3 start 0 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 1, num_txs: 1, cum_num_txs: 1] tx_id: 0, num_all_txs_acc: 12 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 1, num_all_txs_acc: 1 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 2, num_all_txs_acc: 2 -[2023-12-07T00:28:51Z DEBUG zkevm_circuits::tx_circuit] [block_num: 0, num_txs: 0, cum_num_txs: 1] tx_id: 3, num_all_txs_acc: 3 -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } - reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } - reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished data decomposition -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } - reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } - reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished data decomposition -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } - reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } - reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished data decomposition -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash [Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c0) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000a6) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c4) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000024) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ac) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000071) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000057) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000ae) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000040) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000083) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000098) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000007e) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005f) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000045) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000052) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000009) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000001a) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000069) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000012) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005d) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000fc) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b7) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000b8) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000c2) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000065) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000090) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000029) }, Value { inner: Some(0x0000000000000000000000000000000000000000000000000000000000000039) }, Value { inner: Some(0x000000000000000000000000000000000000000000000000000000000000005b) }, Value { inner: Some(0x00000000000000000000000000000000000000000000000000000000000000df) }] -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] address: Value { inner: Some(0x0000000000000000000000007e5f4552091a69125d5dfcb7b8c2659029395bdf) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000007c7b0f7a860d79d1daccf7) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000eab6f7ed73ff0c7f59aaa8) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } - reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000514f67b68c9220ed3377) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000ce28d959f2815b16f81798) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000006295ce870b07029bfcdb2d) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000079be667ef9dcbbac55a0) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000008554199c47d08ffb10d4b8) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000fbfc0e1108a8fd17b448a6) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } - reconstructed Value { inner: Some(0x00000000000000000000000000000000000000000000483ada7726a3c4655da4) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished data decomposition -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000b5baf8b8454773f328df61) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000651a6f34baaf3dc29b396f) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000004faabf49beea23083894) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 1 - input Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000332be9809a444d541272c1) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 2 - input Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } - reconstructed Value { inner: Some(0x000000000000000000000000000000000000000000db7e75bafcb04ea141ca20) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] limb 3 - input Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } - reconstructed Value { inner: Some(0x0000000000000000000000000000000000000000000075ae2dd5e4e688c9dbc6) } -[2023-12-07T00:28:59Z INFO zkevm_circuits::sig_circuit] before proceeding to the next phase -Context "ECDSA context" used 2 advice columns and 1844697 total advice cells in phase 0 -Special lookup advice cells: optimal columns: 1, total 253104 cells used in phase 0. -Fixed columns: 1, Total fixed cells: 8032 -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished sign verify -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished sign verify -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished sign verify -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] evm challenge: Value { inner: Some(0x2cc67045d9924a297606aa509ddcf7235ee11f77683a7d127b4cb83d74c12519) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] assigned msg hash rlc: Value { inner: Some(0x03373ba14e2b334f51f08f631d5f34a89e123e671f6cd34945d053a5e8ffabab) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk rlc: Value { inner: Some(0x0be9c9544e6f4802ce10acdc91895953af1c1ac924051c3673a2f66448f17d06) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] pk hash rlc halo2ecc: Value { inner: Some(0x015fef9eb9ea60256d5350e4e4085a66639f8cd7d1b078a69c15be16224ba117) } -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished sign verify -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] keccak lookup -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] keccak lookup -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] keccak lookup -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] keccak lookup -[2023-12-07T00:28:59Z TRACE zkevm_circuits::sig_circuit] finished keccak lookup -[2023-12-07T00:28:59Z INFO zkevm_circuits::sig_circuit] total number of lookup cells: 0 -Context "ECDSA context" used 2 advice columns and 1844697 total advice cells in phase 0 -Special lookup advice cells: optimal columns: 1, total 253104 cells used in phase 0. -Context "ECDSA context" used 1 advice columns and 2324 total advice cells in phase 1 -Special lookup advice cells: optimal columns: 0, total 0 cells used in phase 1. -Fixed columns: 1, Total fixed cells: 8032 -[2023-12-07T00:28:59Z INFO halo2_proofs::dev] MockProver synthesize took 11.163444334s -test tx_circuit::test::tx_circuit_l1_msg_tx has been running for over 60 seconds -[2023-12-07T00:29:44Z INFO halo2_proofs::dev] num of denominators: 3223 / 159383552 -[2023-12-07T00:30:34Z INFO halo2_proofs::dev] num of denominators: 0 / 13631488 -[2023-12-07T00:30:37Z DEBUG halo2_proofs::dev] regions.len() = 9 -test tx_circuit::test::tx_circuit_l1_msg_tx ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 596 filtered out; finished in 131.65s - From 90473348df0998d257c42f94581fc6bdd76965f7 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 18:34:59 -0800 Subject: [PATCH 112/161] refactor assignment --- zkevm-circuits/src/table.rs | 62 +++++++++++++-------------- zkevm-circuits/src/tx_circuit/test.rs | 22 ++++++++-- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index b3d07043db..a9441c28e1 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -321,9 +321,8 @@ impl TxTable { // the tx calldata and access list. This is required to achieve a constant fixed // column tag regardless of the number of input txs or the // calldata/access list size of each tx. - let mut calldata_assignments: Vec<[Value; 5]> = Vec::new(); - let mut access_list_assignments: Vec<[Value; 5]> = Vec::new(); - // Assign Tx data (all tx fields except for calldata) + + // Assign Tx data (all tx fields except for calldata and access list) let padding_txs = (txs.len()..max_txs) .map(|tx_id| { let mut padding_tx = Transaction::dummy(chain_id); @@ -335,8 +334,6 @@ impl TxTable { for (i, tx) in txs.iter().chain(padding_txs.iter()).enumerate() { debug_assert_eq!(i + 1, tx.id); let tx_data = tx.table_assignments_fixed(*challenges); - let tx_calldata = tx.table_assignments_dyn(*challenges); - let tx_access_list = tx.table_assignments_access_list_dyn(*challenges); for row in tx_data { tx_value_cells.push(assign_row( &mut region, @@ -349,35 +346,36 @@ impl TxTable { )?); offset += 1; } - calldata_assignments.extend(tx_calldata.iter()); - access_list_assignments.extend(tx_access_list.iter()); - } - // Assign Tx calldata - for row in calldata_assignments.into_iter() { - assign_row( - &mut region, - offset, - self.q_enable, - &advice_columns, - &self.tag, - &row, - "", - )?; - offset += 1; } - // Assign Tx access_list - for row in access_list_assignments.into_iter() { - assign_row( - &mut region, - offset, - self.q_enable, - &advice_columns, - &self.tag, - &row, - "", - )?; - offset += 1; + + // Assign dynamic calldata and access list section + for (_, tx) in txs.iter().chain(padding_txs.iter()).enumerate() { + for row in tx.table_assignments_dyn(*challenges).into_iter() { + assign_row( + &mut region, + offset, + self.q_enable, + &advice_columns, + &self.tag, + &row, + "", + )?; + offset += 1; + } + for row in tx.table_assignments_access_list_dyn(*challenges).into_iter() { + assign_row( + &mut region, + offset, + self.q_enable, + &advice_columns, + &self.tag, + &row, + "", + )?; + offset += 1; + } } + Ok(tx_value_cells) }, ) diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index a29a20d8db..bcc2e66749 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -120,7 +120,7 @@ fn build_l1_msg_tx() -> Transaction { } #[cfg(test)] -fn build_eip1559_tx() -> Transaction { +fn build_eip1559_tx(id: usize) -> Transaction { let bytes = "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910"; let raw_tx_rlp_bytes = hex::decode(bytes).expect("decode tx's hex shall not fail"); @@ -136,7 +136,7 @@ fn build_eip1559_tx() -> Transaction { tx.hash = eth_tx.hash; tx.block_number = 1; - tx.id = 1; + tx.id = id; tx.chain_id = eth_tx.chain_id.unwrap_or(U256::zero()).as_u64(); tx.nonce = eth_tx.nonce.as_u64(); tx.value = eth_tx.value; @@ -193,7 +193,7 @@ fn tx_circuit_1tx_2max_eip1559() { const MAX_TXS: usize = 2; const MAX_CALLDATA: usize = 3200; - let tx = build_eip1559_tx(); + let tx = build_eip1559_tx(1); assert_eq!( run::(vec![tx], mock::MOCK_CHAIN_ID, MAX_TXS, MAX_CALLDATA, 0), @@ -201,6 +201,22 @@ fn tx_circuit_1tx_2max_eip1559() { ); } +#[test] +// tx1559_debug +// #[cfg(feature = "scroll")] +fn tx_circuit_2tx_2max_tx_eip1559() { + const MAX_TXS: usize = 2; + const MAX_CALLDATA: usize = 6400; + + let tx1 = build_eip1559_tx(1); + let tx2 = build_eip1559_tx(2); + + assert_eq!( + run::(vec![tx1, tx2], mock::MOCK_CHAIN_ID, MAX_TXS, MAX_CALLDATA, 0), + Ok(()) + ); +} + #[test] #[cfg(feature = "scroll")] fn tx_circuit_2tx_2max_tx() { From db8f395abf577355a2eae6b1053a8212171ec4f1 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 19:01:42 -0800 Subject: [PATCH 113/161] add lookup --- zkevm-circuits/src/tx_circuit.rs | 72 ++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 7 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 9e47daf49e..95cabd3ddf 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -99,6 +99,8 @@ enum LookupCondition { RlpHashTag, // lookup into keccak table Keccak, + // lookup into dynamic access list section of tx table + TxAccessList, } #[derive(Clone, Debug)] @@ -313,6 +315,7 @@ impl SubCircuitConfig for TxCircuitConfig { LookupCondition::RlpSignTag, LookupCondition::RlpHashTag, LookupCondition::Keccak, + LookupCondition::TxAccessList, ] .into_iter() .map(|condition| (condition, meta.advice_column())) @@ -760,6 +763,24 @@ impl SubCircuitConfig for TxCircuitConfig { cb.gate(meta.query_fixed(q_enable, Rotation::cur())) }); + meta.create_gate("lookup to access list dynamic section condition", |meta| { + let mut cb = BaseConstraintBuilder::default(); + + cb.require_equal( + "condition", + and::expr([ + is_access_list_addresses_len(meta), + not::expr(value_is_zero.expr(Rotation::cur())(meta)), + ]), + meta.query_advice( + lookup_conditions[&LookupCondition::TxAccessList], + Rotation::cur(), + ), + ); + + cb.gate(meta.query_fixed(q_enable, Rotation::cur())) + }); + meta.create_gate("sign tag lookup into RLP table condition", |meta| { let mut cb = BaseConstraintBuilder::default(); @@ -1860,7 +1881,6 @@ impl TxCircuitConfig { .map(|(input, table)| (input * enable.expr(), table)) .collect() }); - meta.lookup_any("lookup AccessListAddressLen in the TxTable", |meta| { let enable = and::expr([ meta.query_fixed(q_enable, Rotation::cur()), @@ -1885,7 +1905,6 @@ impl TxCircuitConfig { .map(|(input, table)| (input * enable.expr(), table)) .collect() }); - meta.lookup_any("lookup AccessListStorageKeysLen in the TxTable", |meta| { let enable = and::expr([ meta.query_fixed(q_enable, Rotation::cur()), @@ -1910,7 +1929,6 @@ impl TxCircuitConfig { .map(|(input, table)| (input * enable.expr(), table)) .collect() }); - meta.lookup_any("lookup AccessListRLC in the TxTable", |meta| { let enable = and::expr([ meta.query_fixed(q_enable, Rotation::cur()), @@ -1935,6 +1953,37 @@ impl TxCircuitConfig { .map(|(input, table)| (input * enable.expr(), table)) .collect() }); + meta.lookup_any("is_final access list row should be present", |meta| { + let enable = and::expr(vec![ + meta.query_fixed(q_enable, Rotation::cur()), + meta.query_advice( + lookup_conditions[&LookupCondition::TxAccessList], + Rotation::cur(), + ), + ]); + let input_exprs = vec![ + meta.query_advice(tx_table.tx_id, Rotation::cur()), + 1.expr(), + 1.expr(), + meta.query_advice(tx_table.value, Rotation(0)), // al_idx + meta.query_advice(tx_table.value, Rotation(1)), // sks_acc + meta.query_advice(tx_table.value, Rotation(2)), // section_rlc for access list + ]; + let table_exprs = vec![ + meta.query_advice(tx_table.tx_id, Rotation::cur()), + meta.query_advice(is_access_list, Rotation::cur()), + meta.query_advice(is_final, Rotation::cur()), + meta.query_advice(al_idx, Rotation::cur()), + meta.query_advice(sks_acc, Rotation::cur()), + meta.query_advice(section_rlc, Rotation::cur()), + ]; + + input_exprs + .into_iter() + .zip(table_exprs.into_iter()) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }); ///////////////////////////////////////////////////////////////// ///////////////// RLP table lookups ////////////////////// @@ -2663,7 +2712,16 @@ impl TxCircuitConfig { F::zero() } }); - // 2. lookup to RLP table for signing (non L1 msg) + // 2. lookup to ensure the final row in the access list dynamic section is present. + conditions.insert(LookupCondition::TxAccessList, { + let tag_enable = tx_tag == AccessListAddressesLen; + if tag_enable && tx.access_list.is_some() && tx.access_list.as_ref().unwrap().0.len() > 0 { + F::one() + } else { + F::zero() + } + }); + // 3. lookup to RLP table for signing (non L1 msg) conditions.insert(LookupCondition::RlpSignTag, { let sign_set = [ Nonce, @@ -2682,7 +2740,7 @@ impl TxCircuitConfig { && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); F::from((case1 || case2 || case3 || case4) as u64) }); - // 3. lookup to RLP table for hashing (non L1 msg) + // 4. lookup to RLP table for hashing (non L1 msg) conditions.insert(LookupCondition::RlpHashTag, { let hash_set = [ Nonce, @@ -2704,7 +2762,7 @@ impl TxCircuitConfig { && (tx_tag == MaxFeePerGas || tx_tag == MaxPriorityFeePerGas); F::from((case1 || case2 || case3) as u64) }); - // 4. lookup to RLP table for hashing (L1 msg) + // 5. lookup to RLP table for hashing (L1 msg) conditions.insert(LookupCondition::L1MsgHash, { let hash_set = [ Nonce, @@ -2720,7 +2778,7 @@ impl TxCircuitConfig { let is_tag_in_set = hash_set.into_iter().filter(|tag| tx_tag == *tag).count() == 1; F::from((is_l1_msg && is_tag_in_set) as u64) }); - // 5. lookup to Keccak table for tx_sign_hash and tx_hash + // 6. lookup to Keccak table for tx_sign_hash and tx_hash conditions.insert(LookupCondition::Keccak, { let case1 = (tx_tag == TxSignLength) && !is_l1_msg; let case2 = tx_tag == TxHashLength; From d63851e595085cc2b846e94d38ce530c50169c9a Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 19:03:49 -0800 Subject: [PATCH 114/161] fmt --- zkevm-circuits/src/table.rs | 7 +++++-- zkevm-circuits/src/tx_circuit.rs | 5 ++++- zkevm-circuits/src/tx_circuit/test.rs | 8 +++++++- zkevm-circuits/src/witness/rlp_fsm.rs | 6 +----- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index a9441c28e1..77b79d3d4d 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -362,7 +362,10 @@ impl TxTable { )?; offset += 1; } - for row in tx.table_assignments_access_list_dyn(*challenges).into_iter() { + for row in tx + .table_assignments_access_list_dyn(*challenges) + .into_iter() + { assign_row( &mut region, offset, @@ -375,7 +378,7 @@ impl TxTable { offset += 1; } } - + Ok(tx_value_cells) }, ) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 95cabd3ddf..c88a21f831 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -2715,7 +2715,10 @@ impl TxCircuitConfig { // 2. lookup to ensure the final row in the access list dynamic section is present. conditions.insert(LookupCondition::TxAccessList, { let tag_enable = tx_tag == AccessListAddressesLen; - if tag_enable && tx.access_list.is_some() && tx.access_list.as_ref().unwrap().0.len() > 0 { + if tag_enable + && tx.access_list.is_some() + && tx.access_list.as_ref().unwrap().0.len() > 0 + { F::one() } else { F::zero() diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index bcc2e66749..52a444c815 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -212,7 +212,13 @@ fn tx_circuit_2tx_2max_tx_eip1559() { let tx2 = build_eip1559_tx(2); assert_eq!( - run::(vec![tx1, tx2], mock::MOCK_CHAIN_ID, MAX_TXS, MAX_CALLDATA, 0), + run::( + vec![tx1, tx2], + mock::MOCK_CHAIN_ID, + MAX_TXS, + MAX_CALLDATA, + 0 + ), Ok(()) ); } diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index ce74c5ef6c..f5897b1235 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -1,10 +1,6 @@ use eth_types::{Address, Field, H160, U256}; use gadgets::{impl_expr, util::Expr}; -use halo2_proofs::{ - circuit::Value, - plonk::Expression, - halo2curves::ff::PrimeField, -}; +use halo2_proofs::{circuit::Value, halo2curves::ff::PrimeField, plonk::Expression}; use strum_macros::EnumIter; use crate::util::Challenges; From 7d86f022190c2b64f77db9fc8f556e73de71d503 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 19:07:01 -0800 Subject: [PATCH 115/161] fmt --- zkevm-circuits/src/table.rs | 2 +- zkevm-circuits/src/tx_circuit.rs | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 77b79d3d4d..f3a8c51303 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -349,7 +349,7 @@ impl TxTable { } // Assign dynamic calldata and access list section - for (_, tx) in txs.iter().chain(padding_txs.iter()).enumerate() { + for tx in txs.iter().chain(padding_txs.iter()) { for row in tx.table_assignments_dyn(*challenges).into_iter() { assign_row( &mut region, diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index c88a21f831..cefee440a0 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -1877,7 +1877,7 @@ impl TxCircuitConfig { input_exprs .into_iter() - .zip(table_exprs.into_iter()) + .zip(table_exprs) .map(|(input, table)| (input * enable.expr(), table)) .collect() }); @@ -1901,7 +1901,7 @@ impl TxCircuitConfig { input_exprs .into_iter() - .zip(table_exprs.into_iter()) + .zip(table_exprs) .map(|(input, table)| (input * enable.expr(), table)) .collect() }); @@ -1925,7 +1925,7 @@ impl TxCircuitConfig { input_exprs .into_iter() - .zip(table_exprs.into_iter()) + .zip(table_exprs) .map(|(input, table)| (input * enable.expr(), table)) .collect() }); @@ -1980,7 +1980,7 @@ impl TxCircuitConfig { input_exprs .into_iter() - .zip(table_exprs.into_iter()) + .zip(table_exprs) .map(|(input, table)| (input * enable.expr(), table)) .collect() }); @@ -2130,7 +2130,7 @@ impl TxCircuitConfig { meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx ] .into_iter() - .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .zip_eq(rlp_table.table_exprs(meta)) .map(|(arg, table)| (enable.clone() * arg, table)) .collect() }, @@ -2163,7 +2163,7 @@ impl TxCircuitConfig { meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx ] .into_iter() - .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .zip_eq(rlp_table.table_exprs(meta)) .map(|(arg, table)| (enable.clone() * arg, table)) .collect() }, @@ -2199,7 +2199,7 @@ impl TxCircuitConfig { meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx ] .into_iter() - .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .zip_eq(rlp_table.table_exprs(meta)) .map(|(arg, table)| (enable.clone() * arg, table)) .collect() }, @@ -2232,7 +2232,7 @@ impl TxCircuitConfig { meta.query_advice(sk_idx, Rotation::cur()), // storage_key_idx ] .into_iter() - .zip_eq(rlp_table.table_exprs(meta).into_iter()) + .zip_eq(rlp_table.table_exprs(meta)) .map(|(arg, table)| (enable.clone() * arg, table)) .collect() }, @@ -2717,7 +2717,7 @@ impl TxCircuitConfig { let tag_enable = tx_tag == AccessListAddressesLen; if tag_enable && tx.access_list.is_some() - && tx.access_list.as_ref().unwrap().0.len() > 0 + && !tx.access_list.as_ref().unwrap().0.is_empty() { F::one() } else { @@ -2916,8 +2916,8 @@ impl TxCircuitConfig { // initialize access list section rlc let mut section_rlc = challenges.keccak_input().map(|_| F::zero()); // depending on prev row, the accumulator advances by different magnitude - let r20 = challenges.keccak_input().map(|f| f.pow(&[20, 0, 0, 0])); - let r32 = challenges.keccak_input().map(|f| f.pow(&[32, 0, 0, 0])); + let r20 = challenges.keccak_input().map(|f| f.pow([20, 0, 0, 0])); + let r32 = challenges.keccak_input().map(|f| f.pow([32, 0, 0, 0])); for (al_idx, al) in tx.access_list.as_ref().unwrap().0.iter().enumerate() { curr_row += 1; @@ -3724,8 +3724,8 @@ pub fn access_list_rlc( ) -> Value { if access_list.is_some() { let mut section_rlc = challenges.keccak_input().map(|_| F::zero()); - let r20 = challenges.keccak_input().map(|f| f.pow(&[20, 0, 0, 0])); - let r32 = challenges.keccak_input().map(|f| f.pow(&[32, 0, 0, 0])); + let r20 = challenges.keccak_input().map(|f| f.pow([20, 0, 0, 0])); + let r32 = challenges.keccak_input().map(|f| f.pow([32, 0, 0, 0])); for al in access_list.as_ref().unwrap().0.iter() { let field_rlc = rlc_be_bytes(&al.address.to_fixed_bytes(), challenges.keccak_input()); From 3fc94691d9e5f2e22a665f7000d993ee0058b8b7 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Wed, 6 Dec 2023 19:07:45 -0800 Subject: [PATCH 116/161] restore test --- zkevm-circuits/src/tx_circuit/test.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit/test.rs b/zkevm-circuits/src/tx_circuit/test.rs index 52a444c815..1e25dcbee8 100644 --- a/zkevm-circuits/src/tx_circuit/test.rs +++ b/zkevm-circuits/src/tx_circuit/test.rs @@ -187,8 +187,7 @@ fn run( } #[test] -// tx1559_debug -// #[cfg(feature = "scroll")] +#[cfg(feature = "scroll")] fn tx_circuit_1tx_2max_eip1559() { const MAX_TXS: usize = 2; const MAX_CALLDATA: usize = 3200; @@ -202,8 +201,7 @@ fn tx_circuit_1tx_2max_eip1559() { } #[test] -// tx1559_debug -// #[cfg(feature = "scroll")] +#[cfg(feature = "scroll")] fn tx_circuit_2tx_2max_tx_eip1559() { const MAX_TXS: usize = 2; const MAX_CALLDATA: usize = 6400; From 4333c03556cb9f18535adde5f893620feede3f36 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 11 Dec 2023 19:05:21 -0800 Subject: [PATCH 117/161] remove duplicate --- zkevm-circuits/src/table.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index de201b723c..98aadcff1e 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -190,10 +190,6 @@ pub enum TxFieldTag { MaxPriorityFeePerGas, /// Max Fee Per Gas (EIP1559) MaxFeePerGas, - /// AccessListAddress, - AccessListAddress, - /// AccessListStorageKey - AccessListStorageKey, } impl_expr!(TxFieldTag); From 0aa9f67bebd17ead1d2fc06118e14901262f7cba Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Mon, 11 Dec 2023 19:25:09 +0800 Subject: [PATCH 118/161] Add balance check for gas fee (EIP-1559). --- eth-types/src/geth_types.rs | 5 + .../src/evm_circuit/execution/begin_tx.rs | 28 +++- zkevm-circuits/src/evm_circuit/param.rs | 2 +- .../src/evm_circuit/util/common_gadget.rs | 23 +++ .../util/common_gadget/tx_eip1559.rs | 152 ++++++++++++++++++ .../util/common_gadget/tx_l1_fee.rs | 18 ++- zkevm-circuits/src/table.rs | 4 + zkevm-circuits/src/tx_circuit.rs | 36 ++++- zkevm-circuits/src/witness/tx.rs | 32 ++++ 9 files changed, 287 insertions(+), 13 deletions(-) create mode 100644 zkevm-circuits/src/evm_circuit/util/common_gadget/tx_eip1559.rs diff --git a/eth-types/src/geth_types.rs b/eth-types/src/geth_types.rs index 9a6bc09272..46178c2628 100644 --- a/eth-types/src/geth_types.rs +++ b/eth-types/src/geth_types.rs @@ -57,6 +57,11 @@ impl TxType { matches!(*self, Self::Eip155) } + /// If this type is EIP-1559 or not + pub fn is_eip1559_tx(&self) -> bool { + matches!(*self, Self::Eip1559) + } + /// If this type is EIP-2930 or not pub fn is_eip2930_tx(&self) -> bool { matches!(*self, Self::Eip2930) diff --git a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs index 58a21c0ff9..a9b365d75c 100644 --- a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs +++ b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs @@ -6,8 +6,8 @@ use crate::{ util::{ and, common_gadget::{ - TransferGadgetInfo, TransferWithGasFeeGadget, TxEip2930Gadget, TxL1FeeGadget, - TxL1MsgGadget, + TransferGadgetInfo, TransferWithGasFeeGadget, TxEip1559Gadget, TxEip2930Gadget, + TxL1FeeGadget, TxL1MsgGadget, }, constraint_builder::{ ConstrainBuilderCommon, EVMConstraintBuilder, ReversionInfo, StepStateTransition, @@ -92,6 +92,7 @@ pub(crate) struct BeginTxGadget { is_coinbase_warm: Cell, tx_l1_fee: TxL1FeeGadget, tx_l1_msg: TxL1MsgGadget, + tx_eip1559: TxEip1559Gadget, tx_eip2930: TxEip2930Gadget, } @@ -350,6 +351,17 @@ impl ExecutionGadget for BeginTxGadget { &mut reversion_info, ); + // Construct EIP-1559 gadget to check sender balance. + let tx_eip1559 = TxEip1559Gadget::construct( + cb, + tx_id.expr(), + tx_type.expr(), + tx_gas.expr(), + tx_l1_fee.tx_l1_fee_word(), + &tx_value, + transfer_with_gas_fee.sender_balance_prev(), + ); + let caller_nonce_hash_bytes = array_init::array_init(|_| cb.query_byte()); let create = ContractCreateGadget::construct(cb); cb.require_equal( @@ -719,6 +731,7 @@ impl ExecutionGadget for BeginTxGadget { is_coinbase_warm, tx_l1_fee, tx_l1_msg, + tx_eip1559, tx_eip2930, } } @@ -1057,6 +1070,17 @@ impl ExecutionGadget for BeginTxGadget { tx.tx_data_gas_cost, )?; + self.tx_eip1559.assign( + region, + offset, + tx, + tx_l1_fee, + transfer_assign_result + .sender_balance_sub_fee_pair + .unwrap() + .1, + )?; + self.tx_eip2930.assign(region, offset, tx) } } diff --git a/zkevm-circuits/src/evm_circuit/param.rs b/zkevm-circuits/src/evm_circuit/param.rs index 4acd41c538..620a3c66af 100644 --- a/zkevm-circuits/src/evm_circuit/param.rs +++ b/zkevm-circuits/src/evm_circuit/param.rs @@ -27,7 +27,7 @@ pub(crate) const N_COPY_COLUMNS: usize = 2; // Number of copy columns for phase2 pub(crate) const N_PHASE2_COPY_COLUMNS: usize = 1; -pub(crate) const N_BYTE_LOOKUPS: usize = 26; +pub(crate) const N_BYTE_LOOKUPS: usize = 36; /// Amount of lookup columns in the EVM circuit dedicated to lookups. pub(crate) const EVM_LOOKUP_COLS: usize = FIXED_TABLE_LOOKUPS diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget.rs index d7ac141f8a..b25658fffd 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget.rs @@ -31,10 +31,12 @@ use halo2_proofs::{ plonk::{Error, Expression}, }; +mod tx_eip1559; mod tx_eip2930; mod tx_l1_fee; mod tx_l1_msg; +pub(crate) use tx_eip1559::TxEip1559Gadget; pub(crate) use tx_eip2930::TxEip2930Gadget; pub(crate) use tx_l1_fee::TxL1FeeGadget; pub(crate) use tx_l1_msg::TxL1MsgGadget; @@ -591,6 +593,11 @@ impl TransferFromWithGasFeeGadget { value: U256, gas_fee: U256, ) -> Result<(), Error> { + assert!( + sender_balance_sub_fee >= prev_sender_balance_sub_value, + "fee must be subtracted before value" + ); + if let Either::Left(value_is_zero) = &self.value_is_zero { value_is_zero.assign_value(region, offset, region.word_rlc(value))?; } @@ -609,6 +616,12 @@ impl TransferFromWithGasFeeGadget { sender_balance_sub_value, ) } + + /// Return sender balance before subtracting fee and value. + pub(crate) fn sender_balance_prev(&self) -> &Word { + // Fee is subtracted before value. + self.sender_sub_fee.balance_prev() + } } impl TransferFromAssign for TransferFromWithGasFeeGadget { @@ -626,6 +639,11 @@ impl TransferFromAssign for TransferFromWithGasFeeGadget { } else { (0.into(), 0.into()) }; + assert!( + sender_balance_sub_fee_pair.0 >= sender_balance_sub_value_pair.1, + "fee must be subtracted before value" + ); + self.assign( region, offset, @@ -923,6 +941,11 @@ impl TransferWithGasFeeGadget { to, } } + + /// Return sender balance before subtracting fee and value. + pub(crate) fn sender_balance_prev(&self) -> &Word { + self.from.sender_balance_prev() + } } impl TransferGadget { diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_eip1559.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_eip1559.rs new file mode 100644 index 0000000000..9db70275c9 --- /dev/null +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_eip1559.rs @@ -0,0 +1,152 @@ +//! TxEip1559Gadget is used to check sender balance before fee and value +//! transfer for EIP-1559 transactions. +//! Reference the geth code as: +//! +//! + +use super::CachedRegion; +use crate::{ + evm_circuit::{ + util::{ + constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, + math_gadget::{AddWordsGadget, IsEqualGadget, LtWordGadget, MulWordByU64Gadget}, + or, Expr, Word, + }, + witness::Transaction, + }, + table::TxFieldTag, +}; +use eth_types::{geth_types::TxType, Field, ToLittleEndian, U256}; +use halo2_proofs::plonk::{Error, Expression}; + +/// Transaction EIP-1559 gadget to check sender balance before transfer +#[derive(Clone, Debug)] +pub(crate) struct TxEip1559Gadget { + is_eip1559_tx: IsEqualGadget, + // MaxFeePerGas + gas_fee_cap: Word, + // MaxPriorityFeePerGas + gas_tip_cap: Word, + mul_gas_fee_cap_by_gas: MulWordByU64Gadget, + balance_check: AddWordsGadget, + // Error condition + // + is_insufficient_balance: LtWordGadget, + // Error condition + // + gas_fee_cap_lt_gas_tip_cap: LtWordGadget, +} + +impl TxEip1559Gadget { + pub(crate) fn construct( + cb: &mut EVMConstraintBuilder, + tx_id: Expression, + tx_type: Expression, + tx_gas: Expression, + tx_l1_fee: &Word, + value: &Word, + sender_balance: &Word, + ) -> Self { + let is_eip1559_tx = IsEqualGadget::construct(cb, tx_type, (TxType::Eip1559 as u64).expr()); + + let [gas_fee_cap, gas_tip_cap] = + [TxFieldTag::MaxFeePerGas, TxFieldTag::MaxPriorityFeePerGas] + .map(|field_tag| cb.tx_context_as_word(tx_id.expr(), field_tag, None)); + + let ( + mul_gas_fee_cap_by_gas, + balance_check, + is_insufficient_balance, + gas_fee_cap_lt_gas_tip_cap, + ) = cb.condition(is_eip1559_tx.expr(), |cb| { + let mul_gas_fee_cap_by_gas = + MulWordByU64Gadget::construct(cb, gas_fee_cap.clone(), tx_gas); + + let min_balance = cb.query_word_rlc(); + let balance_check = AddWordsGadget::construct( + cb, + [ + mul_gas_fee_cap_by_gas.product().clone(), + value.clone(), + tx_l1_fee.clone(), + ], + min_balance.clone(), + ); + + let is_insufficient_balance = LtWordGadget::construct(cb, sender_balance, &min_balance); + let gas_fee_cap_lt_gas_tip_cap = + LtWordGadget::construct(cb, &gas_fee_cap, &gas_tip_cap); + + cb.require_zero( + "Sender balance must be sufficient, and gas_fee_cap >= gas_tip_cap", + or::expr([ + is_insufficient_balance.expr(), + gas_fee_cap_lt_gas_tip_cap.expr(), + ]), + ); + + ( + mul_gas_fee_cap_by_gas, + balance_check, + is_insufficient_balance, + gas_fee_cap_lt_gas_tip_cap, + ) + }); + + Self { + is_eip1559_tx, + gas_fee_cap, + gas_tip_cap, + mul_gas_fee_cap_by_gas, + balance_check, + is_insufficient_balance, + gas_fee_cap_lt_gas_tip_cap, + } + } + + pub(crate) fn assign( + &self, + region: &mut CachedRegion<'_, '_, F>, + offset: usize, + tx: &Transaction, + tx_l1_fee: U256, + sender_balance_prev: U256, + ) -> Result<(), Error> { + self.is_eip1559_tx.assign( + region, + offset, + F::from(tx.tx_type as u64), + F::from(TxType::Eip1559 as u64), + )?; + self.gas_fee_cap + .assign(region, offset, Some(tx.max_fee_per_gas.to_le_bytes()))?; + self.gas_tip_cap.assign( + region, + offset, + Some(tx.max_priority_fee_per_gas.to_le_bytes()), + )?; + let mul_gas_fee_cap_by_gas = tx.max_fee_per_gas * tx.gas; + self.mul_gas_fee_cap_by_gas.assign( + region, + offset, + tx.max_fee_per_gas, + tx.gas, + mul_gas_fee_cap_by_gas, + )?; + let min_balance = mul_gas_fee_cap_by_gas + tx.value + tx_l1_fee; + self.balance_check.assign( + region, + offset, + [mul_gas_fee_cap_by_gas, tx.value, tx_l1_fee], + min_balance, + )?; + self.is_insufficient_balance + .assign(region, offset, sender_balance_prev, min_balance)?; + self.gas_fee_cap_lt_gas_tip_cap.assign( + region, + offset, + tx.max_fee_per_gas, + tx.max_priority_fee_per_gas, + ) + } +} diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs index 2532514a06..1d6d4f92dd 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs @@ -4,7 +4,7 @@ use crate::{ param::N_BYTES_U64, util::{ constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, - from_bytes, U64Word, + from_bytes, U64Word, Word, }, }, util::Expr, @@ -13,14 +13,14 @@ use bus_mapping::{ circuit_input_builder::{TxL1Fee, TX_L1_COMMIT_EXTRA_COST, TX_L1_FEE_PRECISION}, l2_predeployed::l1_gas_price_oracle, }; -use eth_types::{Field, ToLittleEndian, ToScalar}; +use eth_types::{Field, ToLittleEndian, ToScalar, U256}; use halo2_proofs::plonk::{Error, Expression}; /// Transaction L1 fee gadget for L1GasPriceOracle contract #[derive(Clone, Debug)] pub(crate) struct TxL1FeeGadget { /// Calculated L1 fee of transaction - tx_l1_fee_word: U64Word, + tx_l1_fee_word: Word, /// Remainder when calculating L1 fee remainder_word: U64Word, /// Current value of L1 base fee @@ -96,7 +96,7 @@ impl TxL1FeeGadget { ) -> Result<(), Error> { let (tx_l1_fee, remainder) = l1_fee.tx_l1_fee(tx_data_gas_cost); self.tx_l1_fee_word - .assign(region, offset, Some(tx_l1_fee.to_le_bytes()))?; + .assign(region, offset, Some(U256::from(tx_l1_fee).to_le_bytes()))?; self.remainder_word .assign(region, offset, Some(remainder.to_le_bytes()))?; self.base_fee_word @@ -132,7 +132,11 @@ impl TxL1FeeGadget { } pub(crate) fn tx_l1_fee(&self) -> Expression { - from_bytes::expr(&self.tx_l1_fee_word.cells) + from_bytes::expr(&self.tx_l1_fee_word.cells[..N_BYTES_U64]) + } + + pub(crate) fn tx_l1_fee_word(&self) -> &Word { + &self.tx_l1_fee_word } fn raw_construct(cb: &mut EVMConstraintBuilder, tx_data_gas_cost: Expression) -> Self { @@ -143,8 +147,8 @@ impl TxL1FeeGadget { let fee_overhead_word = cb.query_word_rlc(); let fee_scalar_word = cb.query_word_rlc(); - let [tx_l1_fee, remainder, base_fee, fee_overhead, fee_scalar] = [ - &tx_l1_fee_word, + let tx_l1_fee = from_bytes::expr(&tx_l1_fee_word.cells[..N_BYTES_U64]); + let [remainder, base_fee, fee_overhead, fee_scalar] = [ &remainder_word, &base_fee_word, &fee_overhead_word, diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 42c1a3fb30..b45c73773b 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -184,6 +184,10 @@ pub enum TxFieldTag { AccessListStorageKeysLen, /// RLC of access list (EIP-2930) AccessListRLC, + /// Max Priority Fee Per Gas (EIP1559) + MaxPriorityFeePerGas, + /// Max Fee Per Gas (EIP1559) + MaxFeePerGas, /// The block number in which this tx is included. BlockNumber, } diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index bd886e5c5c..9ea6ae4057 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -21,8 +21,8 @@ use crate::{ TxFieldTag::{ AccessListAddressesLen, AccessListRLC, AccessListStorageKeysLen, BlockNumber, CallData, CallDataGasCost, CallDataLength, CallDataRLC, CalleeAddress, CallerAddress, ChainID, - Gas, GasPrice, IsCreate, Nonce, SigR, SigS, SigV, TxDataGasCost, TxHashLength, - TxHashRLC, TxSignHash, TxSignLength, TxSignRLC, + Gas, GasPrice, IsCreate, MaxFeePerGas, MaxPriorityFeePerGas, Nonce, SigR, SigS, SigV, + TxDataGasCost, TxHashLength, TxHashRLC, TxSignHash, TxSignLength, TxSignRLC, }, TxTable, U16Table, U8Table, }, @@ -80,7 +80,7 @@ use halo2_proofs::plonk::SecondPhase; use itertools::Itertools; /// Number of rows of one tx occupies in the fixed part of tx table -pub const TX_LEN: usize = 26; +pub const TX_LEN: usize = 28; /// Offset of TxHash tag in the tx table pub const TX_HASH_OFFSET: usize = 21; /// Offset of ChainID tag in the tx table @@ -349,6 +349,8 @@ impl SubCircuitConfig for TxCircuitConfig { is_tx_tag!(is_access_list_addresses_len, AccessListAddressesLen); is_tx_tag!(is_access_list_storage_keys_len, AccessListStorageKeysLen); is_tx_tag!(is_access_list_rlc, AccessListRLC); + is_tx_tag!(is_max_fee_per_gas, MaxFeePerGas); + is_tx_tag!(is_max_priority_fee_per_gas, MaxPriorityFeePerGas); let tx_id_unchanged = IsEqualChip::configure( meta, @@ -479,6 +481,11 @@ impl SubCircuitConfig for TxCircuitConfig { (is_access_list_addresses_len(meta), Null), (is_access_list_storage_keys_len(meta), Null), (is_access_list_rlc(meta), RLC), + (is_max_fee_per_gas(meta), Tag::MaxFeePerGas.into()), + ( + is_max_priority_fee_per_gas(meta), + Tag::MaxPriorityFeePerGas.into(), + ), ]; cb.require_boolean( @@ -1965,6 +1972,29 @@ impl TxCircuitConfig { keccak_input, ), ), + ( + MaxPriorityFeePerGas, + Some(RlpTableInputValue { + tag: Tag::MaxPriorityFeePerGas.into(), + is_none: tx.max_priority_fee_per_gas.is_zero(), + be_bytes_len: tx.max_priority_fee_per_gas.tag_length(), + be_bytes_rlc: rlc_be_bytes( + &tx.max_priority_fee_per_gas.to_be_bytes(), + keccak_input, + ), + }), + rlc_be_bytes(&tx.max_priority_fee_per_gas.to_be_bytes(), evm_word), + ), + ( + MaxFeePerGas, + Some(RlpTableInputValue { + tag: Tag::MaxFeePerGas.into(), + is_none: tx.max_fee_per_gas.is_zero(), + be_bytes_len: tx.max_fee_per_gas.tag_length(), + be_bytes_rlc: rlc_be_bytes(&tx.max_fee_per_gas.to_be_bytes(), keccak_input), + }), + rlc_be_bytes(&tx.max_fee_per_gas.to_be_bytes(), evm_word), + ), (BlockNumber, None, Value::known(F::from(tx.block_number))), ]; diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 5680194c1b..d9b8bbc461 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -57,6 +57,10 @@ pub struct Transaction { pub gas: u64, /// The gas price pub gas_price: Word, + /// Max fee per gas (EIP1559) + pub max_fee_per_gas: Word, + /// Max priority fee per gas (EIP1559) + pub max_priority_fee_per_gas: Word, /// The caller address pub caller_address: Address, /// The callee address @@ -332,6 +336,22 @@ impl Transaction { challenges.keccak_input(), ), ], + [ + Value::known(F::from(self.id as u64)), + Value::known(F::from(TxContextFieldTag::MaxPriorityFeePerGas as u64)), + Value::known(F::zero()), + challenges.evm_word().map(|challenge| { + rlc::value(&self.max_priority_fee_per_gas.to_le_bytes(), challenge) + }), + ], + [ + Value::known(F::from(self.id as u64)), + Value::known(F::from(TxContextFieldTag::MaxFeePerGas as u64)), + Value::known(F::zero()), + challenges + .evm_word() + .map(|challenge| rlc::value(&self.max_fee_per_gas.to_le_bytes(), challenge)), + ], [ Value::known(F::from(self.id as u64)), Value::known(F::from(TxContextFieldTag::BlockNumber as u64)), @@ -886,6 +906,8 @@ impl From for Transaction { nonce: mock_tx.nonce.as_u64(), gas: mock_tx.gas.as_u64(), gas_price: mock_tx.gas_price, + max_fee_per_gas: mock_tx.max_fee_per_gas, + max_priority_fee_per_gas: mock_tx.max_priority_fee_per_gas, caller_address: mock_tx.from.address(), callee_address: mock_tx.to.as_ref().map(|to| to.address()), is_create, @@ -938,6 +960,16 @@ pub(super) fn tx_convert( nonce: tx.nonce, gas: tx.gas, gas_price: tx.gas_price, + max_fee_per_gas: if tx.tx_type.is_eip1559_tx() { + tx.gas_fee_cap + } else { + tx.gas_price + }, + max_priority_fee_per_gas: if tx.tx_type.is_eip1559_tx() { + tx.gas_tip_cap + } else { + tx.gas_price + }, caller_address: tx.from, callee_address, is_create: tx.is_create(), From d0a208a9a4ce835a6d2ca9feaedc583e68314def Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Fri, 15 Dec 2023 08:32:18 +0800 Subject: [PATCH 119/161] Fix CI with scroll feature. --- zkevm-circuits/src/evm_circuit/param.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkevm-circuits/src/evm_circuit/param.rs b/zkevm-circuits/src/evm_circuit/param.rs index 620a3c66af..e4190abc68 100644 --- a/zkevm-circuits/src/evm_circuit/param.rs +++ b/zkevm-circuits/src/evm_circuit/param.rs @@ -7,7 +7,7 @@ use halo2_proofs::{ use std::{collections::HashMap, sync::LazyLock}; // Step dimension -pub(crate) const STEP_WIDTH: usize = 140; +pub(crate) const STEP_WIDTH: usize = 141; /// Step height pub const MAX_STEP_HEIGHT: usize = 21; /// The height of the state of a step, used by gates that connect two From 3f49762c021fe6a40854a1383e1138462491f5bf Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Sat, 16 Dec 2023 15:53:58 +0800 Subject: [PATCH 120/161] Add more comments. --- .../src/evm_circuit/util/common_gadget/tx_l1_fee.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs index 1d6d4f92dd..78c4e935e2 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs @@ -19,7 +19,9 @@ use halo2_proofs::plonk::{Error, Expression}; /// Transaction L1 fee gadget for L1GasPriceOracle contract #[derive(Clone, Debug)] pub(crate) struct TxL1FeeGadget { - /// Calculated L1 fee of transaction + /// Transaction L1 fee + /// It should be an Uint64, but it's also used to check sender balance which + /// needs to be added as a Word. tx_l1_fee_word: Word, /// Remainder when calculating L1 fee remainder_word: U64Word, From e62c8fd8744e210211b2eda16c06647dbef73f66 Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Sun, 17 Dec 2023 19:00:24 +0800 Subject: [PATCH 121/161] Add test case. --- .../src/evm_circuit/execution/begin_tx.rs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs index a9b365d75c..0e493ffeb3 100644 --- a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs +++ b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs @@ -1507,4 +1507,31 @@ mod test { .block_modifier(Box::new(|block| block.circuits_params.max_txs = 3)) .run(); } + + // TODO: add a negative case after upgrading geth. + #[test] + fn test_begin_tx_gadget_for_eip1559_tx() { + let ctx = TestContext::<2, 1>::new( + None, + |accs| { + accs[0].address(MOCK_ACCOUNTS[0]).balance(gwei(80_000)); + accs[1].address(MOCK_ACCOUNTS[1]).balance(eth(1)); + }, + |mut txs, _accs| { + txs[0] + .from(MOCK_ACCOUNTS[0]) + .to(MOCK_ACCOUNTS[1]) + .gas_price(gwei(2)) + .gas(30_000.into()) + .value(gwei(20_000)) + .max_fee_per_gas(gwei(2)) + .max_priority_fee_per_gas(gwei(2)) + .transaction_type(2); // Set tx type to EIP-1559. + }, + |block, _tx| block.number(0xcafeu64), + ) + .unwrap(); + + CircuitTestBuilder::new_from_test_ctx(ctx).run(); + } } From e098b60d404356639896998db9bb956a0c43c6f9 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 18 Dec 2023 16:19:36 -0800 Subject: [PATCH 122/161] add comments --- zkevm-circuits/src/witness/tx.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 148505f594..6690043042 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -508,7 +508,11 @@ impl Transaction { // Queue up stack operations let mut stack_ops: Vec> = vec![]; - let mut last_bytes_on_depth: [usize; 4] = [0, 0, 0, 0]; + // This variable tracks how many bytes were left on a depth level before the last UPDATE. + // Unlike the remaining_bytes variable, it tracks the byte count before the UPDATE + // operation took place. This is a utility variable for correctly filling the + // value_prev field in a POP record. + let mut prev_bytes_on_depth: [usize; 4] = [0, 0, 0, 0]; let mut stack_acc = Value::known(F::zero()); let stack_acc_pow_of_rand = std::iter::successors(Some(Value::known(F::one())), |coeff| { @@ -562,16 +566,16 @@ impl Transaction { ); if !remaining_bytes.is_empty() { - let prev_depth_bytes = *remaining_bytes.last().unwrap(); + let byte_remained = *remaining_bytes.last().unwrap(); stack_acc = stack_acc - stack_acc_pow_of_rand[cur.depth - 1] - * Value::known(F::from(prev_depth_bytes as u64)); + * Value::known(F::from(byte_remained as u64)); stack_ops.push(RlpStackOp::pop( id, cur.depth - 1, - prev_depth_bytes, - last_bytes_on_depth[cur.depth - 1], + byte_remained, + prev_bytes_on_depth[cur.depth - 1], stack_acc, stack_acc_pow_of_rand[cur.depth - 1], )); @@ -696,7 +700,7 @@ impl Transaction { // current list should be subtracted by // the number of bytes of the new list. assert!(*rem >= num_bytes_of_new_list); - last_bytes_on_depth[cur.depth] = *rem + 1; + prev_bytes_on_depth[cur.depth] = *rem + 1; stack_acc = stack_acc + stack_acc_pow_of_rand[cur.depth] * Value::known(F::from( @@ -831,7 +835,7 @@ impl Transaction { } if let Some(rem) = remaining_bytes.last_mut() { assert!(*rem >= lb_len); - last_bytes_on_depth[cur.depth] = *rem + 1; + prev_bytes_on_depth[cur.depth] = *rem + 1; stack_acc = stack_acc + stack_acc_pow_of_rand[cur.depth] * Value::known(F::from((*rem - lb_len) as u64)); From 9f3ba87f37936f29a018bf9ecea9fea6734599d1 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 18 Dec 2023 17:39:37 -0800 Subject: [PATCH 123/161] add comments' --- zkevm-circuits/src/witness/tx.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 6690043042..f3cd348924 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -566,6 +566,11 @@ impl Transaction { ); if !remaining_bytes.is_empty() { + // The circuit recovers the byte count remained on the previous depth level + // by taking it out of the stack_acc using the same random coefficient (a power of keccak_rand) + + // stack_acc = RLC(remaining_bytes[0..depth], keccak_rand); + // stack_acc_pow_of_rand = [keccak_rand^0, keccak_rand^1, keccak_rand^2, keccak_rand^3] let byte_remained = *remaining_bytes.last().unwrap(); stack_acc = stack_acc - stack_acc_pow_of_rand[cur.depth - 1] @@ -618,6 +623,9 @@ impl Transaction { assert!(*rem >= 1); if !(0xc0..=0xf7).contains(&byte_value) { + // Note: if the byte_value is in the range [0xc0..=0xf7], + // then we anticipate a PUSH onto a higher depth. + // add stack op on same depth stack_ops.push(RlpStackOp::update( id, From 9293f21a1f036271da3f055b6517d46d4f0c92d5 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 18 Dec 2023 17:42:16 -0800 Subject: [PATCH 124/161] fmt --- zkevm-circuits/src/witness/tx.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index f3cd348924..7630f7a459 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -510,7 +510,7 @@ impl Transaction { let mut stack_ops: Vec> = vec![]; // This variable tracks how many bytes were left on a depth level before the last UPDATE. // Unlike the remaining_bytes variable, it tracks the byte count before the UPDATE - // operation took place. This is a utility variable for correctly filling the + // operation took place. This is a utility variable for correctly filling the // value_prev field in a POP record. let mut prev_bytes_on_depth: [usize; 4] = [0, 0, 0, 0]; let mut stack_acc = Value::known(F::zero()); @@ -566,11 +566,13 @@ impl Transaction { ); if !remaining_bytes.is_empty() { - // The circuit recovers the byte count remained on the previous depth level - // by taking it out of the stack_acc using the same random coefficient (a power of keccak_rand) + // The circuit recovers the byte count remained on the previous depth + // level by taking it out of the stack_acc + // using the same random coefficient (a power of keccak_rand) // stack_acc = RLC(remaining_bytes[0..depth], keccak_rand); - // stack_acc_pow_of_rand = [keccak_rand^0, keccak_rand^1, keccak_rand^2, keccak_rand^3] + // stack_acc_pow_of_rand = [keccak_rand^0, keccak_rand^1, keccak_rand^2, + // keccak_rand^3] let byte_remained = *remaining_bytes.last().unwrap(); stack_acc = stack_acc - stack_acc_pow_of_rand[cur.depth - 1] From 84701e86d03303bd68166fc09ad4c808f3ab8d66 Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Mon, 18 Dec 2023 12:02:00 +0800 Subject: [PATCH 125/161] Add super circuit test for EIP-2930. --- zkevm-circuits/src/super_circuit.rs | 4 +- zkevm-circuits/src/super_circuit/eip2930.rs | 71 +++++++++++++++++++++ zkevm-circuits/src/super_circuit/test.rs | 16 +++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 zkevm-circuits/src/super_circuit/eip2930.rs diff --git a/zkevm-circuits/src/super_circuit.rs b/zkevm-circuits/src/super_circuit.rs index e2dc6c4882..a2ad2428cb 100644 --- a/zkevm-circuits/src/super_circuit.rs +++ b/zkevm-circuits/src/super_circuit.rs @@ -49,7 +49,9 @@ //! - [x] Bytecode Circuit //! - [x] Tx Circuit //! - [ ] MPT Circuit -pub(crate) mod precompile_block_trace; +#[cfg(feature = "scroll")] +mod eip2930; +mod precompile_block_trace; #[cfg(any(feature = "test", test))] pub(crate) mod test; diff --git a/zkevm-circuits/src/super_circuit/eip2930.rs b/zkevm-circuits/src/super_circuit/eip2930.rs new file mode 100644 index 0000000000..d4005e0cd5 --- /dev/null +++ b/zkevm-circuits/src/super_circuit/eip2930.rs @@ -0,0 +1,71 @@ +//! Helper functions for super circuit tests of EIP-2930 + +use super::CircuitsParams; +use eth_types::{address, l2_types::BlockTrace, AccessList, AccessListItem, H256}; +use ethers_signers::{LocalWallet, Signer}; +use mock::{eth, gwei, TestContext, MOCK_CHAIN_ID}; +use rand::SeedableRng; +use rand_chacha::ChaCha20Rng; + +pub(crate) fn test_block_trace() -> BlockTrace { + let mut rng = ChaCha20Rng::seed_from_u64(2); + let wallet_a = LocalWallet::new(&mut rng).with_chain_id(MOCK_CHAIN_ID); + + let addr_a = wallet_a.address(); + let addr_b = address!("0x000000000000000000000000000000000000BBBB"); + + let test_access_list = AccessList(vec![ + AccessListItem { + address: address!("0x0000000000000000000000000000000000001111"), + storage_keys: [10, 11].map(H256::from_low_u64_be).to_vec(), + }, + AccessListItem { + address: address!("0x0000000000000000000000000000000000002222"), + storage_keys: [20, 22].map(H256::from_low_u64_be).to_vec(), + }, + AccessListItem { + address: address!("0x0000000000000000000000000000000000003333"), + storage_keys: [30, 33].map(H256::from_low_u64_be).to_vec(), + }, + ]); + + TestContext::<2, 1>::new( + None, + |accs| { + accs[0].address(addr_b).balance(eth(20)); + accs[1].address(addr_a).balance(eth(20)); + }, + |mut txs, _accs| { + txs[0] + .from(addr_a) + .to(addr_b) + .gas_price(gwei(2)) + .gas(1_000_000.into()) + .value(eth(2)) + .transaction_type(1) // Set tx type to EIP-2930. + .access_list(test_access_list); + }, + |block, _tx| block.number(0xcafe_u64), + ) + .unwrap() + .l2_trace() + .clone() +} + +pub(crate) fn test_circuits_params(max_txs: usize, max_calldata: usize) -> CircuitsParams { + CircuitsParams { + max_txs, + max_calldata, + max_rws: 256, + max_copy_rows: 256, + max_exp_steps: 256, + max_bytecode: 512, + max_mpt_rows: 2049, + max_poseidon_rows: 512, + max_evm_rows: 0, + max_keccak_rows: 0, + max_inner_blocks: 1, + max_rlp_rows: 500, + ..Default::default() + } +} diff --git a/zkevm-circuits/src/super_circuit/test.rs b/zkevm-circuits/src/super_circuit/test.rs index 7688643673..b37c0e6fad 100644 --- a/zkevm-circuits/src/super_circuit/test.rs +++ b/zkevm-circuits/src/super_circuit/test.rs @@ -485,3 +485,19 @@ fn serial_test_super_circuit_precompile_sha256() { test_super_circuit::(block, circuits_params); } + +#[ignore] +#[cfg(feature = "scroll")] +#[test] +fn serial_test_super_circuit_eip_2930_tx() { + const MAX_TXS: usize = 1; + const MAX_CALLDATA: usize = 256; + + let block_trace = eip2930::test_block_trace(); + let circuits_params = eip2930::test_circuits_params(MAX_TXS, MAX_CALLDATA); + + test_super_circuit::( + block_trace, + circuits_params, + ); +} From db366967dfb811a565e8fc9098b5fdce981da869 Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Wed, 20 Dec 2023 15:53:15 +0800 Subject: [PATCH 126/161] Add super circuit test for EIP-1559. --- zkevm-circuits/src/super_circuit.rs | 2 + zkevm-circuits/src/super_circuit/eip1559.rs | 57 +++++++++++++++++++++ zkevm-circuits/src/super_circuit/eip2930.rs | 2 +- zkevm-circuits/src/super_circuit/test.rs | 15 ++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 zkevm-circuits/src/super_circuit/eip1559.rs diff --git a/zkevm-circuits/src/super_circuit.rs b/zkevm-circuits/src/super_circuit.rs index a2ad2428cb..78e7637c69 100644 --- a/zkevm-circuits/src/super_circuit.rs +++ b/zkevm-circuits/src/super_circuit.rs @@ -50,6 +50,8 @@ //! - [x] Tx Circuit //! - [ ] MPT Circuit #[cfg(feature = "scroll")] +mod eip1559; +#[cfg(feature = "scroll")] mod eip2930; mod precompile_block_trace; #[cfg(any(feature = "test", test))] diff --git a/zkevm-circuits/src/super_circuit/eip1559.rs b/zkevm-circuits/src/super_circuit/eip1559.rs new file mode 100644 index 0000000000..40bb1a488f --- /dev/null +++ b/zkevm-circuits/src/super_circuit/eip1559.rs @@ -0,0 +1,57 @@ +//! Helper functions for super circuit tests of EIP-1559 + +use super::CircuitsParams; +use eth_types::{address, l2_types::BlockTrace}; +use ethers_signers::{LocalWallet, Signer}; +use mock::{eth, gwei, TestContext, MOCK_CHAIN_ID}; +use rand::SeedableRng; +use rand_chacha::ChaCha20Rng; + +pub(crate) fn test_block_trace() -> BlockTrace { + let mut rng = ChaCha20Rng::seed_from_u64(2); + let wallet_a = LocalWallet::new(&mut rng).with_chain_id(MOCK_CHAIN_ID); + + let addr_a = wallet_a.address(); + let addr_b = address!("0x0000000000000000000000000000000000001559"); + + TestContext::<2, 1>::new( + None, + |accs| { + accs[0].address(addr_b).balance(eth(1)); + accs[1].address(addr_a).balance(gwei(80_000)); + }, + |mut txs, _accs| { + txs[0] + .from(addr_a) + .to(addr_b) + .gas_price(gwei(2)) + .gas(30_000.into()) + .value(gwei(20_000)) + .max_fee_per_gas(gwei(2)) + .max_priority_fee_per_gas(gwei(2)) + .transaction_type(2); // Set tx type to EIP-1559. + }, + |block, _tx| block.number(0xcafe_u64), + ) + .unwrap() + .l2_trace() + .clone() +} + +pub(crate) fn test_circuits_params(max_txs: usize, max_calldata: usize) -> CircuitsParams { + CircuitsParams { + max_txs, + max_calldata, + max_rws: 256, + max_copy_rows: 256, + max_exp_steps: 256, + max_bytecode: 512, + max_mpt_rows: 2049, + max_poseidon_rows: 512, + max_evm_rows: 0, + max_keccak_rows: 0, + max_inner_blocks: 1, + max_rlp_rows: 500, + ..Default::default() + } +} diff --git a/zkevm-circuits/src/super_circuit/eip2930.rs b/zkevm-circuits/src/super_circuit/eip2930.rs index d4005e0cd5..57483df306 100644 --- a/zkevm-circuits/src/super_circuit/eip2930.rs +++ b/zkevm-circuits/src/super_circuit/eip2930.rs @@ -12,7 +12,7 @@ pub(crate) fn test_block_trace() -> BlockTrace { let wallet_a = LocalWallet::new(&mut rng).with_chain_id(MOCK_CHAIN_ID); let addr_a = wallet_a.address(); - let addr_b = address!("0x000000000000000000000000000000000000BBBB"); + let addr_b = address!("0x0000000000000000000000000000000000002930"); let test_access_list = AccessList(vec![ AccessListItem { diff --git a/zkevm-circuits/src/super_circuit/test.rs b/zkevm-circuits/src/super_circuit/test.rs index b37c0e6fad..b4dc3bb1db 100644 --- a/zkevm-circuits/src/super_circuit/test.rs +++ b/zkevm-circuits/src/super_circuit/test.rs @@ -486,6 +486,21 @@ fn serial_test_super_circuit_precompile_sha256() { test_super_circuit::(block, circuits_params); } +#[ignore] +#[cfg(feature = "scroll")] +#[test] +fn serial_test_super_circuit_eip_1559_tx() { + const MAX_TXS: usize = 1; + const MAX_CALLDATA: usize = 256; + + let block_trace = eip1559::test_block_trace(); + let circuits_params = eip1559::test_circuits_params(MAX_TXS, MAX_CALLDATA); + + test_super_circuit::( + block_trace, + circuits_params, + ); +} #[ignore] #[cfg(feature = "scroll")] #[test] From 9536b3f3fbee9c3aefb784f67e4615e17a91ce74 Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Thu, 21 Dec 2023 09:42:31 +0800 Subject: [PATCH 127/161] Fix CI. --- zkevm-circuits/src/tx_circuit.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 3d03d20129..9ef4ced97a 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -83,7 +83,7 @@ use halo2_proofs::plonk::SecondPhase; use itertools::Itertools; /// Number of rows of one tx occupies in the fixed part of tx table -pub const TX_LEN: usize = 28; +pub const TX_LEN: usize = 30; /// Offset of TxHash tag in the tx table pub const TX_HASH_OFFSET: usize = 21; /// Offset of ChainID tag in the tx table @@ -532,11 +532,6 @@ impl SubCircuitConfig for TxCircuitConfig { (is_access_list_addresses_len(meta), Null), (is_access_list_storage_keys_len(meta), Null), (is_access_list_rlc(meta), RLC), - (is_max_fee_per_gas(meta), Tag::MaxFeePerGas.into()), - ( - is_max_priority_fee_per_gas(meta), - Tag::MaxPriorityFeePerGas.into(), - ), ]; cb.require_boolean( From 2d71e7a8aa7ba346cbf392f0b3e7df04138246a6 Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Thu, 21 Dec 2023 11:50:49 +0800 Subject: [PATCH 128/161] Enable EIP-1559 and EIP-2930 cases in `testool`. --- testool/Config.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testool/Config.toml b/testool/Config.toml index db84560afc..df0ce4a1ba 100644 --- a/testool/Config.toml +++ b/testool/Config.toml @@ -190,10 +190,10 @@ tests = [] [[skip_paths]] desc = "unimplemented" paths = [ - "EIP1559", - "stExample/eip1559Filler.yml", +# "EIP1559", +# "stExample/eip1559Filler.yml", "stExample/mergeTestFiller.yml", - "EIP2930", +# "EIP2930", #"stPreCompiledContracts", #"stZeroKnowledge" ] From 6b5073deb62424dfbbc3ff270a13e941a23703ae Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Thu, 21 Dec 2023 18:44:04 +0800 Subject: [PATCH 129/161] Update testool config. --- testool/Config.toml | 7 ++-- testool/codehash.txt | 58 ++++++++++++++++++++++++++++++++++ testool/docker/lllc/Dockerfile | 6 ++-- testool/docker/solc/Dockerfile | 2 +- 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/testool/Config.toml b/testool/Config.toml index df0ce4a1ba..ed6c136d75 100644 --- a/testool/Config.toml +++ b/testool/Config.toml @@ -190,10 +190,11 @@ tests = [] [[skip_paths]] desc = "unimplemented" paths = [ -# "EIP1559", -# "stExample/eip1559Filler.yml", +# "EIP1559", +# "stExample/eip1559Filler.yml", + "stEIP1559/valCausesOOFFiller.yml", "stExample/mergeTestFiller.yml", -# "EIP2930", +# "EIP2930", #"stPreCompiledContracts", #"stZeroKnowledge" ] diff --git a/testool/codehash.txt b/testool/codehash.txt index 2b68393128..233960aa2e 100644 --- a/testool/codehash.txt +++ b/testool/codehash.txt @@ -8250,3 +8250,61 @@ ef05bea5645aa48c5e7325bb1a23119c961290af1c112594ee1aa06e054277db=5b61c3506080511 31d87b82490b345887422d30c21c0ce23b669af6171f9d386e845f68fdc272f7=6000600060006000600073bbbf5374fce5edbc8e2a8697c15331677e6ebf0b5af1600055600160015500 2be93bf90fda15c9f97e8936c2ed1850d6dac4aa07c7df2805f827f73c522c56=5b61c3506080511015603e576000600061c350600073aaaf5374fce5edbc8e2a8697c15331677e6ebf0b620186a0fa6000556001608051016080526000565b60805160205500 bfa65cd1585cc6bda1710e286b92a295032f7d4ddcd78151566fbd2bebfcb1af=60005460005500 +845731d3a84982b2898a85c463d8552018afc8153efd3da3406be4937c9c7a2d=5a600052600080600080620f424061ba5e5af1505a60205260216020516000510303600055 +60dddb7cb27e627921ce8a0ce7456a17f134e4880b54f4bffaa7782ebbcd1a41=486000526000516040526021603ff3 +c83d13fe03c8582ad1196031d75cbd6a44c8841ac43ff7d629f84e419c33ddfd=3a6000526000516040526021603ff3 +d96b4fa95327924ee96f6212dfe2a65146614e7ead071e7fa854cc779ed17772=60018001600055 +01cae6f0724d785b4ce2ac83cea7d6f826f04bfcfdaefea4c1584d54461b35fb=600060006000600061c0575af400 +525ff263800e28e7349317c5883862d3ed709f2e0109ebb14a57392d18590ef4=5a600052600260005560115a600051030360005260005160015500 +02725d4132dbd9f67369c09aef936e2a68578c7e755bcc2eba7d09b953965bfe=3331600055 +4721b7ec7dc8d7d56ac8b1417a78df240173b8a7aa74081292f32dfc321dbc08=60006000351461001157600050610018565b6101016020525b60016000351461002a5760005061002f565b326020525b60026000351461004157600050610046565b336020525b6003600035146100585760005061005d565b306020525b60046000351461006f57600050610075565b60016020525b60005160005260006020351461008d576000506100b6565b5a600052602051315060165a60005103036000555a600052602051315060165a60005103036001555b6001602035146100c8576000506100f1565b5a6000526020513b5060165a60005103036000555a6000526020513b5060165a60005103036001555b6002602035146101035760005061012c565b5a6000526020513f5060165a60005103036000555a6000526020513f5060165a60005103036001555b60036020351461013e5760005061017a565b6106a5610100525a600052602060006101006020513c60205a60005103036000555a600052602060006101006020513c60205a60005103036001555b00 +da6eae5f15e950a9b763f8d14d747f821cd2fca4f39ade4b42d36629a7ac16f1=4860005260206000f3 +605387e067d9c0410eb2df922839bde6d9bd4e31966d475b7ec466ed5e223410=3a60005260206000f3 +da8a38488d632b23985f95fe4da99a9189c52b497247fdbe5eb563c51fb985db=6000600060006000600061c0575af100 +3452769bf2d3ba773b1ca4df7a432faaabce711c787f5e075d81313453c9254f=5a6000526000545060135a600051030360005260005160015500 +b57709911888ba34ad65885f4220b0af83516e3d8fbf7f3efc1225f4500022d4=600435610100526024356101205260406000604061010060006101005af15060005160005560205160015500 +4ca45a618de30bcf972ef1fe54652b46f5de89d8490541d721683f83ff73db11=600435600180602061c0de3b63c0dec0de3b6160a7600052856000811461015b5760f181146101645760f281146101785760f4811461018c5760fa811461019f5761f1f181146101b25761f2f181146101c85761f4f181146101de5761faf181146101f35761f1f281146102085761f2f2811461021e5761f4f281146102345761faf281146102495761f1f4811461025e5761f2f481146102745761f4f4811461028a5761faf4811461029f5761f1fa81146102b45761f2fa81146102ca5761f4fa81146102e05761fafa81146102f55760fd811461030a5760fe81146103415760ff811461037a5760f081146103b25760f581146103d55761f0f181146103fb5761f5f181146104255761f0f281146104525761f5f281146104755761f0f4811461049b5761f5f481146104bd5761f0fa81146104e25761f5fa811461050b576460baccfa5781146105375765bad0bad0bad0600052610551565b48600052610551565b602060008060008061ca115af19550610551565b602060008060008061ca115af29550610551565b6020600080600061ca115af49550610551565b6020600080600061ca115afa9550610551565b602060008060008063ca1100f15af19550610551565b602060008060008063ca1100f15af29550610551565b6020600080600063ca1100f15af49550610551565b6020600080600063ca1100f15afa9550610551565b602060008060008063ca1100f25af19550610551565b602060008060008063ca1100f25af29550610551565b6020600080600063ca1100f25af49550610551565b6020600080600063ca1100f25afa9550610551565b602060008060008063ca1100f45af19550610551565b602060008060008063ca1100f45af29550610551565b6020600080600063ca1100f45af49550610551565b6020600080600063ca1100f45afa9550610551565b602060008060008063ca1100fa5af19550610551565b602060008060008063ca1100fa5af29550610551565b6020600080600063ca1100fa5af49550610551565b6020600080600063ca1100fa5afa9550610551565b4860005260005160005560008060008060006260bacc5af150486000526000516000541461033c57640badbadbad6000525b610551565b486000526000516000556000806000806000620600066161a8f150486000526000516000541461037557640badbadbad6000525b610551565b48600052600051600055600080600080600063deaddead5af15048600052600051600054146103ad57640badbadbad6000525b610551565b8260008561c0de3c8284670de0b6b3a7640000f09450602060016000873c610551565b8260008561c0de3c615a178385670de0b6b3a7640000f59450602060016000873c610551565b8160008563c0dec0de3c8184670de0b6b3a7640000f094506020600080600080895af19550610551565b8160008563c0dec0de3c615a178285670de0b6b3a7640000f594506020600080600080895af19550610551565b8160008563c0dec0de3c81846000f094506020600080600080895af29550610551565b8160008563c0dec0de3c615a1782856000f594506020600080600080895af29550610551565b8160008563c0dec0de3c81846000f0945060206000806000885af49550610551565b8160008563c0dec0de3c615a1782856000f5945060206000806000885af49550610551565b8160008563c0dec0de3c8184670de0b6b3a7640000f0945060206000806000885afa9550610551565b8160008563c0dec0de3c615a178285670de0b6b3a7640000f5945060206000806000885afa9550610551565b6103ff6000526020600060206000806460baccfa575af195505b508461055d5760206000fd5b836105685760206000fd5b600051600055505050505050 +c93ba7f931ec2bc09d69e4d6edbf690566163f6bae42b5c8fc07f4b4d4a05927=600435600180602061c0de3b63c0dec0de3b6160a7600052856000811461015b5760f181146101645760f281146101785760f4811461018c5760fa811461019f5761f1f181146101b25761f2f181146101c85761f4f181146101de5761faf181146101f35761f1f281146102085761f2f2811461021e5761f4f281146102345761faf281146102495761f1f4811461025e5761f2f481146102745761f4f4811461028a5761faf4811461029f5761f1fa81146102b45761f2fa81146102ca5761f4fa81146102e05761fafa81146102f55760fd811461030a5760fe81146103415760ff811461037a5760f081146103b25760f581146103d55761f0f181146103fb5761f5f181146104255761f0f281146104525761f5f281146104755761f0f4811461049b5761f5f481146104bd5761f0fa81146104e25761f5fa811461050b576460baccfa5781146105375765bad0bad0bad0600052610551565b3a600052610551565b602060008060008061ca115af19550610551565b602060008060008061ca115af29550610551565b6020600080600061ca115af49550610551565b6020600080600061ca115afa9550610551565b602060008060008063ca1100f15af19550610551565b602060008060008063ca1100f15af29550610551565b6020600080600063ca1100f15af49550610551565b6020600080600063ca1100f15afa9550610551565b602060008060008063ca1100f25af19550610551565b602060008060008063ca1100f25af29550610551565b6020600080600063ca1100f25af49550610551565b6020600080600063ca1100f25afa9550610551565b602060008060008063ca1100f45af19550610551565b602060008060008063ca1100f45af29550610551565b6020600080600063ca1100f45af49550610551565b6020600080600063ca1100f45afa9550610551565b602060008060008063ca1100fa5af19550610551565b602060008060008063ca1100fa5af29550610551565b6020600080600063ca1100fa5af49550610551565b6020600080600063ca1100fa5afa9550610551565b3a60005260005160005560008060008060006260bacc5af1503a6000526000516000541461033c57640badbadbad6000525b610551565b3a6000526000516000556000806000806000620600066161a8f1503a6000526000516000541461037557640badbadbad6000525b610551565b3a600052600051600055600080600080600063deaddead5af1503a600052600051600054146103ad57640badbadbad6000525b610551565b8260008561c0de3c8284670de0b6b3a7640000f09450602060016000873c610551565b8260008561c0de3c615a178385670de0b6b3a7640000f59450602060016000873c610551565b8160008563c0dec0de3c8184670de0b6b3a7640000f094506020600080600080895af19550610551565b8160008563c0dec0de3c615a178285670de0b6b3a7640000f594506020600080600080895af19550610551565b8160008563c0dec0de3c81846000f094506020600080600080895af29550610551565b8160008563c0dec0de3c615a1782856000f594506020600080600080895af29550610551565b8160008563c0dec0de3c81846000f0945060206000806000885af49550610551565b8160008563c0dec0de3c615a1782856000f5945060206000806000885af49550610551565b8160008563c0dec0de3c8184670de0b6b3a7640000f0945060206000806000885afa9550610551565b8160008563c0dec0de3c615a178285670de0b6b3a7640000f5945060206000806000885afa9550610551565b6103ff6000526020600060206000806460baccfa575af195505b508461055d5760206000fd5b836105685760206000fd5b600051600055505050505050 +3bdfc895faf417bafd0313c21f94e235ef9e89648aa071ea18294a6a31a612e5=6000600060006000600061c0575af200 +e726686d2da798215abe8da6734aab9586e39e7955c034fc79dd662143876579=5a600052600060005560115a600051030360005260005160015500 +4b3076d90148be6a57ee0f8664f418b79e5a681104311f0675cc3f4850a0fd32=4860005260206000f3 +e33b84b2b1532e0da8a5c46692c0a5b44be00c989dec3423afeffbe66c7e2722=3a60005260206000f3 +da38b2e85f60fa27816a05665e62bf6e4d91c708ebbe52a79db36eb7f7b71469=5a60005261beef60005560115a600051030360005260005160015500 +432e921be7ac770f9ee868727c305ccadefb5707d8d39a4357acad736e29b4a7=5a600052600260005560115a60005103036000526000516001555a6000526160a75460205260105a600051030360005260005160025500 +dd10fd1bb55c9f939057557203376a231ebb053f749d3bcc6c6327b7d2866ca3=48600052600051600055fe +0b08ede4b4ec174cd57606b4a4b72aff13dcb3178c7a1d4b9dacf3053cddd213=3a600052600051600055fe +67c963506a78d643699af333073558cd98add3b86f326feced32525ebe902472=602060006000600063ead0c0575afa5060005160005500 +eda1d174cdcfe8b80d0320f3339558b25f1b2872b79c9cdd571ed1d1d1502022=4860005260005160005560206000fd +d402943e0b38dbf034c9871cc38209b2d5b2efe6cfbf52c11e54b1df8ee165a6=5a6000526160a760005560115a600051030360005260005160015500 +ca6960368354058d37a1a6188785e0dafac7c3d5e4574bc4d01e789cc598f3df=3a60005260005160005560206000fd +e2293505d71d1d4628a1af87a4a9111e6d24773ba7a370ef63f8cdf3d6b73db1=5a600052600060005560115a600051030360005260005160015500 +b4cb701811a4a98af09efef975fa30d9d1d8ac0be2b0f0af403df7bbff4785a6=5a6000526160a75460205260135a600051030360005260206000f300 +aac70c97ac5694eda55c663bda4d482cfbfe184526b1b06ec945dd77db05d257=600035600081036013574860005260206000f35b600181036000526020600060206000806460baccfa575af160345760206000fd5b60206000f3 +9012d5ed7b2d23330f06815b204434a4a17c92aefd690f980293939abc98189b=600035600081036013573a60005260206000f35b600181036000526020600060206000806460baccfa575af160345760206000fd5b60206000f3 +b29c3aa79a8cc5809eeafead664dce4a662649de06a441c56f358ef51e0944ad=6160a76000555a600052600260005560115a600051030360005260005160015500 +c11d3fec086da5e76de1c4a321b0abda9cf64c526e9b5fc2e81c29b51a0a3ff2=5a600052600260005560115a60005103036000525a6020526160a754604052601a5a602051030360205260406000fd00 +bd794ebe35dc42e461d9b334512fbdf2e68fdaf1182f41625ad9a59092066616=5a6000526000600060006000600063dead01115af150617fe85a600051030360005500 +1526df0d0e1512b9f1ec9e3a25c40cf1b0ed3f0f37ac7c0d34b70330e0704816=6160a76000555a6000526000545060135a600051030360005260005160015500 +80c7b81c77933d7b16c609934268f26c36afbd28cc1f0937dac4f167bf48d454=6000546020525a600052600260005560115a600051030360005260005160015500 +6a2c88b7c3dda43ba8f5e88c514613802fdaec87f23917be2429da4d0a833387=61dead6000556000ff00 +83629d1d3423e43f136c63f07c6c05a247abdb2347ae5e41a6eb77320f437839=6000546020525a6000526000545060135a600051030360005260005160015500 +2d08aff8b66e2efa92b8042c303dae98cd96bde81f5e59415257a690c27761fd=5a6000526000600060006000600063dead01125af150617fe85a600051030360005500 +a15d05ad8a7684f4907c05b8127a97364aca717c083cf9cb52333bcfe78a1c94=600054506000ff00 +55688b2ea5331023bcc58bd53a0fddc33b38f849a4a03200d064604d357a0730=60006000600060006000600435610100015af1505a6000526160a7545060135a60005103036000526000516001555a600052600260005560115a600051030360005260005160025500 +b6a727038a928b7ed3c9ae098292026bbde0daebc67546abbee9586daa023051=610bad600052602060006000600061f1135afa5060005160005500 +f5d3c5c6cb67b4955a128cb40923db25bc17f826f8fbc03e9001b378f513d579=63dead60a760005561600d60005260206000f300 +3a4c42bb50e184de8bc1f19dfa8a797adabd010cfca71b5ff6df06b356396e5c=6020600060006000600061f114610b65f100 +1a0defc6fa59aa9daad84d820685178d063138473c2244a47d948bc72675e2b1=61600d60005500 +c9fd1a848bb6509f49a8eede9d0f4256cee5c280f9615b9289189fe04b4ea658=6020600060006000600061f115611800f100 +2c883ea2085149bb4c927d5f8a6005b6f9d1284b0d9c9d3618e894127f6040cc=6160a75460005261600d60005500 +263e3ba2f1be3838edbe97d9a5833704b94e35ec310aacf72bdeebd952d67ece=600054505a600052600261beef5560115a60005103036000525a6020526160a75460a05260235a60205103036020525a60405261beef60005461f000015560785a60405103036040525a60605260005461f010015450607a5a60605103036060526000516000546101000155602051600054610200015560405160005461030001556060516000546104000155600060005411609b57600060b4565b600160005403600055600060006000600060006101165af15b00 +7c7e18ace7e9fd9ac70095435133aed076d6a6addf8b8a59cea56a900a173236=60068060336101003961020052602180603960003961022052610200516101000160006000f0610240526102405160015500fe60ff600055005a60005261ffff6000555a6000510360015561010061010060003960106000f300 +3b9cdb86e075f42bba45af5f85799494fb8478f94ecbc19bc486454febed156e=60068060366101003961020052602180603c60003961022052615a17610200516101000160006000f5610240526102405160015500fe60ff600055005a60005261ffff6000555a6000510360015561010061010060003960106000f300 +3fd049e1accc65249fb0f137b5716867a3bca1353dcaf8042319f7cf0a26f472=60138060446101003961020052600f80605760003961022052610200516101000160006000f06102405260006000600060006000610240515af1506102405160015500fe5a60005261ffff6000555a600051036001550061010061010060003960806000f300 +b1186f97995f3827a2ccb9e648d8d766828aa5aaa956261629987a5cde03068e=60138060476101003961020052600f80605a60003961022052615a17610200516101000160006000f56102405260006000600060006000610240515af1506102405160015500fe5a60005261ffff6000555a600051036001550061010061010060003960806000f300 +335ad7b7050975a2987ada3ce30d0258668f95982c398354346252f98e4d8506=60138060446101003961020052602180605760003961022052610200516101000160006000f06102405260006000600060006000610240515af1506102405160015500fe5a60005261ffff6000555a60005103600255005a60005261ffff6000555a6000510360015561010061010060003960806000f300 +054b2b2175ff410a3e55f65b9b11989a29c5b862655bfc418bb03380f468d8e0=60138060476101003961020052602180605a60003961022052615a17610200516101000160006000f56102405260006000600060006000610240515af1506102405160015500fe5a60005261ffff6000555a60005103600255005a60005261ffff6000555a6000510360015561010061010060003960806000f300 +2cb5795ea1f7cf399e5c74d79d2fa7c4250ee5a8d91f7daf6ecb00425c4d5f14=6000600060006000600061f1265af1506000600060006000600061f1265af100 +49d91eb5811006981ac40efbe002466cb963cf8edfd290173c7ecd0e0acf5975=5a6000526160a76000555a60005103600052600060015414602457600051600255602b565b6000516001555b00 +2135574766477befd8479b710ced5a46de981168fb1af38db06b9e42bdadf582=60406000600060006000600435610100015af15060005160005560205160015500 +ae3feab7e0150c20f952d7456530c6a222a057caafe5a7854472a9b766126ead=3a6000554860015500 diff --git a/testool/docker/lllc/Dockerfile b/testool/docker/lllc/Dockerfile index 95a0cc393b..f77d1d26fa 100644 --- a/testool/docker/lllc/Dockerfile +++ b/testool/docker/lllc/Dockerfile @@ -2,10 +2,10 @@ FROM alpine:3.15.6 AS build WORKDIR /solidity -RUN apk update && apk add boost-dev boost-static build-base cmake git +RUN apk update && apk add boost-dev boost-static build-base cmake git z3-dev -RUN git clone https://github.com/ethereum/solidity . -RUN git checkout 8f2595957bfc0f3cd18ca29240dabcd6b2122dfd +RUN git clone https://github.com/winsvega/lllc . +RUN git checkout 2b34e1d437bab8b92242262456fc922de86d0d30 COPY patch.diff patch.diff RUN patch -p1 < patch.diff diff --git a/testool/docker/solc/Dockerfile b/testool/docker/solc/Dockerfile index 16b58ac0ca..4a437c9d29 100644 --- a/testool/docker/solc/Dockerfile +++ b/testool/docker/solc/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /solidity RUN apk update && apk add boost-dev boost-static build-base cmake git RUN git clone https://github.com/ethereum/solidity . -RUN git checkout v0.8.13 +RUN git checkout v0.8.19 WORKDIR /solidity/build RUN cmake .. -DCMAKE_BUILD_TYPE=Release From d2faac3c7f5daae43029a1597d75ade10e1e892e Mon Sep 17 00:00:00 2001 From: darth-cy Date: Thu, 21 Dec 2023 19:25:31 -0800 Subject: [PATCH 130/161] remove engagement of stack acc --- zkevm-circuits/src/rlp_circuit_fsm.rs | 133 +++++++++++++------------- zkevm-circuits/src/witness/rlp_fsm.rs | 19 ---- zkevm-circuits/src/witness/tx.rs | 39 -------- 3 files changed, 67 insertions(+), 124 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index a20a18b709..2dc2c9cde7 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -192,11 +192,6 @@ pub struct RlpDecodingTable { pub value: Column, /// Value Previous pub value_prev: Column, - /// Stack Accumulator - /// accumulates remaining bytes on each depth level (excluding top of stack) - pub stack_acc: Column, - /// Power of rand for stack accumulator on depth level (address) - pub stack_acc_pow_of_rand: Column, /// Stack Op flag, Init pub is_stack_init: Column, /// Stack Op flag, Push @@ -216,8 +211,9 @@ impl RlpDecodingTable { depth: meta.advice_column(), value: meta.advice_column(), value_prev: meta.advice_column(), - stack_acc: meta.advice_column_in(SecondPhase), - stack_acc_pow_of_rand: meta.advice_column_in(SecondPhase), + // tx1559_debug + // stack_acc: meta.advice_column_in(SecondPhase), + // stack_acc_pow_of_rand: meta.advice_column_in(SecondPhase), is_stack_init: meta.advice_column(), is_stack_push: meta.advice_column(), is_stack_pop: meta.advice_column(), @@ -1724,15 +1720,16 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.value, Rotation::cur()), meta.query_advice(byte_rev_idx, Rotation::cur()), ); - cb.require_equal( - "stack_acc accumulates depth 0 bytes at 1", - meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), - 1.expr() - ); - cb.require_zero( - "stack accumulator starts at 0", - meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), - ); + // tx1559_debug + // cb.require_equal( + // "stack_acc accumulates depth 0 bytes at 1", + // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + // 1.expr() + // ); + // cb.require_zero( + // "stack accumulator starts at 0", + // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + // ); }, ); @@ -1749,22 +1746,23 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.depth, Rotation::prev()) + 1.expr(), meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), ); - cb.require_equal( - "stack_acc accumulates next depth level at exponent +1 of challenge", - meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()) * challenges.keccak_input(), - meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), - ); - cb.require_equal( - "stack_acc accumulates remaining bytes from previous depth level", - meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) - + (meta.query_advice(rlp_decoding_table.value, Rotation::prev()) - - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) - // 1 byte needs to be subtracted here as the step preceding the PUSH reads one byte from the lower depth - // This byte is already consumed and won't be added to the accumulator - - 1.expr()) - * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), - meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), - ); + // tx1559_debug + // cb.require_equal( + // "stack_acc accumulates next depth level at exponent +1 of challenge", + // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()) * challenges.keccak_input(), + // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + // ); + // cb.require_equal( + // "stack_acc accumulates remaining bytes from previous depth level", + // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) + // + (meta.query_advice(rlp_decoding_table.value, Rotation::prev()) + // - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + // // 1 byte needs to be subtracted here as the step preceding the PUSH reads one byte from the lower depth + // // This byte is already consumed and won't be added to the accumulator + // - 1.expr()) + // * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), + // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + // ); }, ); @@ -1781,18 +1779,19 @@ impl RlpCircuitConfig { "POP can only happen if there's no more bytes to decode on the higher depth", meta.query_advice(rlp_decoding_table.value, Rotation::prev()), ); - cb.require_equal( - "stack_acc accumulates lower depth level at exponent -1 of challenge", - meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), - meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()) * challenges.keccak_input(), - ); - cb.require_equal( - "stack_acc releases remaining bytes from previous depth level", - meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) - - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) - * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), - meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), - ); + // tx1559_debug + // cb.require_equal( + // "stack_acc accumulates lower depth level at exponent -1 of challenge", + // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), + // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()) * challenges.keccak_input(), + // ); + // cb.require_equal( + // "stack_acc releases remaining bytes from previous depth level", + // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) + // - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + // * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + // ); }, ); @@ -1815,16 +1814,17 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.value, Rotation::prev()), meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), ); - cb.require_equal( - "UPDATE doesn't change stack_acc", - meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()), - meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), - ); - cb.require_equal( - "stack_acc accumulates same depth level at the same exponent of challenge", - meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), - meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), - ); + // tx1559_debug + // cb.require_equal( + // "UPDATE doesn't change stack_acc", + // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()), + // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + // ); + // cb.require_equal( + // "stack_acc accumulates same depth level at the same exponent of challenge", + // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), + // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), + // ); }, ); @@ -2021,18 +2021,19 @@ impl RlpCircuitConfig { row, || Value::known(F::from(witness.rlp_decoding_table.value_prev as u64)), )?; - region.assign_advice( - || "rlp_decoding_table.stack_acc", - self.rlp_decoding_table.stack_acc, - row, - || witness.rlp_decoding_table.stack_acc, - )?; - region.assign_advice( - || "rlp_decoding_table.stack_acc_pow_of_rand", - self.rlp_decoding_table.stack_acc_pow_of_rand, - row, - || witness.rlp_decoding_table.stack_acc_pow_of_rand, - )?; + // tx1559_debug + // region.assign_advice( + // || "rlp_decoding_table.stack_acc", + // self.rlp_decoding_table.stack_acc, + // row, + // || witness.rlp_decoding_table.stack_acc, + // )?; + // region.assign_advice( + // || "rlp_decoding_table.stack_acc_pow_of_rand", + // self.rlp_decoding_table.stack_acc_pow_of_rand, + // row, + // || witness.rlp_decoding_table.stack_acc_pow_of_rand, + // )?; region.assign_advice( || "rlp_decoding_table.is_stack_init", self.rlp_decoding_table.is_stack_init, diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index f5897b1235..cc76ec3c41 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -784,11 +784,6 @@ pub struct RlpStackOp { pub value: usize, /// Value Previous pub value_prev: usize, - /// Stack Accumulator - /// accumulates remaining bytes on each depth level (excluding top of stack) - pub stack_acc: Value, - /// Power of rand for stack accumulator on depth level (address) - pub stack_acc_pow_of_rand: Value, /// The stack operation performed at step. pub stack_op: StackOp, } @@ -800,8 +795,6 @@ impl RlpStackOp { depth: 0, value, value_prev: 0, - stack_acc: Value::known(F::ZERO), - stack_acc_pow_of_rand: Value::known(F::ONE), stack_op: StackOp::Init, } } @@ -809,16 +802,12 @@ impl RlpStackOp { id: Value, depth: usize, value: usize, - stack_acc: Value, - stack_acc_pow_of_rand: Value, ) -> Self { Self { id, depth, value, value_prev: 0, - stack_acc, - stack_acc_pow_of_rand, stack_op: StackOp::Push, } } @@ -827,16 +816,12 @@ impl RlpStackOp { depth: usize, value: usize, value_prev: usize, - stack_acc: Value, - stack_acc_pow_of_rand: Value, ) -> Self { Self { id, depth, value, value_prev, - stack_acc, - stack_acc_pow_of_rand, stack_op: StackOp::Pop, } } @@ -844,16 +829,12 @@ impl RlpStackOp { id: Value, depth: usize, value: usize, - stack_acc: Value, - stack_acc_pow_of_rand: Value, ) -> Self { Self { id, depth, value, value_prev: value + 1, - stack_acc, - stack_acc_pow_of_rand, stack_op: StackOp::Update, } } diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 7630f7a459..16c5ee96b7 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -513,13 +513,6 @@ impl Transaction { // operation took place. This is a utility variable for correctly filling the // value_prev field in a POP record. let mut prev_bytes_on_depth: [usize; 4] = [0, 0, 0, 0]; - let mut stack_acc = Value::known(F::zero()); - - let stack_acc_pow_of_rand = std::iter::successors(Some(Value::known(F::one())), |coeff| { - Some(keccak_rand * coeff) - }) - .take(5) - .collect::>>(); // concat tx_id and format as stack identifier let id = keccak_rand * Value::known(F::from(tx_id)) + Value::known(F::from(format as u64)); @@ -566,25 +559,13 @@ impl Transaction { ); if !remaining_bytes.is_empty() { - // The circuit recovers the byte count remained on the previous depth - // level by taking it out of the stack_acc - // using the same random coefficient (a power of keccak_rand) - - // stack_acc = RLC(remaining_bytes[0..depth], keccak_rand); - // stack_acc_pow_of_rand = [keccak_rand^0, keccak_rand^1, keccak_rand^2, - // keccak_rand^3] let byte_remained = *remaining_bytes.last().unwrap(); - stack_acc = stack_acc - - stack_acc_pow_of_rand[cur.depth - 1] - * Value::known(F::from(byte_remained as u64)); stack_ops.push(RlpStackOp::pop( id, cur.depth - 1, byte_remained, prev_bytes_on_depth[cur.depth - 1], - stack_acc, - stack_acc_pow_of_rand[cur.depth - 1], )); } @@ -633,8 +614,6 @@ impl Transaction { id, cur.depth, *rem - 1, - stack_acc, - stack_acc_pow_of_rand[cur.depth], )); } @@ -711,11 +690,6 @@ impl Transaction { // the number of bytes of the new list. assert!(*rem >= num_bytes_of_new_list); prev_bytes_on_depth[cur.depth] = *rem + 1; - stack_acc = stack_acc - + stack_acc_pow_of_rand[cur.depth] - * Value::known(F::from( - (*rem - num_bytes_of_new_list) as u64, - )); *rem -= num_bytes_of_new_list; } @@ -725,8 +699,6 @@ impl Transaction { id, cur.depth + 1, num_bytes_of_new_list, - stack_acc, - stack_acc_pow_of_rand[cur.depth + 1], )); next.depth = cur.depth + 1; @@ -754,8 +726,6 @@ impl Transaction { id, cur.depth, *rem - 1, - stack_acc, - stack_acc_pow_of_rand[cur.depth], )); *rem -= 1; @@ -790,8 +760,6 @@ impl Transaction { id, cur.depth, *rem - 1, - stack_acc, - stack_acc_pow_of_rand[cur.depth], )); *rem -= 1; @@ -825,8 +793,6 @@ impl Transaction { id, cur.depth, *rem - 1, - stack_acc, - stack_acc_pow_of_rand[cur.depth], )); } @@ -846,9 +812,6 @@ impl Transaction { if let Some(rem) = remaining_bytes.last_mut() { assert!(*rem >= lb_len); prev_bytes_on_depth[cur.depth] = *rem + 1; - stack_acc = stack_acc - + stack_acc_pow_of_rand[cur.depth] - * Value::known(F::from((*rem - lb_len) as u64)); *rem -= lb_len; } @@ -857,8 +820,6 @@ impl Transaction { id, cur.depth + 1, lb_len, - stack_acc, - stack_acc_pow_of_rand[cur.depth + 1], )); next.depth = cur.depth + 1; next.state = DecodeTagStart; From 24ed37ebca852c707e96bc0df92cc9788927e6e8 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 24 Dec 2023 19:00:32 -0800 Subject: [PATCH 131/161] remove stack_acc and add new witness --- zkevm-circuits/src/rlp_circuit_fsm.rs | 91 ++++------------------ zkevm-circuits/src/rlp_circuit_fsm/test.rs | 1 + zkevm-circuits/src/witness/rlp_fsm.rs | 53 ++++++++++++- zkevm-circuits/src/witness/tx.rs | 88 ++++++++++++++++++++- 4 files changed, 149 insertions(+), 84 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 2dc2c9cde7..3619afa6df 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -182,12 +182,12 @@ impl RlpFsmRomTable { /// Data decoding table simulates a stack-like structure for constraining remaining_bytes #[derive(Clone, Copy, Debug)] pub struct RlpDecodingTable { - /// Is Write to decoding stack - pub is_write: Column, /// Key1 (Id), concat of tx_id, format pub id: Column, /// Key2 (Address), in this case depth pub depth: Column, + /// Op Counter, byte_idx + pub byte_idx: Column, /// Value pub value: Column, /// Value Previous @@ -200,15 +200,19 @@ pub struct RlpDecodingTable { pub is_stack_pop: Column, /// Stack Op flag, Update pub is_stack_update: Column, + /// Access list idx + pub al_idx: Column, + /// Storage key idx + pub sk_idx: Column, } impl RlpDecodingTable { /// Construct the decoding table. pub fn construct(meta: &mut ConstraintSystem) -> Self { Self { - is_write: meta.advice_column(), id: meta.advice_column(), depth: meta.advice_column(), + byte_idx: meta.advice_column(), value: meta.advice_column(), value_prev: meta.advice_column(), // tx1559_debug @@ -218,6 +222,8 @@ impl RlpDecodingTable { is_stack_push: meta.advice_column(), is_stack_pop: meta.advice_column(), is_stack_update: meta.advice_column(), + al_idx: meta.advice_column(), + sk_idx: meta.advice_column(), } } } @@ -1671,12 +1677,6 @@ impl RlpCircuitConfig { meta.create_gate("stack constraints", |meta| { let mut cb = BaseConstraintBuilder::default(); - // Universal Stack Constraints - cb.require_equal( - "stack ptr (address) must correspond exactly to depth", - meta.query_advice(depth, Rotation::cur()), - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), - ); cb.condition(not::expr(is_end(meta)), |cb| { cb.require_equal( "each row must have a stack operation", @@ -1715,20 +1715,10 @@ impl RlpCircuitConfig { "stack inits at depth 0", meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), ); - cb.require_equal( - "stack init pushes all remaining_bytes onto depth 0", - meta.query_advice(rlp_decoding_table.value, Rotation::cur()), - meta.query_advice(byte_rev_idx, Rotation::cur()), - ); - // tx1559_debug // cb.require_equal( - // "stack_acc accumulates depth 0 bytes at 1", - // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), - // 1.expr() - // ); - // cb.require_zero( - // "stack accumulator starts at 0", - // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + // "stack init pushes all remaining_bytes onto depth 0", + // meta.query_advice(rlp_decoding_table.value, Rotation::cur()), + // meta.query_advice(byte_rev_idx, Rotation::cur()), // ); }, ); @@ -1741,28 +1731,6 @@ impl RlpCircuitConfig { "The higher depth must have 0 bytes.", meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), ); - cb.require_equal( - "PUSH stack operation increases depth", - meta.query_advice(rlp_decoding_table.depth, Rotation::prev()) + 1.expr(), - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), - ); - // tx1559_debug - // cb.require_equal( - // "stack_acc accumulates next depth level at exponent +1 of challenge", - // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()) * challenges.keccak_input(), - // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), - // ); - // cb.require_equal( - // "stack_acc accumulates remaining bytes from previous depth level", - // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) - // + (meta.query_advice(rlp_decoding_table.value, Rotation::prev()) - // - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) - // // 1 byte needs to be subtracted here as the step preceding the PUSH reads one byte from the lower depth - // // This byte is already consumed and won't be added to the accumulator - // - 1.expr()) - // * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), - // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), - // ); }, ); @@ -1770,27 +1738,9 @@ impl RlpCircuitConfig { cb.condition( meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), |cb| { - cb.require_equal( - "POP stack operation decreases depth", - meta.query_advice(rlp_decoding_table.depth, Rotation::prev()), - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) + 1.expr(), - ); - cb.require_zero( - "POP can only happen if there's no more bytes to decode on the higher depth", - meta.query_advice(rlp_decoding_table.value, Rotation::prev()), - ); - // tx1559_debug - // cb.require_equal( - // "stack_acc accumulates lower depth level at exponent -1 of challenge", - // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), - // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()) * challenges.keccak_input(), - // ); - // cb.require_equal( - // "stack_acc releases remaining bytes from previous depth level", - // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()) - // - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) - // * meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), - // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), + // cb.require_zero( + // "POP can only happen if there's no more bytes to decode on the higher depth", + // meta.query_advice(rlp_decoding_table.value, Rotation::prev()), // ); }, ); @@ -1814,17 +1764,6 @@ impl RlpCircuitConfig { meta.query_advice(rlp_decoding_table.value, Rotation::prev()), meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), ); - // tx1559_debug - // cb.require_equal( - // "UPDATE doesn't change stack_acc", - // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::prev()), - // meta.query_advice(rlp_decoding_table.stack_acc, Rotation::cur()), - // ); - // cb.require_equal( - // "stack_acc accumulates same depth level at the same exponent of challenge", - // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::prev()), - // meta.query_advice(rlp_decoding_table.stack_acc_pow_of_rand, Rotation::cur()), - // ); }, ); diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index 06dc403291..a1d5cd890d 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,6 +110,7 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ + // tx1559_debug // empty access list "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", // same as third test but with abridged access list diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index cc76ec3c41..852623425d 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -763,9 +763,9 @@ pub struct StateMachine { pub gas_cost_acc: Value, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub enum StackOp { - Init, + #[default] Init, Push, Pop, Update, @@ -774,68 +774,113 @@ pub enum StackOp { /// Rlp Decoding Witness /// Using simulated stack constraints to make sure all bytes in nested structure are correctly /// decoded -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct RlpStackOp { /// Key1 (Id), concat of tx_id, format pub id: Value, + /// Transaction Id + pub tx_id: u64, + /// Format + pub format: Format, /// Key2 (Address), in this case depth pub depth: usize, + /// Op Counter, similar to rw counter + pub byte_idx: usize, /// Value pub value: usize, /// Value Previous pub value_prev: usize, /// The stack operation performed at step. pub stack_op: StackOp, + /// Access list index + pub al_idx: u64, + /// Storage key index + pub sk_idx: u64, } impl RlpStackOp { - pub fn init(id: Value, value: usize) -> Self { + pub fn init(id: Value, tx_id: u64, format: Format, value: usize) -> Self { Self { id, + tx_id, + format, depth: 0, + byte_idx: 0, value, value_prev: 0, stack_op: StackOp::Init, + al_idx: 0, + sk_idx: 0, } } pub fn push( id: Value, + tx_id: u64, + format: Format, + byte_idx: usize, depth: usize, value: usize, + al_idx: u64, + sk_idx: u64, ) -> Self { Self { id, + tx_id, + format, depth, + byte_idx, value, value_prev: 0, stack_op: StackOp::Push, + al_idx, + sk_idx, } } pub fn pop( id: Value, + tx_id: u64, + format: Format, + byte_idx: usize, depth: usize, value: usize, value_prev: usize, + al_idx: u64, + sk_idx: u64, ) -> Self { Self { id, + tx_id, + format, depth, + byte_idx, value, value_prev, stack_op: StackOp::Pop, + al_idx, + sk_idx, } } pub fn update( id: Value, + tx_id: u64, + format: Format, + byte_idx: usize, depth: usize, value: usize, + al_idx: u64, + sk_idx: u64, ) -> Self { Self { id, + tx_id, + format, depth, + byte_idx, value, value_prev: value + 1, stack_op: StackOp::Update, + al_idx, + sk_idx, } } } diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 16c5ee96b7..01b65ecfd2 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -15,7 +15,7 @@ use crate::{ Tag::{EndObject, EndVector}, }, }; -use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}; +use bus_mapping::{circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}, operation::StackOp}; use eth_types::{ evm_types::gas_utils::{tx_access_list_gas_cost, tx_data_gas_cost}, geth_types::{access_list_size, TxType, TxType::PreEip155}, @@ -523,7 +523,7 @@ impl Transaction { let mut cur_rom_row = vec![0]; let mut remaining_bytes = vec![rlp_bytes.len()]; // initialize stack - stack_ops.push(RlpStackOp::init(id, rlp_bytes.len())); + stack_ops.push(RlpStackOp::init(id, tx_id, format, rlp_bytes.len())); let mut witness_table_idx = 0; // This map keeps track @@ -563,9 +563,14 @@ impl Transaction { stack_ops.push(RlpStackOp::pop( id, + tx_id, + format, + cur.byte_idx, cur.depth - 1, byte_remained, prev_bytes_on_depth[cur.depth - 1], + access_list_idx, + storage_key_idx, )); } @@ -612,8 +617,13 @@ impl Transaction { // add stack op on same depth stack_ops.push(RlpStackOp::update( id, + tx_id, + format, + cur.byte_idx, cur.depth, *rem - 1, + access_list_idx, + storage_key_idx, )); } @@ -697,8 +707,13 @@ impl Transaction { stack_ops.push(RlpStackOp::push( id, + tx_id, + format, + cur.byte_idx, cur.depth + 1, num_bytes_of_new_list, + access_list_idx, + storage_key_idx, )); next.depth = cur.depth + 1; @@ -724,8 +739,13 @@ impl Transaction { // add stack op on same depth stack_ops.push(RlpStackOp::update( id, + tx_id, + format, + cur.byte_idx, cur.depth, *rem - 1, + access_list_idx, + storage_key_idx, )); *rem -= 1; @@ -758,8 +778,13 @@ impl Transaction { // add stack op on same depth stack_ops.push(RlpStackOp::update( id, + tx_id, + format, + cur.byte_idx, cur.depth, *rem - 1, + access_list_idx, + storage_key_idx, )); *rem -= 1; @@ -791,8 +816,13 @@ impl Transaction { if cur.tag_idx < cur.tag_length { stack_ops.push(RlpStackOp::update( id, + tx_id, + format, + cur.byte_idx, cur.depth, *rem - 1, + access_list_idx, + storage_key_idx, )); } @@ -818,8 +848,13 @@ impl Transaction { remaining_bytes.push(lb_len); stack_ops.push(RlpStackOp::push( id, + tx_id, + format, + cur.byte_idx, cur.depth + 1, lb_len, + access_list_idx, + storage_key_idx, )); next.depth = cur.depth + 1; next.state = DecodeTagStart; @@ -888,7 +923,8 @@ impl Transaction { RlpTag::Null => unreachable!("Null is not used"), }; - let stack_op = stack_ops.remove(0); + // tx1559_debug + // let stack_op = stack_ops.remove(0); witness.push(RlpFsmWitnessRow { rlp_table: RlpTable { @@ -917,8 +953,11 @@ impl Transaction { bytes_rlc, gas_cost_acc, }, - rlp_decoding_table: stack_op, + // tx1559_debug + rlp_decoding_table: RlpStackOp::default(), + // rlp_decoding_table: stack_op, }); + witness_table_idx += 1; if cur.tag == EndObject && cur.depth == 0 { @@ -926,6 +965,44 @@ impl Transaction { } cur = next; } + + assert_eq!(stack_ops.len(), witness.len(), "Number of stack_ops must be equal to byte count"); + + // Sort the RlpStackOps and assign to the RlpDecodingTable part of witness + stack_ops.sort_by(|a, b| + if ( + a.tx_id, + a.format as u64, + a.depth, + a.byte_idx, + a.al_idx, + a.sk_idx, + // The stack_op is included in the sorting to + // ensure that the Init step (with byte_idx = 0) is the first row + // before the first update on depth 0 (also with byte_idx = 0) + a.stack_op.clone() as u64 + ) > ( + b.tx_id, + b.format as u64, + b.depth, + b.byte_idx, + b.al_idx, + b.sk_idx, + // The stack_op is included in the sorting to + // ensure that the Init step (with byte_idx = 0) is the first row + // before the first update on depth 0 (also with byte_idx = 0) + b.stack_op.clone() as u64 + ) { + std::cmp::Ordering::Greater + } else { + std::cmp::Ordering::Less + } + ); + + for (idx, op) in stack_ops.into_iter().enumerate() { + witness[idx].rlp_decoding_table = op; + } + // filling up the `tag_next` col of the witness table let mut idx = 0; for (witness_idx, rom_table_row) in tag_rom_row_map { @@ -936,6 +1013,9 @@ impl Transaction { } } + // tx1559_debug + log::trace!("=> witness: {:?}", witness); + witness } From 4ad0b760df4b082c442ff7dc11656497ac6bd443 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 24 Dec 2023 19:52:01 -0800 Subject: [PATCH 132/161] add lookup from rlp_table --- zkevm-circuits/src/rlp_circuit_fsm.rs | 101 +++++++++++++++++++++----- 1 file changed, 81 insertions(+), 20 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 3619afa6df..25706a198f 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -186,8 +186,6 @@ pub struct RlpDecodingTable { pub id: Column, /// Key2 (Address), in this case depth pub depth: Column, - /// Op Counter, byte_idx - pub byte_idx: Column, /// Value pub value: Column, /// Value Previous @@ -212,12 +210,8 @@ impl RlpDecodingTable { Self { id: meta.advice_column(), depth: meta.advice_column(), - byte_idx: meta.advice_column(), value: meta.advice_column(), value_prev: meta.advice_column(), - // tx1559_debug - // stack_acc: meta.advice_column_in(SecondPhase), - // stack_acc_pow_of_rand: meta.advice_column_in(SecondPhase), is_stack_init: meta.advice_column(), is_stack_push: meta.advice_column(), is_stack_pop: meta.advice_column(), @@ -1586,6 +1580,66 @@ impl RlpCircuitConfig { cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }); + // With each access list increments (a new access list or storage key), + // it must be accompanied by the correct PUSH onto a new depth in RlpDecodingTable + meta.lookup_any("New access list must correspond to a new PUSH to level 3 in RlpDecodingTable", |meta| { + let enable = and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + meta.query_advice(is_new_access_list_address, Rotation::cur()), + ]); + + let input_exprs = vec![ + 3.expr(), // depth for new access list is 3 + 1.expr(), // is_push = true + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()) - 1.expr(), + 0.expr(), // new access list has sk_idx = 0 + ]; + let table_exprs = vec![ + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + meta.query_advice(rlp_decoding_table.al_idx, Rotation::cur()), + meta.query_advice(rlp_decoding_table.sk_idx, Rotation::cur()), + ]; + input_exprs + .into_iter() + .zip(table_exprs) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }); + meta.lookup_any("New access list must correspond to a new PUSH to level 3 in RlpDecodingTable", |meta| { + let enable = and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + meta.query_advice(is_new_access_list_address, Rotation::cur()), + ]); + + let input_exprs = vec![ + 4.expr(), // depth for new access list is 3 + 1.expr(), // is_push = true + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), + ]; + let table_exprs = vec![ + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + meta.query_advice(rlp_decoding_table.al_idx, Rotation::cur()), + meta.query_advice(rlp_decoding_table.sk_idx, Rotation::cur()), + ]; + input_exprs + .into_iter() + .zip(table_exprs) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }); + + + // Then in the above example, we "would" make two lookups to the RlpDecodingTable with input exprs as + + // (tx_id, format, al_idx = 2, sk_idx, depth, value=value_prev - 800, value_prev); + // (tx_id, format, al_idx = 2+1, sk_idx = 0, depth + 1, value=800, value_prev=0); + + + + // Access List Clearing // note: right now no other nested structures are defined at these depth levels // hence using depth alone is sufficient to determine clearing conditions. @@ -1936,6 +1990,13 @@ impl RlpCircuitConfig { )?; // assign to rlp decoding table + + // /// Access list idx + // pub al_idx: Column, + // /// Storage key idx + // pub sk_idx: Column, + + region.assign_advice( || "rlp_decoding_table.id", self.rlp_decoding_table.id, @@ -1943,7 +2004,7 @@ impl RlpCircuitConfig { || witness.rlp_decoding_table.id, )?; region.assign_advice( - || "rlp_decoding_table.address", + || "rlp_decoding_table.depth", self.rlp_decoding_table.depth, row, || Value::known(F::from(witness.rlp_decoding_table.depth as u64)), @@ -1960,19 +2021,7 @@ impl RlpCircuitConfig { row, || Value::known(F::from(witness.rlp_decoding_table.value_prev as u64)), )?; - // tx1559_debug - // region.assign_advice( - // || "rlp_decoding_table.stack_acc", - // self.rlp_decoding_table.stack_acc, - // row, - // || witness.rlp_decoding_table.stack_acc, - // )?; - // region.assign_advice( - // || "rlp_decoding_table.stack_acc_pow_of_rand", - // self.rlp_decoding_table.stack_acc_pow_of_rand, - // row, - // || witness.rlp_decoding_table.stack_acc_pow_of_rand, - // )?; + region.assign_advice( || "rlp_decoding_table.is_stack_init", self.rlp_decoding_table.is_stack_init, @@ -2013,6 +2062,18 @@ impl RlpCircuitConfig { )) }, )?; + region.assign_advice( + || "rlp_decoding_table.al_idx", + self.rlp_decoding_table.al_idx, + row, + || Value::known(F::from(witness.rlp_decoding_table.al_idx as u64)), + )?; + region.assign_advice( + || "rlp_decoding_table.sk_idx", + self.rlp_decoding_table.sk_idx, + row, + || Value::known(F::from(witness.rlp_decoding_table.sk_idx as u64)), + )?; let is_new_access_list_address = witness.state_machine.state == DecodeTagStart && witness.state_machine.tag == AccessListAddress; From 55dc0308225f11b23c05113d3f74337e1cef4fda Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 24 Dec 2023 19:52:46 -0800 Subject: [PATCH 133/161] comment correction --- zkevm-circuits/src/rlp_circuit_fsm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 25706a198f..1019441929 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1606,7 +1606,7 @@ impl RlpCircuitConfig { .map(|(input, table)| (input * enable.expr(), table)) .collect() }); - meta.lookup_any("New access list must correspond to a new PUSH to level 3 in RlpDecodingTable", |meta| { + meta.lookup_any("New storage key must correspond to a new PUSH to level 4 in RlpDecodingTable", |meta| { let enable = and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), meta.query_advice(is_new_access_list_address, Rotation::cur()), From 637cb669f7a07fffc006d71bcacba484d5390d8f Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 24 Dec 2023 23:19:10 -0800 Subject: [PATCH 134/161] add depth constraint decoding table --- zkevm-circuits/src/rlp_circuit_fsm.rs | 128 ++++++++++++++------- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 4 +- zkevm-circuits/src/witness/tx.rs | 24 ++-- 3 files changed, 100 insertions(+), 56 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 1019441929..54f84e7663 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -186,6 +186,9 @@ pub struct RlpDecodingTable { pub id: Column, /// Key2 (Address), in this case depth pub depth: Column, + /// Byte idx for comparing with state machine + /// Byte idx is also used as Op counter similar to rw counter + pub byte_idx: Column, /// Value pub value: Column, /// Value Previous @@ -210,6 +213,7 @@ impl RlpDecodingTable { Self { id: meta.advice_column(), depth: meta.advice_column(), + byte_idx: meta.advice_column(), value: meta.advice_column(), value_prev: meta.advice_column(), is_stack_init: meta.advice_column(), @@ -1581,22 +1585,27 @@ impl RlpCircuitConfig { }); // With each access list increments (a new access list or storage key), - // it must be accompanied by the correct PUSH onto a new depth in RlpDecodingTable - meta.lookup_any("New access list must correspond to a new PUSH to level 3 in RlpDecodingTable", |meta| { + // it must be accompanied by the correct PUSH or UPDATE on the right depth in RlpDecodingTable + meta.lookup_any("New access list item must correspond to an UPDATE on level 3 in RlpDecodingTable", |meta| { let enable = and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), meta.query_advice(is_new_access_list_address, Rotation::cur()), ]); let input_exprs = vec![ + challenges.keccak_input() * meta.query_advice(rlp_table.tx_id, Rotation::cur()) + meta.query_advice(rlp_table.format, Rotation::cur()), 3.expr(), // depth for new access list is 3 - 1.expr(), // is_push = true - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()) - 1.expr(), + // Use byte_idx to constrain correct decoding position of new access list item + meta.query_advice(byte_idx, Rotation::cur()), + 1.expr(), // is_update = true + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), 0.expr(), // new access list has sk_idx = 0 ]; let table_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + meta.query_advice(rlp_decoding_table.byte_idx, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), meta.query_advice(rlp_decoding_table.al_idx, Rotation::cur()), meta.query_advice(rlp_decoding_table.sk_idx, Rotation::cur()), ]; @@ -1606,21 +1615,26 @@ impl RlpCircuitConfig { .map(|(input, table)| (input * enable.expr(), table)) .collect() }); - meta.lookup_any("New storage key must correspond to a new PUSH to level 4 in RlpDecodingTable", |meta| { + meta.lookup_any("New storage key must correspond to either a new PUSH to level 4 or an UPDATE on level 4 in RlpDecodingTable", |meta| { let enable = and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), - meta.query_advice(is_new_access_list_address, Rotation::cur()), + meta.query_advice(is_new_access_list_storage_key, Rotation::cur()), ]); let input_exprs = vec![ - 4.expr(), // depth for new access list is 3 - 1.expr(), // is_push = true + challenges.keccak_input() * meta.query_advice(rlp_table.tx_id, Rotation::cur()) + meta.query_advice(rlp_table.format, Rotation::cur()), + 4.expr(), // depth for new storage key is 4 + // Use byte_idx to constrain correct decoding position of new storage key item + meta.query_advice(byte_idx, Rotation::cur()), + 1.expr(), // is_push = true || is_update = true meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), meta.query_advice(rlp_table.storage_key_idx, Rotation::cur()), ]; let table_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + meta.query_advice(rlp_decoding_table.byte_idx, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()) + meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), meta.query_advice(rlp_decoding_table.al_idx, Rotation::cur()), meta.query_advice(rlp_decoding_table.sk_idx, Rotation::cur()), ]; @@ -1631,15 +1645,6 @@ impl RlpCircuitConfig { .collect() }); - - // Then in the above example, we "would" make two lookups to the RlpDecodingTable with input exprs as - - // (tx_id, format, al_idx = 2, sk_idx, depth, value=value_prev - 800, value_prev); - // (tx_id, format, al_idx = 2+1, sk_idx = 0, depth + 1, value=800, value_prev=0); - - - - // Access List Clearing // note: right now no other nested structures are defined at these depth levels // hence using depth alone is sufficient to determine clearing conditions. @@ -1769,14 +1774,38 @@ impl RlpCircuitConfig { "stack inits at depth 0", meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), ); - // cb.require_equal( - // "stack init pushes all remaining_bytes onto depth 0", - // meta.query_advice(rlp_decoding_table.value, Rotation::cur()), - // meta.query_advice(byte_rev_idx, Rotation::cur()), - // ); + cb.require_equal( + "stack init pushes all remaining_bytes onto depth 0", + meta.query_advice(rlp_decoding_table.value, Rotation::cur()), + meta.query_advice(byte_rev_idx, Rotation::cur()), + ); + }, + ); + + // Stack depth must be equal or only increment by 1 when not initiating + cb.condition( + not::expr(meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur())), + |cb| { + cb.require_zero( + "stack depth stays the same or increments by 1", + ( + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) + - meta.query_advice(rlp_decoding_table.depth, Rotation::prev()) + ) * ( + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) + - meta.query_advice(rlp_decoding_table.depth, Rotation::prev()) + - 1.expr() + ), + ); }, ); + + + + + + // Stack Push cb.condition( meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), @@ -1785,19 +1814,35 @@ impl RlpCircuitConfig { "The higher depth must have 0 bytes.", meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), ); + cb.require_zero( + "Before a new PUSH, all previous bytes must be processed.", + meta.query_advice(rlp_decoding_table.value, Rotation::prev()), + ); }, ); // Stack Pop - cb.condition( - meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), - |cb| { - // cb.require_zero( - // "POP can only happen if there's no more bytes to decode on the higher depth", - // meta.query_advice(rlp_decoding_table.value, Rotation::prev()), - // ); - }, - ); + // cb.condition( + // meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), + // |cb| { + // // cb.require_zero( + // // "POP can only happen if there's no more bytes to decode on the higher depth", + // // meta.query_advice(rlp_decoding_table.value, Rotation::prev()), + // // ); + + + + + // // Then in the above example, we "would" make two lookups to the RlpDecodingTable with input exprs as + + // // (tx_id, format, al_idx = 2, sk_idx, depth, value=value_prev - 800, value_prev); + // // (tx_id, format, al_idx = 2+1, sk_idx = 0, depth + 1, value=800, value_prev=0); + + + + + // }, + // ); // Stack Update Top cb.condition( @@ -1989,14 +2034,7 @@ impl RlpCircuitConfig { || Value::known(F::from(witness.rlp_table.storage_key_idx)), )?; - // assign to rlp decoding table - - // /// Access list idx - // pub al_idx: Column, - // /// Storage key idx - // pub sk_idx: Column, - - + // RlpDecodingTable assignments region.assign_advice( || "rlp_decoding_table.id", self.rlp_decoding_table.id, @@ -2074,6 +2112,12 @@ impl RlpCircuitConfig { row, || Value::known(F::from(witness.rlp_decoding_table.sk_idx as u64)), )?; + region.assign_advice( + || "rlp_decoding_table.byte_idx", + self.rlp_decoding_table.byte_idx, + row, + || Value::known(F::from(witness.rlp_decoding_table.byte_idx as u64)), + )?; let is_new_access_list_address = witness.state_machine.state == DecodeTagStart && witness.state_machine.tag == AccessListAddress; @@ -2351,7 +2395,7 @@ impl RlpCircuitConfig { || "q_enable", self.rlp_table.q_enable, row, - || Value::known(F::one()), + || Value::known(F::zero()), )?; region.assign_advice( || "sm.state", diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index a1d5cd890d..60b508119c 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -112,9 +112,9 @@ fn test_eip1559_tx() { let test_bytes = vec![ // tx1559_debug // empty access list - "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", + // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", // same as third test but with abridged access list - "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + // "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", // unabridged access list "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 01b65ecfd2..063d809cc5 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -953,9 +953,8 @@ impl Transaction { bytes_rlc, gas_cost_acc, }, - // tx1559_debug + // The stack operations will be later sorted and assigned rlp_decoding_table: RlpStackOp::default(), - // rlp_decoding_table: stack_op, }); witness_table_idx += 1; @@ -966,7 +965,7 @@ impl Transaction { cur = next; } - assert_eq!(stack_ops.len(), witness.len(), "Number of stack_ops must be equal to byte count"); + assert_eq!(stack_ops.len(), witness.len(), "Number of stack_ops must be equal to witness length"); // Sort the RlpStackOps and assign to the RlpDecodingTable part of witness stack_ops.sort_by(|a, b| @@ -974,6 +973,8 @@ impl Transaction { a.tx_id, a.format as u64, a.depth, + // Using byte_idx alone is sufficient for ensuring ordered al_idx and sk_idx + // as access_list is processed in order a.byte_idx, a.al_idx, a.sk_idx, @@ -986,11 +987,8 @@ impl Transaction { b.format as u64, b.depth, b.byte_idx, - b.al_idx, - b.sk_idx, - // The stack_op is included in the sorting to - // ensure that the Init step (with byte_idx = 0) is the first row - // before the first update on depth 0 (also with byte_idx = 0) + a.al_idx, + a.sk_idx, b.stack_op.clone() as u64 ) { std::cmp::Ordering::Greater @@ -998,11 +996,16 @@ impl Transaction { std::cmp::Ordering::Less } ); - + + // tx1559_debug + // log::trace!("=> stack_ops: {:?}", stack_ops); + for (idx, op) in stack_ops.into_iter().enumerate() { witness[idx].rlp_decoding_table = op; } + // log::trace!("=> witness: {:?}", witness); + // filling up the `tag_next` col of the witness table let mut idx = 0; for (witness_idx, rom_table_row) in tag_rom_row_map { @@ -1013,9 +1016,6 @@ impl Transaction { } } - // tx1559_debug - log::trace!("=> witness: {:?}", witness); - witness } From ef62a79ffbbd2a1d380baa66cc5e0f1bfaaf1148 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 24 Dec 2023 23:57:32 -0800 Subject: [PATCH 135/161] add cross-depth lookup in decoding table --- zkevm-circuits/src/rlp_circuit_fsm.rs | 86 ++++++++++++++-------- zkevm-circuits/src/rlp_circuit_fsm/test.rs | 5 +- zkevm-circuits/src/witness/tx.rs | 10 +-- 3 files changed, 59 insertions(+), 42 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 54f84e7663..7f4b987c72 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1782,7 +1782,7 @@ impl RlpCircuitConfig { }, ); - // Stack depth must be equal or only increment by 1 when not initiating + // Stack depth must stay same or only increment by 1 when the stack is not initiating cb.condition( not::expr(meta.query_advice(rlp_decoding_table.is_stack_init, Rotation::cur())), |cb| { @@ -1800,12 +1800,6 @@ impl RlpCircuitConfig { }, ); - - - - - - // Stack Push cb.condition( meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), @@ -1821,29 +1815,6 @@ impl RlpCircuitConfig { }, ); - // Stack Pop - // cb.condition( - // meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), - // |cb| { - // // cb.require_zero( - // // "POP can only happen if there's no more bytes to decode on the higher depth", - // // meta.query_advice(rlp_decoding_table.value, Rotation::prev()), - // // ); - - - - - // // Then in the above example, we "would" make two lookups to the RlpDecodingTable with input exprs as - - // // (tx_id, format, al_idx = 2, sk_idx, depth, value=value_prev - 800, value_prev); - // // (tx_id, format, al_idx = 2+1, sk_idx = 0, depth + 1, value=800, value_prev=0); - - - - - // }, - // ); - // Stack Update Top cb.condition( meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), @@ -1883,6 +1854,61 @@ impl RlpCircuitConfig { cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }); + // Additional cross-depth stack constraints in the RlpDecodingTable + meta.lookup_any("Each stack PUSH must correspond exactly to a POP into a lower depth level", |meta| { + let enable = and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + ]); + + let input_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) - 1.expr(), + 1.expr(), // is_pop = true + meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + 1.expr(), + ]; + let table_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()) - meta.query_advice(rlp_decoding_table.value, Rotation::cur()), + ]; + input_exprs + .into_iter() + .zip(table_exprs) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }); + // // (al_idx = 2, sk_idx, depth, value=value_prev - 800, value_prev); + // // (al_idx = 2+1, sk_idx = 0, depth + 1, value=800, value_prev=0); + + meta.lookup_any("Each stack POP must correspond exactly to a PUSH into a higher depth level", |meta| { + let enable = and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), + ]); + + let input_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) + 1.expr(), + 1.expr(), // is_push = true + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()) - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) - 1.expr(), + 0.expr(), // value_prev = 0 + ]; + let table_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + meta.query_advice(rlp_decoding_table.value, Rotation::cur()), + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), + ]; + input_exprs + .into_iter() + .zip(table_exprs) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }); + debug_assert!(meta.degree() <= 9); Self { diff --git a/zkevm-circuits/src/rlp_circuit_fsm/test.rs b/zkevm-circuits/src/rlp_circuit_fsm/test.rs index 60b508119c..06dc403291 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/test.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/test.rs @@ -110,11 +110,10 @@ fn test_l1_msg_tx() { #[test] fn test_eip1559_tx() { let test_bytes = vec![ - // tx1559_debug // empty access list - // "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", + "02f8b1010a8404a75411850f705051f08301724b94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb0000000000000000000000006c57d84c55b01f7022999f6c0f95daf0e319dc37000000000000000000000000000000000000000000000000000000003b9aca00c001a0634f6d4b3b4fc658c2c26c1ba0966bd39d7e993b815390f1e778af9cf28d2c22a05410b97e41240ea25eb6250e1af7554cda8991bc4159228c43cfb240503d9870", // same as third test but with abridged access list - // "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", + "02f9025d01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef893f7940b85b3000bef3e26e01428d1b525a532ea7513b8e1a00000000000000000000000000000000000000000000000000000000000000006f85994c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f842a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33e80a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", // unabridged access list "02f90b7b01825cb38520955af4328521cf92558d830a1bff9400fc00900000002c00be4ef8f49c000211000c43830cc4d0b9015504673a0b85b3000bef3e26e01428d1b525a532ea7513b8f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097020c532d1b995b7e3e37a1aa6369386e5939053779abd3597508b00129cd75b800073edec02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f21661d0d1d76d3ecb8e1b9f1c923dbfffae40970bb86c3dc790b0d7291f864244b559b59b30f850a8cfb40dc7c53760375530e5af29fded5e139893252993820686c92b000094b61ba302f01b0f027d40c80d8f70f77d3884776531f80b21d20e5a6b806300024b2c713b4502988e070f96cf3bea50b4811cd5844e13a81b61a8078c761b0b85b3000bef3e26e01428d1b525a532ea7513b80002594ea302f03b9eb369241e4270796e665ea1afac355cb99f0c32078ab8ba00013c08711b06ed871e5a66bebf0af6fb768d343b1d14a04b5b34ab10cf761b0b85b3000bef3e26e01428d1b525a532ea7513b8000143542ef909b0f89b940b85b3000bef3e26e01428d1b525a532ea7513b8f884a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008f8dd94c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2f8c6a0e1dd9768c9de657aca2536cf1cdd1c4536b13ec81ff764307ea8312aa7a8790da070bc879403c8b875e45ea7afbb591f1fd4bde469db47d5f0e879e44c6798d33ea0f88aa3ad276c350a067c34b2bed705e1a2cd30c7c3154f62ece8ee00939bbd2ea0be11b0e2ba48478671bfcd8fd182e025c26fbfbcf4fdf6952051d6147955a36fa09a1a5a7ef77f3399dea2a1044425aaca7fec294fdfdcacd7a960c9c94d15f0a6a091828b9b711948523369ff1651b6332e98f75bcd940a551dc7247d5af88e71faf8bc945b7e3e37a1aa6369386e5939053779abd3597508f8a5a00000000000000000000000000000000000000000000000000000000000000004a00000000000000000000000000000000000000000000000000000000000000002a0697b2bd7bb2984c4e0dc14c79c987d37818484a62958b9c45a0e8b962f20650fa00000000000000000000000000000000000000000000000000000000000000009a00000000000000000000000000000000000000000000000000000000000000000f9018394c7c53760375530e5af29fded5e13989325299382f9016ba00000000000000000000000000000000000000000000000000000000000000010a0000000000000000000000000000000000000000000000000000000000000000ba00000000000000000000000000000000000000000000000000000000000000016a0000000000000000000000000000000000000000000000000000000000000000ea051d155e8243cd6886ab3b36f59778d90f3bbb4af820bc2d4536b23ca13814bfba00000000000000000000000000000000000000000000000000000000000000013a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000ca0bda2b1a2a3e35ca431f3c4b50639098537d215591b9ca3db95c24c01795a9981a0000000000000000000000000000000000000000000000000000000000000000df89b94c790b0d7291f864244b559b59b30f850a8cfb40df884a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd9406ed871e5a66bebf0af6fb768d343b1d14a04b5bf8c6a0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000af8bc94f21661d0d1d76d3ecb8e1b9f1c923dbfffae4097f8a5a04d3eb812b43a439547ce41ef251d01e8ad3d0dad3fde6f2bed3d0c0e29dcdd7aa026644b9dbbd32f8882f3abce5ac1575313789ab081b0fe9f3f39c946527bfa27a072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb776014a0a7609b0290b911c4b52861d3739b36793fd0e23d9ef78cf2fa96dd1b0cbc764da01a3159eb932a0bb66f4d5b9c1cb119796d815774e3c4904b36748d7870d915c2f8dd940f027d40c80d8f70f77d3884776531f80b21d20ef8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8bc941a76bffd6d1fc1660e1d0e0552fde51ddbb120cff8a5a06d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6dfa030e699f4646032d62d40ca795ecffcb27a2d9d2859f21626b5a588210198e7a6a0c929f5ae32c0eabfbdd06198210bc49736d88e6501f814a66dd5b2fa59508b3ea0ea52bdd009b752a3e91262d66aae31638bc36b449d247d61d646b87a733d7d5da0877978b096db3b11862d0cdfe5f5b74f30fd7d5d29e8ce80626ed8a8bbef1beef8dd944502988e070f96cf3bea50b4811cd5844e13a81bf8c6a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007f8dd949eb369241e4270796e665ea1afac355cb99f0c32f8c6a00000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000007a00000000000000000000000000000000000000000000000000000000000000009a0000000000000000000000000000000000000000000000000000000000000000aa0000000000000000000000000000000000000000000000000000000000000000cf85994f9a2d7e60a3297e513317ad1d7ce101cc4c6c8f6f842a04b376a11d00750d42abab4d4e465d5dc4d9b1286d77cf0c819f028213ea08bdfa072fd74a6edf1b99d41f2c81c57f871e198cb7a24fd9861e998221c4aeb77601480a0d274986e36e16ec2d4846168d59422f68e4b8ec41690b80bdd2ee65819f238eea03d0394f6daae31ba5a276a3741cc2b3ba79b90024f80df865622a62078e72910", ]; diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 063d809cc5..e2a2c2ff62 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -15,7 +15,7 @@ use crate::{ Tag::{EndObject, EndVector}, }, }; -use bus_mapping::{circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}, operation::StackOp}; +use bus_mapping::circuit_input_builder::{self, get_dummy_tx_hash, TxL1Fee}; use eth_types::{ evm_types::gas_utils::{tx_access_list_gas_cost, tx_data_gas_cost}, geth_types::{access_list_size, TxType, TxType::PreEip155}, @@ -923,9 +923,6 @@ impl Transaction { RlpTag::Null => unreachable!("Null is not used"), }; - // tx1559_debug - // let stack_op = stack_ops.remove(0); - witness.push(RlpFsmWitnessRow { rlp_table: RlpTable { tx_id, @@ -997,15 +994,10 @@ impl Transaction { } ); - // tx1559_debug - // log::trace!("=> stack_ops: {:?}", stack_ops); - for (idx, op) in stack_ops.into_iter().enumerate() { witness[idx].rlp_decoding_table = op; } - // log::trace!("=> witness: {:?}", witness); - // filling up the `tag_next` col of the witness table let mut idx = 0; for (witness_idx, rom_table_row) in tag_rom_row_map { From 5a8f6b44012c9f6607587485dc3d4e7ff7f617cd Mon Sep 17 00:00:00 2001 From: darth-cy Date: Sun, 24 Dec 2023 23:58:46 -0800 Subject: [PATCH 136/161] fmt --- zkevm-circuits/src/rlp_circuit_fsm.rs | 191 ++++++++++++++------------ zkevm-circuits/src/witness/rlp_fsm.rs | 3 +- zkevm-circuits/src/witness/tx.rs | 16 ++- 3 files changed, 113 insertions(+), 97 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 7f4b987c72..3a87f4b098 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -1585,36 +1585,41 @@ impl RlpCircuitConfig { }); // With each access list increments (a new access list or storage key), - // it must be accompanied by the correct PUSH or UPDATE on the right depth in RlpDecodingTable - meta.lookup_any("New access list item must correspond to an UPDATE on level 3 in RlpDecodingTable", |meta| { - let enable = and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - meta.query_advice(is_new_access_list_address, Rotation::cur()), - ]); - - let input_exprs = vec![ - challenges.keccak_input() * meta.query_advice(rlp_table.tx_id, Rotation::cur()) + meta.query_advice(rlp_table.format, Rotation::cur()), - 3.expr(), // depth for new access list is 3 - // Use byte_idx to constrain correct decoding position of new access list item - meta.query_advice(byte_idx, Rotation::cur()), - 1.expr(), // is_update = true - meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), - 0.expr(), // new access list has sk_idx = 0 - ]; - let table_exprs = vec![ - meta.query_advice(rlp_decoding_table.id, Rotation::cur()), - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), - meta.query_advice(rlp_decoding_table.byte_idx, Rotation::cur()), - meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), - meta.query_advice(rlp_decoding_table.al_idx, Rotation::cur()), - meta.query_advice(rlp_decoding_table.sk_idx, Rotation::cur()), - ]; - input_exprs - .into_iter() - .zip(table_exprs) - .map(|(input, table)| (input * enable.expr(), table)) - .collect() - }); + // it must be accompanied by the correct PUSH or UPDATE on the right depth in + // RlpDecodingTable + meta.lookup_any( + "New access list item must correspond to an UPDATE on level 3 in RlpDecodingTable", + |meta| { + let enable = and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + meta.query_advice(is_new_access_list_address, Rotation::cur()), + ]); + + let input_exprs = vec![ + challenges.keccak_input() * meta.query_advice(rlp_table.tx_id, Rotation::cur()) + + meta.query_advice(rlp_table.format, Rotation::cur()), + 3.expr(), // depth for new access list is 3 + // Use byte_idx to constrain correct decoding position of new access list item + meta.query_advice(byte_idx, Rotation::cur()), + 1.expr(), // is_update = true + meta.query_advice(rlp_table.access_list_idx, Rotation::cur()), + 0.expr(), // new access list has sk_idx = 0 + ]; + let table_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.byte_idx, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_update, Rotation::cur()), + meta.query_advice(rlp_decoding_table.al_idx, Rotation::cur()), + meta.query_advice(rlp_decoding_table.sk_idx, Rotation::cur()), + ]; + input_exprs + .into_iter() + .zip(table_exprs) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }, + ); meta.lookup_any("New storage key must correspond to either a new PUSH to level 4 or an UPDATE on level 4 in RlpDecodingTable", |meta| { let enable = and::expr([ meta.query_fixed(q_enabled, Rotation::cur()), @@ -1788,14 +1793,11 @@ impl RlpCircuitConfig { |cb| { cb.require_zero( "stack depth stays the same or increments by 1", - ( - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) - - meta.query_advice(rlp_decoding_table.depth, Rotation::prev()) - ) * ( - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) - - meta.query_advice(rlp_decoding_table.depth, Rotation::prev()) - - 1.expr() - ), + (meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) + - meta.query_advice(rlp_decoding_table.depth, Rotation::prev())) + * (meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) + - meta.query_advice(rlp_decoding_table.depth, Rotation::prev()) + - 1.expr()), ); }, ); @@ -1845,69 +1847,78 @@ impl RlpCircuitConfig { ]), |cb| { cb.require_zero( - "at the end of decoding, remaining bytes on depth level 0 should be 0.", + "at the end of decoding, remaining bytes on depth level 0 should be 0.", meta.query_advice(rlp_decoding_table.value, Rotation::cur()), ); - } + }, ); cb.gate(meta.query_fixed(q_enabled, Rotation::cur())) }); // Additional cross-depth stack constraints in the RlpDecodingTable - meta.lookup_any("Each stack PUSH must correspond exactly to a POP into a lower depth level", |meta| { - let enable = and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), - ]); - - let input_exprs = vec![ - meta.query_advice(rlp_decoding_table.id, Rotation::cur()), - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) - 1.expr(), - 1.expr(), // is_pop = true - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + 1.expr(), - ]; - let table_exprs = vec![ - meta.query_advice(rlp_decoding_table.id, Rotation::cur()), - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), - meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), - meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()) - meta.query_advice(rlp_decoding_table.value, Rotation::cur()), - ]; - input_exprs - .into_iter() - .zip(table_exprs) - .map(|(input, table)| (input * enable.expr(), table)) - .collect() - }); + meta.lookup_any( + "Each stack PUSH must correspond exactly to a POP into a lower depth level", + |meta| { + let enable = and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + ]); + + let input_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) - 1.expr(), + 1.expr(), // is_pop = true + meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + 1.expr(), + ]; + let table_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()) + - meta.query_advice(rlp_decoding_table.value, Rotation::cur()), + ]; + input_exprs + .into_iter() + .zip(table_exprs) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }, + ); // // (al_idx = 2, sk_idx, depth, value=value_prev - 800, value_prev); // // (al_idx = 2+1, sk_idx = 0, depth + 1, value=800, value_prev=0); - meta.lookup_any("Each stack POP must correspond exactly to a PUSH into a higher depth level", |meta| { - let enable = and::expr([ - meta.query_fixed(q_enabled, Rotation::cur()), - meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), - ]); - - let input_exprs = vec![ - meta.query_advice(rlp_decoding_table.id, Rotation::cur()), - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) + 1.expr(), - 1.expr(), // is_push = true - meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()) - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) - 1.expr(), - 0.expr(), // value_prev = 0 - ]; - let table_exprs = vec![ - meta.query_advice(rlp_decoding_table.id, Rotation::cur()), - meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), - meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), - meta.query_advice(rlp_decoding_table.value, Rotation::cur()), - meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), - ]; - input_exprs - .into_iter() - .zip(table_exprs) - .map(|(input, table)| (input * enable.expr(), table)) - .collect() - }); + meta.lookup_any( + "Each stack POP must correspond exactly to a PUSH into a higher depth level", + |meta| { + let enable = and::expr([ + meta.query_fixed(q_enabled, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_pop, Rotation::cur()), + ]); + + let input_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()) + 1.expr(), + 1.expr(), // is_push = true + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()) + - meta.query_advice(rlp_decoding_table.value, Rotation::cur()) + - 1.expr(), + 0.expr(), // value_prev = 0 + ]; + let table_exprs = vec![ + meta.query_advice(rlp_decoding_table.id, Rotation::cur()), + meta.query_advice(rlp_decoding_table.depth, Rotation::cur()), + meta.query_advice(rlp_decoding_table.is_stack_push, Rotation::cur()), + meta.query_advice(rlp_decoding_table.value, Rotation::cur()), + meta.query_advice(rlp_decoding_table.value_prev, Rotation::cur()), + ]; + input_exprs + .into_iter() + .zip(table_exprs) + .map(|(input, table)| (input * enable.expr(), table)) + .collect() + }, + ); debug_assert!(meta.degree() <= 9); diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 852623425d..c6c89592d3 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -765,7 +765,8 @@ pub struct StateMachine { #[derive(Clone, Debug, Default)] pub enum StackOp { - #[default] Init, + #[default] + Init, Push, Pop, Update, diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index e2a2c2ff62..365285c578 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -962,10 +962,14 @@ impl Transaction { cur = next; } - assert_eq!(stack_ops.len(), witness.len(), "Number of stack_ops must be equal to witness length"); + assert_eq!( + stack_ops.len(), + witness.len(), + "Number of stack_ops must be equal to witness length" + ); // Sort the RlpStackOps and assign to the RlpDecodingTable part of witness - stack_ops.sort_by(|a, b| + stack_ops.sort_by(|a, b| { if ( a.tx_id, a.format as u64, @@ -978,7 +982,7 @@ impl Transaction { // The stack_op is included in the sorting to // ensure that the Init step (with byte_idx = 0) is the first row // before the first update on depth 0 (also with byte_idx = 0) - a.stack_op.clone() as u64 + a.stack_op.clone() as u64, ) > ( b.tx_id, b.format as u64, @@ -986,13 +990,13 @@ impl Transaction { b.byte_idx, a.al_idx, a.sk_idx, - b.stack_op.clone() as u64 + b.stack_op.clone() as u64, ) { std::cmp::Ordering::Greater } else { std::cmp::Ordering::Less - } - ); + } + }); for (idx, op) in stack_ops.into_iter().enumerate() { witness[idx].rlp_decoding_table = op; From 817c5d39e41fdf3946b1caa8234966d00db7a341 Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 25 Dec 2023 00:02:12 -0800 Subject: [PATCH 137/161] clippy --- zkevm-circuits/src/rlp_circuit_fsm.rs | 4 ++-- zkevm-circuits/src/witness/rlp_fsm.rs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 3a87f4b098..31d1ed2cc1 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -2141,13 +2141,13 @@ impl RlpCircuitConfig { || "rlp_decoding_table.al_idx", self.rlp_decoding_table.al_idx, row, - || Value::known(F::from(witness.rlp_decoding_table.al_idx as u64)), + || Value::known(F::from(witness.rlp_decoding_table.al_idx)), )?; region.assign_advice( || "rlp_decoding_table.sk_idx", self.rlp_decoding_table.sk_idx, row, - || Value::known(F::from(witness.rlp_decoding_table.sk_idx as u64)), + || Value::known(F::from(witness.rlp_decoding_table.sk_idx)), )?; region.assign_advice( || "rlp_decoding_table.byte_idx", diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index c6c89592d3..4a650e662c 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -814,6 +814,7 @@ impl RlpStackOp { sk_idx: 0, } } + #[allow(clippy::too_many_arguments)] pub fn push( id: Value, tx_id: u64, @@ -837,6 +838,7 @@ impl RlpStackOp { sk_idx, } } + #[allow(clippy::too_many_arguments)] pub fn pop( id: Value, tx_id: u64, @@ -861,6 +863,7 @@ impl RlpStackOp { sk_idx, } } + #[allow(clippy::too_many_arguments)] pub fn update( id: Value, tx_id: u64, From b3694d021da225611ff9414e370a62f5f81515cf Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 25 Dec 2023 14:24:16 -0800 Subject: [PATCH 138/161] rm comments --- zkevm-circuits/src/witness/tx.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 365285c578..863a9c1ec0 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -974,14 +974,9 @@ impl Transaction { a.tx_id, a.format as u64, a.depth, - // Using byte_idx alone is sufficient for ensuring ordered al_idx and sk_idx - // as access_list is processed in order a.byte_idx, a.al_idx, a.sk_idx, - // The stack_op is included in the sorting to - // ensure that the Init step (with byte_idx = 0) is the first row - // before the first update on depth 0 (also with byte_idx = 0) a.stack_op.clone() as u64, ) > ( b.tx_id, From bb5a635f57f9e2fb22814ddeb983845dd38add9a Mon Sep 17 00:00:00 2001 From: darth-cy Date: Mon, 25 Dec 2023 17:01:04 -0800 Subject: [PATCH 139/161] stack op order correction --- zkevm-circuits/src/witness/tx.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index 863a9c1ec0..5d2a179328 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -558,22 +558,6 @@ impl Transaction { 0 ); - if !remaining_bytes.is_empty() { - let byte_remained = *remaining_bytes.last().unwrap(); - - stack_ops.push(RlpStackOp::pop( - id, - tx_id, - format, - cur.byte_idx, - cur.depth - 1, - byte_remained, - prev_bytes_on_depth[cur.depth - 1], - access_list_idx, - storage_key_idx, - )); - } - if cur.depth == 1 { assert_eq!(remaining_bytes.len(), 1); assert_eq!(remaining_bytes[0], 0); @@ -598,6 +582,22 @@ impl Transaction { rlp_tag = RlpTag::GasCost; } + if !remaining_bytes.is_empty() { + let byte_remained = *remaining_bytes.last().unwrap(); + + stack_ops.push(RlpStackOp::pop( + id, + tx_id, + format, + cur.byte_idx, + cur.depth - 1, + byte_remained, + prev_bytes_on_depth[cur.depth - 1], + access_list_idx, + storage_key_idx, + )); + } + // state transitions // if cur.depth == 0 then we are at the end of decoding if cur.depth > 0 { From a7a707bfff82424a0ed71c87f1be65af419db641 Mon Sep 17 00:00:00 2001 From: Steven Gu Date: Tue, 26 Dec 2023 09:51:28 +0800 Subject: [PATCH 140/161] Parse access-list from json and yaml in testool. --- testool/src/statetest/executor.rs | 2 +- testool/src/statetest/json.rs | 32 ++++++- testool/src/statetest/parse.rs | 148 +++++++++++++++++++++--------- testool/src/statetest/spec.rs | 4 +- testool/src/statetest/yaml.rs | 104 ++++++++++++++++----- 5 files changed, 220 insertions(+), 70 deletions(-) diff --git a/testool/src/statetest/executor.rs b/testool/src/statetest/executor.rs index f64b9cc642..69fada1008 100644 --- a/testool/src/statetest/executor.rs +++ b/testool/src/statetest/executor.rs @@ -193,7 +193,7 @@ fn into_traceconfig(st: StateTest) -> (String, TraceConfig, StateTestResult) { gas_fee_cap: U256::zero(), gas_tip_cap: U256::zero(), call_data: st.data, - access_list: None, + access_list: st.access_list, v: sig.v, r: sig.r, s: sig.s, diff --git a/testool/src/statetest/json.rs b/testool/src/statetest/json.rs index 3ba038bccc..0883fa3359 100644 --- a/testool/src/statetest/json.rs +++ b/testool/src/statetest/json.rs @@ -76,6 +76,7 @@ struct JsonStateTest { #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] struct Transaction { + access_list: Option, data: Vec, gas_limit: Vec, gas_price: String, @@ -125,12 +126,13 @@ impl<'a> JsonStateTestBuilder<'a> { let from = secret_key_to_address(&SigningKey::from_slice(&secret_key)?); let nonce = parse::parse_u256(&test.transaction.nonce)?; let gas_price = parse::parse_u256(&test.transaction.gas_price)?; + let access_list = &test.transaction.access_list; let data_s: Vec<_> = test .transaction .data .iter() - .map(|item| parse::parse_calldata(self.compiler, item)) + .map(|item| parse::parse_calldata(self.compiler, item, access_list)) .collect::>()?; let gas_limit_s: Vec<_> = test @@ -171,7 +173,7 @@ impl<'a> JsonStateTestBuilder<'a> { } } - for (idx_data, data) in data_s.iter().enumerate() { + for (idx_data, calldata) in data_s.iter().enumerate() { for (idx_gas, gas_limit) in gas_limit_s.iter().enumerate() { for (idx_value, value) in value_s.iter().enumerate() { for (data_refs, gas_refs, value_refs, result) in &expects { @@ -200,7 +202,8 @@ impl<'a> JsonStateTestBuilder<'a> { gas_price, gas_limit: *gas_limit, value: *value, - data: data.0.clone(), + data: calldata.data.clone(), + access_list: calldata.access_list.clone(), exception: false, }); } @@ -320,6 +323,7 @@ impl<'a> JsonStateTestBuilder<'a> { #[cfg(test)] mod test { use super::*; + use eth_types::{address, AccessList, AccessListItem}; const JSON: &str = r#" { @@ -364,6 +368,15 @@ mod test { } }, "transaction" : { + "accessList" : [ + { + "address" : "0x009e7baea6a6c7c4c2dfeb977efac326af552d87", + "storageKeys" : [ + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000000000000000000000000000000000000000000001" + ] + } + ], "data" : [ "0x6001", "0x6002" @@ -416,6 +429,19 @@ mod test { nonce: U256::from(0u64), value: U256::from(100000u64), data: Bytes::from(hex::decode("6001")?), + access_list: Some(AccessList(vec![AccessListItem { + address: address!("0x009e7baea6a6c7c4c2dfeb977efac326af552d87"), + storage_keys: vec![ + H256::from_str( + "0x0000000000000000000000000000000000000000000000000000000000000000", + ) + .unwrap(), + H256::from_str( + "0x0000000000000000000000000000000000000000000000000000000000000001", + ) + .unwrap(), + ], + }])), pre: BTreeMap::from([( acc095e, Account { diff --git a/testool/src/statetest/parse.rs b/testool/src/statetest/parse.rs index ebdfa213ec..e270829e79 100644 --- a/testool/src/statetest/parse.rs +++ b/testool/src/statetest/parse.rs @@ -1,12 +1,51 @@ use crate::{abi, Compiler}; use anyhow::{bail, Context, Result}; -use eth_types::{Address, Bytes, H256, U256}; +use eth_types::{address, AccessList, AccessListItem, Address, Bytes, H256, U256}; use log::debug; use regex::Regex; -use std::{collections::HashMap, sync::LazyLock}; +use serde::Deserialize; +use std::{collections::HashMap, str::FromStr, sync::LazyLock}; type Label = String; +/// Raw access list to parse +pub type RawAccessList = Vec; + +/// Raw access list item to parse +#[derive(Clone, Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct RawAccessListItem { + address: String, + storage_keys: Vec, +} + +impl RawAccessListItem { + pub fn new(address: String, storage_keys: Vec) -> Self { + Self { + address, + storage_keys, + } + } +} + +/// parsed calldata +#[derive(Debug)] +pub struct Calldata { + pub data: Bytes, + pub label: Option