Skip to content

Aleph-302: fix messages.json start_block and end_block params #653

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

Merged
merged 4 commits into from
Nov 27, 2024

Conversation

Psycojoker
Copy link
Collaborator

@Psycojoker Psycojoker commented Nov 22, 2024

Query like http://0.0.0.0:4024/api/v0/messages.json?msgType=POST&tags=mainnet&contentTypes=balances-update&pagination=50&sort_order=1&start_block=21135862&addresses=0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10 was broken and generating a 500 error

Related Clickup or Jira tickets : ALEPH-302

Self proofreading checklist

  • Is my code clear enough and well documented
  • Are my files well typed

Changes

So, basically until this commit the start_block/end_block part of the code was never reached and was not working (except if you call the html query params StartBlock)

  • first, a select query tried to access the height attribute on the table message_confirmations that doesn't have any height
  • so using a join we grab the transaction height value
  • add it to the GROUP BY
  • then we fix a priority operator because | has less precedence than >=
  • and then we had a default value to order_by_columns because in some branches of the if/elif/else block it can be uninitialized

How to test

Launch pyaleph then run this query: http://0.0.0.0:4024/api/v0/messages.json?msgType=POST&tags=mainnet&contentTypes=balances-update&pagination=50&sort_order=1&start_block=21135862&addresses=0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10

Notes

I'm not 100% sure that the modification of the GROUP BY and of the default value for order_by_columns are the behavior we want but this part of the code just never worked before 😕

We also probably really want to have some tests here that handle that situation but I understand that this PR is urgent and 301 is also so I'm prioritizing this.

@Psycojoker Psycojoker self-assigned this Nov 22, 2024
@Psycojoker Psycojoker requested a review from nesitor November 22, 2024 00:08
@Psycojoker Psycojoker mentioned this pull request Nov 22, 2024
nesitor
nesitor previously approved these changes Nov 26, 2024
This was because this part of the if was never accessed and thus was
pretty buggy. This changed once this commit was introduced:
eb3b653

The specific bug here is that the height column was access but never
fetched in the Select query (and that the message_confirmations table
never had a height column)
@Psycojoker
Copy link
Collaborator Author

@nesitor chan you approve this PR again plz? I've just solved the merge conflict

@nesitor nesitor merged commit 995e6f2 into main Nov 27, 2024
4 checks passed
@nesitor nesitor deleted the aleph-302 branch November 27, 2024 10:31
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.

2 participants