New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce fixed gas for transfers #939
Labels
module:rusk
Issues related to rusk module
Comments
herr-seppia
added
module:transfer-contract
module:rusk
Issues related to rusk module
labels
Jun 28, 2023
To keep it simpler, we can wrap those 3 fn in a new enum TransactionResult {
SUCCESS,
FAIL(Piecrust::Error)
}
enum InvalidTx {
UNSPENDABLE,
OTHER
} |
ureeves
added a commit
that referenced
this issue
Jun 29, 2023
To allow for splitting execution of a transaction, we split the `execute` function into two different functions - `spend` and `refund`. The `spend` function checks that a transaction can spend its inputs and produce its outputs, and execute the transfer, while the `refund` function refunds a specific amount to the previously performed transaction. This allows the host to execute code in between the two calls, such as executing a contract call, and decide exactly what a transaction should be charged based on the results. See also: #939
ureeves
added a commit
that referenced
this issue
Jun 29, 2023
ureeves
added a commit
that referenced
this issue
Jun 29, 2023
Transactions are now executed in three steps: 1. Call to "spend" to spend inputs and generate outputs 2. Execute possible contract call 3. Call to "refund" to refund the transaction some amount This allows the host to specify *exactly* the amount of gas it wants to charge a transaction. In this case we choose to charge `0.001 Dusk` per input of a transaction, at a gas price of 1. Resolves: #939
ureeves
added a commit
that referenced
this issue
Jun 29, 2023
Transactions are now executed in three steps: 1. Call to "spend" to spend inputs and generate outputs 2. Execute possible contract call 3. Call to "refund" to refund the transaction some amount This allows the host to specify *exactly* the amount of gas it wants to charge a transaction. In this case we choose to charge `0.001 Dusk` per input of a transaction, at a gas price of 1. Resolves: #939
ureeves
added a commit
that referenced
this issue
Jun 29, 2023
Transactions are now executed in three steps: 1. Call to "spend" to spend inputs and generate outputs 2. Execute possible contract call 3. Call to "refund" to refund the transaction some amount This allows the host to specify *exactly* the amount of gas it wants to charge a transaction. In this case we choose to charge `0.001 Dusk` per input of a transaction, at a gas price of 1. Resolves: #939
ureeves
added a commit
that referenced
this issue
Jun 29, 2023
Transactions are now executed in three steps: 1. Call to "spend" to spend inputs and generate outputs 2. Execute possible contract call 3. Call to "refund" to refund the transaction some amount This allows the host to specify *exactly* the amount of gas it wants to charge a transaction. In this case we choose to charge `0.001 Dusk` per input of a transaction, at a gas price of 1. Resolves: #939
ureeves
added a commit
that referenced
this issue
Jun 29, 2023
Transactions are now executed in three steps: 1. Call to "spend" to spend inputs and generate outputs 2. Execute possible contract call 3. Call to "refund" to refund the transaction some amount This allows the host to specify *exactly* the amount of gas it wants to charge a transaction. In this case we choose to charge `1_000_000` per input of a transaction. Resolves: #939
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
Currently, when rusk is performing transactions, it calls the method
execute
of the transfer contractexecute
methods does the following:Current implementation lead to some issues, due to the atomic logic of piecrust (a sort of "all or nothing).
Possible solution design or implementation
Introduce a fixed artificial gas limit for transfers (aka TX_GAS)
Split the
execute
into three different host calls:spend
: ensure thattx.gas_limit >= TX_GAS
and set session to useGasLimit::MAX
call
(if any): set session's gas limit totx.gas_limit-TX_GAS
refund
: pop crossover (if any) and refundtx.gas_limit - call.gas_spent - TX_GAS
)With this 3 host functions, rusk can handle all the actual use cases:
spend
then tx should be discardedcall
then tx returnErr(_)
, otherwise it's considered successfulrefund
should never failAdditional context
N.B:
The text was updated successfully, but these errors were encountered: