Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Nonces missmatch between pool and historyDB #392

Closed
arnaubennassar opened this issue Dec 20, 2020 · 4 comments
Closed

Nonces missmatch between pool and historyDB #392

arnaubennassar opened this issue Dec 20, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@arnaubennassar
Copy link
Contributor

When a tx is sent to the pool, it uses the current nonce (starting by 0), however in the HistoryDB the next nonce is used (starting by 1). This causes a missmatch of TxID, that defeats the purpose of the ID (being able to track the tx from the moment it's sent to the pool to the moment it's forged, and therefore added to HistoryDB)

@ed255
Copy link
Contributor

ed255 commented Dec 21, 2020

From an online discussion; the correct spec is this:

  • The account is created with nonce = 0
  • The nonce in the account states the next valid nonce for that account

@ed255
Copy link
Contributor

ed255 commented Dec 21, 2020

This also affects the purger methods:

var checkNoncesQuery = fmt.Sprintf(`
		UPDATE tx_pool SET
			state = '%s',
			batch_num = %%d
		FROM (VALUES
			(NULL::::BIGINT, NULL::::BIGINT),
			(:idx, :nonce)
		) as updated_acc (idx, nonce)
		WHERE tx_pool.from_idx = updated_acc.idx AND tx_pool.nonce <= updated_acc.nonce;
	`, common.PoolL2TxStateInvalid)

tx_pool.nonce <= updated_acc.nonce should be tx_pool.nonce < updated_acc.nonce

ed255 added a commit that referenced this issue Dec 21, 2020
- Test all the purger functions
- Fix nonces set by til (previously til started with nonce 1 for pool l2txs,
  but the correct implementation is to start with nonce 0)
- Rename L2DB.CheckNonces to L2DB.invalidateOldNoncesQuery
- Rename L2DB.checkNoncesQuery to L2DB.InvalidateOldNonces

Related #392 (Fix checkNoncesQuery)
Resolve #396
ed255 added a commit that referenced this issue Dec 22, 2020
- Test all the purger functions
- Fix nonces set by til (previously til started with nonce 1 for pool l2txs,
  but the correct implementation is to start with nonce 0)
- Rename L2DB.CheckNonces to L2DB.invalidateOldNoncesQuery
- Rename L2DB.checkNoncesQuery to L2DB.InvalidateOldNonces

Related #392 (Fix checkNoncesQuery)
Resolve #396
ed255 added a commit that referenced this issue Dec 22, 2020
- Test all the purger functions
- Fix nonces set by til (previously til started with nonce 1 for pool l2txs,
  but the correct implementation is to start with nonce 0)
- Rename L2DB.CheckNonces to L2DB.invalidateOldNoncesQuery
- Rename L2DB.checkNoncesQuery to L2DB.InvalidateOldNonces

Related #392 (Fix checkNoncesQuery)
Resolve #396
@ed255
Copy link
Contributor

ed255 commented Dec 23, 2020

This should have been fixed after #412
@arnaubennassar if you are able to test this and verify that it's fixed, please write back to this issue and close it!

@arnaubennassar arnaubennassar self-assigned this Jan 7, 2021
@arnaubennassar
Copy link
Contributor Author

I've run the integration-testing env and forged a L2 tx, and I can confirm that the nonces now start with 0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants