when the program is deployed, modifying the data structure
I really want to know what will happen if after deploying the program, I need to upgrade it and change some fields in the struct, such as the following situations.
The struct before my upgrade is like this.
#[account(zero_copy)]
pub struct ProtocolConfig {
pub protocol_fee_rate: u32,
pub whitelist_protocol_fee_rate: u32,
pub whitelist_uuid: [[u8; 24]; WHITE_PUBKEY_SIZE_USIZE],
pub future_use: [u8; 128], //for future use
}
I think there won’t be any issues if the upgraded struct becomes like this (using the for_feature_use field,), but I’m not completely sure.I want to know a definite answer
#[account(zero_copy)]
pub struct ProtocolConfig {
pub protocol_fee_rate: u32,
pub whitelist_protocol_fee_rate: u32,
pub whitelist_uuid: [[u8; 24]; WHITE_PUBKEY_SIZE_USIZE],
pub new_use:Pubkey, //new field
pub future_use: [u8; 96], //sub 32 byte
}
Additionally,If i directly add a new byte to the current data structure without using the for_feature_use field, what will happen? Will the accounts created through PDA become invalid?like this
#[account(zero_copy)]
pub struct ProtocolConfig {
pub protocol_fee_rate: u32,
pub whitelist_protocol_fee_rate: u32,
pub whitelist_uuid: [[u8; 24]; WHITE_PUBKEY_SIZE_USIZE],
pub future_use: [u8; 128], //didnt sub 32 byte
pub new_use:Pubkey, //just add a new filed(32byte)
}
Responses