diff --git a/hive_integration/nodocker/engine/clmock.nim b/hive_integration/nodocker/engine/clmock.nim index 2d2314822..b7166603e 100644 --- a/hive_integration/nodocker/engine/clmock.nim +++ b/hive_integration/nodocker/engine/clmock.nim @@ -368,7 +368,7 @@ func versionedHashes(bb: BlobsBundleV1): seq[BlockHash] = for com in bb.commitments: var h = keccakHash(com.bytes) - h.data[0] = BLOB_COMMITMENT_VERSION_KZG + h.data[0] = VERSIONED_HASH_VERSION_KZG result.add BlockHash(h.data) proc broadcastNewPayload(cl: CLMocker, payload: ExecutionPayload): Result[PayloadStatusV1, string] = diff --git a/nimbus/constants.nim b/nimbus/constants.nim index 9cb0f9217..6d95322c4 100644 --- a/nimbus/constants.nim +++ b/nimbus/constants.nim @@ -76,13 +76,13 @@ const MAX_ACCESS_LIST_SIZE* = 1 shl 24 # 2^24 MAX_ACCESS_LIST_STORAGE_KEYS* = 1 shl 24 # 2^24 MAX_TX_WRAP_COMMITMENTS* = 1 shl 12 # 2^12 - BLOB_COMMITMENT_VERSION_KZG* = 0x01.byte + VERSIONED_HASH_VERSION_KZG* = 0x01.byte FIELD_ELEMENTS_PER_BLOB* = 4096 GAS_PER_BLOB* = (1 shl 17).uint64 # 2^17 - TARGET_BLOB_GAS_PER_BLOCK* = (1 shl 18).uint64 # 2^18 + TARGET_BLOB_GAS_PER_BLOCK* = 393216 MIN_BLOB_GASPRICE* = 1'u64 - BLOB_GASPRICE_UPDATE_FRACTION* = 2225652'u64 - MAX_BLOB_GAS_PER_BLOCK* = (1 shl 19).uint64 # 2^19 - MaxAllowedBlob* = MAX_BLOB_GAS_PER_BLOCK div GAS_PER_BLOB + BLOB_GASPRICE_UPDATE_FRACTION* = 3338477'u64 + MAX_BLOB_GAS_PER_BLOCK* = 786432 + MAX_ALLOWED_BLOB* = MAX_BLOB_GAS_PER_BLOCK div GAS_PER_BLOB # End diff --git a/nimbus/core/eip4844.nim b/nimbus/core/eip4844.nim index d89dd9fa4..ea402d8f2 100644 --- a/nimbus/core/eip4844.nim +++ b/nimbus/core/eip4844.nim @@ -40,7 +40,7 @@ const # kzgToVersionedHash implements kzg_to_versioned_hash from EIP-4844 proc kzgToVersionedHash(kzg: kzg.KZGCommitment): VersionedHash = result = keccakHash(kzg) - result.data[0] = BLOB_COMMITMENT_VERSION_KZG + result.data[0] = VERSIONED_HASH_VERSION_KZG # pointEvaluation implements point_evaluation_precompile from EIP-4844 # return value and gas consumption is handled by pointEvaluation in @@ -66,6 +66,9 @@ proc pointEvaluation*(input: openArray[byte]): Result[void, string] = commitment[0..<48] = input[96..<144] kzgProof[0..<48] = input[144..<192] + if kzgToVersionedHash(commitment).data != versionedHash: + return err("versionedHash should equal to kzgToVersionedHash(commitment)") + # Verify KZG proof let res = kzg.verifyKzgProof(commitment, z, y, kzgProof) if res.isErr: @@ -197,7 +200,7 @@ proc validateBlobTransactionWrapper*(tx: Transaction): # Now that all commitments have been verified, check that versionedHashes matches the commitments for i in 0 ..< tx.versionedHashes.len: # this additional check also done in tx validation - if tx.versionedHashes[i].data[0] != BLOB_COMMITMENT_VERSION_KZG: + if tx.versionedHashes[i].data[0] != VERSIONED_HASH_VERSION_KZG: return err("wrong kzg version in versioned hash at index " & $i) if tx.versionedHashes[i] != kzgToVersionedHash(tx.networkPayload.commitments[i]): diff --git a/nimbus/core/validate.nim b/nimbus/core/validate.nim index 220b98295..77a5258d8 100644 --- a/nimbus/core/validate.nim +++ b/nimbus/core/validate.nim @@ -287,14 +287,14 @@ proc validateTxBasic*( if tx.versionedHashes.len == 0: return err("invalid tx: there must be at least one blob") - if tx.versionedHashes.len > MaxAllowedBlob.int: - return err("invalid tx: versioned hashes len exceeds MaxAllowedBlob=" & $MaxAllowedBlob & + if tx.versionedHashes.len > MAX_ALLOWED_BLOB.int: + return err("invalid tx: versioned hashes len exceeds MAX_ALLOWED_BLOB=" & $MAX_ALLOWED_BLOB & ". get=" & $tx.versionedHashes.len) for i, bv in tx.versionedHashes: - if bv.data[0] != BLOB_COMMITMENT_VERSION_KZG: + if bv.data[0] != VERSIONED_HASH_VERSION_KZG: return err("invalid tx: one of blobVersionedHash has invalid version. " & - "get=$1, expect=$2" % [$bv.data[0].int, $BLOB_COMMITMENT_VERSION_KZG.int]) + "get=$1, expect=$2" % [$bv.data[0].int, $VERSIONED_HASH_VERSION_KZG.int]) except CatchableError as ex: return err(ex.msg) diff --git a/nimbus/evm/precompiles.nim b/nimbus/evm/precompiles.nim index 0f10ccb22..4dfe3761e 100644 --- a/nimbus/evm/precompiles.nim +++ b/nimbus/evm/precompiles.nim @@ -47,12 +47,7 @@ type # paBlsMapG1 # paBlsMapG2 # Cancun - paNoop0x0A, paNoop0x0B, paNoop0x0C, - paNoop0x0D, paNoop0x0E, paNoop0x0F, - paNoop0x10, paNoop0x11, paNoop0x12, - paNoop0x13, - - paPointEvaluation = 0x14 + paPointEvaluation = 0x0A proc getMaxPrecompileAddr(fork: EVMFork): PrecompileAddresses = if fork < FkByzantium: paIdentity @@ -64,8 +59,7 @@ proc getMaxPrecompileAddr(fork: EVMFork): PrecompileAddresses = else: PrecompileAddresses.high proc validPrecompileAddr(addrByte, maxPrecompileAddr: byte): bool = - (addrByte in PrecompileAddresses.low.byte .. maxPrecompileAddr) and - (addrByte notin paNoop0x0A.byte .. paNoop0x13.byte) + (addrByte in PrecompileAddresses.low.byte .. maxPrecompileAddr) proc validPrecompileAddr(addrByte: byte, fork: EVMFork): bool = let maxPrecompileAddr = getMaxPrecompileAddr(fork) diff --git a/nimbus/transaction.nim b/nimbus/transaction.nim index 8c3ddb0b7..856847df7 100644 --- a/nimbus/transaction.nim +++ b/nimbus/transaction.nim @@ -139,11 +139,11 @@ proc validateTxEip4844(tx: Transaction) = (acl.storageKeys.len <= MAX_ACCESS_LIST_STORAGE_KEYS) isValid = isValid and - tx.versionedHashes.len <= MaxAllowedBlob.int + tx.versionedHashes.len <= MAX_ALLOWED_BLOB.int for bv in tx.versionedHashes: isValid = isValid and - bv.data[0] == BLOB_COMMITMENT_VERSION_KZG + bv.data[0] == VERSIONED_HASH_VERSION_KZG if not isValid: raise newException(ValidationError, "Invalid EIP-4844 transaction")