Refactor/cleanup tx success method #5901
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This change makes a cleanup of
TransactionResult::success
andTransactionResult::success_with_soft_limit
, removing the 'fee' argument, while it is possible to retrieve the same data usingStacksTransaction::get_tx_fee()
internally.Applicable issues
Additional info (benefits, drawbacks, caveats)
The refactoring has been kept localized to the direct client of
TransactionResult::success
andTransactionResult::success_with_soft_limit
.Maybe could be also cleaned the
TransactionSuccess
struct (instantiated by the two methods above) that as a copy of theStacksTransaction
and relatedfee
. (it could also be a non-problem considering that is now computed internally, and works like a shortcut overtx.get_txt_fee()
, but potentially could be or become an unused field)stacks-core/stackslib/src/chainstate/stacks/miner.rs
Lines 303 to 312 in 3123ccb
Furthermore, the refactor (around the fee topic) could be pushed a little further involving
StacksChainState::process_transaction
.stacks-core/stackslib/src/chainstate/stacks/db/transactions.rs
Lines 1468 to 1474 in 3123ccb
Basically, this method receive a StacksTransaction and return a fee as part of the result (the
u64
in the tuple). This fee value is retrieved internally usingStacksTransaction::get_tx_fee()
(and not manipulated in any way if I got it right).Then the fee result is used from the caller (the is the one that also pass the StacksTrasaction) to feed some
TansactionResult::success
andTansactionResult::success_with_soft_limit
(and infact in the proposed change the fee result is marked as ignored variable), but also for doing other operation (like accumulating fee amount)Probably, (just my speculation) the signature of
StacksChainState::process_transaction
has been designed this way to bematch keyword
friendly.Anyhow if it's worth it, I'm opened to do further investigation on this (maybe in a separted PR?) or just leave as is if it is the correct design.
Checklist
docs/rpc/openapi.yaml
andrpc-endpoints.md
for v2 endpoints,event-dispatcher.md
for new events)clarity-benchmarking
repobitcoin-tests.yml