feat(dapi): return actual fees paid in state transition broadcast responses #2977
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.
Issue being fixed or feature implemented
It would be nice if clients (like dash-evo-tool) could know the actual fees paid for state transitions without having to fetch identity balances before and after. Something similar to how Ethereum returns
gasUsedin transaction receipts. Previously,WaitForStateTransitionResultResponseonly returned proof or error without the fee breakdown, even though the fee information was calculated internally inStateTransitionExecutionResult::SuccessfulExecution.What was done?
Proto: Added
FeeResultmessage withprocessing_fee,storage_fee, andremoved_from_systemfields. Added optionalfee_resultfield toWaitForStateTransitionResultResponseV0.Drive: Encode fee result into
ExecTxResult.dataduring state transition execution (20 bytes: 8 + 8 + 4 for processing_fee, storage_fee, removed_bytes). Included for both successful executions and paid consensus errors.DAPI: Decode fee data from Tenderdash transaction results (both websocket events and existing tx queries). Populate
fee_resultfield in gRPC responses for success and paid error cases.SDK: Added
FeeResultstruct andStateTransitionBroadcastResult<T>wrapper. Added new trait methodsbroadcast_and_wait_with_fee()andwait_for_response_with_fee()that return fee information alongside the proof result. Existing methods unchanged for backwards compatibility.How Has This Been Tested?
test_encode_fee_result,test_encode_fee_result_zero_values,test_encode_fee_result_max_values)test_decode_fee_result_valid,test_decode_fee_result_zero_values,test_decode_fee_result_too_short,test_decode_fee_result_empty,test_decode_fee_result_extra_bytes)test_fee_result_from_grpc,test_fee_result_total_no_overflow)cargo testBreaking Changes
None - existing
broadcast_and_wait()andwait_for_response()methods remain unchanged. New methods are additive.Checklist:
For repository code-owners and collaborators only