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

Transaction Ordering #18

Open
ncying opened this issue Jun 22, 2018 · 2 comments
Open

Transaction Ordering #18

ncying opened this issue Jun 22, 2018 · 2 comments
Assignees

Comments

@ncying
Copy link
Contributor

ncying commented Jun 22, 2018

Two ordering methods in Waves,

  1. TransactionOrdering.InUTXPool (-txFee, timeStamp, txId)
  2. TransactionOrdering.InBlock (-txFee, -timeStamp, txId)
    https://github.com/wavesplatform/Waves/blob/v0.7.9/src/main/scala/scorex/consensus/TransactionsOrdering.scala

in waves v0.7.9 (Aug 14, 2017), they use sort 1 first and choose 100 valid txs, then use sort 2 to package the utxs.

start from waves v0.8.0 ( Oct 13, 2017), an extra parameter (sortInBlock) added to control the sort 2.
if sortInBlock then return utxs with sort 2
else return utxs.reverse (tx +: valid is used to generate the utxs, so reverse is needed)
https://github.com/wavesplatform/Waves/blob/00c59dd68ef19d8dcfc252909295f43c86ae4d50/src/main/scala/com/wavesplatform/UtxPool.scala#L124

the sortInBlock is defined as follows:
sortInBlock = history.height() <= blockchainSettings.functionalitySettings.dontRequireSortedTransactionsAfter
https://github.com/wavesplatform/Waves/blob/00c59dd68ef19d8dcfc252909295f43c86ae4d50/src/main/scala/com/wavesplatform/mining/Miner.scala#L104
dontRequireSortedTransactionsAfter: Long = blockVersion3After
https://github.com/wavesplatform/Waves/blob/00c59dd68ef19d8dcfc252909295f43c86ae4d50/src/main/scala/com/wavesplatform/settings/BlockchainSettings.scala#L29
in waves v0.8.7 (Dec 7, 2017), this value fixed
blockVersion3AfterHeight = 795000
https://github.com/wavesplatform/Waves/blob/de7f53841e6589354062f458e5d3ecdd72c8e902/src/main/scala/com/wavesplatform/settings/BlockchainSettings.scala#L50
before that
blockVersion3AfterHeight = Long.MaxValue

from the blockVersion3, all new blocks will not use the sort 2, which means that the order of txs fixed.

a fixed transaction order can handle the blocks with reliant txs (ex. contend/release txs or smart contract txs)

@virtualeconomy
Copy link
Contributor

thanks for documenting this!

@ncying
Copy link
Contributor Author

ncying commented Aug 6, 2018

reset the order by (feeScale, fee, timestamp, txType)

@virtualeconomy virtualeconomy removed their assignment Nov 21, 2018
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

No branches or pull requests

4 participants