-
Notifications
You must be signed in to change notification settings - Fork 1k
refactor(experimental): add simulateTransaction RPC call #1526
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
Conversation
d29c221 to
f1dda4e
Compare
packages/rpc-core/src/rpc-methods/__tests__/simulate-transaction-test.ts
Show resolved
Hide resolved
packages/rpc-core/src/rpc-methods/__tests__/simulate-transaction-test.ts
Show resolved
Hide resolved
|
Moved this to draft - this API can return Should probably do after #1528 to make it less annoying! |
f1dda4e to
f293b01
Compare
|
lgtm but summoning @steveluscher |
<3 |
steveluscher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Both are optional booleans, but conflict - so cannot both be true | ||
| type SigVerifyAndReplaceRecentBlockhashConfig = | ||
| | Readonly<{ | ||
| /** if `true` the transaction signatures will be verified (conflicts with `replaceRecentBlockhash`) */ | ||
| sigVerify: true; | ||
| /** if `true` the transaction recent blockhash will be replaced with the most recent blockhash. (conflicts with `sigVerify`) */ | ||
| replaceRecentBlockhash?: false; | ||
| }> | ||
| | Readonly<{ | ||
| /** if `true` the transaction recent blockhash will be replaced with the most recent blockhash. (conflicts with `sigVerify`) */ | ||
| replaceRecentBlockhash: true; | ||
| /** if `true` the transaction signatures will be verified (conflicts with `replaceRecentBlockhash`) */ | ||
| sigVerify?: false; | ||
| }> | ||
| | Readonly<{ | ||
| /** if `true` the transaction signatures will be verified (conflicts with `replaceRecentBlockhash`) */ | ||
| sigVerify?: false; | ||
| /** if `true` the transaction recent blockhash will be replaced with the most recent blockhash. (conflicts with `sigVerify`) */ | ||
| replaceRecentBlockhash?: false; | ||
| }>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/rpc-core/src/rpc-methods/__tests__/simulate-transaction-test.ts
Show resolved
Hide resolved
packages/rpc-core/src/rpc-methods/__tests__/simulate-transaction-test.ts
Outdated
Show resolved
Hide resolved
|
|
||
| await expect(resultPromise).rejects.toMatchObject({ | ||
| code: -32602 satisfies (typeof SolanaJsonRpcErrorCode)['JSON_RPC_INVALID_PARAMS'], | ||
| message: expect.stringContaining('failed to fill whole buffer'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙄
packages/rpc-core/src/rpc-methods/__tests__/simulate-transaction-test.ts
Show resolved
Hide resolved
69db34b to
d9ffdf3
Compare
| value: expect.objectContaining({ | ||
| accounts: [ | ||
| expect.objectContaining({ | ||
| // falls back to base64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is out of place, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops yep, removed!
d9ffdf3 to
10d833c
Compare
|
🎉 This PR is included in version 1.78.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
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. |


This PR adds the
simulateTransactionRPC call to the experimental web3jscommitmentandminContextSlotare optional, as in most of these configs. Note that herecommitmentdefaults tofinalized. Like withsendTransactionthis means that tests specify the commitment becausefinalizedmay fail shortly after the validator starts up.sigVerifyandreplaceRecentBlockhash, which both default to false. Their mutual exclusivity is enforced with typesencodingparameter defaults to base58, but should be set to base64 since this is deprecated. As withsendTransactionthis means that excluding the config object, or not settingencodingon it, is deprecated. Most tests use thebase64version and I haven't duplicated them all with the deprecatedbase58one.accountsparameter which can be used to request account data for a subset of accounts involved in a transaction. This contains a list of addresses, and an encoding (unrelated to the transaction level one) for those accounts returned. This is responsible for most of the overloads, because thisencodingaffects the structure of the returnedaccounts. Note thatbase58is not supported: https://github.com/solana-labs/solana/blob/7902ac106d1c537149b44143d080247a6ec85891/rpc/src/rpc.rs#L3774The tests in this PR are modified from the
sendTransactionones, including the specific transaction structure used.Ref #1449