excelsia / vee

VEE Reference Full Node
MIT No Attribution
29 stars 10 forks source link

alias/contract insufficient fee in api #42

Open ncying opened 6 years ago

ncying commented 6 years ago

when create an alias or contract in api, if the fee number insufficient, for example:

{
  "sender": "3N4SMepbKXPRADdjfUwNYKdcZdMoVJGXQP5",
  "name": "test",
  "content": "tes",
  "fee": 100000
}

we will get

{
  "error": 199,
  "message": "Fee in WAVES for CreateContractTransaction transaction does not exceed minimal value of 200000"
}

then increase the fee

{
  "sender": "3N4SMepbKXPRADdjfUwNYKdcZdMoVJGXQP5",
  "name": "test",
  "content": "tes",
  "fee": 300000
}

and return the same error, but this time the fee number is valid

{
  "error": 199,
  "message": "Fee in WAVES for CreateContractTransaction transaction does not exceed minimal value of 200000"
}
ncying commented 6 years ago

here is the reason: APIs collect the data and create the transaction => put into utx pool if the tx id is already in cache, return the infomation, see https://github.com/excelsia/VEE/blob/28d3b4efe32bfbaff84356a76245cc11913cef6a/src/main/scala/com/wavesplatform/UtxPool.scala#L62 else validate the transaction (e.g. judge the fee sufficiency)

the tx id of alias and contract transaction will be exactly same if we use same alias or name. in the case i reported, a same tx id with insufficient fee error is already in cache. so, if you try to submit another transaction with same alias or name, you will return the insufficient fee error again.

i tested the same submission after restarting the node, then it passed.

suggestion: add timestamps in toHash data and get a dynamic tx id

virtualeconomy commented 6 years ago

makes sense. maybe just remove the following line so that the id is based on toSign()?

override lazy val id: ByteStr = ByteStr(FastCryptographicHash(transactionType.id.toByte +: contract.name.getBytes("UTF-8")))

virtualeconomy commented 6 years ago

@ning2056 did some more research, this will only happen if the fee is not 0 and the fee is not enough. the txn is only in the utxpool for 90 minutes. we can just reduce the time if we want to solve this issue.

we can't just change the id as it is used by @ning2056 for uniqueness of the contract.

Unverified transactions pool settings

utx {

Pool size

max-size = 10000
# Evict transaction from UTX pool after it gets older than specified
max-transaction-age = 90m

}

ncying commented 6 years ago

Yes, I know the tx id was used as uniqueness test in contract transaction. It seems that we can add extra parameter like what used in original payment transaction, and use the new parameter for uniqueness in contract.

ning2056 commented 6 years ago

seems we can either

  1. don't put it in cache at all if there is validation error. that means if you resubmit it again we need to do the same validation again, though the validation is light weighted at this time. or
  2. add more fields to generate id, and then we need to do extra validation to make sure the alias or contract name is unique.
  3. reduce the timeout time, but the user will still have the problem, just for shorter period.
virtualeconomy commented 6 years ago

maybe we just try 3 -- since we are generating one block every second, the time should be reduced anyway.