program: use counter to access accounts list #17
Merged
+121
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When initializing a config account, the config account is expected to be a signer. However, if it's also included in the signer list as a required signer, the loop where signer keys are checked will fail, telling the user that the account is missing. This failure case also arises when updating a config account, and attempting to declare that the config account must be a signer for updates.
The account isn't actually missing, it's just the fact that the
if signer != config_account_keyis being evaluated after the counter is advanced, so the rest of the loop is off by one.https://github.com/anza-xyz/agave/blob/d9c24ed5837407aa411fbb7cc881c4a1a9757f5e/programs/config/src/config_processor.rs#L61-L72
In the BPF version, we properly handle this case by only advancing the
accounts_iterwhen the list of accounts is actually accessed.In my opinion, this seems like a bug with the builtin implementation, not the BPF version. It's possible that maybe the program isn't designed to allow you to include the config account as a required signer, but that seems like an unnecessary constraint.