Skip to content

refactor(stdlib): consolidate find-function-by-selector helpers#23008

Open
dbanks12 wants to merge 1 commit intodb/fastforward-contract-updatefrom
db/consolidate-find-fn-helpers
Open

refactor(stdlib): consolidate find-function-by-selector helpers#23008
dbanks12 wants to merge 1 commit intodb/fastforward-contract-updatefrom
db/consolidate-find-fn-helpers

Conversation

@dbanks12
Copy link
Copy Markdown
Contributor

@dbanks12 dbanks12 commented May 6, 2026

Summary

Addresses comment #22957 (comment)

The same artifact-lookup loop was duplicated three times. Puts two helper fns in stdlib/abi:

  • findFunctionArtifactBySelector(artifact, selector) — searches artifact.functions, returns FunctionArtifact | undefined.
  • findFunctionAbiBySelector(artifact, selector) — searches artifact.functions ∪ nonDispatchPublicFunctions via getAllFunctionAbis, returns FunctionAbi | undefined.

Both ContractStore and ProxiedContractStoreFactory now call the same stdlib primitive. The existing throwing getFunctionArtifact helper also reuses findFunctionArtifactBySelector.

Test plan

  • yarn workspace @aztec/pxe test src/storage/contract_store/contract_store.test.ts
  • yarn workspace @aztec/stdlib test src/abi/abi.test.ts
  • yarn lint pxe, yarn lint stdlib

Copy link
Copy Markdown
Contributor Author

dbanks12 commented May 7, 2026

@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from bd45d90 to 761b425 Compare May 7, 2026 01:51
@dbanks12 dbanks12 force-pushed the db/private-sim-contract-overrides branch from 0b5052d to 50fe709 Compare May 7, 2026 01:51
@dbanks12 dbanks12 changed the base branch from db/private-sim-contract-overrides to graphite-base/23008 May 7, 2026 02:30
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from 761b425 to dc6a7b5 Compare May 7, 2026 02:30
@dbanks12 dbanks12 force-pushed the graphite-base/23008 branch from 50fe709 to cf63e74 Compare May 7, 2026 02:30
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from dc6a7b5 to ee3005d Compare May 7, 2026 02:43
@dbanks12 dbanks12 force-pushed the graphite-base/23008 branch from cf63e74 to 721ca99 Compare May 7, 2026 02:43
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from ee3005d to 52a8355 Compare May 7, 2026 03:01
@dbanks12 dbanks12 changed the base branch from graphite-base/23008 to db/fastforward-contract-update May 7, 2026 03:01
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from 52a8355 to 875d840 Compare May 7, 2026 04:03
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 721ca99 to 7b2bf7e Compare May 7, 2026 04:03
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 7b2bf7e to f752939 Compare May 7, 2026 14:41
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch 2 times, most recently from 952c942 to 9ea80fe Compare May 7, 2026 14:44
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from f752939 to 5eab42b Compare May 7, 2026 14:44
@dbanks12 dbanks12 marked this pull request as ready for review May 7, 2026 14:44
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from 9ea80fe to d93eec1 Compare May 7, 2026 17:39
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from 5eab42b to bad11ee Compare May 7, 2026 17:39
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from d93eec1 to 7cdc4d6 Compare May 7, 2026 18:43
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch 2 times, most recently from 6ee0009 to bc31ce0 Compare May 8, 2026 00:55
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch 2 times, most recently from 61dc935 to 48179ec Compare May 8, 2026 00:55
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch 2 times, most recently from 1f320fd to c05adb8 Compare May 8, 2026 01:19
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from 48179ec to 7f6ff8d Compare May 8, 2026 01:19
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from c05adb8 to e7a14dc Compare May 8, 2026 01:19
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from 7f6ff8d to 9204319 Compare May 8, 2026 01:19
@dbanks12 dbanks12 marked this pull request as draft May 8, 2026 01:20
The same artifact lookup loop was duplicated three times — as
ContractStore's private #findFunctionArtifactBySelector and
#findFunctionAbiBySelector, and as a local helper inside
ProxiedContractStoreFactory. Hoist the two variants into stdlib/abi as
findFunctionArtifactBySelector and findFunctionAbiBySelector so both
ContractStore and the proxied store call the same primitive.

Also have the existing throwing getFunctionArtifact helper reuse
findFunctionArtifactBySelector for its selector branch.
@dbanks12 dbanks12 force-pushed the db/fastforward-contract-update branch from e7a14dc to aef8c87 Compare May 8, 2026 01:25
@dbanks12 dbanks12 force-pushed the db/consolidate-find-fn-helpers branch from 9204319 to 191de66 Compare May 8, 2026 01:25
@dbanks12 dbanks12 marked this pull request as ready for review May 8, 2026 01:28
@dbanks12 dbanks12 requested a review from Thunkar May 8, 2026 01:29
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.

1 participant