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

Bug(Oracle): Expiration timestamp stored in publisher list storage #116

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JordyRo1
Copy link
Contributor

@JordyRo1 JordyRo1 commented Jul 23, 2024

Resolves #117

Issue found

  • When adding a new source for a future/spot entry, we verify first that the source does not exist for a given pair_id, by checking the storage if oracle_list_of_publishers_for_sources_storage, which is the list of publishers for a given source, is empty. However, this list considers only the pair_id, not the expiration timestamp.
    Thus when publishing for example, an entry with an expiry set to 0, the source will be added to the storage for futures entries associated to the pair_id. However, now that the oracle_list_of_publishers_for_sources_storage is not empty anymore, we will not add this source anymore. When we try to add a future entry with an expiry, since the source is already locked, nothing will be added to oracle_list_of_publishers_for_sources_storage, thus the number of sources for the future entry with expiry will remain 0.

Breaking changes

  • Added a parameterexpiration_timestamp to the oracle_list_of_publishers_for_sources_storage
  • Updated the get_publishes_for_sources by taking the expiration_timestamp as parameter

Additional changes

  • Bug test function in test_oracle.cairo

@JordyRo1 JordyRo1 requested a review from EvolveArt July 23, 2024 16:42
@JordyRo1 JordyRo1 changed the title Fix(oracle) expiration timestamp stored in publisher list storage Bug(Oracle): Expiration timestamp stored in publisher list storage Jul 23, 2024
Copy link

Output from Compare Snapshot:

****IMPROVEMENTS****
pragma::tests::test_oracle::test_data_median_multi_should_fail_if_no_expiration_time_associated 22464386 --> 22435036 -0.13 %


