neo-project / neo

NEO Smart Economy
MIT License
3.47k stars 1.03k forks source link

Make NEO transfers free #1452

Closed erikzhang closed 3 years ago

erikzhang commented 4 years ago

Abstract Currently, if an address wants to obtain GAS, it must first make a NEO transfer. However, you must have GAS in the address before you can transfer NEO. This creates a contradiction. Although there are other ways to solve this problem, I think the most advantageous way is to make NEO's transfers free.

Can it be attacked? It will not be attacked. The total amount of NEO is 100 million, and the smallest unit is 1. So there are at most 100 million NEO addresses in the network at the same time. The amount of data occupied by these addresses is only a few gigabyte at most, and I think this is acceptable. The only problem may be GAS. Because GAS is generated after the transfer, and the minimum unit of GAS is 0.00000001. This may cause an attack. Therefore, we must stipulate that only voting NEO can get GAS rewards, and voting needs to lock NEO for a period of time.

Advantages

Other improvements In addition, voting can be free too. Because the amount of data is similar. Moreover, since NEO will be locked for a period of time after voting, this makes it more difficult to be attacked.

shargon commented 4 years ago

I like it, but how do you want to do it? recycling gas or detecting the script pattern?

Tommo-L commented 4 years ago

but how do you want to do it? recycling gas or detecting the script pattern?

Different transaction type like the oracle tx?

I think we can also set a MaxFreeNeoTransferPerBlock limit in PolicyContract, and user can choose to pay a little fee for fast onchain.

erikzhang commented 4 years ago

It is very easy. Just modify this line.

https://github.com/neo-project/neo/blob/4ddca3eaea0ac039f349dcf2b782aa52253c9e72/src/neo/SmartContract/Native/Tokens/Nep5Token.cs#L163

shargon commented 4 years ago

But we need gas for the Transaction.Size and for the opcodes required to hit this native contract.

erikzhang commented 4 years ago

Another way is to create a new SYSCALL. Neo.Native.Tokens.NEO.Transfer.

Tommo-L commented 4 years ago

I recommend we can add from, to and amount fields for NEO free transfer.

shargon commented 4 years ago

I recommend we can add from, to and amount fields for NEO free transfer.

In transactions?

For me the problem is that there are more checks before the execution, we need to ensure that he pay for the transaction.size, if we want to make free NEO transfers (i want) we need to identify that this is a NEO transfer.

Tommo-L commented 4 years ago

In transactions?

Yes

