diff --git a/nimbus/core/tx_pool/tx_tasks/tx_classify.nim b/nimbus/core/tx_pool/tx_tasks/tx_classify.nim index bd8304b0f8..a2954e1822 100644 --- a/nimbus/core/tx_pool/tx_tasks/tx_classify.nim +++ b/nimbus/core/tx_pool/tx_tasks/tx_classify.nim @@ -110,7 +110,7 @@ proc txFeesCovered(xp: TxPoolRef; item: TxItemRef): bool = baseFee = xp.baseFee return false - if item.tx.txType >= TxEip4844: + if item.tx.txType == TxEip4844: let excessBlobGas = xp.excessBlobGas blobGasPrice = getBlobBaseFee(excessBlobGas) diff --git a/nimbus/core/validate.nim b/nimbus/core/validate.nim index fe4825321b..8a62e1989b 100644 --- a/nimbus/core/validate.nim +++ b/nimbus/core/validate.nim @@ -14,7 +14,7 @@ import std/[sequtils, sets, strformat], ../db/ledger, ".."/[transaction, common/common], - ".."/[errors], + ".."/[errors, constants], ../utils/utils, "."/[dao, eip4844, gaslimit, withdrawals], ./pow/[difficulty, header], @@ -205,6 +205,9 @@ proc validateTxBasic*( if tx.txType == TxEip4844 and fork < FkCancun: return err("invalid tx: Eip4844 Tx type detected before Cancun") + if tx.txType == TxEip7702 and fork < FkPrague: + return err("invalid tx: Eip7702 Tx type detected before Prague") + if fork >= FkShanghai and tx.contractCreation and tx.payload.len > EIP3860_MAX_INITCODE_SIZE: return err("invalid tx: initcode size exceeds maximum") @@ -228,7 +231,7 @@ proc validateTxBasic*( return err("invalid tx: access list storage keys len exceeds MAX_ACCESS_LIST_STORAGE_KEYS. " & &"index={i}, len={acl.storageKeys.len}") - if tx.txType >= TxEip4844: + if tx.txType == TxEip4844: if tx.to.isNone: return err("invalid tx: destination must be not empty") @@ -243,6 +246,19 @@ proc validateTxBasic*( return err("invalid tx: one of blobVersionedHash has invalid version. " & &"get={bv.data[0].int}, expect={VERSIONED_HASH_VERSION_KZG.int}") + if tx.txType == TxEip7702: + if tx.authorizationList.len == 0: + return err("invalid tx: authorization list must not empty") + + const SECP256K1halfN = SECPK1_N div 2 + + for auth in tx.authorizationList: + if auth.yParity > 1'u64: + return err("invalid tx: auth.yParity must be 0 or 1") + + if auth.S > SECP256K1halfN: + return err("invalid tx: auth.S must be <= SECP256K1N/2") + ok() proc validateTransaction*( @@ -306,7 +322,7 @@ proc validateTransaction*( if codeHash != EMPTY_CODE_HASH: return err(&"invalid tx: sender is not an EOA. sender={sender.toHex}, codeHash={codeHash.data.toHex}") - if tx.txType >= TxEip4844: + if tx.txType == TxEip4844: # ensure that the user was willing to at least pay the current data gasprice let blobGasPrice = getBlobBaseFee(excessBlobGas) if tx.maxFeePerBlobGas < blobGasPrice: diff --git a/premix/parser.nim b/premix/parser.nim index 0a5a3a89d2..a515d94f23 100644 --- a/premix/parser.nim +++ b/premix/parser.nim @@ -187,12 +187,15 @@ proc parseTransaction*(n: JsonNode): Transaction = for acn in accessList: tx.accessList.add parseAccessPair(acn) - if tx.txType >= TxEip4844: + if tx.txType == TxEip4844: n.fromJson "maxFeePerBlobGas", tx.maxFeePerBlobGas - if n.hasKey("versionedHashes") and n["versionedHashes"].kind != JNull: - n.fromJson "versionedHashes", tx.versionedHashes + if n.hasKey("versionedHashes") and n["versionedHashes"].kind != JNull: + n.fromJson "versionedHashes", tx.versionedHashes + if tx.txType == TxEip7702: + n.fromJson "authorizationList", tx.authorizationList + tx proc parseWithdrawal*(n: JsonNode): Withdrawal =