-
Notifications
You must be signed in to change notification settings - Fork 117
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
[IND-399] Fix line numbers in SQL function stack traces #821
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
CREATE OR REPLACE FUNCTION dydx_create_tendermint_event( | ||
event jsonb, block_height text | ||
) RETURNS jsonb AS $$ | ||
/** | ||
Parameters: | ||
- event: The IndexerTendermintEvent object. | ||
- block_height: the height of the block being processed. | ||
Returns: The inserted event. | ||
|
||
(Note that no text should exist before the function declaration to ensure that exception line numbers are correct.) | ||
*/ | ||
CREATE OR REPLACE FUNCTION dydx_create_tendermint_event( | ||
event jsonb, block_height text | ||
) RETURNS jsonb AS $$ | ||
DECLARE | ||
transaction_idx int; | ||
event_id bytea; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no explicit error handling for the |
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,5 @@ | ||||||||||||||||||||||||||||||
CREATE OR REPLACE FUNCTION dydx_funding_handler( | ||||||||||||||||||||||||||||||
block_height int, block_time timestamp, event_data jsonb, event_index int, transaction_index int) RETURNS jsonb AS $$ | ||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||
Parameters: | ||||||||||||||||||||||||||||||
- block_height: the height of the block being processing. | ||||||||||||||||||||||||||||||
|
@@ -10,9 +12,9 @@ | |||||||||||||||||||||||||||||
Returns: JSON object containing fields: | ||||||||||||||||||||||||||||||
- perpetual_markets: A mapping from perpetual market id to the associated perpetual market in perpetual-market-model format (https://github.com/dydxprotocol/v4-chain/blob/9ed26bd/indexer/packages/postgres/src/models/perpetual-market-model.ts). | ||||||||||||||||||||||||||||||
- errors: An array containing an error string (or NULL if no error occurred) for each FundingEventUpdate. | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
(Note that no text should exist before the function declaration to ensure that exception line numbers are correct.) | ||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||
CREATE OR REPLACE FUNCTION dydx_funding_handler( | ||||||||||||||||||||||||||||||
block_height int, block_time timestamp, event_data jsonb, event_index int, transaction_index int) RETURNS jsonb AS $$ | ||||||||||||||||||||||||||||||
DECLARE | ||||||||||||||||||||||||||||||
PPM_EXPONENT constant numeric = -6; | ||||||||||||||||||||||||||||||
FUNDING_RATE_FROM_PROTOCOL_IN_HOURS constant numeric = 8; | ||||||||||||||||||||||||||||||
Comment on lines
18
to
20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The constants - TYPE_PREMIUM_SAMPLE constant jsonb = '1';
- TYPE_FUNDING_RATE_AND_INDEX constant jsonb = '2';
+ TYPE_PREMIUM_SAMPLE constant text = '1';
+ TYPE_FUNDING_RATE_AND_INDEX constant text = '2'; Committable suggestion
Suggested change
The constants Appending - errors_response = array_append(errors_response, NULL);
+ IF current_error IS NOT NULL THEN
+ errors_response = array_append(errors_response, current_error);
+ END IF; Where Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function
dydx_asset_create_handler
is well-documented and handles the creation of an asset with appropriate error handling for missing market records. However, consider adding error handling for theINSERT INTO assets
statement to catch any potential exceptions that may occur during the insertion process.The function does not perform any validation on the
event_data
parameter. It is assumed that the input is well-formed and matches the expected schema. If this function is exposed to external calls or if there's any chance thatevent_data
might not be well-structured, it would be prudent to add validation logic to ensure robustness and prevent potential runtime errors.