I suggest he only pay for the size = attrs.length + script.length + witnesses.length(except sender's)

Tommo-L commented 4 years ago

If possible, I hope we can add a constraint that each account has up to 10 free NEO transfer transactions.

For voting, I suggest that there should still have a fee if we use governance committee mechanism.

shargon commented 4 years ago

I would like to have free tx independent of the execution. Maybe requiring a lock of your NEO of the amount of GAS it could be beneficial for users.

You want a free tx? then lock X neo during Y time

erikzhang commented 4 years ago

You want a free tx? then lock X neo during Y time

That's why we have GAS.

Tommo-L commented 4 years ago

Another way, we can just create a FreeCallContract, and also use it as the Tx.Sender. Then we don't have to anything with transaction structure or syscall.

class FreeCallContract{

    IsActive(){
        return true/false
   }

    Verification(){ // for VerificationTrigger
         if (!IsActive()) return false;
         // limit the number of free transactions per account.
         // limit the total GAS amount of this Contract, which is equivalent to limiting free transactions per block

         // check script
       return true;
    }

    TransferNEO(from, to, amount){
         if (!checkConstraints()) return false;
         NEO.Contract.Transfer(from, to, amount)
         paybackFee(fixedTransferFee)
     }

     VoteCommittee(from, list){
         if (!checkConstraints()) return false;
         //....
         paybackFee(fixedVotingFee)
     }

    paybackFee(fee){
        NEO.Contract.Mint(fee, self)
    }

   checkConstraints(){
         //....
   }
}

And we can also limit the number of free transactions per account in this way.

shargon commented 4 years ago

You can call other contracts after this call

FreCallContract [args]

MyContract [method] [args]
Tommo-L commented 4 years ago

Don't worry, we will check whether the script is legal in Verification method, and it can't be packaged in block unless this script is legal, which means we only support the following format:

tx.Script = System.Contract.Call FreeCallContract args
tx.Sender = FreeCallContract.Hash
shargon commented 4 years ago

Like IsMultiSigContract?

https://github.com/neo-project/neo/blob/f26ac1be3b7ab421e8c88d03a72a42deacae3a05/src/neo/SmartContract/Helper.cs#L41

Tommo-L commented 4 years ago

Yes

Tommo-L commented 4 years ago

I hope we can keep the free transaction. When the user only has NEO without GAS, he can apply for the free transaction. We can limit one account to 3 free transactions. And this approach will not affect our system revenue or increase network congestion, but it has greatly improved our user friendliness.

shargon commented 4 years ago

If the problem of free transactions is the spam, we will have this problem with any kind of free transactions, so for me, limit free tx only for transfer neo, only bring us problems, no benefits (Excepts the first transaction).

Tommo-L commented 4 years ago

Why spam? We can limit the GAS amount in FreeContractCall to limit the number of free transactions.

Tommo-L commented 4 years ago

Got your point, one can create a lot of new addresses to create a lot of free txs.

Tommo-L commented 4 years ago

Maybe it's better to be solved at business layer, like Uniswap swaping NEO for GAS.

erikzhang commented 4 years ago

Currently, the transfer of neo will automatically modify the storage of the gas contract (to generate gas for the account). If we require users to explicitly claim gas, it can significantly reduce neo transfer fees.

In fact, I think that only locked neo can generate gas. So the user must explicitly unlock to get gas.

vncoelho commented 4 years ago

In https://github.com/neo-project/neo/issues/1468 @igormcoelho talks about discounts when this automatically claim happens, then, we could allow cheap transactions for NEP5 and others

Tommo-L commented 4 years ago

only locked neo can generate gas

In a sense, hold is lock, but lock has one more display action.

shargon commented 4 years ago

What do you think in allow free tx for all kind of transactions.

So the idea is, create a local configuration for CN where they can choose if they want to serve or not free tx. If it's only one, free tx will be delayed, but I think that it's not a problem.

It's easier to implement, easier for the user, good for the daps..

In fact, bitcoin and ethereum works like that, but with other consensus mechanism.

Tommo-L commented 4 years ago

We could configure the polic of the consensus, if they want to mine free transaction they can do it, if they don't want, it doesn't care, we will remove the free later, when other transactions bring to the mempool

I think it's not good enough, it'll affect the performance of consensus nodes.

Tommo-L commented 4 years ago

If the problem of free transactions is the spam, we will have this problem with any kind of free transactions

@shargon I think we can solve this issue for FreeCallContract. As we can set two limitations for the contract:

Personally, I still hope we can support free transaction, and the solution is decoupled. We can disable the contract when we don't need free transaction.

shargon commented 4 years ago

Maybe the max fee for tree tx should be configured in the policy native contract in order to be able to disable it if there are spam :)

Limit the free tx to a syscall require the execution of this script in order to know the priority.

Tommo-L commented 4 years ago

Maybe the max fee for tree tx should be configured in the policy native contract in order to be able to disable it if there are spam :)

Agree

Limit the free tx to a syscall require the execution of this script in order to know the priority.

I think it's not necessary as it's already the low priority without extra network fee?
Or don't need to execute the script, we'll have a special transaction version? Or identify the Sender?

Tommo-L commented 4 years ago

For me, maybe we need special transction version/type, which will also be used in oracle.

Tommo-L commented 4 years ago

In #1468 @igormcoelho talks about discounts when this automatically claim happens, then, we could allow cheap transactions for NEP5 and others

For me, I like this proposal, as it makes business sense.