Skip to content
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: improve how depositor ATA interactions work #710

Merged
merged 6 commits into from
Nov 1, 2024

Conversation

chrismaree
Copy link
Member

Signed-off-by: chrismaree christopher.maree@gmail.com

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
token::mint = mint,
token::authority = signer,
associated_token::mint = mint,
associated_token::authority = depositor,
token::token_program = token_program
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change also token_program constraint to use associated_token

@@ -37,17 +35,18 @@ pub struct DepositV3<'info> {

#[account(
seeds = [b"route", input_token.as_ref(), state.key().as_ref(), destination_chain_id.to_le_bytes().as_ref()],
bump
bump,
constraint = route.enabled @ CommonError::DisabledRoute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was explicit check in EVM implementation. why move it here in constraints?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it to match how we apply similar constraints on fill.rs

constraint = !state.paused_fills @ CommonError::FillsArePaused

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For fills EVM implementation has unpausedFills modifier, so we moved it to constraints so that implementation logic is as close as possible in SVM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ye, I recall this. that still feels funny to me though. Would we not rather be consistent between rust implementation? the EVM logic feels inconsistent between the modifier use vs inline checks anyways.

#[account(mut)]
#[account(
mut,
constraint = signer.key() == depositor @ SvmError::DepositorMustBeSigner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have this restriction in EVM where sender can provide any depositor address

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, we dont really care about this as long as the authority is the depositor. previously we checked the authority is the signer, but now we check it is the depositor, which is functionally different. the goal I was trying to achieve is that deposit will work for a multi-sig & correct ATA support, where the depositor is the owner of the ATA. I think how it's structured, without this constraint, will support multisigs where the authority is not the signer.

Copy link
Contributor

@Reinis-FRP Reinis-FRP Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we don't really care that depositor is signer. and in case of multisig the authority account will be owned by the token program. we don't need to replicate any authorsation checks here as they will be performed in CPI transfer

Signed-off-by: chrismaree <christopher.maree@gmail.com>
@@ -71,6 +71,8 @@ pub enum SvmError {
InvalidClaimInitializer,
#[msg("Seed must be 0 in production!")]
InvalidProductionSeed,
#[msg("Depositor Must be signer!")]
DepositorMustBeSigner,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is now redundant

Signed-off-by: chrismaree <christopher.maree@gmail.com>
@chrismaree chrismaree merged commit 31693cd into master Nov 1, 2024
9 checks passed
@chrismaree chrismaree deleted the chrismaree/change-deposit-to-ata branch November 1, 2024 10:00
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.

2 participants