Skip to content

Conversation

@otselnik
Copy link
Contributor

@otselnik otselnik commented Dec 25, 2021

Add to SQLDict class ability to work with key-value storage with complex keys.
In indexer_base use SQLDictBinKey to store known transactions. Use slot and signature pair as key. Save only transactions directed to neon-evm. And added function to move transactions from the old table to the new.
Request from Solana transactions newer than in known transactions table.
In indexer and airdroper use ordered transactions directly from the known transactions table by sorting by slot and remembering the last processed slot to skip it on the next step.
In indexer if from a certain slot there is no unprocessed transaction skip those.

@otselnik otselnik self-assigned this Dec 25, 2021

if len(self.transaction_receipts) > 0:
self.min_known_tx = min(self.transaction_receipts)
self.max_known_tx = max(self.transaction_receipts)
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems this call can cause unnecessary iteration over all table. I'd rather prefer to explicitely define methods min_key and max_key in SQLDictBinKey that will execute corresponding optimized queries in DB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is impossible in the current realization of SQLDictBinKey. It stores the key as serialized binary.

Copy link
Contributor

@ivandzen ivandzen Dec 27, 2021

Choose a reason for hiding this comment

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

I suggest to separate current key column by two columns: 'slot', 'signature' and use it in composite key. The 'slot' column then can be used to create index. This will allow to create optimized queries for airdropper and also to find min and max txs

if trx['transaction']['message']['instructions'] is not None:
self.process_trx_airdropper_mode(trx)
max_slot = 0
for slot_sig, trx in sorted(self.transaction_receipts.iteritems(), reverse=True):
Copy link
Contributor

Choose a reason for hiding this comment

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

This call could be potentially very slow because it will always sort all available transactions. I'd suggest to implement special method in SqlDictBinKeys that would query all trxs after given slot ordered backwards

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to have a metric, let's call it "process_receipts_ms"
What do you think of this?

ivandzen
ivandzen previously approved these changes Dec 28, 2021
* Create TrxReceiptsStorage

* Use new container in indexer and airdropper

* Fix bug

* Fix assertions in tests, use random start_slot

Co-authored-by: Ivan Loboda <[email protected]>
@otselnik otselnik merged commit 43f6e8b into develop Dec 30, 2021
@otselnik otselnik deleted the 409_indexer_optimizations branch December 30, 2021 09:21
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.

4 participants