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

lastValidBlockHeight property for VersionedTransaction #2825

Closed
AlexRubik opened this issue Jun 17, 2024 · 2 comments
Closed

lastValidBlockHeight property for VersionedTransaction #2825

AlexRubik opened this issue Jun 17, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@AlexRubik
Copy link

Motivation

I want to prevent a versioned transaction from landing too late.

If I understand the docs correctly, this feature already exists on legacy transactions. It's the lastValidBlockHeight property.

Could we look into adding this to versioned transactions also? Thanks!
https://solana-labs.github.io/solana-web3.js/classes/VersionedTransaction.html

@AlexRubik AlexRubik added the enhancement New feature or request label Jun 17, 2024
@steveluscher
Copy link
Collaborator

You are correct that lastValidBlockHeight exists on Transaction, but that's actually an anti-pattern.

The thing is, the last block height for which a blockhash is valid is neither encoded in a transaction (it's nowhere in the bytes) nor is it even resolvable from a transaction (there's no call you can make to ask ‘until which blockheight is this blockhash valid?’). In short, it doesn't belong on transactions.

The lastValidBlockHeight is a property of you-having-fetched-the-blockhash. You should save it for use in transaction confirmation. If you obtained the blockhash from somewhere else, that somewhere else should also vend the lastValidBlockHeight. If neither of those is the case, and you're really desperate to know when the blockhash expires, you can fetch the SysvarRecentB1ockHashes11111111111111111111 account, figure out the position at which your blockhash sits, and infer how many blocks it has to go before it falls off the end.

@steveluscher steveluscher closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2024
Copy link
Contributor

Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants