feat: index public call requests from pending transactions#540
feat: index public call requests from pending transactions#540
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds support for extracting, storing, and indexing public call requests from pending L2 transactions via new API endpoints.
- Introduces three new GET endpoints to fetch public call requests by transaction hash, contract address, or sender address.
- Defines a new
tx_public_call_requesttable in the database schema with controllers to store, retrieve, and delete entries. - Integrates public call request handling into transaction storage and dropped‐transaction cleanup logic.
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| services/explorer-api/src/svcs/http-server/routes/paths_and_validation.ts | Added new path constants and Zod schema for public call requests |
| services/explorer-api/src/svcs/http-server/routes/index.ts | Registered new routes for public call request endpoints |
| services/explorer-api/src/svcs/http-server/routes/controllers/public-call.ts | Implemented controllers and OpenAPI specs for public call requests |
| services/explorer-api/src/svcs/http-server/routes/controllers/index.ts | Exported the new public-call controller |
| services/explorer-api/src/svcs/database/schema/l2tx/index.ts | Extended l2Tx relations to include many public call requests |
| services/explorer-api/src/svcs/database/schema/l2public-call/index.ts | Defined the tx_public_call_request table and relations |
| services/explorer-api/src/svcs/database/controllers/l2Tx/store.ts | Hooked into transaction storage to persist public call requests |
| services/explorer-api/src/svcs/database/controllers/l2Tx/get-tx.ts | Augmented transaction fetch to include stored public call requests |
| services/explorer-api/src/svcs/database/controllers/l2Public-call/store.ts | Created store logic to upsert public call requests |
| services/explorer-api/src/svcs/database/controllers/l2Public-call/get.ts | Added retrieval functions for public call requests |
| services/explorer-api/src/svcs/database/controllers/l2Public-call/delete.ts | Added deletion logic for public call requests |
| services/explorer-api/src/svcs/database/controllers/index.ts | Exported the new l2PublicCall controller namespace |
| services/explorer-api/src/events/received/on-dropped-txs.ts | Cleaned up public call requests when a transaction is dropped |
| services/explorer-api/migrations/meta/_journal.json | Updated journal metadata (note: no new migration script present) |
Comments suppressed due to low confidence (1)
services/explorer-api/src/svcs/database/schema/l2public-call/index.ts:1
- New table
tx_public_call_requestis defined but no corresponding migration script was added; ensure a migration is created to persist this schema in the database.
import { generateAztecAddressColumn } from "@chicmoz-pkg/backend-utils";
| }), | ||
| }); | ||
|
|
||
| export const getPublicCallRequessByAddressSchema = z.object({ |
There was a problem hiding this comment.
Typo in schema name: 'Requess' should be 'Requests' for consistency and clarity.
| export const getPublicCallRequessByAddressSchema = z.object({ | |
| export const getPublicCallRequestsByAddressSchema = z.object({ |
| ); | ||
| router.get( | ||
| paths.publicDataSender, | ||
| controller.GET_PUBLIC_CALL_REQUESTS_BY_CONTRACT_ADDRESS, |
There was a problem hiding this comment.
The handler for the 'sender' endpoint is using the contract-address controller; swap so publicDataSender uses GET_PUBLIC_CALL_REQUESTS_BY_SENDER_ADDRESS.
| controller.GET_PUBLIC_CALL_REQUESTS_BY_CONTRACT_ADDRESS, | |
| controller.GET_PUBLIC_CALL_REQUESTS_BY_SENDER_ADDRESS, |
| ); | ||
| router.get( | ||
| paths.publicDataContract, | ||
| controller.GET_PUBLIC_CALL_REQUESTS_BY_SENDER_ADDRESS, |
There was a problem hiding this comment.
The handler for the 'contract' endpoint is using the sender-address controller; use GET_PUBLIC_CALL_REQUESTS_BY_CONTRACT_ADDRESS instead.
| controller.GET_PUBLIC_CALL_REQUESTS_BY_SENDER_ADDRESS, | |
| controller.GET_PUBLIC_CALL_REQUESTS_BY_CONTRACT_ADDRESS, |
| @@ -14,9 +14,16 @@ CREATE TABLE IF NOT EXISTS "aztec-chain-connection" ( | |||
| "protocol_contract_addresses" jsonb NOT NULL | |||
There was a problem hiding this comment.
I can see that you have deleted all the older migrations. We can't do that any longer since we need to persist the DB
| txs: "/l2/txs", | ||
| txByHash: `/l2/txs/:${txEffectHash}`, | ||
|
|
||
| publicDataTx: `/l2/public-call-requests/tx/:${txEffectHash}`, |
There was a problem hiding this comment.
Since public-call-requests is only one DB-table. We should also only have one (or two) endpoints.
publicCallRequestsByTxHash: /l2/public-call-requests/:${txEffectHash}
publicCallRequests: /l2/public-call-requests // this one can have query-params to search for contractAddress or senderAddress
Add support for extracting and storing public call requests from pending transactions with new API endpoints