From 729524cf98948c0192036e50fd9fdbb9462b6db0 Mon Sep 17 00:00:00 2001 From: Bogdan Ursu Date: Fri, 30 May 2025 09:56:25 +0200 Subject: [PATCH] =?UTF-8?q?bug(state-manager):=20fix=20issue=20with=20inse?= =?UTF-8?q?rtion=20filter=20missing=20in=20the=20in=E2=80=A6=20(#1069)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * bug(state-manager): fix issue with insertion filter missing in the initial storage lookup * fix mimc code template --------- Co-authored-by: AlexandreBelling --- prover/cmd/dev-tools/mimc/mimc.sol.gotmpl | 2 +- .../statesummary/arithmetization_connector.go | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/prover/cmd/dev-tools/mimc/mimc.sol.gotmpl b/prover/cmd/dev-tools/mimc/mimc.sol.gotmpl index 4499038f..4849bd2d 100644 --- a/prover/cmd/dev-tools/mimc/mimc.sol.gotmpl +++ b/prover/cmd/dev-tools/mimc/mimc.sol.gotmpl @@ -15,7 +15,7 @@ // limitations under the License. // Code generated by gnark DO NOT EDIT -pragma solidity 0.8.25; +pragma solidity 0.8.30; /** * @title Library to perform MiMC hashing diff --git a/prover/zkevm/prover/statemanager/statesummary/arithmetization_connector.go b/prover/zkevm/prover/statemanager/statesummary/arithmetization_connector.go index 2bc9fe2c..4d754ed7 100644 --- a/prover/zkevm/prover/statemanager/statesummary/arithmetization_connector.go +++ b/prover/zkevm/prover/statemanager/statesummary/arithmetization_connector.go @@ -485,6 +485,7 @@ func storageIntegrationDefineInitial(comp *wizard.CompiledIOP, ss Module, smc Hu filterSummary, ) + filterAccountInsert := defineInsertionFilterForFinalStorage(comp, smc, sc) filterEphemeralAccounts := defineEphemeralAccountFilterStorage(comp, smc, sc) // Now we define the constraints for our filters comp.InsertGlobal( @@ -496,6 +497,7 @@ func storageIntegrationDefineInitial(comp *wizard.CompiledIOP, ss Module, smc Hu sc.SelectorMinDeplBlock, smc.PeekAtStorage, smc.FirstKOCBlock, + filterAccountInsert, filterEphemeralAccounts, ), ), @@ -544,12 +546,14 @@ func storageIntegrationAssignInitial(run *wizard.ProverRuntime, ss Module, smc H } svSelectorMinDeplBlock := smartvectors.NewRegular(selectorMinDeplBlock) + filterAccountInsert := assignInsertionFilterForStorage(run, smc) filterEphemeralAccounts := assignEphemeralAccountFilterStorage(run, smc) filterArith := smartvectors.Mul( svSelectorMinDeplBlock, smc.PeekAtStorage.GetColAssignment(run), smc.FirstKOCBlock.GetColAssignment(run), + filterAccountInsert, filterEphemeralAccounts, ) run.AssignColumn( @@ -610,7 +614,7 @@ func storageIntegrationDefineFinal(comp *wizard.CompiledIOP, ss Module, smc HubC ss.Account.Address.Size(), ) - filterAccountInsert = defineInsertionFilterForFinalStorage(comp, smc, sc) + filterAccountInsert = comp.Columns.GetHandle("FILTER_CONNECTOR_HUB_STATE_SUMMARY_ACCOUNT_INSERT_FILTER") filterEphemeralAccounts = comp.Columns.GetHandle("FILTER_CONNECTOR_HUB_STATE_SUMMARY_ACCOUNT_EPHEMERAL_FILTER") ) @@ -692,7 +696,7 @@ func storageIntegrationAssignFinal(run *wizard.ProverRuntime, ss Module, smc Hub run.AssignColumn("FILTER_CONNECTOR_SUMMARY_ARITHMETIZATION_STORAGE_FINAL_SUMMARY", filterSummary) // assign the insertion filter - filterAccountInsert := assignInsertionFilterForFinalStorage(run, smc) + filterAccountInsert := run.GetColumn("FILTER_CONNECTOR_HUB_STATE_SUMMARY_ACCOUNT_INSERT_FILTER") filterEphemeralAccounts := run.GetColumn("FILTER_CONNECTOR_HUB_STATE_SUMMARY_ACCOUNT_EPHEMERAL_FILTER") filterArith := smartvectors.Mul( @@ -807,11 +811,11 @@ func defineInsertionFilterForFinalStorage(comp *wizard.CompiledIOP, smc HubColum } /* -assignInsertionFilterForFinalStorage assigns the insertion filter for the edge case of +assignInsertionFilterForStorage assigns the insertion filter for the edge case of missing storage keys that get created but then wiped when an account that did not exist is not added to the state */ -func assignInsertionFilterForFinalStorage(run *wizard.ProverRuntime, smc HubColumnSet) smartvectors.SmartVector { +func assignInsertionFilterForStorage(run *wizard.ProverRuntime, smc HubColumnSet) smartvectors.SmartVector { // compute the filter that detects account inserts in order to exclude those key reads from the // arithmetization to state summary lookups. filterAccountInsert := make([]field.Element, smc.AddressHI.Size()) @@ -848,7 +852,6 @@ func assignInsertionFilterForFinalStorage(run *wizard.ProverRuntime, smc HubColu } } - svfilterAccountInsert := smartvectors.NewRegular(filterAccountInsert) run.AssignColumn("FILTER_CONNECTOR_HUB_STATE_SUMMARY_ACCOUNT_INSERT_FILTER", svfilterAccountInsert) return svfilterAccountInsert