excelsia / vee

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

transaction status and feeCharged states #108

Closed ncying closed 6 years ago

ncying commented 6 years ago
  1. add txStatus and chargedFee states in Diff
    • the two states keep the related states after putting the last transaction to TransactionDiffer
    • the default txStatus is Success
    • the default chargedFee is 0
  2. change contend slots transaction rules
    • set the minimal contend transaction fee to 50K VEE coin
    • add a constrain that the minimal effective balance after contend (fee charged) should larger than 1M VEE coin
    • if contend with insufficient effective balance or failed in competition with owner of slots => transaction fee will be charged and the transaction will be packed into blocks with transaction status = ContendFailed
  3. add chargedFee = tx.fee to all transaction diff except contend (see 2)
  4. change the related transaction function to processed transaction
    • stateReader retated
    • transactionInfos will record id -> (h, processed transaction's bytes) maps in db
  5. modify transaction related API
    • will return processed type json when call the API to search the confirmed transactions
    • unconfirmed transaction will continue return transaction type json (Q: @wanliy @sunnyking shall we return processed type with status "Unprocessed" ?)
  6. add extra validation in BlockDiffer
    • since there is in-block transactions with transaction status not equal to Success
    • add validation about txStatus
    • add validation about chargedFee (this case should be more complex if we enable our fee calculation system)
  7. change the return of packUnconfirmed
    • from Seq[Transaction] to Seq[ProcessedTransaction]
    • since we keep the latest txStatus and chargedFee in TransactionDiifer, so we can use these states and ProcessedTransaction method to get the required sequence.

unit test passed

[info] ScalaTest
[info] Run completed in 1 minute, 12 seconds.
[info] Total number of tests run: 322
[info] Suites: completed 101, aborted 0
[info] Tests: succeeded 322, failed 0, canceled 0, ignored 14, pending 2
[info] All tests passed.
[info] Passed: Total 322, Failed 0, Errors 0, Passed 322, Ignored 14, Pending 2
[success] Total time: 84 s, completed Aug 27, 2018 4:37:32 PM

sbt mode minter and docker seed test success manually stop at height 220

ncying commented 6 years ago

sbt mode minter and docker seed test

  1. transaction related API can get the status and feeCharged states
    {
    "type": 2,
    "id": "nk2p716Ub1vr4JsCh5XKHehe1oxSskvCV6bk9BZCQTY",
    "fee": 10000000,
    "timestamp": 1535358665039891700,
    "proofs": [
    {
      "proofType": "Curve25519",
      "publicKey": "ATtRykARbyJS1RwNsA6Rn1Um3S7FuVSovHK",
      "signature": "CcoqdK5MwShhjU26gBfKFZZ45V25qvMo9n96g1kLtG4hkhgJY8KbcaF5SzAVEJ4NAdoJuHr8eNsVLN4y1mQJfh7"
    }
    ],
    "recipient": "AUD9poQ3ernHVx2kUz9XRJvmCJEk6sZrj9T",
    "feeScale": 100,
    "amount": 100000000000000,
    "attachment": "veetest",
    "status": "Success",
    "feeCharged": 10000000,
    "height": 14
    }
ncying commented 6 years ago
  1. failed contend in competition will return an in-block transaction with status equal to ContendFailed failed case:
    {
    "type": 6,
    "id": "E34Bfd5zZoSCkozGcdtdeG8ijai8b7QtwgupPJjMQ4Ft",
    "fee": 5000000000000,
    "timestamp": 1535358355473432000,
    "proofs": [
    {
      "proofType": "Curve25519",
      "publicKey": "ATuc9KxZmMZcKEBWpkhMJfgJzrtLJ7gepA4",
      "signature": "5u2H2KyUNzqB82ijeRGT44TEHWPtukqbjtJebE6QvDREwKEirYmvEhzovGLBZkfTKrkVyFKY9PpLTDW4Tqcmqr1C"
    }
    ],
    "slotId": 0,
    "feeScale": 100,
    "status": "ContendFailed",
    "feeCharged": 5000000000000,
    "height": 6
    }

    success case:

    {
    "type": 6,
    "id": "J8W2NoeafsGA3CMuF8Tkmz9mQu4YV5AFk357JaUpgBqb",
    "fee": 5000000000000,
    "timestamp": 1535358516241921300,
    "proofs": [
    {
      "proofType": "Curve25519",
      "publicKey": "ATuc9KxZmMZcKEBWpkhMJfgJzrtLJ7gepA4",
      "signature": "5YzG7gWAmKLej8FQQecnVoH2eeNsi6PZgJE2jqfaCFRKyckA3cXd1ZKuwSq8VFpN3TQh2aDAScen1sNwfUpZbXLS"
    }
    ],
    "slotId": 11,
    "feeScale": 100,
    "status": "Success",
    "feeCharged": 5000000000000,
    "height": 9
    }
ncying commented 6 years ago
  1. failed contend with insufficient effective balance will return an in-block transaction with status equal to ContendFailed
    {
    "type": 6,
    "id": "4QKFMG6fCDYc9BfYL57ZmokhwzmLNsy8XYsRkC9aQPHk",
    "fee": 5000000000000,
    "timestamp": 1535358688182656000,
    "proofs": [
    {
      "proofType": "Curve25519",
      "publicKey": "AUD9poQ3ernHVx2kUz9XRJvmCJEk6sZrj9T",
      "signature": "47ccmKLHYYT2xt45LLdcmwFmf4vJhgU6PkYcUu4muh1N52wKapefr4AnaM5iAe9bvxFcA6dvEJmPcE2Xfmig7fxs"
    }
    ],
    "slotId": 21,
    "feeScale": 100,
    "status": "ContendFailed",
    "feeCharged": 5000000000000,
    "height": 15
    }
virtualeconomy commented 6 years ago

lgtm

On Mon, Aug 27, 2018 at 7:11 AM ncying notifications@github.com wrote:

@ncying commented on this pull request.

In src/main/scala/com/wavesplatform/state2/diffs/BlockDiffer.scala https://github.com/excelsia/VEE/pull/108#discussion_r212989480:

 val txsDiffEi = txs.foldLeft(right(feesDistribution)) { case (ei, tx) => ei.flatMap(diff =>
  • txDiffer(new CompositeStateReader(s, diff.asBlockDiff), tx)
  • .map(newDiff => diff.combine(newDiff)))
  • txDiffer(new CompositeStateReader(s, diff.asBlockDiff), tx.transaction) match {

the transaction status is reported by minter. how can we judge the status is correct or not? so, i just reprocess the transaction and validate the status. i know your idea here, because if the transaction is complex, all nodes should process this failed status transaction in their local machine.

— You are receiving this because your review was requested.

Reply to this email directly, view it on GitHub https://github.com/excelsia/VEE/pull/108#discussion_r212989480, or mute the thread https://github.com/notifications/unsubscribe-auth/AlKdEO_CjhCTw8bJdrNO3NUzK_pZkPdyks5uU_4rgaJpZM4WNdq7 .