Open ppedziwiatr opened 2 years ago
Assumptions:
interactWrite
function (using the original smartweave.js
functions naming), only integer values ranging from 1 are allowed.Protocol changes:
nonce
parameter in the interactWrite
should result in creating a new tag in the interaction transaction - Nonce
sortKey
should have a wallet address assigned (Transaction.owner
).
Next - for transactions within given block, based on the value of the Nonce
transaction tag, we rearrange the order - but only within the "slots" associated with a given wallet address.Example:
Let's say that original ordering of transactions (i.e. generated by the current sorting alg) for contract x
at block height y
looks like this:
owner1
tx1
nonce 3
owner2
tx2
owner1
tx3
nonce 2
owner3
tx4
owner2
tx5
nonce 1
owner1
tx6
nonce 1
After applying the nonce-based sorting, the final ordering of transactions for contract x
at block height y
would be:
owner1
tx6
nonce 1
owner2
tx5
nonce 1
owner1
tx3
nonce 2
owner3
tx4
owner2
tx2
owner1
tx1
nonce 3
There should be an option for the user to decide what is the order of execution of his interactions mined within one block. Currently - if two or more transactions for given smart contract are mined within one block, the order of execution depends on the ordering of
sha256(transactionId + blockHash)
- because of the random nature of the transactionId, it cannot be guaranteed that the order of execution will be the same as the order in which the transactions were posted.An example use case would be:
Original issue: https://github.com/redstone-finance/redstone-smartcontracts/issues/47