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

RPC node simulate transaction consumed units #34445

Closed
Arrowana opened this issue Dec 13, 2023 · 2 comments · Fixed by #34450
Closed

RPC node simulate transaction consumed units #34445

Arrowana opened this issue Dec 13, 2023 · 2 comments · Fixed by #34450
Labels
community Community contribution

Comments

@Arrowana
Copy link
Contributor

Arrowana commented Dec 13, 2023

Problem

The JSON RPC simulate_transaction method does not return a meaningful consumed_units. It returns what is consumed by the successful ixs only. Rather than the total consumed units.

Example:

https://explorer.solana.com/tx/3KMqaFZQwWaL9evSZYWHzptxdqZfS7o1XhQDgLmvPzU1hsAgssnWqQJTWYfXbqBMH4MimSEjLSepQg74aYxe9GN2

Simulating this transaction returned consumed_units 19165

However, it consumed 111,898 units. That value is correct in the transaction meta after submitting as we can see in the explorer

Proposed Solution

@joncinque found it should be an easy fix by adding total_errored_units to accumulated_units

solana/runtime/src/bank.rs

Lines 4359 to 4365 in 2dfcdce

let units_consumed = timings
.details
.per_program_timings
.iter()
.fold(0, |acc: u64, (_, program_timing)| {
acc.saturating_add(program_timing.accumulated_units)
});

@joncinque
Copy link
Contributor

According to the docs for simulateTransaction at https://docs.solana.com/api/http#simulatetransaction, the unitsConsumed field is "The number of compute budget units consumed during the processing of this transaction", which means that it should probably be reporting all units consumed, even from an errored instruction.

@CriesofCarrots
Copy link
Contributor

Whoa, is that AI spam? I wonder where it got the 545 value.
"each successful instruction manual" is my favorite part.
Okay, I'll shut up now, in case this will encourage it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants