Nonce, queue and conflict transactions
Nonce concept
In blockchain-based systems, such as cryptocurrencies like Bitcoin or Ethereum, a nonce
is used as part of the transaction verification process. When a user initiates a transaction, they include a nonce as one of the fields in the transaction data.
The nonce is typically an integer value that starts at 0
and is incremented by 1 for each subsequent transaction made by the same sender (multisig safe). The purpose of the nonce is to ensure that each transaction from a sender is unique and can only be processed once. This prevents double spending, where a user attempts to spend the same amount of cryptocurrency multiple times by creating multiple transactions with the same data. Each transaction with a different nonce is considered a distinct transaction, even if other details of the transaction, such as the recipient or the amount, remain the same. The transaction nonce serves several important purposes:
Prevents replay attacks: By including a nonce in a transaction, the sender can ensure that the transaction cannot be replayed, preventing an attacker from capturing and re-submitting the same transaction multiple times to gain unauthorized access or spend the same funds multiple times.
Enforces transaction order: The nonce also helps to enforce the order of transactions from an account. Transactions must be submitted with consecutive nonces, meaning that a transaction with nonce
n
must be submitted after a transaction with noncen-1
. This prevents transactions from being reordered or skipped, ensuring that they are processed in the intended sequence.Ensures transaction uniqueness: The transaction nonce ensures that each transaction from a sender's account is unique. Even if the transaction details, such as the recipient address or the amount, are the same, transactions with different nonces are considered distinct transactions. This prevents double spending, where the same funds are used for multiple transactions.
Transaction queue
Only transactions that have current nonce or nonce of last executed transaction +1
can actually be executed at any given time. Transactions with a higher nonce are staged for execution in the queue
. To view the transaction queue go to the main safe page, locate the Activity tab -> Queue tab.
So whenever a transaction gets executed, the next transaction in the queue will be made available for execution, given it has collected enough signatures.
Transactions staged for execution in the queue are available to be signed by multisig safe owners in order to reach confirmation threshold in advance.
Queued transactions are listed under the alert with information which nonce is expected to be executed first. Queued transactions with the completed signing flow are displayed with inactive Execute button.
You can sign queued transaction in spite of its order in the queue.
Editing nonce
Creating any multisig transaction the user can edit its nonce. Transaction nonce field will guide your with essential hints.
Automatically to any subsequent transaction will be assigned recommended nonce.
Recommended nonce:
Is equal the current nonce, when there are no transactions with the current nonce the the Queue tab.
Is higher than current nonce, when there are transactions with the current and subsequent nonce the the Queue tab.
For example:
1) the last executed nonce of the safe 2
, the current nonce equals 3
, there are no queued transactions with nonce 3
-> recommended nonce will be 3
.
2) the last executed nonce of the safe 2
, the current nonce equals 3
, there are queued transactions with nonces 3,4,6
-> recommended nonce will be 5
.
Edited nonce:
Edited nonce cannot be lower than current nonce, or
last executed transaction +1
.
Edited nonce can be higher than recommended or current nonce. In this case the user can create a transaction with higher nonce, get all the owner confirmations, but cannot execute the transaction before other transactions with lower nonce are executed. Such transaction (with higher nonce) will be queued for later execution.
Edited nonce can be the same as nonce of an already created but not executed transaction. This will create conflict transactions.
Conflict transactions
In case there are transactions with the same nonce that are waiting to be executed, they are conflicting with each other.
There are two ways to create conflict transactions:
Create from scratch any new transaction and assign to it the
same nonce
as the already created transaction has.This option will be introduced later: Created but not executed transaction has action button Replace. It pop-ups a window with two options: create a reject transaction or create a replace transaction.
Any conflict transaction can acquire owners’ confirmations independently. Conflict transactions displayed in the Queue tab with the same nonce and same action buttons (Sign / Execute). After getting all the owners’ confirmations one of the conflict transactions can be executed.
Executing one transaction will automatically replace the other(s) from the list of conflict transactions. Replaced, or rejected, conflict transactions are displayed in the History tab with Rejected
status.
The transaction that has already been sent to the blockchain acquires Processing
status in the Queue tab.
To reject this processing transaction and execute another one, you can still create and execute the conflict transaction with the higher gas fee. That means, the execution of the conflict transaction, with the gas fee higher than the processing one has, will be faster.
Nevertheless, when this transaction is close to its completion, the Processing status is changed to Finalizing
status in the Queue tab.
At this stage, creation or execution of the conflict transactions with the same nonce is not possible anymore, the execution process reaches the point of no return.
Last updated