-
Notifications
You must be signed in to change notification settings - Fork 319
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
CLI: Auto-extend program accounts by default #791
CLI: Auto-extend program accounts by default #791
Conversation
4f42e42
to
bd6f86a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Not a bad idea, and thanks for rolling tests and nice output logs.
I'm wondering if we should just make this the default behavior, rather than requiring an option to trigger it. It seems to me like 10/10 times the user who encounters that error message instructing them to use --auto-extend-program
is going to immediately retry with the option.
Instead, your program data account will always be extended automatically on deployment. Maybe we can also offer an option for --no-extend
to do opposite, for those rare cases where someone might want that.
What do you think?
Yeah sounds good to me , I can change logic to auto extend and add no-extend flag as well |
bd6f86a
to
392244c
Compare
@buffalojoec have changed the logic |
1bfd5fe
to
8bcbc3c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for reworking that. I left a couple of comments!
I haven't reviewed the test you've written yet, but do you think it makes sense to also include a test where we introduce a program upgrade that's clearly larger than the existing program, and verify it succeeds?
a275242
to
20dd1ce
Compare
okay i have removed that test now , as we auto extend the program data account |
e92681a
to
9c8078b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you're trying to give the user a little log message about the program size being too small, but since we've flopped this option around to be explicitly "do not attempt to extend", I think it's fine to allow the transaction to fail as it currently does, if --no-extend
is provided.
With that being said, I think you can simplify this approach by sliding the block of code that does the program data account lookup down into the initial_instructions
setup step.
Basically, you could condense everything you've changed in do_process_program_upgrade
into something like this and place it on line 2521
.
if !no_extend {
// Attempt to look up the existing program's size, and automatically
// add an extend instruction if the program data account is too small.
let program_data_address = get_program_data_address(program_id);
if let Some(program_data_account) = rpc_client
.get_account_with_commitment(&program_data_address, config.commitment)?
.value
{
let program_len = UpgradeableLoaderState::size_of_programdata(program_len);
let account_data_len = program_data_account.data.len();
if program_len > account_data_len {
let additional_bytes = program_len.sub(account_data_len);
let additional_bytes: u32 = additional_bytes.try_into().map_err(|_| {
format!(
"Cannot auto-extend Program Data Account space due to size limit \
please extend it manually with command `solana program extend {} \
<BYTES>`. Additional bytes required: {}",
program_id, additional_bytes
)
})?;
initial_instructions.push(bpf_loader_upgradeable::extend_program(
program_id,
Some(&fee_payer_signer.pubkey()),
additional_bytes,
));
}
}
}
What do you think?
P.S. clippy is yelling at you about something!
9c8078b
to
faf9d31
Compare
sounds good to me ! ,i have resolved this |
ca1fb01
to
e225def
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #791 +/- ##
=======================================
Coverage 81.9% 81.9%
=======================================
Files 855 855
Lines 232134 232157 +23
=======================================
+ Hits 190134 190160 +26
+ Misses 42000 41997 -3 |
bbbc23d
to
8e4ba65
Compare
Hey @Nagaprasadvr try running:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! I went ahead and added the test for you :)
Thanks for contributing!
069986b
to
24f6d00
Compare
your welcome , looking forward to contribute more |
24f6d00
to
e480c25
Compare
…-auto-extend-program flag to solana program deploy command
e480c25
to
9b189a7
Compare
issue #564
Problem
When you deploy a program, it initially takes up 2x the program size. At a later date if you try to deploy larger than the currently allocated size, you get the following error:
Error: Deploying program failed: Error processing Instruction 0: account data too small for instruction
The correct way to solve this is to use solana program extend <PROGRAM_ID> <MORE_BYTES> to extend the program, then deploy it again.
Developers attempting to calculate this amount over and over again have become frustrated and some have just spent the money to allocate way more than they should. Some even as much as 10mb. This is bad both for the cluster and developer experience.
Summary of Changes