Skip to content

SmtLib updates#443

Open
daveroga wants to merge 18 commits into
masterfrom
PID-3817-smt-lib-updates
Open

SmtLib updates#443
daveroga wants to merge 18 commits into
masterfrom
PID-3817-smt-lib-updates

Conversation

@daveroga

@daveroga daveroga commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator
  • Add updateLeaf, removeLeaf with corresponding tests
  • Enhance to support configurable hashing algorithm

@coveralls

coveralls commented Jun 5, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 27819600194

Coverage decreased (-0.2%) to 85.224%

Details

  • Coverage decreased (-0.2%) from the base build.
  • Patch coverage: 30 uncovered changes across 4 files (131 of 161 lines covered, 81.37%).
  • 12 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
contracts/lib/SmtLib.sol 121 99 81.82%
contracts/identitytreestore/IdentityTreeStore.sol 11 8 72.73%
contracts/state/State.sol 10 7 70.0%
contracts/lib/hash/KeccakHasher.sol 6 4 66.67%
Total (10 files) 161 131 81.37%

Coverage Regressions

12 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
contracts/validators/request/CredentialAtomicQueryV3StableValidator.sol 8 93.43%
contracts/validators/request/LinkedMultiQueryStableValidator.sol 4 95.35%

Coverage Stats

Coverage Status
Relevant Lines: 4135
Covered Lines: 3524
Line Coverage: 85.22%
Coverage Strength: 0.85 hits per line

💛 - Coveralls

@daveroga daveroga changed the title Add updateLeaf, removeLeaf to SmtLib SmtLib updates Jun 6, 2026
@daveroga daveroga marked this pull request as ready for review June 8, 2026 15:48
@daveroga daveroga requested a review from Copilot June 8, 2026 15:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Sparse Merkle Tree (SMT) implementation to support configurable hashing and adds new SMT leaf mutation capabilities, along with broad test/script adjustments to the Hardhat 3 runtime setup.

Changes:

  • Added updateLeaf and removeLeaf support to SmtLib, plus new/expanded SMT tests (Poseidon + new Keccak test suite).
  • Introduced configurable hashing via IHasher with PoseidonHasher and Keccak256Hasher implementations, and wired hasher injection through State / identity initialization paths and Ignition modules.
  • Updated tests and operational scripts to use hre.network.create() instead of network.connect().

Reviewed changes

