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

would it provides balance changes response in rpc, simulateTransaction ? #18509

Closed
yihau opened this issue Jul 8, 2021 · 6 comments
Closed
Labels
stale [bot only] Added to stale content; results in auto-close after a week.

Comments

@yihau
Copy link
Member

yihau commented Jul 8, 2021

Problem

I can't get the exact balance changes via rpc, simulateTransaction

For now, I can only get it by twice rpc call. (getBalance and simulateTransaction)

It will cause a problem that I can't call those two rpc in the same context.

I have a chance to get result of simulateTransaction which contains one more confirmed block.

Proposed Solution

add something like preBalance, postBalance or balance changes in simulateTransaction

or

make getBalance and simulateTransaction can run in the same context. (like specific slot)

@mvines
Copy link
Member

mvines commented Jul 8, 2021

The accounts input array to simulateTransaction can be used to request accounts affected by the simulation to be returned, which includes their "postBalance". I think using this existing feature would solve the program described here.

@yihau
Copy link
Member Author

yihau commented Jul 9, 2021

Yes, It contains postBalance but no preBalance.

The scenario is that:

A account transfer to B two times.
The first has sent.
When I want to send the second.

get B account balance (for pre balance) => the first tx confirmed => call simulateTransaction

I will get the postBalance including the first and the second.

I also try to improve this situation like

get B account balance (for pre balance) => the first tx confirmed => call simulateTransaction => get B account balance again

I check B balance is consist after I call simulateTransaction.
I still encounter the problem that postBalance including the other txs although the balances match.

@yihau
Copy link
Member Author

yihau commented Jul 13, 2021

Hi @mvines. Are there any updates?

@mvines
Copy link
Member

mvines commented Jul 13, 2021

Got it. How about a new option to request "preAccounts" from simulateTranstion. The currently returned "accounts" are essentially "postAccounts" already. The "preAccounts" would allow the user to obtain the account balance and data at the time of the simulation.

@yihau
Copy link
Member Author

yihau commented Jul 13, 2021

I think it works! Thank you.

@ryoqun
Copy link
Member

ryoqun commented Jul 14, 2021

(this functionality is needed for one of advanced usages of #17796 )

@github-actions github-actions bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Dec 26, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale [bot only] Added to stale content; results in auto-close after a week.
Projects
None yet
Development

No branches or pull requests

3 participants