trace Namespace
Through trace
RPCs we can know the transaction executive details. To use these RPC Conflux archive node need set two additional config:
Note: An existing archive node need clear all blockchain data to open executive_trace
config.
Note: From Conflux-rust v2.0 trace RPC have some breaking change, Read below for details.
#
Trace objectA Trace
trace object contain below field:
type
:STRING
- Type of trace. Avaliable value iscall
,create
,call_result
,create_result
,internal_transfer_action
action
:OBJECT
- Trace's action info,different type trace's action have different fields.
Example:
Check this document to get detail explanation of Conflux trace
#
RPCs#
trace_blockGet block traces by block hash
#
Parameters- DATA, 32 Bytes - hash of a block
#
ReturnsblockHash
:HASH
- Hash of blockepochHash
:HASH
- Hash of epochepochNumber
:QUANTITY
- Number of epochtransactionTraces
:Array
- Array ofTransactionTrace
info
#
TransactionTracetransactionHash
:HASH
- Hash of transactiontransactionPosition
:QUANTITY
- Position of transaction in blocktraces
:Array
- Array ofTrace
#
Returns#
trace_transactionGet transaction's trace by it's hash
#
Parameters- DATA, 32 Bytes - hash of a transaction
#
Returnstype
:string
- Avaliable value iscall
,create
,call_result
,create_result
,internal_transfer_action
transactionPosition
:QUANTITY
- Position of transaction in blocktransactionHash
:HASH
- Hash of transactionepochNumber
:QUANTITY
- Number of epochepochHash
:HASH
- Hash of epochblockHash
:HASH
- Hash of blockaction
:OBJECT
- Trace info
#
Note- One
call
trace, will have one correspondingcall_result
trace. Acreate
trace will also have one correspondingcreate_result
trace call
trace'sresult
field have three possible value:success
,fail
,revert
- Only traces which's
callType
value iscall
and havesuccess
result status, that can indicate CFX transfer
#
V2.0 trace breaking changeFrom Conflux-rust v2.0 the trace RPC have imported some breaking change, below is a quick introduction of the updates, there also is detail document here
Note: To use the new trace data, the fullnode data should be cleaned and resynchronization.
valid
#
New added field A new field valid
is added to trace to indicate whether the corresponding trace is reverted.
Note: If the old trace data is not cleaned and resynchronization, the valid
filed will always be true.
#
Gas consume and refund trace was introducedAny transaction bumping nonce during execution will generate one or two traces with type "internal_transfer_action" to indicate gas payment and gas refund.
Consider a transaction has gas limit 40000 and gas price 3 Drip.
If the transaction is not sponsored, the trace will be
This should be the first trace of most transactions.
After execution, if this transaction costs 25000 gas, up to 1/4 of gas limit, i.e., 10000 gas (30000 Drip when gas price = 3) will be refunded, then it will generate a trace
#
Trace for storage collateral.Consider a transaction collateralize 10 Drip (it can not happen in a real Conflux system, just for example).
If the transaction is sponsored,
If the transaction is not sponsored,
When releasing storage, the value will be returned to the same route.
#
Indicator for kill contractEach time a contract is killed, it will produce such a trace,
space
field#
New added The call
and create
type action will add a new field space
indicate wich space the trace is occured, the possible value are:
native
ethereum
none
internal_transfer_action
#
Four new field added to fromPocket
toPocket
fromSpace
toSpace
#
Specification for pocketIn Conflux, each account could have several pockets to store CFX.
balance
staking_balance
storage_collateral
sponsor_balance_for_gas
sponsor_balance_for_collateral
The fromPocket field and toPocket field could be one of them.
Besides these five values, the "pocket" could be two special values mint_burn
and gas_payment
.
- fromPocket =
mint_burn
: mint CFX, e.g., generate staking interest - toPocket =
mint_burn
: burn CFX, e.g., when a contract is killed, its staking balance will be burnt. - fromPocket =
gas_payment
: gas payment, usually equals to gas_price * gas_limit - toPocket =
gas_payment
: gas refund after transaction execution.
#
Specification for space- native
- evm
- none
#
Changes in integrity constraints#
Before change- The balance increasing (or decreasing) of an address (except the internal contract) during transaction execution corresponds to a trace whose "to" (or "from") is this address.
#
After change- The balance increasing (or decreasing) of an address (all the address) during transaction execution corresponds to a trace whose "to" (or "from") is this address and "toPocket" (or "fromPocket") is "balance". (Note: for trace type except "interal_transfer_action", the "fromPocket" and "toPocket" equal to "balance" implicitly.)
- The staking balance/collateral balance/sponsor balance for gas/sponsor balance for collateral increasing (or decreasing) of an address during transaction execution corresponds to an internal_transfer type trace whose "to" (or "from") is this address and "toPocket" (or "fromPocket") is "sponsor_balance"/"storage_collateral"/"sponsor_balance_for_gas"/"sponsor_balance_for_collateral".