Copilot reviewed 101 out of 101 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/verifier/verifier.test.ts Switches Hardhat runtime initialization to hre.network.create() in verifier tests.
test/verifier/validatorWhitelist.test.ts Switches Hardhat runtime initialization to hre.network.create() in whitelist tests.
test/verifier/universal-verifier.test.ts Switches Hardhat runtime initialization to hre.network.create() in universal verifier tests.
test/verifier/requestOwnership.test.ts Switches Hardhat runtime initialization to hre.network.create() in request-ownership tests.
test/verifier/requestDisableable.test.ts Switches Hardhat runtime initialization to hre.network.create() in request-disableable tests.
test/verifier/embedded-verifier.test.ts Switches Hardhat runtime initialization to hre.network.create() in embedded verifier tests.
test/validators/v3/index.ts Switches Hardhat runtime initialization to hre.network.create() in v3 validator tests.
test/validators/v3-stable/index.ts Switches Hardhat runtime initialization to hre.network.create() in v3-stable validator tests.
test/validators/sig/index.ts Switches Hardhat runtime initialization to hre.network.create() in signature validator tests.
test/validators/mtp/index.ts Switches Hardhat runtime initialization to hre.network.create() in MTP validator tests.
test/validators/linked-multi-query/linked-multi-query10.test.ts Switches Hardhat runtime initialization to hre.network.create() in linked multi-query tests.
test/validators/linked-multi-query/linked-multi-query-stable.test.ts Switches Hardhat runtime initialization to hre.network.create() in linked multi-query stable tests.
test/validators/eth-identity/index.ts Switches Hardhat runtime initialization to hre.network.create() in eth-identity validator tests.
test/validators/authv3/index.ts Switches Hardhat runtime initialization to hre.network.create() in authv3 validator tests.
test/validators/authv3-8-32/index.ts Switches Hardhat runtime initialization to hre.network.create() in authv3-8-32 validator tests.
test/validators/authv2/index.ts Switches Hardhat runtime initialization to hre.network.create() in authv2 validator tests.
test/utils/packData.ts Switches Hardhat runtime initialization to hre.network.create() for packing utilities used in tests.
test/utils/id-calculation-utils.ts Switches Hardhat runtime initialization to hre.network.create() for ID calculation helpers.
test/stateLib/stateLib.test.ts Switches Hardhat runtime initialization to hre.network.create() in StateLib tests.
test/state/state.test.ts Switches Hardhat runtime initialization to hre.network.create() in State contract tests.
test/smtLib/smtLib.poseidon.test.ts Updates Poseidon SMT tests; adds update/remove leaf test cases and minor timing tweaks.
test/smtLib/smtLib.keccak.test.ts Adds a full SMT test suite for Keccak-based hashing.
test/reverseHash/reverseHash.test.ts Switches Hardhat runtime initialization to hre.network.create() in reverse-hash tests.
test/primitiveUtils/primitiveUtils.test.ts Switches Hardhat runtime initialization to hre.network.create() in primitive utils tests.
test/poseidon/poseidon.test.ts Switches Hardhat runtime initialization to hre.network.create() in poseidon tests.
test/payment/vc-payment.test.ts Switches Hardhat runtime initialization to hre.network.create() in VC payment tests.
test/payment/mc-payment.test.ts Switches Hardhat runtime initialization to hre.network.create() in MC payment tests.
test/onchain-identity/onchain-identity.test.ts Switches Hardhat runtime initialization to hre.network.create() in onchain identity tests.
test/onchain-identity/claim-builder.test.ts Switches Hardhat runtime initialization to hre.network.create() in claim-builder tests.
test/integration-tests/integration-verifier.test.ts Switches Hardhat runtime initialization to hre.network.create() in integration verifier tests.
test/IdentityTreeStore/IdentityTreeStore.test.ts Switches Hardhat runtime initialization to hre.network.create() in IdentityTreeStore tests.
test/get-own-unified-addresses.test.ts Switches Hardhat runtime initialization to hre.network.create() in unified-address helper test.
test/genesisUtils/genesisUtils.test.ts Switches Hardhat runtime initialization to hre.network.create() in genesis utils tests.
test/disable-proxy.test.ts Switches Hardhat runtime initialization to hre.network.create() in disable-proxy tests.
test/cross-chain/cross-chain-proof-validator.test.ts Switches Hardhat runtime initialization to hre.network.create() in cross-chain proof validator tests.
test/check-unified-addresses.test.ts Switches Hardhat runtime initialization to hre.network.create() in unified-address check test.
scripts/upgrade/verifiers/universal-verifier-upgrade.ts Switches Hardhat runtime initialization to hre.network.create() in verifier upgrade script.
scripts/upgrade/verifiers/helpers/testVerifier.ts Switches Hardhat runtime initialization to hre.network.create() in verifier helper script.
scripts/upgrade/verifiers/embedded-verifier-upgrade.ts Switches Hardhat runtime initialization to hre.network.create() in embedded verifier upgrade script.
scripts/upgrade/validators/validators-upgrade.ts Switches Hardhat runtime initialization to hre.network.create() in validators upgrade script.
scripts/upgrade/state/state-upgrade.ts Switches Hardhat runtime initialization to hre.network.create() in state upgrade script.
scripts/upgrade/payments/vcPayment-upgrade.ts Switches Hardhat runtime initialization to hre.network.create() in VC payment upgrade script.
scripts/upgrade/payments/mcPayment-upgrade.ts Switches Hardhat runtime initialization to hre.network.create() in MC payment upgrade script.
scripts/upgrade/identitytreestore/identitytreestore-upgrade.ts Switches Hardhat runtime initialization to hre.network.create() in ITS upgrade script.
scripts/upgrade/helpers/utils.ts Switches Hardhat runtime initialization to hre.network.create() in upgrade helper utilities.
scripts/maintenance/setSupportedIdTypes.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/maintenance/setProofRequest.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/maintenance/setPaymentValue.ts Switches Hardhat runtime initialization to hre.network.create() and updates TypeChain import path.
scripts/maintenance/setOracleSigningAddress.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/maintenance/multi-chain/checkValidatorsUniversalVerifier.ts Switches Hardhat runtime initialization to hre.network.create() and minor formatting.
scripts/maintenance/multi-chain/checkUnifiedContracts.ts Switches Hardhat runtime initialization to hre.network.create() in multi-chain maintenance.
scripts/maintenance/multi-chain/checkOracleSigningAddress.ts Switches Hardhat runtime initialization to hre.network.create() in multi-chain maintenance.
scripts/maintenance/multi-chain/checkIdTypes.ts Switches Hardhat runtime initialization to hre.network.create() in multi-chain maintenance.
scripts/maintenance/getContractsAt.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/maintenance/disableProxyContract.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/maintenance/disableLegacySigningAddressOfCrossChainValidator.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/maintenance/computeCreate2Address.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/maintenance/checkUniversalVerifierSingleNetwork.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/maintenance/checkUniversalVerifierCustomNetwork.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/maintenance/addValidatorsToUniversalVerifier.ts Switches Hardhat runtime initialization to hre.network.create() in maintenance script.
scripts/deploy/linkValidatorsToUniversalVerifier.ts Switches Hardhat runtime initialization to hre.network.create() and refactors tx call formatting.
scripts/deploy/deployVCPayment.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployValidators.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployUniversalVerifier.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployState.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployment-step-2/deployValidators.ts Switches Hardhat runtime initialization to hre.network.create() in step-2 deploy script.
scripts/deploy/deployment-step-2/deployUniversalVerifier.ts Switches Hardhat runtime initialization to hre.network.create() in step-2 deploy script.
scripts/deploy/deployment-step-2/deploySystem.ts Switches Hardhat runtime initialization to hre.network.create() in step-2 deploy script.
scripts/deploy/deployment-step-1/deployValidators.ts Switches Hardhat runtime initialization to hre.network.create() in step-1 deploy script.
scripts/deploy/deployment-step-1/deployUniversalVerifier.ts Switches Hardhat runtime initialization to hre.network.create() in step-1 deploy script.
scripts/deploy/deployment-step-1/deploySystem.ts Adds PoseidonHasher deployment wiring and switches Hardhat runtime initialization to hre.network.create().
scripts/deploy/deployMCPayment.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployLibraries.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployIdentityTreeStore.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployIdentityExample.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployEverythingBasicStrategy.ts Switches Hardhat runtime initialization to hre.network.create() and adjusts deployed contract list.
scripts/deploy/deployCrossChainProofValidator.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployCreateX.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
scripts/deploy/deployCreate2AddressAnchor.ts Switches Hardhat runtime initialization to hre.network.create() in deploy script.
ignition/modules/state.ts Wires PoseidonHasher into State module initialization wiring.
ignition/modules/libraries.ts Adds PoseidonHasher module and adjusts SMT library module deployment strategy.
ignition/modules/deployment/deploySystemFinalImplementations.ts Switches Hardhat runtime initialization to hre.network.create() for final implementations deploy flow.
ignition/modules/deployEverythingBasicStrategy/universalVerifier.ts Propagates PoseidonHasher dependency from State module into universal verifier module outputs.
ignition/modules/deployEverythingBasicStrategy/testHelpers.ts Updates SMT/BinarySearch test helper wrappers to accept an injected hasher; adds Keccak wrapper module.
ignition/modules/deployEverythingBasicStrategy/state.ts Injects PoseidonHasher into State implementation initialization and module outputs.
ignition/modules/deployEverythingBasicStrategy/libraries.ts Adds PoseidonHasher and Keccak hasher deployment modules; decouples SmtLib deployment.
ignition/modules/deployEverythingBasicStrategy/identityExample.ts Updates IdentityExample initialization to pass hasher to IdentityBase.
ignition/modules/deployEverythingBasicStrategy/deployEverythingBasicStrategy.ts Propagates PoseidonHasher through system deployment outputs; removes many-responses-per-user wrapper wiring.
ignition/modules/contractsAt.ts Adds PoseidonHasherAtModule for attaching to deployed PoseidonHasher.
helpers/helperUtils.ts Switches Hardhat runtime initialization to hre.network.create() for helper utilities.
helpers/constants.ts Switches Hardhat runtime initialization to hre.network.create(), bumps State version, adds PoseidonHasher contract info.
contracts/test-helpers/SmtLibTestWrapper.sol Updates wrapper to inject a hasher and expose update/remove wrappers.
contracts/test-helpers/IdentityExample.sol Updates initializer to accept hasher and pass through to IdentityBase.
contracts/test-helpers/BinarySearchTestWrapper.sol Updates wrapper to inject a hasher for SMT initialization.
contracts/state/State.sol Adds hasher dependency into State initialization and initializes GIST SMT with injected hasher.
contracts/lib/SmtLib.sol Adds configurable hasher storage, updateLeaf/removeLeaf, and collision-safe node insertion behavior.
contracts/lib/IdentityLib.sol Injects hasher into identity SMT tree initialization.
contracts/lib/IdentityBase.sol Extends initialization to accept hasher and pass into IdentityLib initialization.
contracts/lib/hash/PoseidonHasher.sol Adds Poseidon-based IHasher implementation.
contracts/lib/hash/KeccakHasher.sol Adds Keccak-based IHasher implementation.
contracts/interfaces/IHasher.sol Introduces IHasher interface for pluggable SMT hashing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread contracts/state/State.sol
Comment thread contracts/lib/SmtLib.sol
Comment thread contracts/lib/SmtLib.sol Outdated
Comment thread test/state/state.test.ts Outdated
@daveroga daveroga force-pushed the PID-3817-smt-lib-updates branch from a16fa32 to 338ff6d Compare June 18, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants