@@ -1142,7 +1142,7 @@ func (c *DBFT) processPreBlockCb(b dbft.PreBlock[common.Hash]) error {
11421142 break
11431143 }
11441144 }
1145- err = c .validateDecryptedTx (parent , decryptedTx , pre .transactions [i ])
1145+ err = c .validateDecryptedTx (parent , decryptedTx , pre .transactions [i ], pre . finalReceipts [ i ] )
11461146 if err != nil {
11471147 if fallbackToEnvelope (i , true , fmt .Sprintf ("decrypted transaction verification failed: %s" , err )) {
11481148 continue
@@ -1232,7 +1232,7 @@ func (c *DBFT) newLocalPool(parent *types.Header) *legacypool.LegacyPool {
12321232}
12331233
12341234// validateDecryptedTx checks the validity of the transaction to determine whether the outer envelope transaction should be replaced.
1235- func (c * DBFT ) validateDecryptedTx (head * types.Header , decryptedTx * types.Transaction , envelope * types.Transaction ) error {
1235+ func (c * DBFT ) validateDecryptedTx (head * types.Header , decryptedTx * types.Transaction , envelope * types.Transaction , envelopeReceipt * types. Receipt ) error {
12361236 // Make sure the transaction is signed properly and has the same sender and nonce with envelope
12371237 if decryptedTx .Nonce () != envelope .Nonce () {
12381238 return fmt .Errorf ("decryptedTx nonce mismatch: decryptedNonce %v, envelopeNonce %v" , decryptedTx .Nonce (), envelope .Nonce ())
@@ -1262,6 +1262,15 @@ func (c *DBFT) validateDecryptedTx(head *types.Header, decryptedTx *types.Transa
12621262 if decryptedTx .Hash ().Cmp (expectedH ) != 0 {
12631263 return fmt .Errorf ("decryptedTx hash mismatch: expected %s, got %s" , expectedH , decryptedTx .Hash ())
12641264 }
1265+ // Ensure decrypted gas limit is the same as the envelope declared
1266+ expectedG := antimev .GetEncryptedGas (envelope )
1267+ if decryptedTx .Gas () != uint64 (expectedG ) {
1268+ return fmt .Errorf ("decryptedTx gas limit mismatch: expected %v, got %v" , expectedG , decryptedTx .Gas ())
1269+ }
1270+ // Ensure decrypted gas limit has been allocated by Envelope
1271+ if decryptedTx .Gas () > envelopeReceipt .GasUsed {
1272+ return fmt .Errorf ("decryptedTx gas limit not allocated: needed %v, got %v" , decryptedTx .Gas (), envelopeReceipt .GasUsed )
1273+ }
12651274
12661275 return nil
12671276}
0 commit comments