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

fix: address LUT issues on tests #811

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chrismaree
Copy link
Member

@chrismaree chrismaree commented Dec 19, 2024

addresses an issue we were seeing with unit tests after an anchor update. Now, all tests work.

reason this was needed is as follows:

Note that after you create or extend a lookup table, it must "warm up" for one slot before the lookup table or newly added addresses can be used in transactions. You can only access lookup tables and addresses added in slots prior to the current one.

Safari 2024-12-19 15 14 03

Signed-off-by: Chris Maree <[email protected]>
@chrismaree chrismaree marked this pull request as draft December 19, 2024 14:42
// Avoids invalid ALT index as ALT might not be active yet on the following tx.
await new Promise((resolve) => setTimeout(resolve, 1000));
// Wait for slot to advance. LUTs only active after slot advance.
const initialSlot = await connection.getSlot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice finding!
Suggestion: Could we use something like this connection.onSlotChange to subscribe to slot changes? Not sure how reliable onSlotChange is though

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried this and this was better. not sure if onSlotChange was delayed or returned early but it did to result in the tests always working as expected, like this implementation does.

@chrismaree chrismaree marked this pull request as ready for review December 20, 2024 10:09
await web3.sendAndConfirmTransaction(connection, new web3.Transaction().add(extendInstruction), [sender], {
skipPreflight: true, // Avoids recent slot mismatch in simulation.
});
await web3.sendAndConfirmTransaction(connection, new web3.Transaction().add(extendInstruction), [sender]);
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we also set this to "confirmed", otherwise might default to "max"

Copy link
Member Author

Choose a reason for hiding this comment

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

sure & done.

Signed-off-by: Chris Maree <[email protected]>
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.

3 participants