Migrate from address maps to address lookup tables#21634
Migrate from address maps to address lookup tables#21634jstarry merged 4 commits intosolana-labs:masterfrom
Conversation
04e54e3 to
5c96e59
Compare
|
@lijunwangs can you please advise at what the impact of changing these Postgres types and tables will be? |
5c96e59 to
4e6c9d2
Compare
|
|
||
| // there should be at least 1 RW fee-payer account. | ||
| if self.header.num_readonly_signed_accounts >= self.header.num_required_signatures { | ||
| return Err(SanitizeError::IndexOutOfBounds); |
There was a problem hiding this comment.
I think probably SanitizeError::InvalidValue is more appropriate.
| let num_table_loaded_accounts = lookup | ||
| .writable_indexes | ||
| .len() | ||
| .saturating_add(lookup.readonly_indexes.len()); |
There was a problem hiding this comment.
Do we need validations for writable_indexes?
There was a problem hiding this comment.
The writable and readonly indexes are used to lookup addresses in an on-chain address table. We can't sanitize those here, the runtime will fail in another location if the lookup fails. The indexes can be as high as u8::MAX so there's no need to sanitize them
| } | ||
| } | ||
|
|
||
| Ok(()) |
There was a problem hiding this comment.
Most of the errors returned in this function is IndexOutOfBounds, when one does run into such error -- it is actually difficult to figure out what causes it to fail. I guess some debug logging before the return will help.
There was a problem hiding this comment.
This sanitization is done on the validator to filter out invalid transactions. It's not a method that users will interface with
There was a problem hiding this comment.
Heh, I meant for the developer doing test. I found myself adding println! code in the error conditions to figure out what offended the sanitizer. I know this is not new code -- just copied from earlier location. And can be addressed separately.
| #[serde(rename_all = "camelCase")] | ||
| pub struct MessageAddressTableLookup { | ||
| /// Address lookup table account key | ||
| pub account_key: Pubkey, |
There was a problem hiding this comment.
How is the account_key used? Where do we actually store the table?
There was a problem hiding this comment.
There are many such tables (users can create their own as they please) and they are all on-chain accounts so they are identified by this account key.
| CREATE TYPE "AddressMapIndexes" AS ( | ||
| writable SMALLINT[], | ||
| readonly SMALLINT[] | ||
| CREATE TYPE "TransactionMessageAddressTableLookup" AS ( |
There was a problem hiding this comment.
Is the TransactionMessageAddressTable a global construct or stored in the transaction itself? If it is the former, we will have to persist that global table as well otherwise the indexes cannot be used.
There was a problem hiding this comment.
Is the TransactionMessageAddressTable a global construct
It's stored on-chain so the full address table won't be included in the transaction object, but those addresses are resolved into "LoadedAddresses"
There was a problem hiding this comment.
Cool. It should work then
|
@lijunwangs can you please advise at what the impact of changing these Postgres types and tables will be? |
| } | ||
| } | ||
|
|
||
| Ok(()) |
There was a problem hiding this comment.
Heh, I meant for the developer doing test. I found myself adding println! code in the error conditions to figure out what offended the sanitizer. I know this is not new code -- just copied from earlier location. And can be addressed separately.
| #[serde(rename_all = "camelCase")] | ||
| pub struct MessageAddressTableLookup { | ||
| /// Address lookup table account key | ||
| pub account_key: Pubkey, |
| CREATE TYPE "AddressMapIndexes" AS ( | ||
| writable SMALLINT[], | ||
| readonly SMALLINT[] | ||
| CREATE TYPE "TransactionMessageAddressTableLookup" AS ( |
There was a problem hiding this comment.
Cool. It should work then
Pull request has been modified.
| /// is bit is not set, all bytes are used to encode the legacy `Message` | ||
| /// format. | ||
| #[frozen_abi(digest = "x2F3RG2RhJQWN6L2N3jebvcAvNYFrhE3sKTPJ4sENvL")] | ||
| #[frozen_abi(digest = "G4EAiqmGgBprgf5ePYemLJcoFfx4R7rhC1Weo2FVJ7fn")] |
There was a problem hiding this comment.
Just out of curiosity, how is the new digest generated?
There was a problem hiding this comment.
It's generated using some procedural macros that build a type graph and hash the output. I just ran ./test-abi.sh locally to see what the mismatch was and updated the value.
Codecov Report
@@ Coverage Diff @@
## master #21634 +/- ##
=========================================
- Coverage 81.6% 81.6% -0.1%
=========================================
Files 511 511
Lines 143320 143304 -16
=========================================
- Hits 116976 116962 -14
+ Misses 26344 26342 -2 |
* Migrate from address maps to address lookup tables * update sanitize error * cargo fmt * update abi (cherry picked from commit 6c108c8)
Problem
The transaction v2 proposal has new proposed changes that rename "address maps" to "address lookup tables" and the design of address lookup tables has shifted.
Summary of Changes
message.account_keysbut address table lookups track the account key separately.Fixes #