solana-labs / solana-web3.js

Solana JavaScript SDK
https://solana-labs.github.io/solana-web3.js
MIT License
1.97k stars 793 forks source link

[experimental] Consider making `address` of `IAccountLookupMeta` optional #2744

Open steveluscher opened 1 month ago

steveluscher commented 1 month ago

Background

Consider this type:

https://github.com/solana-labs/solana-web3.js/blob/a97c34b61532157d914ca975d5c90fdd5e12468c/packages/instructions/src/accounts.ts#L21-L26

One could argue that address doesn't need to be there. When you go to compile the message, the address gets dropped in favour of its index in the LUT.

The reason that address is there is so that the compiler can do some extra tricks:

Problem

The problem is that the presence of this property implies that in order to decompileMessage() a message with LUTs, you need to know the addresses so that the decompiler can rehydrate the TransactionMessage.

There are some use cases for which knowing the addresses is not important though. You might want to decompile a transaction to look at something other than the account addresses. You might also just like to add an instruction and recompile it. Knowing the LUT addresses is not a prerequisite for this; you can recompile the message just fine without knowing them.

Summary

This issue considers the possibility of relaxing this type by making address optional. Alternatively we could add a type to this union like IAccountIndeterminateLookupMeta that has the indexes but not the `address.

steveluscher commented 2 weeks ago

Actually, this idea might be dead on arrival. The addresses themselves are used for deduplication – ie. to prevent the same address from showing up in the accounts list and among one of the looked-up-addresses.