Skip to content

Commit

Permalink
Be explicit about where to get next nonce from when performing extra
Browse files Browse the repository at this point in the history
    check on pre-verified transaction.
  • Loading branch information
MilkywayPirate committed Nov 17, 2023
1 parent 7c3f13c commit e5fb993
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -898,12 +898,14 @@ instance
oldCredential <- case wmdData of
CredentialDeployment{} -> memberTransactionTable wmdHash
_ -> return False
-- We need to check here that the nonce is still ok, because it could be
-- that a block was finalized thus the next account nonce being incremented
-- We need to check here that the nonce is still ok with respect to the last finalized block,
-- because it could be that a block was finalized thus the next account nonce being incremented
-- after this transaction was received and pre-verified.
isNonceOk <- case wmdData of
NormalTransaction tr -> do
(nonce, _) <- getNextAccountNonce $ accountAddressEmbed (transactionSender tr)
lfbState <- use (skovPersistentData . lastFinalized . to _bpState)
mAcc <- getAccount lfbState $ transactionSender tr
nonce <- maybe (pure minNonce) getAccountNonce (snd <$> mAcc)
return $! nonce <= transactionNonce tr
-- the sequence number will be checked by @Impl.addTransaction@.
_ -> return False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,14 @@ addPreverifiedTransaction ::
TVer.OkResult ->
m AddTransactionResult
addPreverifiedTransaction bi okRes = do
-- We need to check here that the nonce is still ok, because it could be
-- that a block was finalized thus the next account nonce being incremented
-- We need to check here that the nonce is still ok with respect to the last finalized block,
-- because it could be that a block was finalized thus the next account nonce being incremented
-- after this transaction was received and pre-verified.
isNonceOk <- case wmdData bi of
NormalTransaction tr -> do
(nonce, _) <- runAccountNonceQueryT $ getNextAccountNonce $ accountAddressEmbed (transactionSender tr)
lfbState <- use (Impl.lastFinalized . to bpState)
mAcc <- getAccount lfbState $ transactionSender tr
nonce <- maybe (pure minNonce) getAccountNonce (snd <$> mAcc)
return $! nonce <= transactionNonce tr
-- the sequence number will be checked by @Impl.addTransaction@.
_ -> return True
Expand Down

0 comments on commit e5fb993

Please sign in to comment.