Skip to content
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

[WIP] Storage payback #1372

Closed
wants to merge 10 commits into from
Closed

Conversation

lock9
Copy link
Contributor

@lock9 lock9 commented Dec 17, 2019

Recreating my previous PR as a draft. Please check the tests for more information.

@shargon @igormcoelho I faced some issues while trying to implement the payback.
What value will be stored on the SysFee property in a transaction that has pay-back? The value with or without the credit?

The issue of only paying back, in the end, is that this is going to demand users to have the full balance to call a transaction that may cost them 0. Doesn't feel right to me 😅

bool keyAdded = false;
if (!updatedKeys.Contains(key))
{
updatedKeys.Add(key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to return a value if it's added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? It returns true or false. Why should I return the added key if invoker already has it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not your method, updatedKeys.Add(key)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But "Add" is void

src/neo/SmartContract/InteropDescriptor.cs Show resolved Hide resolved
foreach (Transaction tx in engine.Snapshot.PersistingBlock.Transactions)
Burn(engine, tx.Sender, tx.SystemFee + tx.NetworkFee);
{
var sysFee = CalculateSystemFeeWithPayback(tx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In CalculateSystemFeeWithPayback, tx.SysFeeCredit = 0 ? As GasToken.OnPersist executes before tx.script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add more tests, so far I was only able to ensure that the payback is being calculated correctly. The next step is to ensure that we are charging the user the adequate fee.


public TriggerType Trigger { get; }
public IVerifiable ScriptContainer { get; }
public StoreView Snapshot { get; }
public long GasConsumed { get; private set; } = 0;
public long GasCredit { get; private set; } = 0;
public long MinimumGasRequired { get { return Math.Max(GasConsumed, maxConsumedGas); } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could remove MinimumGasRequired and maxConsumedGas, but keep GasConsumed and rename GasCredit to RecyclingRewardGas.
Add reuse and release discount rewards to RecyclingRewardGas. In this way, we don't have to modify the Wallets.MakeTransaction.
After tx.script executed, we can pay back the RecyclingRewardGas to user.

Copy link
Contributor Author

@lock9 lock9 Dec 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tommo-L if we remove maxConsumedGas the user will need the full-balance to send the TX. I think it is not possible to do it without updating the wallet, because the user can send less fees now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not possible to do it without updating the wallet, because the user can send less fees now.

If we allow user send less fees, we will face the contract halting problem. as the transaction's sysfee will loss the use for limitation of execution, is it right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This minimum is exactly for that. The minimum required for the transaction to not fault.

@shargon
Copy link
Member

shargon commented Feb 13, 2020

@lock9 conflicts

@Tommo-L
Copy link
Contributor

Tommo-L commented Mar 13, 2020

@shargon Close?

@erikzhang erikzhang closed this Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants