Skip to content

Commit

Permalink
analyzer/consensus: Do not bump nonce for consensus.Meta txs
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjat committed Mar 1, 2024
1 parent b102297 commit 477b49a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions analyzer/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,14 @@ func (m *processor) queueTransactionInserts(batch *storage.QueryBatch, data *con
result.Error.Code,
message,
)
if m.mode != analyzer.FastSyncMode {
// Skip during fast sync; will be provided by the genesis.
batch.Queue(queries.ConsensusAccountNonceUpsert,
sender,
tx.Nonce+1,
)
// Bump the nonce.
if m.mode != analyzer.FastSyncMode { // Skip during fast sync; nonce will be provided by the genesis.
if tx.Method != "consensus.Meta" { // consensus.Meta is a special internal tx that doesn't affect the nonce.
batch.Queue(queries.ConsensusAccountNonceUpsert,
sender,
tx.Nonce+1,
)
}
}

// TODO: Use event when available
Expand Down
2 changes: 1 addition & 1 deletion api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ components:
nonce:
type: integer
format: int64
description: A nonce used to prevent replay.
description: The expected nonce for the next transaction (= last used nonce + 1)
example: 0
available:
allOf: [$ref: '#/components/schemas/TextBigInt']
Expand Down
2 changes: 1 addition & 1 deletion storage/migrations/00_consensus.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ CREATE TABLE chain.accounts

-- General Account
general_balance UINT_NUMERIC DEFAULT 0,
nonce UINT63 NOT NULL DEFAULT 0,
nonce UINT63 NOT NULL DEFAULT 0, -- expected nonce for the next transaction (= last used nonce + 1)

-- Escrow Account
-- TODO: Use UINT_NUMERIC for the next four columns. Their values should always be >=0;
Expand Down

0 comments on commit 477b49a

Please sign in to comment.