Skip to content

Commit 8495221

Browse files
committed
dbft: split validateDecryptedTx into logical blocks
Validation rules are going to be extended, so it's more readable to have a set of validation rules splitted. Signed-off-by: Anna Shaleva <[email protected]>
1 parent ec31e5d commit 8495221

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

consensus/dbft/dbft.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,11 +1237,14 @@ func (c *DBFT) validateDecryptedTx(head *types.Header, decryptedTx *types.Transa
12371237
if decryptedTx.Nonce() != envelope.Nonce() {
12381238
return fmt.Errorf("decryptedTx nonce mismatch: decryptedNonce %v, envelopeNonce %v", decryptedTx.Nonce(), envelope.Nonce())
12391239
}
1240+
12401241
// Ensure the gasprice is high enough to replace the envelope transaction
12411242
baseFee := head.BaseFee
12421243
if decryptedTx.EffectiveGasTipCmp(envelope, baseFee) < 0 {
12431244
return fmt.Errorf("decryptedTx underpriced: EffectiveGasTip needed %v, EffectiveGasTip permitted %v", envelope.EffectiveGasTipValue(baseFee), decryptedTx.EffectiveGasTipValue(baseFee))
12441245
}
1246+
1247+
// Ensure envelope sender matches decrypted sender.
12451248
envelopeFrom, err := types.Sender(c.signerConfig, envelope)
12461249
if err != nil {
12471250
return fmt.Errorf("%w: failed to retrieve envelope sender: %w", txpool.ErrInvalidSender, err)
@@ -1253,6 +1256,7 @@ func (c *DBFT) validateDecryptedTx(head *types.Header, decryptedTx *types.Transa
12531256
if envelopeFrom != decryptedFrom {
12541257
return fmt.Errorf("decryptedTx from mismatch: decryptedFrom %v, envelopeFrom %v", decryptedFrom, envelopeFrom)
12551258
}
1259+
12561260
return nil
12571261
}
12581262

0 commit comments

Comments
 (0)