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

Add feed index for batch publish #416

Merged
merged 9 commits into from
Aug 29, 2024
Merged

Add feed index for batch publish #416

merged 9 commits into from
Aug 29, 2024

Conversation

Riateche
Copy link
Contributor

@Riateche Riateche commented Aug 5, 2024

  • Store last assigned feed index in the permission account.
  • Assign new feed index when creating a new price feed.
  • Add a migration instruction to assign feed index to an existing feed.

reserve_new_price_feed_index gets called from init_price_feed_index (to assign an index to an existing price) and from add_price (to assign an index to a new price).
The transition process would be to top up the permission account so that it's rent exempt with the new size, then to call init_price_feed_index for every existing price feed.

@Riateche Riateche force-pushed the batch-publish branch 3 times, most recently from 6ff3f80 to 7e3636c Compare August 6, 2024 12:07
Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

Looks great! I'll approve once we have some tests for it too.

Copy link
Contributor

@guibescos guibescos left a comment

Choose a reason for hiding this comment

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

I think MIN_SIZE_WITH_LAST_FEED_INDEX, INITIAL_SIZE and NEW_ACCOUNT_SPACE are all the same, can't we use INITIAL_SIZE everywhere?

@Riateche
Copy link
Contributor Author

Riateche commented Aug 9, 2024

I think MIN_SIZE_WITH_LAST_FEED_INDEX, INITIAL_SIZE and NEW_ACCOUNT_SPACE are all the same, can't we use INITIAL_SIZE everywhere?

Originally, I tried to alter INITIAL_SIZE for PermissionAccount, but I realized that unfortunately INITIAL_SIZE is not the initial size of the account, but the initial size of the initialized data. The naming is a bit counter-intuitive. INITIAL_SIZE can in fact be smaller than MINIMUM_SIZE for accounts that have variable data length. So originally MINIMUM_SIZE was used both as the space to create the account and as the required minimum size when reading the account. Now that I want to support reading permission accounts with old (smaller) size but at the same time I want to create new permission accounts with new (larger) size, I have to introduce a separate constant (NEW_ACCOUNT_SPACE) to distinguish between these use cases specifically for the permission account.

I've removed MIN_SIZE_WITH_LAST_FEED_INDEX because it's really the same thing as NEW_ACCOUNT_SPACE now.

Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

Nice!

@Riateche Riateche merged commit 256b575 into main Aug 29, 2024
3 checks passed
@Riateche Riateche deleted the batch-publish branch August 29, 2024 09:52
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.

3 participants