Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Conversation

buffalojoec
Copy link
Contributor

@buffalojoec buffalojoec commented Oct 23, 2024

Problem

With the upcoming upgrade from 1.18 to 2.0 on Solana mainnet-beta, deprecated RPC methods have been removed, therefore they will no longer be available through Web3.js client requests.

The Agave 2.0 Migration Guide lists semi-equivalent RPC method counterparts for each of the removed methods.

Summary of Changes

Replace getRecentBlockhash with getLatestBlockhash. This method still vends a blockhash, but the field lamportsPerSignature cannot be served, so accessing it throws an error. However, if apps use the deprecated getRecentBlockhash method and only access the blockhash field, they will not see an error, and the request is served by getLatestBlockhash.

Copy link

changeset-bot bot commented Oct 23, 2024

⚠️ No Changeset found

Latest commit: 6abe586

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getconfirmedtransaction_with_gettransaction_ branch from 950dba5 to ee67085 Compare October 29, 2024 07:05
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch from b1112a4 to 4e4ba0c Compare October 29, 2024 07:05
@buffalojoec buffalojoec marked this pull request as ready for review October 29, 2024 07:05
@buffalojoec buffalojoec marked this pull request as draft October 29, 2024 07:18
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getconfirmedtransaction_with_gettransaction_ branch from ee67085 to f96e4d2 Compare October 29, 2024 09:54
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch 3 times, most recently from ea25c54 to 02c228c Compare November 1, 2024 13:09
@mcintyre94
Copy link
Contributor

What's our semver deal here, are we committed to backward compatibility across 1.x? I'd like to just remove the deprecated method TBH, but maybe we can't do that in a 1.x release. Failing that I'd prefer to just hardcode 5000, but not too worried either way.

@buffalojoec
Copy link
Contributor Author

What's our semver deal here, are we committed to backward compatibility across 1.x? I'd like to just remove the deprecated method TBH, but maybe we can't do that in a 1.x release. Failing that I'd prefer to just hardcode 5000, but not too worried either way.

We can't just remove them, even if they are deprecated. I can change this to be hard-coded, but we'd lose out on the fact that fees are supposed to change under varying network load.
https://github.com/anza-xyz/agave/blob/96249691b4b7c873220b27376f271ead38392541/sdk/fee-calculator/src/lib.rs#L109

This might not be the prettiest solution, but it does capture fee rate changes with accuracy.

It's worth noting that the probability of someone using this field - on a long-deprecated method no less - is quite low.

@steveluscher what do you think here?

@steveluscher
Copy link
Contributor

OK, hear me out. How absolutely nuts would it be to:

  1. Deploy a program to mainnet/testnet/devnet that gave you the fee-per-signature as returnData
  2. Create a message that calls that program, having no blockhash
  3. Use simulateTransaction with that message, configured with replaceRecentBlockhash set to true
  4. Pull out the replacementBlockhash and returnData from that simulation

That way you could get this all done in a single call to the server.

@buffalojoec
Copy link
Contributor Author

  1. Deploy a program to mainnet/testnet/devnet that gave you the fee-per-signature as returnData

How does a program get this info?

@steveluscher
Copy link
Contributor

How does a program get this info?

I was hoping you'd know better than me. This?

@buffalojoec
Copy link
Contributor Author

buffalojoec commented Nov 13, 2024

How does a program get this info?

I was hoping you'd know better than me. This?

Actually I was tempted to use this and just load it from account data, but it's deprecated. So we can officially kick the can down the road and just load from a deprecated sysvar for now, and probably avoid the requirement for an on-chain program altogether.

https://github.com/anza-xyz/agave/blob/32b677bf4f2b4a718f62683e1daec87a3a83b83d/sdk/program/src/sysvar/fees.rs#L42
https://github.com/anza-xyz/agave/blob/32b677bf4f2b4a718f62683e1daec87a3a83b83d/sdk/fee-calculator/src/lib.rs#L23

This sysvar is still updated per-slot by Bank, so it would totally work (for now).

It would still be two calls, one to getLatestBlockhash and one to getAccountInfo to load the Fees sysvar and decode the lamports per signature. At least we wouldn't have to craft and serialize a message, though.

@steveluscher
Copy link
Contributor

It would still be two calls…

Well, the difference with that approach is that you could parallelize the calls, so that's much, much better than the implementation with serial calls. Go for it.

@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch from 02c228c to c250727 Compare November 14, 2024 14:19
@buffalojoec buffalojoec marked this pull request as ready for review November 14, 2024 14:19
@buffalojoec
Copy link
Contributor Author

@steveluscher the feature to disable the fees sysvar (JAN1trEUEtZjgXYzNBYHU9DYd7GnThhXfFP7SzPXkPsG) has been activated on all clusters.

The only way to get it properly loaded into the test validator is the hackery that is my second commit. The test validator's genesis config overwrites the account fixture if the feature is enabled.

If we still want to go this route, we just have to be aware that the sysvar's account itself hasn't been cleaned up on any higher clusters, but it's not being updated anymore.

@steveluscher
Copy link
Contributor

Oof. I'm not sure who we're building this for anymore.

  • The person who can't just switch to getFeeForMessage()
  • …but who is willing to upgrade all the way to the latest 1.x version

Surely that's nobody, right?

At this point I'm tempted to just:

return {
  context,
  value: {
    blockhash,
    feeCalculator: {
      get lamportsPerSignature() {
        throw new Error(
          'The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is ' +
          'no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee ' +
          'for a given message.',
        );
      }
    },
  },
}

@buffalojoec
Copy link
Contributor Author

Oof. I'm not sure who we're building this for anymore.

  • The person who can't just switch to getFeeForMessage()
  • …but who is willing to upgrade all the way to the latest 1.x version

Surely that's nobody, right?

At this point I'm tempted to just:

return {
  context,
  value: {
    blockhash,
    feeCalculator: {
      get lamportsPerSignature() {
        throw new Error(
          'The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is ' +
          'no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee ' +
          'for a given message.',
        );
      }
    },
  },
}

Honestly this works for me. With this approach, we aren't technically breaking our API. However, the network simply doesn't support this field anymore, so they're going to get an error anyway. At least here we can vend a response for the endpoint, instead of the app getting an error outright (which it should).

@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch from fff4e5a to 05de6fa Compare November 18, 2024 11:12
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getconfirmedtransaction_with_gettransaction_ branch from f96e4d2 to 1dbecf8 Compare November 18, 2024 11:49
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch from 05de6fa to f6255b3 Compare November 18, 2024 11:49
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getconfirmedtransaction_with_gettransaction_ branch from 1dbecf8 to ac08a16 Compare November 27, 2024 11:56
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch from f6255b3 to c082afa Compare November 27, 2024 11:56
Copy link
Contributor

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

Added via Giphy

src/connection.ts Outdated Show resolved Hide resolved
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch from f1b03b4 to fe71082 Compare December 6, 2024 07:00
@steveluscher
Copy link
Contributor

steveluscher commented Dec 6, 2024

Ship it, except you can't because you need to sign your commits now.

@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getconfirmedtransaction_with_gettransaction_ branch from ac08a16 to e23d27c Compare December 6, 2024 07:26
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch from fe71082 to 1ef3e1c Compare December 6, 2024 07:26
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getconfirmedtransaction_with_gettransaction_ branch from e23d27c to e71da6f Compare December 6, 2024 07:29
@buffalojoec buffalojoec force-pushed the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch from 1ef3e1c to 6abe586 Compare December 6, 2024 07:29
steveluscher
steveluscher previously approved these changes Dec 15, 2024
Copy link
Contributor Author

buffalojoec commented Dec 16, 2024

Merge activity

@buffalojoec buffalojoec changed the base branch from 10-23-feat_agave_v2_rpc_replace_getconfirmedtransaction_with_gettransaction_ to graphite-base/3419 December 16, 2024 04:16
@buffalojoec buffalojoec changed the base branch from graphite-base/3419 to maintenance/v1.x December 16, 2024 04:28
@buffalojoec buffalojoec dismissed steveluscher’s stale review December 16, 2024 04:28

The base branch was changed.

@buffalojoec buffalojoec merged commit 8ea27fc into maintenance/v1.x Dec 16, 2024
6 checks passed
@buffalojoec buffalojoec deleted the 10-23-feat_agave_v2_rpc_replace_getrecentblockhash_with_getlatestblockhash_ branch December 16, 2024 04:34
Copy link
Contributor

🎉 This PR is included in version 1.98.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, 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 Dec 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants