-
Notifications
You must be signed in to change notification settings - Fork 49
feat(dapi): return actual fees paid in state transition broadcast responses#2977
feat(dapi): return actual fees paid in state transition broadcast responses#2977pauldelucia wants to merge 1 commit intov3.0-devfrom
Conversation
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 gasUsed in transaction receipts. Previously, WaitForStateTransitionResultResponse only returned proof or error without the fee breakdown, even though the fee information was calculated internally in StateTransitionExecutionResult::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 andStateTransitionBroadcastResultwrapper. 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?
- Unit tests added for fee encoding in Drive (
test_encode_fee_result,test_encode_fee_result_zero_values,test_encode_fee_result_max_values) - Unit tests added for fee decoding in DAPI (
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) - Unit tests added for SDK FeeResult conversion (
test_fee_result_from_grpc,test_fee_result_total_no_overflow) - All tests pass with
cargo test
Breaking Changes
None - existing broadcast_and_wait() and wait_for_response() methods remain unchanged. New methods are additive.
Checklist:
- I have performed a self-review of my own code
- I have commented my code, particularly in hard-to-understand areas
- I have added or updated relevant unit/integration/functional/e2e tests
- I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
- I have made corresponding changes to the documentation if needed
For repository code-owners and collaborators only
- I have assigned this pull request to a milestone
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
gRPC Query Coverage Report================================================================================ |