Skip to content

Add seeds::program constraint for PDAs. - #1197

Merged
armaniferrante merged 19 commits into
otter-sec:masterfrom
cqfd:add_program_id_constraint
Jan 11, 2022
Merged

armaniferrante merged 19 commits into
otter-sec:masterfrom
cqfd:add_program_id_constraint

Conversation

@cqfd

@cqfd cqfd commented Dec 27, 2021

Copy link
Copy Markdown
Contributor

This addresses #1131

@paul-schaaf I should have double-checked about the desired name for the attribute—happy to change from program_id to something else, just wanted to hurry up and get a PR started.

Comment thread tests/misc/programs/misc/src/context.rs
};
ConstraintToken::Bump(Context::new(ident.span(), ConstraintTokenBump { bump }))
}
"program_id" => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the other name that the solana sdk uses for this is base. I don't have a preference though.

@armaniferrante

Copy link
Copy Markdown
Contributor

Build failing due to clippy warnings.

@paul-schaaf

paul-schaaf commented Dec 27, 2021 •

Copy link
Copy Markdown
Contributor

program_seed would be more user-friendly. something that indicates this is used exclusively with seeds

pls also add a line to the changelog

Comment thread tests/misc/programs/misc/src/context.rs
};
ConstraintToken::Bump(Context::new(ident.span(), ConstraintTokenBump { bump }))
}
"program_seed" => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any place in the existing solana sdk that uses the term "program_seed"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tag @jstarry. Any ideas for an accurate keyword to refer to the base program id for PDAs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah tbh I also find that term a little odd

@paul-schaaf paul-schaaf Jan 2, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

other words mentioned in discord: seeds::program, program, derive_from, seed_program

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Discussed offline. Let's do seeds::program.

@paul-schaaf
paul-schaaf force-pushed the add_program_id_constraint branch from ee911d0 to 676b934 Compare January 7, 2022 16:22
Comment thread CHANGELOG.md Outdated

### Features

*lang: Improved error msgs when required programs are missing when using the `init` constraint([#1257](https://github.com/project-serum/anchor/pull/1257))

@paul-schaaf paul-schaaf Jan 7, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

used the opportunity to move this into feature section (wasnt really a bug fix)

@paul-schaaf
paul-schaaf marked this pull request as draft January 7, 2022 16:25
@paul-schaaf
paul-schaaf marked this pull request as ready for review January 7, 2022 21:57
@paul-schaaf paul-schaaf changed the title Add program_id constraint for PDAs. Add seeds::program constraint for PDAs. Jan 7, 2022
@paul-schaaf

Copy link
Copy Markdown
Contributor

took over with alan's permission

@paul-schaaf

Copy link
Copy Markdown
Contributor

closes #1131

/// #[account(
/// seeds = [b"other_seed],
/// bump = second_bump,
/// seeds::program = other_program.key()

@armaniferrante armaniferrante Jan 11, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A bit ugly now that I look at this next to seeds, bump. We'll want to rethink this in the future. Potentially just solved by the constraint grouping work, though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yea once we group them it can just be program cause it will be clear which constraint it belongs to

Comment thread lang/syn/src/codegen/accounts/constraints.rs Outdated
Comment thread lang/syn/src/codegen/accounts/constraints.rs Outdated
@armaniferrante
armaniferrante merged commit e04f144 into otter-sec:master Jan 11, 2022
akash-osec pushed a commit to akash-osec/anchor that referenced this pull request Mar 25, 2026
@jamie-osec jamie-osec added this to the Pre-1.0 milestone Jun 24, 2026
akash-osec pushed a commit to akash-osec/anchor that referenced this pull request Jul 25, 2026
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.

5 participants