****WORSENED****
pragma::tests::test_oracle::get_data_for_sources 27699736 --> 27908356 0.75 %
pragma::tests::test_oracle::get_data_median 38355466 --> 38711286 0.93 %
pragma::tests::test_oracle::get_data_median_for_sources 24632846 --> 24797196 0.67 %
pragma::tests::test_oracle::get_data_median_for_sources_should_fail_if_wrong_sources 22487186 --> 22622556 0.60 %
pragma::tests::test_oracle::test_add_currency_should_fail_if_currency_id_null 21924186 --> 22044566 0.55 %
pragma::tests::test_oracle::test_add_pair_should_panic_if_base_currency_do_not_corresponds 22069856 --> 22190236 0.55 %
pragma::tests::test_oracle::test_add_pair_should_panic_if_quote_currency_do_not_corresponds 22094856 --> 22215236 0.54 %
pragma::tests::test_oracle::test_data_entry 24076656 --> 24197036 0.50 %
pragma::tests::test_oracle::test_data_entry_should_fail_if_not_found 21809256 --> 21929636 0.55 %
pragma::tests::test_oracle::test_data_entry_should_fail_if_not_found_2 21809256 --> 21929636 0.55 %
pragma::tests::test_oracle::test_data_entry_should_fail_if_not_found_3 21809256 --> 21929636 0.55 %
pragma::tests::test_oracle::test_data_median_multi_should_fail_if_wrong_data_types 23214746 --> 23359776 0.62 %
pragma::tests::test_oracle::test_data_median_multi_should_fail_if_wrong_sources 23233156 --> 23378186 0.62 %
pragma::tests::test_oracle::test_get_admin_address 21693576 --> 21813956 0.55 %
pragma::tests::test_oracle::test_get_all_publishers 24876588 --> 25006228 0.52 %
pragma::tests::test_oracle::test_get_all_sources 22223886 --> 22344266 0.54 %
pragma::tests::test_oracle::test_get_data 45631346 --> 46090796 1.01 %
pragma::tests::test_oracle::test_get_data_entry_for_publishers 35727834 --> 35904174 0.49 %
pragma::tests::test_oracle::test_get_data_median_multi 34635806 --> 34933666 0.86 %
pragma::tests::test_oracle::test_get_data_with_USD_hop_should_fail_if_wrong_id 23330226 --> 23451606 0.52 %
pragma::tests::test_oracle::test_get_data_with_usd_hop 33892396 --> 34160176 0.79 %
pragma::tests::test_oracle::test_get_data_with_usd_hop_diff 26536286 --> 26715626 0.68 %
pragma::tests::test_oracle::test_get_decimals 23110266 --> 23230646 0.52 %
pragma::tests::test_oracle::test_get_decimals_should_fail_if_not_found 21916346 --> 22036726 0.55 %
pragma::tests::test_oracle::test_get_decimals_should_fail_if_not_found_2 21916346 --> 22036726 0.55 %
pragma::tests::test_oracle::test_get_last_checkpoint_before 29491336 --> 29699956 0.71 %
pragma::tests::test_oracle::test_get_last_checkpoint_before_should_fail_if_timestamp_too_old 29006666 --> 29215286 0.72 %
pragma::tests::test_oracle::test_get_last_checkpoint_before_should_fail_if_wrong_data_type 29006666 --> 29215286 0.72 %
pragma::tests::test_oracle::test_max_publish_multiple_entries 55861188 --> 56268628 0.73 %
pragma::tests::test_oracle::test_multiple_publishers_price 71228730 --> 71799300 0.80 %
pragma::tests::test_oracle::test_publish_multiple_entries 33209240 --> 33453200 0.73 %
pragma::tests::test_oracle::test_publishing_data_for_less_sources_than_initially_planned 29927208 --> 30144688 0.73 %
pragma::tests::test_oracle::test_remove_source 27201890 --> 27374900 0.64 %
pragma::tests::test_oracle::test_set_checkpoint 29315156 --> 29523776 0.71 %
pragma::tests::test_oracle::test_set_checkpoint_should_fail_if_wrong_data_type 22511126 --> 22636836 0.56 %
pragma::tests::test_oracle::test_transfer_ownership 22063676 --> 22184056 0.55 %
pragma::tests::test_oracle::test_update_pair 22602536 --> 22722916 0.53 %
pragma::tests::test_randomness::test_admin_address 5650072 --> 5659332 0.16 %
pragma::tests::test_randomness::test_cancel_random_request_should_fail_if_fulflled 10948192 --> 10986932 0.35 %
pragma::tests::test_randomness::test_fetch_multiple_out_of_gas_id 13575382 --> 13643602 0.50 %
pragma::tests::test_randomness::test_out_of_gas_refund_check 10361212 --> 10399952 0.37 %
pragma::tests::test_randomness::test_randomness 11430502 --> 11469242 0.34 %
pragma::tests::test_randomness::test_randomness_cancellation 11062632 --> 11101372 0.35 %
pragma::tests::test_randomness::test_randomness_id_incrementation 13693182 --> 13761402 0.50 %
pragma::tests::test_randomness::test_refund_fails_if_id_not_valid_id 5576022 --> 5585282 0.17 %
pragma::tests::test_randomness::test_refund_fails_if_no_due_amount 9197872 --> 9236612 0.42 %
pragma::tests::test_randomness::test_submit_random_should_fail_if_request_cancelled 10521642 --> 10560382 0.37 %
pragma::tests::test_randomness::test_withdraw_funds 12698012 --> 12736752 0.31 %
pragma::tests::test_summary_stats::test_set_future_checkpoint 67558938 --> 68042738 0.72 %
pragma::tests::test_summary_stats::test_summary_stats_mean_mean 63793772 --> 64289032 0.78 %
pragma::tests::test_summary_stats::test_summary_stats_mean_median 63793772 --> 64289032 0.78 %
pragma::tests::test_yield_curve::test_yield_curve_computation 23472522 --> 23515062 0.18 %
pragma::tests::test_yield_curve::test_yield_curve_empty 7212370 --> 7222430 0.14 %


Overall gas change: performance degradation, gas consumption +0.98 %

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.

Bug: function get_all_sources returns 0 elements for a given future pair_id/expiration timestamp
1 participant