Skip to content

Commit 4b9dee7

Browse files
committed
consensus/dbft: forbid new transaction types in envelope verification
1 parent 0d2d149 commit 4b9dee7

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

antimev/envelope.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var (
5151
// IsEnvelope checks whether a transaction is an Envelope transaction. The criteria
5252
// include receiver's address, data prefix and data length check.
5353
func IsEnvelope(tx *types.Transaction) bool {
54-
return IsEnvelopeToAddress(tx.To()) && IsEnvelopeData(tx.Data())
54+
return (tx.Type() != types.BlobTxType && tx.Type() != types.SetCodeTxType) && IsEnvelopeToAddress(tx.To()) && IsEnvelopeData(tx.Data())
5555
}
5656

5757
// IsEnvelopeToAddress checks whether an address pointer has the expected value for

consensus/dbft/dbft.go

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -926,13 +926,19 @@ func (c *DBFT) verifyPreBlockCb(b dbft.PreBlock[common.Hash]) bool {
926926
}
927927
ethBlock := dbftBlock.ToEthBlock()
928928

929-
errs := c.staticPool.Add(dbftBlock.transactions, false)
929+
// Only take legacy pool transactions.
930+
legacyTxs := make(types.Transactions, 0, len(dbftBlock.transactions))
931+
for _, tx := range dbftBlock.transactions {
932+
if tx.Type() != types.BlobTxType {
933+
legacyTxs = append(legacyTxs, tx)
934+
}
935+
}
936+
errs := c.staticPool.Add(legacyTxs, false)
930937
c.staticPool.ResetStatic()
931938
for i, err := range errs {
932939
if err != nil {
933940
log.Warn("proposed PreBlock has invalid transaction",
934-
"index", i,
935-
"hash", dbftBlock.transactions[i].Hash(),
941+
"hash", legacyTxs[i].Hash(),
936942
"error", err,
937943
)
938944
return false
@@ -1144,15 +1150,17 @@ func (c *DBFT) processPreBlockCb(b dbft.PreBlock[common.Hash]) error {
11441150
"envelope index", i,
11451151
"reason", reason)
11461152
}
1147-
errs := c.staticPool.Add([]*types.Transaction{pre.transactions[i]}, false)
1148-
if errs[0] != nil {
1149-
log.Info("Falling back to original set of transactions",
1150-
"envelope hash", pre.transactions[i].Hash(),
1151-
"envelope index", i,
1152-
"reason", fmt.Sprintf("envelope has pool conflicts: %s", errs[0]))
1153-
txx = pre.transactions
1154-
hasDecryptedTxs = false
1155-
return false
1153+
if pre.transactions[i].Type() != types.BlobTxType {
1154+
errs := c.staticPool.Add([]*types.Transaction{pre.transactions[i]}, false)
1155+
if errs[0] != nil {
1156+
log.Info("Falling back to original set of transactions",
1157+
"envelope hash", pre.transactions[i].Hash(),
1158+
"envelope index", i,
1159+
"reason", fmt.Sprintf("envelope has pool conflicts: %s", errs[0]))
1160+
txx = pre.transactions
1161+
hasDecryptedTxs = false
1162+
return false
1163+
}
11561164
}
11571165
txx[i] = pre.transactions[i]
11581166
if incrementJ {
@@ -1295,6 +1303,11 @@ func (c *DBFT) initStaticPool(parent *types.Header, state *state.StateDB) error
12951303

12961304
// validateDecryptedTx checks the validity of the transaction to determine whether the outer envelope transaction should be replaced.
12971305
func (c *DBFT) validateDecryptedTx(head *types.Header, decryptedTx *types.Transaction, envelope *types.Transaction, envelopeReceipt *types.Receipt) error {
1306+
// Make sure the transaction type is supported by legacy tx pool
1307+
if decryptedTx.Type() == types.BlobTxType {
1308+
return fmt.Errorf("decryptedTx has unsupported type: %v", decryptedTx.Type())
1309+
}
1310+
12981311
// Make sure the transaction is signed properly and has the same sender and nonce with envelope
12991312
if decryptedTx.Nonce() != envelope.Nonce() {
13001313
return fmt.Errorf("decryptedTx nonce mismatch: decryptedNonce %v, envelopeNonce %v", decryptedTx.Nonce(), envelope.Nonce())

0 commit comments

Comments
 (0)