Skip to content

Conversation

@ivandzen
Copy link
Contributor

No description provided.

return b58encode(signature).decode("utf-8")

def create_slot_sig(self, max_slot):
slot = randint(0, max_slot)
Copy link
Contributor

Choose a reason for hiding this comment

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

random slot makes test fail "randomly"

Copy link
Contributor

Choose a reason for hiding this comment

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

======================================================================
FAIL: test_query (proxy.testing.test_trx_receipts_storage.TestTrxReceiptsStorage)
Test get_trxs method workds as expected
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/proxy/testing/test_trx_receipts_storage.py", line 63, in test_query
    self.assertEqual(retrieved_trxs[0][0], start_slot)
AssertionError: 35 != 34

----------------------------------------------------------------------

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! This is due to probabilistic reasons: sometimes generated data not contains any transaction for given slot. In average, it will exist only two transaction for every given slot with current generation parameters (100 trxs in 50 slots randomly), but in reality there a cases when there are no transactions for given slot at all. Actually, testing expression must cover such cases, so I changed it.

max_slot = max(max_slot, slot)
if slot < self.latest_processed_slot:
break
if trx['transaction']['message']['instructions'] is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

from ..common_neon.utils import get_from_dict
...
get_from_dict(trx, 'transaction', 'message', 'instructions')

cur.execute(f'SELECT 1 FROM {self.table_name} WHERE slot = %s AND signature = %s', (slot, signature,))
return cur.fetchone() is not None

def get_trxs(self, start_slot = 0, reverse = False):
Copy link
Contributor

Choose a reason for hiding this comment

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

Annotations?

Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need extra spaces around = according to PEP8

def get_trxs(self, start_slot=0, reverse=False):

@otselnik otselnik merged commit 799285c into 409_indexer_optimizations Dec 30, 2021
@otselnik otselnik deleted the 421_optimise_indexer_transaction_receipt_storage branch December 30, 2021 09:02
otselnik added a commit that referenced this pull request Dec 30, 2021
* #409 indexer optomizations

* #409 catch exceptiopns

* #409 add airdropper and faucet artifacts

* #409 remove unused variables

* #409 return`self.last_slot` to `IndexerBase` class

* #409 merge SQLDict and SQLDictBinKey classes to one

* #409 remove debug log

* #409 add metrics

* 421 optimise indexer transaction receipt storage (#423)

* 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]>

Co-authored-by: ivandzen <[email protected]>
Co-authored-by: Ivan Loboda <[email protected]>
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