diff --git a/eth/common/eth_types.nim b/eth/common/eth_types.nim index ab79b40..3d00c81 100644 --- a/eth/common/eth_types.nim +++ b/eth/common/eth_types.nim @@ -70,11 +70,12 @@ export eth_hash type # Names that don't appear in the spec and have no particular purpose any more - # just use the underlying type directly + Blob* {.deprecated.} = seq[byte] + BlockHeader*{.deprecated: "Header".} = Header + BlockNonce* {.deprecated.} = Bytes8 BloomFilter* {.deprecated.} = Bloom StorageKey* {.deprecated.} = Bytes32 - Blob* {.deprecated.} = seq[byte] VersionedHashes* {.deprecated.} = seq[VersionedHash] - BlockNonce* {.deprecated.} = Bytes8 func toBlockNonce*(n: uint64): BlockNonce {.deprecated.} = n.to(BlockNonce) diff --git a/eth/common/eth_types_json_serialization.nim b/eth/common/eth_types_json_serialization.nim index 32d0992..974ba07 100644 --- a/eth/common/eth_types_json_serialization.nim +++ b/eth/common/eth_types_json_serialization.nim @@ -8,7 +8,10 @@ import std/typetraits, json_serialization, ./eth_types -export json_serialization, eth_types +export json_serialization + +export eth_types + except BlockHeader, BlockNumber, BlockNonce, BloomFilter, Hash256, StorageKey # This module contains "convenience formatting" for logging `eth_types` - this # formatting does not conform to any particular Ethereum-based standard - in diff --git a/eth/common/hashes.nim b/eth/common/hashes.nim index 3013aee..0575ab6 100644 --- a/eth/common/hashes.nim +++ b/eth/common/hashes.nim @@ -24,6 +24,11 @@ type Root* = Hash32 ## Alias used for MPT roots + VersionedHash* = Hash32 + ## Alias used for blob hashes whose first byte indicates what the payload + ## actually is - primarily used with KZG commitments at the time of writing + ## https://github.com/ethereum/execution-specs/blob/9b95554a88d2a8485f8180254d0f6a493a593fda/src/ethereum/crypto/kzg.py#L74C1-L74C38 + const zeroHash32* = system.default(Hash32) ## Hash32 value consisting of all zeroes template to*(v: array[32, byte], _: type Hash32): Hash32 = diff --git a/eth/common/headers.nim b/eth/common/headers.nim index 65e69cb..b0d08ce 100644 --- a/eth/common/headers.nim +++ b/eth/common/headers.nim @@ -38,8 +38,6 @@ type parentBeaconBlockRoot*: Opt[Hash32] # EIP-4788 requestsRoot*: Opt[Hash32] # EIP-7685 - BlockHeader*{.deprecated: "Header".} = Header - # starting from EIP-4399, `mixDigest` field is called `prevRandao` template prevRandao*(h: Header): Hash32 = h.mixHash diff --git a/eth/common/transactions.nim b/eth/common/transactions.nim index 751f0d7..e6b35dd 100644 --- a/eth/common/transactions.nim +++ b/eth/common/transactions.nim @@ -7,9 +7,9 @@ {.push raises: [].} -import "."/addresses, base +import "."/[addresses, base, hashes] -export addresses, base +export addresses, base, hashes type AccessPair* = object @@ -18,8 +18,6 @@ type AccessList* = seq[AccessPair] - VersionedHash* = Bytes32 - Authorization* = object chainId*: ChainId address*: Address diff --git a/eth/common/transactions_rlp.nim b/eth/common/transactions_rlp.nim index 69d8f24..e130643 100644 --- a/eth/common/transactions_rlp.nim +++ b/eth/common/transactions_rlp.nim @@ -7,11 +7,11 @@ {.push raises: [].} -import "."/[addresses_rlp, base_rlp, transactions], ../rlp +import "."/[addresses_rlp, base_rlp, hashes_rlp, transactions], ../rlp from stew/objects import checkedEnumAssign -export addresses_rlp, base_rlp, transactions, rlp +export addresses_rlp, base_rlp, hashes_rlp, transactions, rlp proc appendTxLegacy(w: var RlpWriter, tx: Transaction) = w.startList(9) diff --git a/tests/common/test_eip4844.nim b/tests/common/test_eip4844.nim index 3097a04..5733528 100644 --- a/tests/common/test_eip4844.nim +++ b/tests/common/test_eip4844.nim @@ -14,7 +14,7 @@ import unittest2, ../../eth/common, ../../eth/rlp, - ../../eth/common/transaction + ../../eth/common/transactions_rlp const recipient = address"095e7baea6a6c7c4c2dfeb977efac326af552d87" @@ -94,7 +94,7 @@ proc tx5(i: int): PooledTransaction = proc tx6(i: int): PooledTransaction = const - digest = bytes32"010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c444014" + digest = hash32"010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c444014" PooledTransaction( tx: Transaction( @@ -113,7 +113,7 @@ proc tx6(i: int): PooledTransaction = proc tx7(i: int): PooledTransaction = const - digest = bytes32"01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e" + digest = hash32"01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e" PooledTransaction( tx: Transaction( @@ -129,7 +129,7 @@ proc tx7(i: int): PooledTransaction = proc tx8(i: int): PooledTransaction = const - digest = bytes32"01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e" + digest = hash32"01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e" PooledTransaction( tx: Transaction(