Add address map program#19473
Conversation
09db86c to
bf31023
Compare
0c51bea to
addc847
Compare
addc847 to
8f4312d
Compare
Codecov Report
@@ Coverage Diff @@
## master #19473 +/- ##
===========================================
+ Coverage 70.2% 82.3% +12.1%
===========================================
Files 35 475 +440
Lines 2066 132434 +130368
Branches 295 0 -295
===========================================
+ Hits 1451 109119 +107668
- Misses 515 23315 +22800
+ Partials 100 0 -100 |
|
Should these be exposed via the sdk? |
Yeah, definitely. I think I can use cargo features to have the sdk directly depend on the address map program crate without bringing in the program runtime. |
joncinque
left a comment
There was a problem hiding this comment.
Looks really good! Most of my questions are nits and ideas about the interface, but I did look at the implementation as well, which looks safe
| } | ||
|
|
||
| /// Derive an address map address from a wallet address and the current epoch. | ||
| pub fn derive_address_map_address(payer_address: &Pubkey, current_epoch: Epoch) -> (Pubkey, u8) { |
There was a problem hiding this comment.
I'm worried that this will make discoverability of address maps difficult. One of the great features of the associated token account is that you can immediately find someone's token account with just their wallet and the mint. Here, you may have to iterate through a bunch of epochs in order to find their address map, or you'll just use find_program_address and do it the "easy" way.
What if, instead of an epoch, this is another Pubkey? That way, you can setup a different address map for each program that you interact with. Since you've cleverly put this on a PDA dependent on the signer, there's no way for one of these to get hijacked after CloseAccount.
There was a problem hiding this comment.
I agree that it's not ideal and I did consider this point when reimplementing the program here: #21616. However, I think indexing or creating a known registry of on-chain lookup tables is going to have to be the way forward here. I think it's more likely that bots and protocols will manage their own lookup table accounts and users will never have to manage them.
| /// Returns an instruction that updates the authority of an address map account. | ||
| /// If the new authority is `None`, the address map account will be immutable. | ||
| /// Inactive address maps cannot be made immutable. | ||
| pub fn set_authority( |
There was a problem hiding this comment.
Similar to an associated token account, should we discourage people from reassigning authority? Immutability makes sense, since you may want to setup an address map for your program as a one-time procedure, and have it hard-coded into the program.
What are the use-cases for reassigning authority? I'm thinking that a user may create an address map for a program, then give the authority over to one of the program addresses which performs the setup and adjusts it as needed after updates.
| &AddressMapInstruction::InitializeAccount { | ||
| bump_seed, | ||
| num_entries, | ||
| authority: authority_address, |
There was a problem hiding this comment.
take it or leave it: Since we've had potential hijackings in the past, we may want to have a signature from the authority as well. This way, bad integrations that just look for any account map for an authority can't get duped.
For example, if it's a defi application, the attacker sets up trap address map accounts for a bunch of addresses, using their own token accounts as the receivers, and just hopes that a bad integration uses the trap address map.
There was a problem hiding this comment.
Great call, I modified the create instruction here (#21616) to use the authority in the PDA and enforce that it's a signer. It's also no longer possible to set the authority address to another address.
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
8f4312d to
d1f6225
Compare
|
Addressed all relevant comments and closing this implementation in favor of a more dev-friendly version here: #21616 |
Problem
Users and protocols need a way to store addresses on-chain for transaction v2 address lookups.
Summary of Changes
Added address map program
u8::MAXsince transaction v2 account indices are typed asu8Fixes #