migrate_from_0_1_0
This instruction can be used to migrate the singleton storage
account in-place from the legacy layout to the current storage layout.
The instruction handler takes the storage
account as a raw AccountInfo
, manually verifies the discriminant and deserializes it according to the legacy layout.
It then ensures that the top_authority
signer account matches the top_authority
field of the deserialized storage account.
The storage account is reallocated, increasing its size to account for the additional space needed by the newer Storage
account type.
Finally, the function reinitializes the account, by instantiating an instance of the new Storage
account type and serializing it manually into the storage
account.
This function does not prevent to migrate an already migrated storage
account, allowing to corrupt its data. Refer to finding ref↗ for a more in depth discussion.
Arguments
treasury
: public key value used to initialize thetreasury
field of the migratedstorage
account
Accounts
top_authority
: Signer account giving authorizing the migrationAnchor flags: signer
Checks: must match the
top_authority
field of thestorage
account when decoded using the legacy layout
storage
: storage account to be migrated; taken as a rawAccountInfo
Anchor flags: mut
Seed:
STORAGE_SEED
(fixed constant)
Tests
Positive cases
Negative cases
Note: this test was added as part of the remediations