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

remove tx fee #743

Merged
merged 1 commit into from
Jul 27, 2022
Merged

remove tx fee #743

merged 1 commit into from
Jul 27, 2022

Conversation

Ashuaidehao
Copy link
Contributor

No description provided.

@shargon
Copy link
Member

shargon commented Jul 12, 2022

What's the problem?

@Ashuaidehao
Copy link
Contributor Author

We use the rpc method calculate tx fee mostly, so the fake tx fee is not necessay.
If contract has some code to check tx fee then do something, it will block by the huge fake tx fee here.

@Jim8y
Copy link
Contributor

Jim8y commented Jul 13, 2022

We use the rpc method calculate tx fee mostly, so the fake tx fee is not necessay. If contract has some code to check tx fee then do something, it will block by the huge fake tx fee here.

My concern here is that removing a field from the interface might cause some chaos to other services who rely on it. Maybe we should mark it as deprecated for a while, instead of removing it directly.

@superboyiii
Copy link
Member

superboyiii commented Jul 13, 2022

My concern here is that removing a field from the interface might cause some chaos to other services who rely on it. Maybe we should mark it as deprecated for a while, instead of removing it directly.

As I know some dapps relying on it has been blocked already by this sysfee as it's 0 before, now it's using MaxGasInvoke...

@Jim8y
Copy link
Contributor

Jim8y commented Jul 13, 2022

If you say so.

@shargon
Copy link
Member

shargon commented Jul 14, 2022

We use the rpc method calculate tx fee mostly, so the fake tx fee is not necessay. If contract has some code to check tx fee then do something, it will block by the huge fake tx fee here.

Sorry but still don't understand the problem, the invocation is with this limited gas, so what's the problem if someone extract the tx and find the same gas?

@Ashuaidehao
Copy link
Contributor Author

We use the rpc method calculate tx fee mostly, so the fake tx fee is not necessay. If contract has some code to check tx fee then do something, it will block by the huge fake tx fee here.

Sorry but still don't understand the problem, the invocation is with this limited gas, so what's the problem if someone extract the tx and find the same gas?

Just like this .

            var totalGas = tx.SystemFee + tx.NetworkFee;
            var estimateGases = (BigInteger[])Contract.Call(RouterContract, "getAmountsOut", CallFlags.All, amountIn, tokenPath);
            var estimateGas = estimateGases[^1];
            Assert(estimateGas > totalGas, "EstimateGas is not enough", estimateGas, totalGas);

@shargon
Copy link
Member

shargon commented Jul 14, 2022

We use the rpc method calculate tx fee mostly, so the fake tx fee is not necessay. If contract has some code to check tx fee then do something, it will block by the huge fake tx fee here.

Sorry but still don't understand the problem, the invocation is with this limited gas, so what's the problem if someone extract the tx and find the same gas?

Just like this .

            var totalGas = tx.SystemFee + tx.NetworkFee;
            var estimateGases = (BigInteger[])Contract.Call(RouterContract, "getAmountsOut", CallFlags.All, amountIn, tokenPath);
            var estimateGas = estimateGases[^1];
            Assert(estimateGas > totalGas, "EstimateGas is not enough", estimateGas, totalGas);

I see, but this case it's too specific, another project can check the SystemFee and if is it 0, return. I think that it's better to add something to allow to detect if it's a test or a real invocation.

@steven1227
Copy link
Member

Any progress of this pull request? I think some contract invocation are blocked because of this change

@shargon
Copy link
Member

shargon commented Jul 19, 2022

I think that it's a very specific case. We should think in another solution, for example, configure the dummy transaction in a json

@erikzhang
Copy link
Member

erikzhang commented Jul 19, 2022

Assert(estimateGas > totalGas, "EstimateGas is not enough", estimateGas, totalGas);

And in a real transaction, the fee has been paid. Even if an exception is thrown, the fee cannot be refunded. So it doesn't make sense to make such an assert here.

@Ashuaidehao
Copy link
Contributor Author

Assert(estimateGas > totalGas, "EstimateGas is not enough", estimateGas, totalGas);

And in a real transaction, the fee has been paid. Even if an exception is thrown, the fee cannot be refunded. So it doesn't make sense to make such an assert here.

Even after removed the assert, we still block by the default 20 gas here

            var receiverAmount = amountOut - totalGas - charges;
            if (receiverAmount > 0)
            {
                SafeTransfer(GAS.Hash, me, sender, receiverAmount);
            }
            else
            {
                onNotEnough(sender, amountOut, totalGas);
            }

Because the 20 gas is too big, most transactions will run into "else" in pre-execution condition and get a wrong estimate system fee, when the real tx is persist, they will go into "if" and fault.

@erikzhang
Copy link
Member

Because the 20 gas is too big, most transactions will run into "else" in pre-execution condition and get a wrong estimate system fee, when the real tx is persist, they will go into "if" and fault.

Then I prefer Shargon‘s solution.

I think that it's better to add something to allow to detect if it's a test or a real invocation.

@steven1227
Copy link
Member

Any detailed solution? Actually, my dapp is currently stuck because of this..

@erikzhang
Copy link
Member

erikzhang commented Jul 23, 2022

How about allowing the contract to control the process during pre-execution?

I haven't thought of a good way yet.

@roman-khimov
Copy link
Contributor

  1. In NeoGo test invocations use transactions with both fees set to zero, just like it was before aa730fb.

  2. I still don't understand why contract cares about fees. I can't see all of it, but if we're talking about Flamingo, it probably cares about amountIn/amountOut balance, while fees are just out of its scope.

  3. add something to allow to detect if it's a test or a real invocation.

    Any test/real branches are better be avoided, it can lead to wrong system fee estimates and wrong execution result estimates.

@erikzhang
Copy link
Member

Any test/real branches are better be avoided, it can lead to wrong system fee estimates and wrong execution result estimates.

I agree. Then we can't set fee to 0 in test calls. Otherwise, contracts can detect if it's a test call by checking if the fee is 0.

@erikzhang
Copy link
Member

Then we can't set fee to 0 in test calls. Otherwise, contracts can detect if it's a test call by checking if the fee is 0.

One solution I can think of is two test executions per transaction. The first time the fee is set to 0, and the contract is allowed to control the branches. The second time the fee is set to the actual gas consumed, so that the contract cannot control the branches.

@roman-khimov
Copy link
Contributor

How about the network fee? Any static value there will also be wrong.

What I'd do here is merge this PR as is to solve the problem some dApps have now and create a new issue for additional discussion. The behavior was changed, this change broke some (buggy) contracts, reverting it won't affect good contracts (they don't care about fees), but will restore the old behavior and make contracts that depend on it work. Then we can try to fix contracts/create a better solution for 3.4.1.

@Ashuaidehao Ashuaidehao mentioned this pull request Jul 26, 2022
@erikzhang
Copy link
Member

We can merge it first and consider #746 in the next release.

@erikzhang erikzhang merged commit a6e1a12 into neo-project:master Jul 27, 2022
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.

None yet

7 participants