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 RPC support for versioned transactions #22530

Merged
merged 4 commits into from
Mar 8, 2022

Conversation

jstarry
Copy link
Member

@jstarry jstarry commented Jan 16, 2022

Problem

  • Clients have no way to tell RPC which transaction versions they support receiving
  • RPC doesn't support sending transactions which use address lookup tables

Summary of Changes

  • Added max_supported_transaction_version request parameter to enable receiving versioned transactions in RPC responses and pubsub notifications. This ensures that older clients will get an "unsupported version error" instead of a response for a transaction version they can't parse.
  • Added RPC support for sending and simulating transactions which load addresses from on-chain lookup tables
  • Added version field to transaction responses when the max_supported_transaction_version is used whose value is "legacy" string for legacy transactions and a number (ie 0) for versioned transactions.
  • Added loaded_addresses field to transaction metadata responses for transactions with version 0
  • Added address_table_lookups field to transaction message responses for transactions with version 0

Fixes #

@jstarry jstarry force-pushed the lut/rpc-support branch 2 times, most recently from 7bea926 to 8091f1d Compare January 16, 2022 13:16
@jstarry jstarry force-pushed the lut/rpc-support branch 28 times, most recently from cf6b5dc to 84699da Compare February 5, 2022 08:36
@jstarry jstarry changed the title Add RPC support for transactions which use address lookup tables Add RPC support for versioned transactions Feb 5, 2022
@jstarry jstarry force-pushed the lut/rpc-support branch 4 times, most recently from 24ea904 to e1816e3 Compare February 12, 2022 08:54
@jstarry jstarry marked this pull request as ready for review February 12, 2022 08:54
@jstarry jstarry force-pushed the lut/rpc-support branch 4 times, most recently from 34241b9 to 0b54e92 Compare February 28, 2022 07:22
@@ -389,6 +389,7 @@ Returns identity and transaction information about a confirmed block in the ledg
- (optional) `transactionDetails: <string>` - level of transaction detail to return, either "full", "signatures", or "none". If parameter not provided, the default detail level is "full".
- (optional) `rewards: bool` - whether to populate the `rewards` array. If parameter not provided, the default includes rewards.
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment); "processed" is not supported. If parameter not provided, the default is "finalized".
- (optional) `maxSupportedTransactionVersion: <number>` - set the max transaction version to return in responses. If the requested block contains a transaction with a higher version, an error will be returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I might be being dense, but I'm not sure I follow why this is necessary for either getBlock and getTransaction? We generally consider adding fields to rpc responses as non-breaking, and it looks to me like all the new rpc fields are additive (loadedAddresses and version for blocks, addressTableLookups for transactions).

Copy link
Contributor

@CriesofCarrots CriesofCarrots Feb 28, 2022

Choose a reason for hiding this comment

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

Is it that you think it's important for clients to receive an error rather than a v0 block/transaction that is just missing those fields? If so, I don't think I agree. Change my mind?

Copy link
Member Author

Choose a reason for hiding this comment

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

My intent here is that we can totally diverge from keeping backwards compatible fields for future transaction versions if we want.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it that you think it's important for clients to receive an error rather than a v0 block/transaction that is just missing those fields? If so, I don't think I agree. Change my mind?

And yes, I also think this is important. Clients might be parsing transactions for certain account keys and if they don't explicitly support the loaded addresses field for v0 transactions, they can totally miss important certain accounts

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I still don't really love that it forces all clients to upgrade (unexpectedly) when the first v0 transaction comes down the pipe. But to confirm, this won't affect clients querying getBlock with transactionDetails: none|signatures, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

That said, I will start giving this a proper review now :)

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you envision the client upgrade / feature-activation process looking like? Basically every exchange will be affected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I still don't really love that it forces all clients to upgrade (unexpectedly) when the first v0 transaction comes down the pipe

Yeah, I don't love the forced upgrade either but I do feel like this approach opens the door for us to start iterating on the transaction format. We will likely be changing other things about the format in the future and it's inevitable that clients will need to be upgraded to support new features.

What do you envision the client upgrade / feature-activation process looking like? Basically every exchange will be affected.

The rollout process should look like this:

  1. Clients are updated with support for handling versioned transactions
  2. RPC servers and runtime are updated to handle versioned transactions
  3. Once clients and validators are updated, the feature can be activated
  4. Users start processing these new versioned transactions
  5. Old clients will start getting errors when they request blocks / transactions which they don't opt in to receiving
  6. Users complain and realize they need to update their clients

But to confirm, this won't affect clients querying getBlock with transactionDetails: none|signatures, right?

Correct

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

I didn't catch any issues with implementation, just maybe need a little more persuading on the approach ;) One test case would be nice to add.
I also want to sanity-test Blockstore-Bigtable writes and reads -- what's the easiest way to generate and submit a v0 transaction?

expect58
);
}

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's a bit of a pita to construct, but would be nice to have a test case demonstrating unsupported tx error for getBlock to make the effect of one v0 tx clear.

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 rebased off master to get the rpc test refactorings and added a new test test_get_block_with_versioned_tx

@jstarry
Copy link
Member Author

jstarry commented Mar 2, 2022

I also want to sanity-test Blockstore-Bigtable writes and reads -- what's the easiest way to generate and submit a v0 transaction?

This test is a good starting point:

fn test_write_persist_transaction_status() {

@jstarry jstarry force-pushed the lut/rpc-support branch 2 times, most recently from 62e5b49 to be3ce9e Compare March 4, 2022 11:21
rpc/src/rpc.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

Okay, thank you for your patience with me. Blockstore/bigtable flow all works, and I guess I am on board with the approach. It feels okay in practice, and I'm stuck coming up with a better one.

Just the question about the AddressLoader bank commitment on this PR

Oh also, incidentally: I hacked together solana-client methods that will submit a VersionedTransaction, and wrote a little program that creates an address-lookup account and submits a v0 transaction using that account. Can share, if it would be helpful.

@jstarry
Copy link
Member Author

jstarry commented Mar 7, 2022

I hacked together solana-client methods that will submit a VersionedTransaction, and wrote a little program that creates an address-lookup account and submits a v0 transaction using that account. Can share, if it would be helpful.

Yes, that would be great, thanks!

@CriesofCarrots
Copy link
Contributor

@jstarry jstarry merged commit 3114c19 into solana-labs:master Mar 8, 2022
@jstarry jstarry deleted the lut/rpc-support branch March 8, 2022 07:20
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