Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analyzer/consensus: Do not bump nonce for consensus.Meta txs #651

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions analyzer/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,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 @@ -1973,7 +1973,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 @@ -188,7 +188,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
Loading