-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Migrate from address maps to address lookup tables #21634
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need validations for writable_indexes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the account_key used? Where do we actually store the table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Thanks
CREATE TYPE "AddressMapIndexes" AS ( | ||
writable SMALLINT[], | ||
readonly SMALLINT[] | ||
CREATE TYPE "TransactionMessageAddressTableLookup" AS ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Thanks
CREATE TYPE "AddressMapIndexes" AS ( | ||
writable SMALLINT[], | ||
readonly SMALLINT[] | ||
CREATE TYPE "TransactionMessageAddressTableLookup" AS ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. It should work then
Pull request has been modified.
@@ -28,7 +28,7 @@ pub const MESSAGE_VERSION_PREFIX: u8 = 0x80; | |||
/// which message version is serialized starting from version `0`. If the first | |||
/// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, how is the new digest generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_keys
but address table lookups track the account key separately.Fixes #