Skip to content

Conversation

@md0x
Copy link
Contributor

@md0x md0x commented Oct 22, 2024

Changes proposed in this PR:

  • Add emergency_delete_root_bundle

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
@linear
Copy link

linear bot commented Oct 22, 2024

@md0x md0x marked this pull request as ready for review October 22, 2024 19:33
@md0x md0x requested review from Reinis-FRP and chrismaree October 23, 2024 08:10
let root_bundle = &mut ctx.accounts.root_bundle;

root_bundle.claimed_bitmap.clear();
root_bundle.relayer_refund_root = [0; 32];
Copy link
Member

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

Copy link
Contributor

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

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
Copy link
Member

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.

Copy link
Member

@chrismaree chrismaree left a 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>
@md0x md0x requested a review from chrismaree October 23, 2024 10:29
}

#[event]
pub struct EmergencyDeletedRootBundle {
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

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)]
Copy link
Contributor

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,
Copy link
Contributor

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];
Copy link
Contributor

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

md0x added 4 commits October 23, 2024 17:01
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
md0x added 2 commits October 24, 2024 09:53
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
@md0x md0x merged commit 6f4db17 into master Oct 24, 2024
9 checks passed
@md0x md0x deleted the pablo/acx-2923-instructionsadminrs-add-emergency_delete_root_bundle branch October 24, 2024 09:50
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.

4 participants