mirror of https://github.com/status-im/nim-eth.git
Change `VersionedHash` to `Hash32` (#738)
This is closer to both the exeuction spec and api
This commit is contained in:
parent
119c910a4e
commit
086ac68c86
|
@ -70,11 +70,12 @@ export eth_hash
|
||||||
type
|
type
|
||||||
# Names that don't appear in the spec and have no particular purpose any more -
|
# Names that don't appear in the spec and have no particular purpose any more -
|
||||||
# just use the underlying type directly
|
# just use the underlying type directly
|
||||||
|
Blob* {.deprecated.} = seq[byte]
|
||||||
|
BlockHeader*{.deprecated: "Header".} = Header
|
||||||
|
BlockNonce* {.deprecated.} = Bytes8
|
||||||
BloomFilter* {.deprecated.} = Bloom
|
BloomFilter* {.deprecated.} = Bloom
|
||||||
StorageKey* {.deprecated.} = Bytes32
|
StorageKey* {.deprecated.} = Bytes32
|
||||||
Blob* {.deprecated.} = seq[byte]
|
|
||||||
VersionedHashes* {.deprecated.} = seq[VersionedHash]
|
VersionedHashes* {.deprecated.} = seq[VersionedHash]
|
||||||
BlockNonce* {.deprecated.} = Bytes8
|
|
||||||
|
|
||||||
func toBlockNonce*(n: uint64): BlockNonce {.deprecated.} =
|
func toBlockNonce*(n: uint64): BlockNonce {.deprecated.} =
|
||||||
n.to(BlockNonce)
|
n.to(BlockNonce)
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
|
|
||||||
import std/typetraits, json_serialization, ./eth_types
|
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
|
# This module contains "convenience formatting" for logging `eth_types` - this
|
||||||
# formatting does not conform to any particular Ethereum-based standard - in
|
# formatting does not conform to any particular Ethereum-based standard - in
|
||||||
|
|
|
@ -24,6 +24,11 @@ type
|
||||||
Root* = Hash32
|
Root* = Hash32
|
||||||
## Alias used for MPT roots
|
## 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
|
const zeroHash32* = system.default(Hash32) ## Hash32 value consisting of all zeroes
|
||||||
|
|
||||||
template to*(v: array[32, byte], _: type Hash32): Hash32 =
|
template to*(v: array[32, byte], _: type Hash32): Hash32 =
|
||||||
|
|
|
@ -38,8 +38,6 @@ type
|
||||||
parentBeaconBlockRoot*: Opt[Hash32] # EIP-4788
|
parentBeaconBlockRoot*: Opt[Hash32] # EIP-4788
|
||||||
requestsRoot*: Opt[Hash32] # EIP-7685
|
requestsRoot*: Opt[Hash32] # EIP-7685
|
||||||
|
|
||||||
BlockHeader*{.deprecated: "Header".} = Header
|
|
||||||
|
|
||||||
# starting from EIP-4399, `mixDigest` field is called `prevRandao`
|
# starting from EIP-4399, `mixDigest` field is called `prevRandao`
|
||||||
template prevRandao*(h: Header): Hash32 =
|
template prevRandao*(h: Header): Hash32 =
|
||||||
h.mixHash
|
h.mixHash
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import "."/addresses, base
|
import "."/[addresses, base, hashes]
|
||||||
|
|
||||||
export addresses, base
|
export addresses, base, hashes
|
||||||
|
|
||||||
type
|
type
|
||||||
AccessPair* = object
|
AccessPair* = object
|
||||||
|
@ -18,8 +18,6 @@ type
|
||||||
|
|
||||||
AccessList* = seq[AccessPair]
|
AccessList* = seq[AccessPair]
|
||||||
|
|
||||||
VersionedHash* = Bytes32
|
|
||||||
|
|
||||||
Authorization* = object
|
Authorization* = object
|
||||||
chainId*: ChainId
|
chainId*: ChainId
|
||||||
address*: Address
|
address*: Address
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
import "."/[addresses_rlp, base_rlp, transactions], ../rlp
|
import "."/[addresses_rlp, base_rlp, hashes_rlp, transactions], ../rlp
|
||||||
|
|
||||||
from stew/objects import checkedEnumAssign
|
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) =
|
proc appendTxLegacy(w: var RlpWriter, tx: Transaction) =
|
||||||
w.startList(9)
|
w.startList(9)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import
|
||||||
unittest2,
|
unittest2,
|
||||||
../../eth/common,
|
../../eth/common,
|
||||||
../../eth/rlp,
|
../../eth/rlp,
|
||||||
../../eth/common/transaction
|
../../eth/common/transactions_rlp
|
||||||
|
|
||||||
const
|
const
|
||||||
recipient = address"095e7baea6a6c7c4c2dfeb977efac326af552d87"
|
recipient = address"095e7baea6a6c7c4c2dfeb977efac326af552d87"
|
||||||
|
@ -94,7 +94,7 @@ proc tx5(i: int): PooledTransaction =
|
||||||
|
|
||||||
proc tx6(i: int): PooledTransaction =
|
proc tx6(i: int): PooledTransaction =
|
||||||
const
|
const
|
||||||
digest = bytes32"010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c444014"
|
digest = hash32"010657f37554c781402a22917dee2f75def7ab966d7b770905398eba3c444014"
|
||||||
|
|
||||||
PooledTransaction(
|
PooledTransaction(
|
||||||
tx: Transaction(
|
tx: Transaction(
|
||||||
|
@ -113,7 +113,7 @@ proc tx6(i: int): PooledTransaction =
|
||||||
|
|
||||||
proc tx7(i: int): PooledTransaction =
|
proc tx7(i: int): PooledTransaction =
|
||||||
const
|
const
|
||||||
digest = bytes32"01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e"
|
digest = hash32"01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e"
|
||||||
|
|
||||||
PooledTransaction(
|
PooledTransaction(
|
||||||
tx: Transaction(
|
tx: Transaction(
|
||||||
|
@ -129,7 +129,7 @@ proc tx7(i: int): PooledTransaction =
|
||||||
|
|
||||||
proc tx8(i: int): PooledTransaction =
|
proc tx8(i: int): PooledTransaction =
|
||||||
const
|
const
|
||||||
digest = bytes32"01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e"
|
digest = hash32"01624652859a6e98ffc1608e2af0147ca4e86e1ce27672d8d3f3c9d4ffd6ef7e"
|
||||||
|
|
||||||
PooledTransaction(
|
PooledTransaction(
|
||||||
tx: Transaction(
|
tx: Transaction(
|
||||||
|
|
Loading…
Reference in New Issue