Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the handling of the recentTxs #140

Merged
merged 1 commit into from
Mar 24, 2023
Merged

Conversation

enobayram
Copy link
Contributor

@enobayram enobayram commented Mar 24, 2023

This PR removes the recentTxs tracking from the CW-D server state and always makes a DB query when recent transactions are needed.

With the current indexes that we have in place, the recent txs query is very fast to execute (see #119), so there's no need to complicate the server state for it anymore.

Note that, in addition to simplifying the codebase, this PR is also needed for the continuations search improvements mentioned here as well as for the planned work of decoupling the node listener from the HTTP API server.

With the current indexes that we have in place, the recent txs query is
very fast to execute, so there's no need to complicate the server state
for it anymore.
@enobayram enobayram self-assigned this Mar 24, 2023
@enobayram
Copy link
Contributor Author

Here's the query that gets executed by the recent transactions handler:

=> EXPLAIN ANALYZE 
SELECT "t0"."chainid" AS "res0", "t0"."height" AS "res1", "t0"."block" AS "res2", "t0"."creationtime" AS "res3", "t0"."requestkey" AS "res4", "t0"."sender" AS "res5", "t0"."code" AS "res6", "t0"."continuation" AS "res7", "t0"."goodresult" AS "res8" 
FROM "transactions" AS "t0" 
ORDER BY "t0"."height" DESC 
LIMIT 20;
                                                                                QUERY PLAN                                                                                
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=0.43..24.48 rows=20 width=1127) (actual time=0.042..0.113 rows=20 loops=1)
   ->  Index Scan Backward using transactions_height_idx on transactions t0  (cost=0.43..16022668.97 rows=13324521 width=1127) (actual time=0.040..0.106 rows=20 loops=1)
 Planning Time: 0.166 ms
 Execution Time: 0.153 ms
(4 rows)

So it should be OK to perform it every time its's needed.

@enobayram enobayram added tech-debt Related to future development costs minor A minor issue or PR labels Mar 24, 2023
@enobayram enobayram merged commit d4ec40e into master Mar 24, 2023
enobayram added a commit that referenced this pull request Mar 24, 2023
Left over from #140
enobayram added a commit that referenced this pull request Mar 27, 2023
This PR extends the transaction endpoints to gather the history of continuation transactions. It extends the following endpoints and adds the `initialCode` and `previousSteps` fields to them:
* Single transaction details: `/txs/tx`
* Multiple transaction details: `/txs/txs`
* Transaction search: `/txs/search`
* Recent transactions: `/txs/recent`

In addition to attaching this continuation history to the response, this PR also extends the search logic of `/txs/search` so that if the given search term appears in the `initialCode` of a continuation transaction, the search still finds it.

This PR supports kadena-io/block-explorer#64 and kadena-io/block-explorer#63

* Search related continuations in tx search

* Retreive continuation history recursively

* Explain the continuation histor custom expression

* Deduplicate tx summary plumbing

* Deduplicate dbToApi tx detail conversion

* Deduplicate txs query execution

* Add transaction continuation histories

* Delete dead code

Left over from #140

---------

Co-authored-by: Stuart Popejoy <[email protected]>
Co-authored-by: Enis Bayramoğlu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor A minor issue or PR tech-debt Related to future development costs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants