-
Notifications
You must be signed in to change notification settings - Fork 75
feat(svm): add emergency delete bundle #680
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
feat(svm): add emergency delete bundle #680
Conversation
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
| let root_bundle = &mut ctx.accounts.root_bundle; | ||
|
|
||
| root_bundle.claimed_bitmap.clear(); | ||
| root_bundle.relayer_refund_root = [0; 32]; |
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.
this makes sense. in the EVM implementation when we emergencyDeleteRootBundle we delete the element from the array but don't shrink/re-size or adjust the length of the array. this means that subsequent relayRootBundle calls extend past empty elements, enabling blank spots in the array. Functionally, you've done the same thing here by simple clearing the PDA but not decrementing/affecting the prevailing root_bundle_id
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.
not sure we really need to clear these structures as the account gets closed and we don't have any path to reinit the same account as rood bundle id is always incrementing
test/svm/SvmSpoke.Bundle.ts
Outdated
| const emergencyDeleteRootBundleAccounts = { state, rootBundle, signer: owner, program: program.programId }; | ||
| await program.methods.emergencyDeleteRootBundle(rootBundleId).accounts(emergencyDeleteRootBundleAccounts).rpc(); | ||
|
|
||
| // Verify that the root bundle has been deleted |
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.
might want to slightly extend this test to show that post deletion we can continue to add new bundles without the deleted bundle affecting the subsequent bundles.
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.
looks good! just one additional test should be added but past that this is great
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
| } | ||
|
|
||
| #[event] | ||
| pub struct EmergencyDeletedRootBundle { |
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.
EVM implementation has EmergencyDeleteRootBundle event, though that would conflict with instruction context struct. So maybe add comment here to later fix EVM event naming.
| pub struct EmergencyDeleteRootBundle<'info> { | ||
| #[account( | ||
| mut, | ||
| constraint = is_local_or_remote_owner(&signer, &state) @ CustomError::NotOwner |
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.
We also need to add translation in handle_receive_message, so that we are able to invoke this from mainnet
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'll add this together with remote call for relayRootBundle in separate PR
| pub signer: Signer<'info>, | ||
|
|
||
| // TODO: standardize usage of state.seed vs state.key() | ||
| #[account(mut, seeds = [b"state", state.seed.to_le_bytes().as_ref()], bump)] |
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.
no need for mutable state here
| // TODO: consider deriving seed from state.seed instead of state.key() as this could be cheaper (need to verify). | ||
| #[account(mut, | ||
| seeds =[b"root_bundle", state.key().as_ref(), root_bundle_id.to_le_bytes().as_ref()], | ||
| close = signer, |
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.
Not sure how this work for remote calls as the signer would be PDA. Have to add tests and see if PDA would hold returned lamports.
| let root_bundle = &mut ctx.accounts.root_bundle; | ||
|
|
||
| root_bundle.claimed_bitmap.clear(); | ||
| root_bundle.relayer_refund_root = [0; 32]; |
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.
not sure we really need to clear these structures as the account gets closed and we don't have any path to reinit the same account as rood bundle id is always incrementing
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
…rgency_delete_root_bundle
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
…rgency_delete_root_bundle
Changes proposed in this PR: