-
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
Storage payback #1356
Storage payback #1356
Conversation
c524b26
to
ebfb974
Compare
Again, I would like to ask you guys to think about the possibility of allowing this credit GAS to be used since the first instruction. We need a way to know the storage changes beforehand. Maybe this is not possible in the current situation. |
@@ -51,6 +52,20 @@ private bool AddGas(long gas) | |||
return testMode || GasConsumed <= gas_amount; | |||
} | |||
|
|||
public void StorageReused(int reusedBytes) | |||
{ | |||
var discountPerByte = NativeContract.Policy.GetDiscountPerByteReused(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.
public const long GasPerByte = 100000; |
Use GasPerByte
?
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.
Do you mean using this property directly? (don't get it from the policy)
Shouldn't this GasPerByte be on the network policy? Otherwise, it may break the chain if we change it.
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.
Will we change it?
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.
Hmm, but if the fees are given to the consensus nodes, shouldn't they be responsible for updating this fee?
Maybe this is a little out of the scope of this PR. My concern is that we will never be allowed to change the fee.
About the PR itself, I can move to variables, I think that we can pay back 1:1 when users release storage, but when they reuse storage too? What if we can pay back a little more when the storage is being released since the user is also charged by the opcode?
How "attractive" should be this storage release?
I added the values to the policy because I think it will be hard to come up with value easily. I don't really know the best ratio for this payback.
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 fee is pay to the neo holders, not the consensus nodes.
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.
Yes, sorry. Reading NetworkPolicy everywhere that I thought this was a network fee value.
About the difference between reuse and release, do you still prefer one single variable (GasPerByte) or should I add one or two more variables?
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.
I don't know. The core developers should discuss it again.
This PR has a bug that needs to be solved. I'm not sure how yet. The ConsumedGas cannot be the final result, but rather the "highest amount" during execution. Gas consumption variation (t = time): Now: ConsumedGas = 1 If the user sends 1 GAS instead of 3, it won't be enough to reach the "free storage" instruction. I was thinking about having an additional callback to be called after the method Execute on the VM, but I don't know if this will be accepted. Pseudocode:
|
8dc6fba
to
c88f234
Compare
@shargon forget about the callback thing. I'm not very satisfied with the solution too, I'm still figuring out all the problems 😅 |
I will try to make a different solution using a pre-computed state hash. I don't know if it will work. This PR has a problem that Shargon identified (besides not being the best final solution). This fixes this scenario:
|
Interesting issue... indeed if user only gains back "after", then it needs enough gas, at least to reach that execution point. Obviously, payback should never equals or exceed expended amount, otherwise user can loop it. |
Agree with igor, they can send all the fee and payback later |
dca1eb2
to
8aa93f5
Compare
I updated the PR, but I still have to wait for #1357. Do you guys think we can return 100% of the fee? |
Considering the competitors, I think return 100% is desirable. and also we need to keep fees low for developers. |
Could we set the discount in |
Hello @Tommo-L, |
cb9ddc4
to
152923d
Compare
152923d
to
7616f1a
Compare
Why is it closed? It's a pretty useful PR. |
Hello @Tommo-L , I'm refactoring it, I had some issues to rebase it. I need to reopen it as a draft. |
Extending VM Gas when user reuses or releases storage. Related to #278 .
Another option would be evaluating previously the amount of data that would be released, allowing this GAS to be used before in any part of the transaction, however, this has a greater performance impact and this would be required to occur during the verification and would require us to run the application trigger twice.
@shargon when possible, could you please contact me on Discord to help me improve the tests? Thanks.