-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add Fee Ratio #2032
Add Fee Ratio #2032
Conversation
src/neo/Ledger/Blockchain.cs
Outdated
@@ -459,7 +460,7 @@ private void Persist(Block block) | |||
clonedSnapshot.Transactions.Add(tx.Hash, state); | |||
clonedSnapshot.Transactions.Commit(); | |||
|
|||
using (ApplicationEngine engine = ApplicationEngine.Create(TriggerType.Application, tx, clonedSnapshot, tx.SystemFee)) | |||
using (ApplicationEngine engine = ApplicationEngine.Create(TriggerType.Application, tx, clonedSnapshot, tx.SystemFee * ratio)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good. I like this design.
Thus, ratio 0.5 makes the network more expensive.
@@ -294,7 +294,7 @@ public virtual VerifyResult VerifyStateDependent(StoreView snapshot, Transaction | |||
foreach (TransactionAttribute attribute in Attributes) | |||
if (!attribute.Verify(snapshot, this)) | |||
return VerifyResult.Invalid; | |||
long net_fee = NetworkFee - Size * NativeContract.Policy.GetFeePerByte(snapshot); | |||
long net_fee = NetworkFee * NativeContract.Policy.GetFeeRatio(snapshot) - Size * NativeContract.Policy.GetFeePerByte(snapshot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same, but maybe:
(NetworkFee * NativeContract.Policy.GetFeeRatio(snapshot)) - (Size * NativeContract.Policy.GetFeePerByte(snapshot))
, to make it clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have fixed, please have a check
In the latest commit I changed the definition of original value * FeeRatio / 100 Or in other word, Initial |
I think the easiest way is to set the price of |
This PR provides a method to set overall fee dynamically. If we don't set such an ratio and want to change tx fee later, we would need a hard folk. |
Can we merge this one? |
We should implement this first. |
Do we need a hard-coded ratio or a dynamic one like described in this PR? |
We need a dynamic one with the initial value |
Done |
This ratio should not affect the storage price. And many native contract methods are based on the storage size. |
Have done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case we want to use withoutRatio
for witnesses ?
For opcodes & interops which should not be influenced by fee ratio i.e. StoragePrice |
If we want to pay 1 USD per byte (for example), we will need to affect the storage price, isn't it? |
I think any storage-related prices can be derived from |
|
I rewrote the fee logic so that fee ratio is applied to each opcode & interops. Scenarios for func |
@@ -67,10 +69,12 @@ protected ApplicationEngine(TriggerType trigger, IVerifiable container, StoreVie | |||
this.ScriptContainer = container; | |||
this.Snapshot = snapshot; | |||
this.gas_amount = gas; | |||
this.feeRatio = snapshot is null ? 1 : NativeContract.Policy.GetFeeRatio(Snapshot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The verifications always use the ratio 1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This serves scenarios such as Transaction.VerifyIndependent
where input snapshot is null. In such cases we should use minimum fee ratio. This is because if fee ratio is really set to 1, using other values might drop transactions which are actually valid. And the "real" expense used by verifying witness will be checked afterwards in Transaction.VerifyDependent
so that no invalid transaction will get on chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But 1
will cause attacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But
1
will cause attacks.
In PR #2054, we will check whether a witness's VerificationScript is StandardContract, so that attack can be blocked.
I personally think this PR works better because: (1) Interop services are also considered. As VM expense = fee of opcodes + fee of interops, interops should also be considered naturally. (2) In this PR hard-coded limitations are also considered such as TestModeFee, OracleRequestPrice, etc. These limitations should also be considered in case of fee ratio changing.
Sure of course. |
Close #1875 & another implementation of dynamic "fee ratio" part in #1453.
This PR aims to implement a dynamic
fee ratio
which can be used to adjust real gas cost of transactions, i.e. when ratio = 2, overall transaction gas cost will be half of original value. This ratio can be adjusted by committee members if needed.