Closed ChenxingLi closed 2 years ago
Reference:
Paragraph of Changes in integrity constraints
-> After change
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_gas".
Comment:
Should the last word sponsor_balance_for_gas
be sponsor_balance_for_collateral
?
Fixed
A recent PR changes the trace of transaction trace. The changes are described as follows.
中文摘要
"valid"
."valid"
为false
时表示该条 trace 因为 revert 等原因没有改变 state.The
"valid"
fieldIf the inner message call triggers an error and the error is caught by the outside contract, the whole transaction could also succeed, but the effects of the inner message call are reverted. The traces of the reverted message call will also be retained for debugging usage.
Here, we add a new field
"valid"
to indicate whether the corresponding trace is reverted.Trace for gas payment.
Any 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.
For gas payment, if the transaction is sponsored, the trace will be
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.
Changes in the sponsorship (example)
When a user adds sponsor balance for gas for a contract, the trace will be
Before change
After change
Now you can know which contract is sponsored from the trace.
Changes in the staking (example)
When a user stakes, the trace will be
Before change
After change
Indicator for kill contract
Each time a contract is killed, it will produce such a trace,
Changes in integrity constraints
Before change
"to"
(or"from"
) is this address.After change
"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.)"to"
(or"from"
) is this address and"toPocket"
(or"fromPocket"
) is"sponsor_balance"
/"storage_collateral"
/"sponsor_balance_for_gas"
/"sponsor_balance_for_collateral"
.Specification for pocket
In 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 andtoPocket
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 interesttoPocket = "mint_burn"
: burn CFX, e.g., when a contract is killed, its staking balance will be burnt.fromPocket = "gas_payment"
: gas payment, usually equals togas_price * gas_limit
toPocket = "gas_payment"
: gas refund after transaction execution.