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

Deprecate SysvarRecentBlockhashes #18875

Merged

Conversation

jackcmay
Copy link
Contributor

@jackcmay jackcmay commented Jul 23, 2021

Problem

SysvarRecentBlockhashes exposes the fee structure internals and thus locks the Solana blockchain down to the current fee structure.

Summary of Changes

This sysvar is mostly used by Nonce accounts (only as far as I can tell) and Nonce accounts don't even need it since they could get the information from InvokeContext. Deprecate the sysvar so no new developers start to use it.

Next step is to switch nonce handling over to getting the blockhash/fee calculator from InvokeContext and then hopefully drop fee_calculator altogether and just use the fee calculator available at the time the transaction is submitted for processing.

Fixes #18817

@jackcmay jackcmay force-pushed the deprecate-recent-blockhashes-sysvar branch from 4f58764 to 5a1da03 Compare July 23, 2021 19:00
@jackcmay
Copy link
Contributor Author

@t-nelson Step one in reducing FeeCalculator exposure

@oJshua oJshua mentioned this pull request Jul 23, 2021
@codecov
Copy link

codecov bot commented Jul 23, 2021

Codecov Report

Merging #18875 (91649b2) into master (f51d648) will decrease coverage by 0.0%.
The diff coverage is 42.1%.

❗ Current head 91649b2 differs from pull request most recent head 2c095c3. Consider uploading reports for the commit 2c095c3 to get more accurate results

@@            Coverage Diff            @@
##           master   #18875     +/-   ##
=========================================
- Coverage    82.8%    82.8%   -0.1%     
=========================================
  Files         444      444             
  Lines      126568   126662     +94     
=========================================
+ Hits       104859   104918     +59     
- Misses      21709    21744     +35     

t-nelson
t-nelson previously approved these changes Jul 23, 2021
Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

lgtm!

let's add an issue to update the deprecation warning strings with the invoke context method once it's ready

@jackcmay
Copy link
Contributor Author

lgtm!

let's add an issue to update the deprecation warning strings with the invoke context method once it's ready

The invoke_context mechanism will only be available to built-in programs and even there we are planning for it to only return the current blockhash and fee_calculator. RecentBlockhashes will no longer be available to developers.

@jackcmay jackcmay force-pushed the deprecate-recent-blockhashes-sysvar branch from 2f367fa to 91649b2 Compare July 27, 2021 03:55
@mergify mergify bot dismissed t-nelson’s stale review July 27, 2021 03:55

Pull request has been modified.

@jackcmay jackcmay force-pushed the deprecate-recent-blockhashes-sysvar branch from 91649b2 to 2c095c3 Compare July 27, 2021 18:55
@jackcmay jackcmay merged commit 72e374d into solana-labs:master Jul 27, 2021
@jackcmay jackcmay deleted the deprecate-recent-blockhashes-sysvar branch July 27, 2021 23:34
@ruuda
Copy link
Contributor

ruuda commented Aug 20, 2021

Hi, we are using this sysvar in Lido for Solana. Not in the on-chain program, but to be able to know what the most recent blockhash was when you call getMultipleAccounts through the RPC. Will there be a different way to know which block you read from when calling getMultipleAccounts?

@CriesofCarrots
Copy link
Contributor

CriesofCarrots commented Aug 20, 2021

Will there be a different way to know which block you read from when calling getMultipleAccounts?

@ruuda , the getMultipleAccounts call is one of a number that return a context object that includes the slot that the data was read from. Eg:

$ curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getMultipleAccounts", "params":[["Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX"]]}' api.mainnet-beta.solana.com

{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 92536948 // <-- HERE
    },
    "value": [
      {
        "data": [
          "",
          "base64"
        ],
        "executable": false,
        "lamports": 629691080,
        "owner": "11111111111111111111111111111111",
        "rentEpoch": 214
      }
    ]
  },
  "id": 1
}

Does that help?

@ruuda
Copy link
Contributor

ruuda commented Aug 26, 2021

the getMultipleAccounts call is one of a number that return a context object that includes the slot that the data was read from.
Does that help?

It helps a little; this context is not exposed in the Rust client, but I can see it is available internally, so if we fork solana-client I suppose we could expose it. Then from the slot number we can get the blockhash with get_block(slot).

@Aphoh
Copy link

Aphoh commented Nov 22, 2021

@jackcmay
Is there a reason why we couldn't expose only the recent blockhash on a transaction to a program called in that transaction? The recent blockhashes sysvar gave programs a convenient way to have a checkable nonce in signed messages (like those verified with a KeccakSecp256k1 instruction). Without something like this, program developers have to create their own nonce-handling logic (like this ethereum style one from audius), which involves allocating a separate nonce account that stores incremental nonces. It makes this more complicated and requires more space to be allocated.

@ramizhasan111
Copy link

Hi, I see the RecentBlockhashes is still used in the advance_nonce_account() function to create the AdvanceNonceAccount system call in the latest version of the Solana repo. I am confused why the deprecated feature is still used and whether it is safe to use it? I want to create a create a AdvanceNonceAccount SystemInstruction and it looks like using RecentBlockhashes is still the way to do it as per the doc examples in the latest version of the Solana SDK.

@t-nelson
Copy link
Contributor

t-nelson commented Jan 9, 2024

the sysvar is only queried and used to perform a legacy check. it can be removed. all instances where the blockhash is actually used, query the invoke context

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.

RecentBlockhashes sysvar exposes the inners of fee calculation
6 participants