Skip to content

Commit a64d2b6

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

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
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: 18 additions & 3 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
@@ -1175,6 +1181,10 @@ func (c *DBFT) processPreBlockCb(b dbft.PreBlock[common.Hash]) error {
11751181
// No need to reinitialize static pool since it was already initialized in verifyPreBlockCb.
11761182
// Reset the static pool after processing all transactions.
11771183
for i := range pre.transactions {
1184+
if pre.transactions[i].Type() == types.BlobTxType { // Skip blob transactions.
1185+
txx[i] = pre.transactions[i]
1186+
continue
1187+
}
11781188
var isEnvelope = j < len(pre.envelopesData) && pre.envelopesData[j].index == i
11791189
if !isEnvelope || // pre.transactions[i] is not an envelope, use it as-is.
11801190
decryptedTxsBytes[j] == nil { // pre.transactions[i] is Envelope, but its content failed to be decrypted, use Envelope as-is.
@@ -1295,6 +1305,11 @@ func (c *DBFT) initStaticPool(parent *types.Header, state *state.StateDB) error
12951305

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

0 commit comments

Comments
 (0)