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

check_acct_cnt: add a check for zero accts in a instruction #3785

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

Conversation

jumpsiegel
Copy link
Contributor

A lot of this PR is white space edits. The only real change is at line 1198 where I check for zero accounts
to match the solana behavior.

Comment on lines +1195 to +1199
// https://github.com/anza-xyz/agave/blob/b1acfbde5bd78488641e7dca3cafc07bef48b87b/program-runtime/src/invoke_context.rs#L251
//
// the get_last_program_key() throws the error that causes the UNSUPPORTED_PROGRAM_ID
int err = ( instr->acct_cnt == 0 ) ? FD_EXECUTOR_INSTR_ERR_UNSUPPORTED_PROGRAM_ID : fd_instr_stack_push( txn_ctx, instr );
if( FD_UNLIKELY( err ) ) {
Copy link
Contributor

@topointon-jump topointon-jump Dec 26, 2024

Choose a reason for hiding this comment

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

From what I can tell, InstructionContext.get_last_program_key uses the transaction's program indicies list. This is given to the instruction context at instruction preperation time, but is ultimately populated when the accounts for the transaction are loaded: https://github.com/anza-xyz/agave/blob/e063c19025d65870a513fcc010c47685dc989d52/svm/src/account_loader.rs#L476

This uses each instruction's program_id_index (https://github.com/anza-xyz/agave/blob/e063c19025d65870a513fcc010c47685dc989d52/svm-transaction/src/instruction.rs#L9), not the list of instruction accounts (https://github.com/anza-xyz/agave/blob/e063c19025d65870a513fcc010c47685dc989d52/svm-transaction/src/instruction.rs#L11).

So this check likely needs to be done at the transaction level, using the instruction's program_id field and checking that this corresponds to a transaction account.

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