You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
User creates an interaction that approves token transfer on token contract
User creates an interaction that stakes tokens on staking contract (which underneath calls the token's contract "transferFrom" - firstly verifying if there's enough allowance (so the transaction from point 1. should be executed as first))
setting nonce is optional. If on a given block there are transactions from one wallet address with and without nonce set - the ones with nonce take precedence.
nonce is an optional parameter to the interactWrite function (using the original smartweave.js functions naming), only integer values ranging from 1 are allowed.
The nonce affect the ordering only within the transactions on a one given block (not globally).
Protocol changes:
Setting the nonce parameter in the interactWrite should result in creating a new tag in the interaction transaction - Nonce
Sorting:
The sorting algorithm first sorts the interactions according to the current specs. Each generated 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:
owner1tx1nonce 3
owner2tx2
owner1tx3nonce 2
owner3tx4
owner2tx5nonce 1
owner1tx6nonce 1
After applying the nonce-based sorting, the final ordering of transactions for contract x at block height y would be:
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: warp-contracts/warp#47
The text was updated successfully, but these errors were encountered: