Skip to content
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

Add address lookup table program #21616

Merged
merged 2 commits into from
Dec 10, 2021

Conversation

jstarry
Copy link
Member

@jstarry jstarry commented Dec 5, 2021

Problem

Users and protocols need a way to store addresses on-chain for transaction v2 address lookups.

Summary of Changes

  • Added "address lookup table" program
  • Number of table entries is capped at 256 since transaction v2 account indices are typed as u8
  • Lookup tables are append only, and new addresses are not usable until the following block
  • Support closing address lookup table accounts but use derived addresses based on a recent slot to prevent new lookup tables from being re-initialized at the same address.

Implements the amended proposal here: #21576

@jstarry jstarry added the v1.9 label Dec 5, 2021
@jstarry jstarry mentioned this pull request Dec 5, 2021
@jstarry jstarry force-pushed the address-lookup-table-program branch 3 times, most recently from 98fa440 to 0b444db Compare December 5, 2021 14:40
@jstarry jstarry force-pushed the address-lookup-table-program branch from 0b444db to 34d4ebb Compare December 8, 2021 04:01
@jstarry jstarry requested review from lijunwangs and joncinque and removed request for lijunwangs December 8, 2021 04:01
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

As with the first round of this program, looks really good! Only one potentially substantive comment, then this is definitely ready to go

program-test/src/lib.rs Show resolved Hide resolved
programs/address-lookup-table-tests/Cargo.toml Outdated Show resolved Hide resolved
programs/address-lookup-table/Cargo.toml Outdated Show resolved Hide resolved
programs/address-lookup-table/src/instruction.rs Outdated Show resolved Hide resolved
programs/address-lookup-table/src/state.rs Show resolved Hide resolved
programs/address-lookup-table/src/processor.rs Outdated Show resolved Hide resolved
programs/address-lookup-table-tests/tests/common.rs Outdated Show resolved Hide resolved
Comment on lines +293 to +304
{
let mut lookup_table_account_ref_mut = lookup_table_account.try_account_ref_mut()?;
AddressLookupTable::overwrite_meta_data(
lookup_table_account_ref_mut.data_as_mut_slice(),
lookup_table_meta,
)?;

let table_data = lookup_table_account_ref_mut.data_mut();
for new_address in new_addresses {
table_data.extend_from_slice(new_address.as_ref());
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This block changed in the latest commit. Rather than allocating a new account data vector, this tries to modify the AccountSharedData data vector directly if it isn't already referenced somewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, looks good!

@codecov
Copy link

codecov bot commented Dec 10, 2021

Codecov Report

Merging #21616 (7045e80) into master (0224a8b) will decrease coverage by 0.1%.
The diff coverage is 27.6%.

@@            Coverage Diff            @@
##           master   #21616     +/-   ##
=========================================
- Coverage    81.6%    81.4%   -0.2%     
=========================================
  Files         511      515      +4     
  Lines      143320   143691    +371     
=========================================
+ Hits       116976   117099    +123     
- Misses      26344    26592    +248     

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Not sure if you want anyone else to review, but it's good from my side!

Comment on lines +293 to +304
{
let mut lookup_table_account_ref_mut = lookup_table_account.try_account_ref_mut()?;
AddressLookupTable::overwrite_meta_data(
lookup_table_account_ref_mut.data_as_mut_slice(),
lookup_table_meta,
)?;

let table_data = lookup_table_account_ref_mut.data_mut();
for new_address in new_addresses {
table_data.extend_from_slice(new_address.as_ref());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, looks good!

@jstarry jstarry merged commit 9b41ddd into solana-labs:master Dec 10, 2021
@jstarry jstarry deleted the address-lookup-table-program branch December 10, 2021 21:02
mergify bot pushed a commit that referenced this pull request Dec 10, 2021
* Add address lookup table program

* feedback

(cherry picked from commit 9b41ddd)

# Conflicts:
#	runtime/Cargo.toml
mergify bot added a commit that referenced this pull request Dec 11, 2021
* Add address lookup table program (#21616)

* Add address lookup table program

* feedback

(cherry picked from commit 9b41ddd)

# Conflicts:
#	runtime/Cargo.toml

* resolve conflicts

Co-authored-by: Justin Starry <justin@solana.com>
@brooksprumo brooksprumo mentioned this pull request Jan 5, 2022
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.

2 participants