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

[RFC] Make adding and deleting pubs idempotent #373

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

guibescos
Copy link
Contributor

@guibescos guibescos commented May 26, 2023

We have a way of proposing to add a publisher to all symbols that will make a proposal where the publisher gets added to all symbols where it is not already permissioned and the symbol has less than 32 pubs.

However, this doesn't always work. For example, if one raises a proposal to add publisher A to all symbols and then a proposal to add publisher B to all symbols; once they are both approved only one of the two will be executed without errors.

An alternative to this PR would be a "add many publishers to all symbols" button in the UI.

@guibescos guibescos changed the title Make adding and deleting pubs idempotent [RFC] Make adding and deleting pubs idempotent May 26, 2023
Copy link
Contributor

@jayantk jayantk 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 this change is fine, though the case where you hit the 32 pub limit is weird. I get why you're doing that though, and it is technically idempotent so fine. I think my one ask is to document the semantics of both the add and delete operations so it's clear to the reader why the functions return Ok() in these cases where you might expect an error.

@@ -65,12 +65,12 @@ pub fn add_publisher(
let mut price_data = load_checked::<PriceAccount>(price_account, cmd_args.header.version)?;

if price_data.num_ >= PC_COMP_SIZE {
return Err(ProgramError::InvalidArgument);
Copy link
Contributor

Choose a reason for hiding this comment

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

this means that if you try to exceed the 32 pub limit, the tx succeeds ? that seems questionable.

@@ -128,6 +145,6 @@ fn test_add_publisher() {
&[funding_account.clone(), price_account.clone(),],
instruction_data
),
Err(ProgramError::InvalidArgument)
Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe check here that the pub array is unchanged after this operation?

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