bump nim-eth to `171531fbf1a308c1bf4d2f6b88c6ee6924657437` (#6645)
- rm Goerli bootnodes - update Sepolia and Holesky bootnodes - Fix Authorization fields name to v, r, s - Add helper for recovering authority
This commit is contained in:
parent
03369d9c07
commit
c4be5f677a
|
@ -1104,7 +1104,7 @@ const ETHWithdrawals *ETHExecutionBlockHeaderGetWithdrawals(
|
|||
const ETHExecutionBlockHeader *executionBlockHeader);
|
||||
|
||||
/**
|
||||
* Obtains the requests MPT root of a given execution block header.
|
||||
* Obtains the requests hash of a given execution block header.
|
||||
*
|
||||
* - The returned value is allocated in the given execution block header.
|
||||
* It must neither be released nor written to, and the execution block
|
||||
|
@ -1112,10 +1112,10 @@ const ETHWithdrawals *ETHExecutionBlockHeaderGetWithdrawals(
|
|||
*
|
||||
* @param executionBlockHeader Execution block header.
|
||||
*
|
||||
* @return Execution requests root.
|
||||
* @return Execution requests hash.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const ETHRoot *ETHExecutionBlockHeaderGetRequestsRoot(
|
||||
const ETHRoot *ETHExecutionBlockHeaderGetRequestsHash(
|
||||
const ETHExecutionBlockHeader *executionBlockHeader);
|
||||
|
||||
/**
|
||||
|
@ -1278,7 +1278,7 @@ const ETHRoot *ETHTransactionGetHash(const ETHTransaction *transaction);
|
|||
* @return Chain ID.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const ETHUInt256 *ETHTransactionGetChainId(const ETHTransaction *transaction);
|
||||
const uint64_t *ETHTransactionGetChainId(const ETHTransaction *transaction);
|
||||
|
||||
/**
|
||||
* Obtains the from address of a transaction.
|
||||
|
@ -1552,6 +1552,16 @@ const ETHRoot *ETHTransactionGetBlobVersionedHash(
|
|||
const ETHTransaction *transaction,
|
||||
int versionedHashIndex);
|
||||
|
||||
/**
|
||||
* Indicates whether or not a transaction has an authorization list.
|
||||
*
|
||||
* @param transaction Transaction.
|
||||
*
|
||||
* @return Whether or not the transaction has an authorization list.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
bool ETHTransactionHasAuthorizationList(const ETHTransaction *transaction);
|
||||
|
||||
/**
|
||||
* Transaction authorization list.
|
||||
*/
|
||||
|
@ -1588,7 +1598,7 @@ int ETHAuthorizationListGetCount(const ETHAuthorizationList *authorizationList);
|
|||
/**
|
||||
* Authorization tuple.
|
||||
*/
|
||||
typedef struct ETHAuthorizationTuple ETHAuthorizationTuple;
|
||||
typedef struct ETHAuthorization ETHAuthorization;
|
||||
|
||||
/**
|
||||
* Obtains an individual authorization tuple by sequential index
|
||||
|
@ -1604,7 +1614,7 @@ typedef struct ETHAuthorizationTuple ETHAuthorizationTuple;
|
|||
* @return Authorization tuple.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const ETHAuthorizationTuple *ETHAuthorizationListGet(
|
||||
const ETHAuthorization *ETHAuthorizationListGet(
|
||||
const ETHAuthorizationList *authorizationList,
|
||||
int authorizationIndex);
|
||||
|
||||
|
@ -1615,13 +1625,13 @@ const ETHAuthorizationTuple *ETHAuthorizationListGet(
|
|||
* It must neither be released nor written to, and the authorization tuple
|
||||
* must not be released while the returned value is in use.
|
||||
*
|
||||
* @param authorizationTuple Authorization tuple.
|
||||
* @param authorization Authorization tuple.
|
||||
*
|
||||
* @return Chain ID.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const ETHUInt256 *ETHAuthorizationTupleGetChainId(
|
||||
const ETHAuthorizationTuple *authorizationTuple);
|
||||
const uint64_t *ETHAuthorizationGetChainId(
|
||||
const ETHAuthorization *authorization);
|
||||
|
||||
/**
|
||||
* Obtains the address of an authorization tuple.
|
||||
|
@ -1630,13 +1640,13 @@ const ETHUInt256 *ETHAuthorizationTupleGetChainId(
|
|||
* It must neither be released nor written to, and the authorization tuple
|
||||
* must not be released while the returned value is in use.
|
||||
*
|
||||
* @param authorizationTuple Authorization tuple.
|
||||
* @param authorization Authorization tuple.
|
||||
*
|
||||
* @return Address.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const ETHExecutionAddress *ETHAuthorizationTupleGetAddress(
|
||||
const ETHAuthorizationTuple *authorizationTuple);
|
||||
const ETHExecutionAddress *ETHAuthorizationGetAddress(
|
||||
const ETHAuthorization *authorization);
|
||||
|
||||
/**
|
||||
* Obtains the nonce of an authorization tuple.
|
||||
|
@ -1645,13 +1655,13 @@ const ETHExecutionAddress *ETHAuthorizationTupleGetAddress(
|
|||
* It must neither be released nor written to, and the authorization tuple
|
||||
* must not be released while the returned value is in use.
|
||||
*
|
||||
* @param authorizationTuple Authorization tuple.
|
||||
* @param authorization Authorization tuple.
|
||||
*
|
||||
* @return Nonce.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const uint64_t *ETHAuthorizationTupleGetNonce(
|
||||
const ETHAuthorizationTuple *authorizationTuple);
|
||||
const uint64_t *ETHAuthorizationGetNonce(
|
||||
const ETHAuthorization *authorization);
|
||||
|
||||
/**
|
||||
* Obtains the authority execution address of an authorization tuple.
|
||||
|
@ -1660,13 +1670,13 @@ const uint64_t *ETHAuthorizationTupleGetNonce(
|
|||
* It must neither be released nor written to, and the authorization tuple
|
||||
* must not be released while the returned value is in use.
|
||||
*
|
||||
* @param authorizationTuple Authorization tuple.
|
||||
* @param authorization Authorization tuple.
|
||||
*
|
||||
* @return Authority execution address.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const ETHExecutionAddress *ETHAuthorizationTupleGetAuthority(
|
||||
const ETHAuthorizationTuple *authorizationTuple);
|
||||
const ETHExecutionAddress *ETHAuthorizationGetAuthority(
|
||||
const ETHAuthorization *authorization);
|
||||
|
||||
/**
|
||||
* Obtains the signature of a authorization tuple.
|
||||
|
@ -1675,14 +1685,14 @@ const ETHExecutionAddress *ETHAuthorizationTupleGetAuthority(
|
|||
* It must neither be released nor written to, and the authorization tuple
|
||||
* must not be released while the returned value is in use.
|
||||
*
|
||||
* @param authorizationTuple Authorization tuple.
|
||||
* @param authorization Authorization tuple.
|
||||
* @param[out] numBytes Length of buffer.
|
||||
*
|
||||
* @return Buffer with signature.
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const void *ETHAuthorizationTupleGetSignatureBytes(
|
||||
const ETHAuthorizationTuple *authorizationTuple,
|
||||
const void *ETHAuthorizationGetSignatureBytes(
|
||||
const ETHAuthorization *authorization,
|
||||
int *numBytes);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1205,7 +1205,7 @@ type
|
|||
transactionsRoot: Eth2Digest
|
||||
withdrawalsRoot: Eth2Digest
|
||||
withdrawals: seq[ETHWithdrawal]
|
||||
requestsRoot: Eth2Digest
|
||||
requestsHash: Eth2Digest
|
||||
depositRequests: seq[ETHDepositRequest]
|
||||
withdrawalRequests: seq[ETHWithdrawalRequest]
|
||||
consolidationRequests: seq[ETHConsolidationRequest]
|
||||
|
@ -1324,7 +1324,7 @@ proc ETHExecutionBlockHeaderCreateFromJson(
|
|||
Opt.some data.parentBeaconBlockRoot.get.asEth2Digest.to(Hash32)
|
||||
else:
|
||||
Opt.none(Hash32),
|
||||
requestsRoot:
|
||||
requestsHash:
|
||||
if data.requestsRoot.isSome:
|
||||
Opt.some(data.requestsRoot.get.asEth2Digest.to(Hash32))
|
||||
else:
|
||||
|
@ -1455,7 +1455,7 @@ proc ETHExecutionBlockHeaderCreateFromJson(
|
|||
targetPubkey: ValidatorPubKey(blob: req.targetPubkey.data),
|
||||
bytes: rlpBytes)
|
||||
|
||||
# Verify requests root
|
||||
# Verify requests hash
|
||||
if data.depositRequests.isSome or
|
||||
data.withdrawalRequests.isSome or
|
||||
data.consolidationRequests.isSome:
|
||||
|
@ -1476,7 +1476,7 @@ proc ETHExecutionBlockHeaderCreateFromJson(
|
|||
transactionsRoot: blockHeader.txRoot,
|
||||
withdrawalsRoot: blockHeader.withdrawalsRoot.get(zeroHash32),
|
||||
withdrawals: wds,
|
||||
requestsRoot: blockHeader.requestsRoot.get(zeroHash32),
|
||||
requestsHash: blockHeader.requestsHash.get(zeroHash32),
|
||||
depositRequests: depositRequests,
|
||||
withdrawalRequests: withdrawalRequests,
|
||||
consolidationRequests: consolidationRequests)
|
||||
|
@ -1540,10 +1540,10 @@ func ETHExecutionBlockHeaderGetWithdrawals(
|
|||
## * Withdrawal sequence.
|
||||
addr executionBlockHeader[].withdrawals
|
||||
|
||||
func ETHExecutionBlockHeaderGetRequestsRoot(
|
||||
func ETHExecutionBlockHeaderGetRequestsHash(
|
||||
executionBlockHeader: ptr ETHExecutionBlockHeader
|
||||
): ptr Eth2Digest {.exported.} =
|
||||
## Obtains the requests MPT root of a given execution block header.
|
||||
## Obtains the requests hash of a given execution block header.
|
||||
##
|
||||
## * The returned value is allocated in the given execution block header.
|
||||
## It must neither be released nor written to, and the execution block
|
||||
|
@ -1553,8 +1553,8 @@ func ETHExecutionBlockHeaderGetRequestsRoot(
|
|||
## * `executionBlockHeader` - Execution block header.
|
||||
##
|
||||
## Returns:
|
||||
## * Execution requests root.
|
||||
addr executionBlockHeader[].requestsRoot
|
||||
## * Execution requests hash.
|
||||
addr executionBlockHeader[].requestsHash
|
||||
|
||||
func ETHExecutionBlockHeaderGetDepositRequests(
|
||||
executionBlockHeader: ptr ETHExecutionBlockHeader
|
||||
|
@ -1614,8 +1614,8 @@ type
|
|||
address: ExecutionAddress
|
||||
storageKeys: seq[Eth2Digest]
|
||||
|
||||
ETHAuthorizationTuple = object
|
||||
chainId: UInt256
|
||||
ETHAuthorization = object
|
||||
chainId: uint64
|
||||
address: ExecutionAddress
|
||||
nonce: uint64
|
||||
authority: ExecutionAddress
|
||||
|
@ -1623,7 +1623,7 @@ type
|
|||
|
||||
ETHTransaction = object
|
||||
hash: Eth2Digest
|
||||
chainId: UInt256
|
||||
chainId: uint64
|
||||
`from`: ExecutionAddress
|
||||
nonce: uint64
|
||||
maxPriorityFeePerGas: uint64
|
||||
|
@ -1636,7 +1636,8 @@ type
|
|||
accessList: seq[ETHAccessTuple]
|
||||
maxFeePerBlobGas: UInt256
|
||||
blobVersionedHashes: seq[Eth2Digest]
|
||||
authorizationList: seq[ETHAuthorizationTuple]
|
||||
hasAuthorizationList: bool
|
||||
authorizationList: seq[ETHAuthorization]
|
||||
signature: seq[byte]
|
||||
bytes: TypedTransaction
|
||||
|
||||
|
@ -1733,12 +1734,11 @@ proc ETHTransactionsCreateFromJson(
|
|||
# Construct transaction
|
||||
static:
|
||||
doAssert sizeof(uint64) == sizeof(ChainId)
|
||||
doAssert sizeof(uint64) == sizeof(data.chainId.get)
|
||||
doAssert sizeof(uint64) == sizeof(data.gas)
|
||||
doAssert sizeof(uint64) == sizeof(data.gasPrice)
|
||||
doAssert sizeof(uint64) == sizeof(data.maxPriorityFeePerGas.get)
|
||||
doAssert sizeof(UInt256) == sizeof(data.maxFeePerBlobGas.get)
|
||||
if distinctBase(data.chainId.get(0.Quantity)) > distinctBase(ChainId.high):
|
||||
return nil
|
||||
if data.maxFeePerBlobGas.get(0.u256) > uint64.high.u256:
|
||||
return nil
|
||||
if data.yParity.isSome:
|
||||
|
@ -1750,9 +1750,8 @@ proc ETHTransactionsCreateFromJson(
|
|||
return nil
|
||||
if data.authorizationList.isSome:
|
||||
for authorization in data.authorizationList.get:
|
||||
if distinctBase(authorization.chainId) > distinctBase(ChainId.high):
|
||||
return nil
|
||||
if distinctBase(authorization.yParity) > 1:
|
||||
static: doAssert sizeof(uint64) == sizeof(authorization.chainId)
|
||||
if distinctBase(authorization.yParity) > uint8.high:
|
||||
return nil
|
||||
let
|
||||
tx = eth_types.EthTransaction(
|
||||
|
@ -1792,9 +1791,9 @@ proc ETHTransactionsCreateFromJson(
|
|||
chainId: it.chainId.ChainId,
|
||||
address: distinctBase(it.address).to(EthAddress),
|
||||
nonce: distinctBase(it.nonce),
|
||||
yParity: distinctBase(it.yParity),
|
||||
R: it.R,
|
||||
S: it.S))
|
||||
v: distinctBase(it.yParity),
|
||||
r: it.R,
|
||||
s: it.S))
|
||||
else:
|
||||
@[],
|
||||
V: distinctBase(data.v),
|
||||
|
@ -1809,18 +1808,20 @@ proc ETHTransactionsCreateFromJson(
|
|||
if data.hash.asEth2Digest != hash:
|
||||
return nil
|
||||
|
||||
func packSignature(r, s: UInt256, yParity: bool): array[65, byte] =
|
||||
func packSignature(r, s: UInt256, yParity: uint8): array[65, byte] =
|
||||
var rawSig {.noinit.}: array[65, byte]
|
||||
rawSig[0 ..< 32] = tx.R.toBytesBE()
|
||||
rawSig[32 ..< 64] = tx.S.toBytesBE()
|
||||
rawSig[64] = if yParity: 1 else: 0
|
||||
rawSig[64] = yParity
|
||||
rawSig
|
||||
|
||||
func recoverSignerAddress(rawSig: array[65, byte]): Opt[array[20, byte]] =
|
||||
func recoverSignerAddress(
|
||||
rawSig: array[65, byte],
|
||||
hashForSigning: Hash32): Opt[array[20, byte]] =
|
||||
let
|
||||
sig = SkRecoverableSignature.fromRaw(rawSig).valueOr:
|
||||
return Opt.none(array[20, byte])
|
||||
sigHash = SkMessage.fromBytes(tx.txHashNoSignature().data).valueOr:
|
||||
sigHash = SkMessage.fromBytes(hashForSigning.data).valueOr:
|
||||
return Opt.none(array[20, byte])
|
||||
pubkey = sig.recover(sigHash).valueOr:
|
||||
return Opt.none(array[20, byte])
|
||||
|
@ -1830,11 +1831,12 @@ proc ETHTransactionsCreateFromJson(
|
|||
let
|
||||
yParity =
|
||||
if txType != TxLegacy:
|
||||
tx.V != 0
|
||||
tx.V.uint8
|
||||
else:
|
||||
(tx.V and 1) == 0
|
||||
((tx.V and 1) == 0).uint8
|
||||
rawSig = packSignature(tx.R, tx.S, yParity)
|
||||
fromAddress = recoverSignerAddress(rawSig).valueOr:
|
||||
sigHash = tx.rlpHashForSigning(tx.isEip155())
|
||||
fromAddress = recoverSignerAddress(rawSig, sigHash).valueOr:
|
||||
return nil
|
||||
if distinctBase(data.`from`) != fromAddress:
|
||||
return nil
|
||||
|
@ -1855,23 +1857,23 @@ proc ETHTransactionsCreateFromJson(
|
|||
hash.to(EthAddress)
|
||||
|
||||
# Compute authorizations
|
||||
var authorizationList = newSeqOfCap[ETHAuthorizationTuple](
|
||||
var authorizationList = newSeqOfCap[ETHAuthorization](
|
||||
tx.authorizationList.len)
|
||||
for auth in tx.authorizationList:
|
||||
let
|
||||
signature = packSignature(auth.R, auth.S, auth.yParity != 0)
|
||||
authority = recoverSignerAddress(signature).valueOr:
|
||||
sig = packSignature(auth.r, auth.s, auth.v.uint8)
|
||||
authority = recoverSignerAddress(sig, auth.rlpHashForSigning).valueOr:
|
||||
return nil
|
||||
authorizationList.add ETHAuthorizationTuple(
|
||||
chainId: distinctBase(auth.chainId).u256,
|
||||
authorizationList.add ETHAuthorization(
|
||||
chainId: distinctBase(auth.chainId),
|
||||
address: ExecutionAddress(data: auth.address.data),
|
||||
nonce: auth.nonce,
|
||||
authority: ExecutionAddress(data: authority),
|
||||
signature: @signature)
|
||||
signature: @sig)
|
||||
|
||||
txs.add ETHTransaction(
|
||||
hash: keccakHash(rlpBytes),
|
||||
chainId: distinctBase(tx.chainId).u256,
|
||||
chainId: distinctBase(tx.chainId),
|
||||
`from`: ExecutionAddress(data: fromAddress),
|
||||
nonce: tx.nonce,
|
||||
maxPriorityFeePerGas: tx.maxPriorityFeePerGas.uint64,
|
||||
|
@ -1886,6 +1888,7 @@ proc ETHTransactionsCreateFromJson(
|
|||
storageKeys: it.storageKeys.mapIt(Eth2Digest(data: it.data)))),
|
||||
maxFeePerBlobGas: tx.maxFeePerBlobGas,
|
||||
blobVersionedHashes: tx.versionedHashes.mapIt(Eth2Digest(data: it.data)),
|
||||
hasAuthorizationList: tx.txType == TxEip7702,
|
||||
authorizationList: authorizationList,
|
||||
signature: @rawSig,
|
||||
bytes: rlpBytes.TypedTransaction)
|
||||
|
@ -1954,7 +1957,7 @@ func ETHTransactionGetHash(
|
|||
addr transaction[].hash
|
||||
|
||||
func ETHTransactionGetChainId(
|
||||
transaction: ptr ETHTransaction): ptr UInt256 {.exported.} =
|
||||
transaction: ptr ETHTransaction): ptr uint64 {.exported.} =
|
||||
## Obtains the chain ID of a transaction.
|
||||
##
|
||||
## * The returned value is allocated in the given transaction.
|
||||
|
@ -2253,9 +2256,20 @@ func ETHTransactionGetBlobVersionedHash(
|
|||
## * Blob versioned hash.
|
||||
addr transaction[].blobVersionedHashes[versionedHashIndex.int]
|
||||
|
||||
func ETHTransactionHasAuthorizationList(
|
||||
transaction: ptr ETHTransaction): bool {.exported.} =
|
||||
## Indicates whether or not a transaction has an authorization list.
|
||||
##
|
||||
## Parameters:
|
||||
## * `transaction` - Transaction.
|
||||
##
|
||||
## Returns:
|
||||
## * Whether or not the transaction has an authorization list.
|
||||
transaction[].hasAuthorizationList
|
||||
|
||||
func ETHTransactionGetAuthorizationList(
|
||||
transaction: ptr ETHTransaction
|
||||
): ptr seq[ETHAuthorizationTuple] {.exported.} =
|
||||
): ptr seq[ETHAuthorization] {.exported.} =
|
||||
## Obtains the authorization list of a transaction.
|
||||
##
|
||||
## * The returned value is allocated in the given transaction.
|
||||
|
@ -2270,7 +2284,7 @@ func ETHTransactionGetAuthorizationList(
|
|||
addr transaction[].authorizationList
|
||||
|
||||
func ETHAuthorizationListGetCount(
|
||||
authorizationList: ptr seq[ETHAuthorizationTuple]): cint {.exported.} =
|
||||
authorizationList: ptr seq[ETHAuthorization]): cint {.exported.} =
|
||||
## Indicates the total number of authorization tuples
|
||||
## in a transaction authorization list.
|
||||
##
|
||||
|
@ -2285,8 +2299,8 @@ func ETHAuthorizationListGetCount(
|
|||
authorizationList[].len.cint
|
||||
|
||||
func ETHAuthorizationListGet(
|
||||
authorizationList: ptr seq[ETHAuthorizationTuple],
|
||||
authorizationIndex: cint): ptr ETHAuthorizationTuple {.exported.} =
|
||||
authorizationList: ptr seq[ETHAuthorization],
|
||||
authorizationIndex: cint): ptr ETHAuthorization {.exported.} =
|
||||
## Obtains an individual authorization tuple by sequential index
|
||||
## in a transaction authorization list.
|
||||
##
|
||||
|
@ -2302,8 +2316,8 @@ func ETHAuthorizationListGet(
|
|||
## * Authorization tuple.
|
||||
addr authorizationList[][authorizationIndex.int]
|
||||
|
||||
func ETHAuthorizationTupleGetChainId(
|
||||
authorizationTuple: ptr ETHAuthorizationTuple): ptr UInt256 {.exported.} =
|
||||
func ETHAuthorizationGetChainId(
|
||||
authorization: ptr ETHAuthorization): ptr uint64 {.exported.} =
|
||||
## Obtains the chain ID of an authorization tuple.
|
||||
##
|
||||
## * The returned value is allocated in the given authorization tuple.
|
||||
|
@ -2311,14 +2325,14 @@ func ETHAuthorizationTupleGetChainId(
|
|||
## must not be released while the returned value is in use.
|
||||
##
|
||||
## Parameters:
|
||||
## * `authorizationTuple` - Authorization tuple.
|
||||
## * `authorization` - Authorization tuple.
|
||||
##
|
||||
## Returns:
|
||||
## * Chain ID.
|
||||
addr authorizationTuple[].chainId
|
||||
addr authorization[].chainId
|
||||
|
||||
func ETHAuthorizationTupleGetAddress(
|
||||
authorizationTuple: ptr ETHAuthorizationTuple
|
||||
func ETHAuthorizationGetAddress(
|
||||
authorization: ptr ETHAuthorization
|
||||
): ptr ExecutionAddress {.exported.} =
|
||||
## Obtains the address of an authorization tuple.
|
||||
##
|
||||
|
@ -2327,14 +2341,14 @@ func ETHAuthorizationTupleGetAddress(
|
|||
## must not be released while the returned value is in use.
|
||||
##
|
||||
## Parameters:
|
||||
## * `authorizationTuple` - Authorization tuple.
|
||||
## * `authorization` - Authorization tuple.
|
||||
##
|
||||
## Returns:
|
||||
## * Address.
|
||||
addr authorizationTuple[].address
|
||||
addr authorization[].address
|
||||
|
||||
func ETHAuthorizationTupleGetNonce(
|
||||
authorizationTuple: ptr ETHAuthorizationTuple): ptr uint64 {.exported.} =
|
||||
func ETHAuthorizationGetNonce(
|
||||
authorization: ptr ETHAuthorization): ptr uint64 {.exported.} =
|
||||
## Obtains the nonce of an authorization tuple.
|
||||
##
|
||||
## * The returned value is allocated in the given authorization tuple.
|
||||
|
@ -2342,14 +2356,14 @@ func ETHAuthorizationTupleGetNonce(
|
|||
## must not be released while the returned value is in use.
|
||||
##
|
||||
## Parameters:
|
||||
## * `authorizationTuple` - Authorization tuple.
|
||||
## * `authorization` - Authorization tuple.
|
||||
##
|
||||
## Returns:
|
||||
## * Nonce.
|
||||
addr authorizationTuple[].nonce
|
||||
addr authorization[].nonce
|
||||
|
||||
func ETHAuthorizationTupleGetAuthority(
|
||||
authorizationTuple: ptr ETHAuthorizationTuple
|
||||
func ETHAuthorizationGetAuthority(
|
||||
authorization: ptr ETHAuthorization
|
||||
): ptr ExecutionAddress {.exported.} =
|
||||
## Obtains the authority execution address of an authorization tuple.
|
||||
##
|
||||
|
@ -2358,14 +2372,14 @@ func ETHAuthorizationTupleGetAuthority(
|
|||
## must not be released while the returned value is in use.
|
||||
##
|
||||
## Parameters:
|
||||
## * `authorizationTuple` - Authorization tuple.
|
||||
## * `authorization` - Authorization tuple.
|
||||
##
|
||||
## Returns:
|
||||
## * Authority execution address.
|
||||
addr authorizationTuple[].authority
|
||||
addr authorization[].authority
|
||||
|
||||
func ETHAuthorizationTupleGetSignatureBytes(
|
||||
authorizationTuple: ptr ETHAuthorizationTuple,
|
||||
func ETHAuthorizationGetSignatureBytes(
|
||||
authorization: ptr ETHAuthorization,
|
||||
numBytes #[out]#: ptr cint): ptr UncheckedArray[byte] {.exported.} =
|
||||
## Obtains the signature of an authorization tuple.
|
||||
##
|
||||
|
@ -2374,18 +2388,18 @@ func ETHAuthorizationTupleGetSignatureBytes(
|
|||
## must not be released while the returned value is in use.
|
||||
##
|
||||
## Parameters:
|
||||
## * `authorizationTuple` - Authorization tuple.
|
||||
## * `authorization` - Authorization tuple.
|
||||
## * `numBytes` [out] - Length of buffer.
|
||||
##
|
||||
## Returns:
|
||||
## * Buffer with signature.
|
||||
numBytes[] = distinctBase(authorizationTuple[].signature).len.cint
|
||||
if distinctBase(authorizationTuple[].signature).len == 0:
|
||||
numBytes[] = distinctBase(authorization[].signature).len.cint
|
||||
if distinctBase(authorization[].signature).len == 0:
|
||||
# https://github.com/nim-lang/Nim/issues/22389
|
||||
const defaultBytes: cstring = ""
|
||||
return cast[ptr UncheckedArray[byte]](defaultBytes)
|
||||
cast[ptr UncheckedArray[byte]](
|
||||
addr distinctBase(authorizationTuple[].signature)[0])
|
||||
addr distinctBase(authorization[].signature)[0])
|
||||
|
||||
func ETHTransactionGetSignatureBytes(
|
||||
transaction: ptr ETHTransaction,
|
||||
|
@ -2514,6 +2528,8 @@ proc ETHReceiptsCreateFromJson(
|
|||
TxEip1559
|
||||
of 3.Quantity:
|
||||
TxEip4844
|
||||
of 4.Quantity:
|
||||
TxEip7702
|
||||
else:
|
||||
return nil
|
||||
if data.root.isNone and data.status.isNone or
|
||||
|
|
|
@ -356,5 +356,39 @@
|
|||
"logsBloom": "0x0000000000000000000000000000000040000000000000000080000001000000000000000000000000000000000000000000000200004000000000000201000000000000000000000000000000000200000100000000000000000000000000000000000002000000000000000000080004000080000000000000000000000040000000000000000000000004000000000000000000008000000000040080000000000000000000000000000000040000000000000000000000000000000000000000002020000000000000000004000a000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000020000",
|
||||
"status": "0x1",
|
||||
"effectiveGasPrice": "0xa00a0c2f8"
|
||||
},
|
||||
{
|
||||
"blobGasPrice": "0x1",
|
||||
"blobGasUsed": "0x20000",
|
||||
"blockHash": "0xa2917e0758c98640d868182838c93bb12f0d07b6b17efe6b62d9df42c7643791",
|
||||
"blockNumber": "0x1286d1d",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x174c84",
|
||||
"effectiveGasPrice": "0xd364c1438",
|
||||
"from": "0x40c35d4faf69234986cb599890c2d2ef546074a9",
|
||||
"gasUsed": "0x5208",
|
||||
"logs": [],
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"status": "0x1",
|
||||
"to": "0x0000000000000000000000000000000000000000",
|
||||
"transactionHash": "0x9c1fbda4f649ac806ab0faefbe94e1a60282eb374ead6aa01bac042f52b28a8c",
|
||||
"transactionIndex": "0x6",
|
||||
"type": "0x3"
|
||||
},
|
||||
{
|
||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockNumber": "0x0",
|
||||
"contractAddress": null,
|
||||
"cumulativeGasUsed": "0x174c85",
|
||||
"effectiveGasPrice": "0x1",
|
||||
"from": "0x55c158d0fa4619db7e655a78e6627a752a847f12",
|
||||
"gasUsed": "0x1",
|
||||
"logs": [],
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"status": "0x0",
|
||||
"to": "0x0001020304050607080910111213141516171819",
|
||||
"transactionHash": "0xaef87a34a0efb40e90614a96fa0dfa74c596dfb772ce8c73d624121f17aaa610",
|
||||
"transactionIndex": "0x7",
|
||||
"type": "0x4"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -262,5 +262,77 @@
|
|||
"v": "0x0",
|
||||
"r": "0x6fd00841d705c002a846de1b56d0c36941cd2897a7bb19419d427a252bc4fff4",
|
||||
"s": "0x5be5ed4725f8b6047b5309da5f47d1e98fa2c79e5c0841595291fae7167de108"
|
||||
},
|
||||
{
|
||||
"blockHash": "0xa2917e0758c98640d868182838c93bb12f0d07b6b17efe6b62d9df42c7643791",
|
||||
"blockNumber": "0x1286d1d",
|
||||
"from": "0x40c35d4faf69234986cb599890c2d2ef546074a9",
|
||||
"gas": "0x5208",
|
||||
"gasPrice": "0xd364c1438",
|
||||
"maxPriorityFeePerGas": "0x3b9aca00",
|
||||
"maxFeePerGas": "0x1d1e4e4ea00",
|
||||
"hash": "0x9c1fbda4f649ac806ab0faefbe94e1a60282eb374ead6aa01bac042f52b28a8c",
|
||||
"input": "0x",
|
||||
"nonce": "0x0",
|
||||
"to": "0x0000000000000000000000000000000000000000",
|
||||
"transactionIndex": "0x6",
|
||||
"value": "0x0",
|
||||
"type": "0x3",
|
||||
"accessList": [],
|
||||
"chainId": "0x1",
|
||||
"maxFeePerBlobGas": "0x3b9aca00",
|
||||
"blobVersionedHashes": [
|
||||
"0x0175f564b393e44640ecffddce4010a42c1c966413987d8a59a253ef64a0c5cf"
|
||||
],
|
||||
"v": "0x1",
|
||||
"r": "0x4169d4bf9df18182d86715d4ec031c20aded1a4a2613f57e0c0169e16cf763c2",
|
||||
"s": "0x6fc81d18602b8a1e065193488a7c943dfd780adb7b72dfc332de7d68605986e"
|
||||
},
|
||||
{
|
||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockNumber": "0x0",
|
||||
"from": "0x55c158d0fa4619db7e655a78e6627a752a847f12",
|
||||
"gas": "0x5",
|
||||
"gasPrice": "0x1",
|
||||
"maxPriorityFeePerGas": "0x3",
|
||||
"maxFeePerGas": "0x4",
|
||||
"hash": "0xaef87a34a0efb40e90614a96fa0dfa74c596dfb772ce8c73d624121f17aaa610",
|
||||
"input": "0x4269",
|
||||
"nonce": "0x2",
|
||||
"to": "0x0001020304050607080910111213141516171819",
|
||||
"transactionIndex": "0x7",
|
||||
"value": "0x6",
|
||||
"type": "0x4",
|
||||
"accessList": [
|
||||
{
|
||||
"address": "0x2021222324252627282930313233343536373839",
|
||||
"storageKeys": [
|
||||
"0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
|
||||
"0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"
|
||||
]
|
||||
}
|
||||
],
|
||||
"chainId": "0x1",
|
||||
"authorizationList": [
|
||||
{
|
||||
"chainId": "0x0",
|
||||
"address": "0x3031323334353637383940414243444546474849",
|
||||
"nonce": "0x0",
|
||||
"yParity": "0x1",
|
||||
"R": "0xa4be86c16c6d3a2b907660b24187d0b30b69f6db3e6e8e7a7bb1183a4706d454",
|
||||
"S": "0x28aba84cdee6059dde41620422959d01da4f6cfff21a9b97036db018f1d815f6"
|
||||
},
|
||||
{
|
||||
"chainId": "0x1",
|
||||
"address": "0x5051525354555657585960616263646566676869",
|
||||
"nonce": "0x309",
|
||||
"yParity": "0x1",
|
||||
"R": "0xa4be86c16c6d3a2b907660b24187d0b30b69f6db3e6e8e7a7bb1183a4706d454",
|
||||
"S": "0x28aba84cdee6059dde41620422959d01da4f6cfff21a9b97036db018f1d815f6"
|
||||
}
|
||||
],
|
||||
"v": "0x1",
|
||||
"r": "0xa4be86c16c6d3a2b907660b24187d0b30b69f6db3e6e8e7a7bb1183a4706d454",
|
||||
"s": "0x28aba84cdee6059dde41620422959d01da4f6cfff21a9b97036db018f1d815f6"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -417,10 +417,10 @@ int main(void)
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
const ETHRoot *executionRequestsRoot =
|
||||
ETHExecutionBlockHeaderGetRequestsRoot(executionBlockHeader);
|
||||
printf(" - requests_root: ");
|
||||
printHexString(executionRequestsRoot, sizeof *executionRequestsRoot);
|
||||
const ETHRoot *executionRequestsHash =
|
||||
ETHExecutionBlockHeaderGetRequestsHash(executionBlockHeader);
|
||||
printf(" - requests_hash: ");
|
||||
printHexString(executionRequestsHash, sizeof *executionRequestsHash);
|
||||
printf("\n");
|
||||
|
||||
const ETHDepositRequests *depositRequests =
|
||||
|
@ -525,10 +525,10 @@ int main(void)
|
|||
ETHExecutionBlockHeaderDestroy(executionBlockHeader);
|
||||
|
||||
ETHRoot sampleTransactionsRoot = {{
|
||||
0x73, 0x36, 0x36, 0xe8, 0x0e, 0x47, 0x60, 0x09,
|
||||
0xd1, 0xc8, 0x9f, 0x81, 0xaa, 0x64, 0xe1, 0xfd,
|
||||
0xf7, 0xff, 0x36, 0xd6, 0x04, 0x6e, 0x95, 0x6c,
|
||||
0x39, 0xed, 0xcd, 0x6c, 0x95, 0x2d, 0xce, 0xc2,
|
||||
0x7d, 0x42, 0x30, 0x71, 0x99, 0x8f, 0xab, 0x13,
|
||||
0xf5, 0x3f, 0xc2, 0x13, 0xa3, 0xea, 0xed, 0x4f,
|
||||
0x46, 0x68, 0x43, 0xed, 0x07, 0x4d, 0x86, 0x8e,
|
||||
0xca, 0x02, 0x78, 0x85, 0x0c, 0xb9, 0x20, 0xe4,
|
||||
}};
|
||||
void *sampleTransactionsJson = readEntireFile(
|
||||
__DIR__ "/test_files/transactions.json", /* numBytes: */ NULL);
|
||||
|
@ -538,10 +538,10 @@ int main(void)
|
|||
free(sampleTransactionsJson);
|
||||
|
||||
ETHRoot sampleReceiptsRoot = {{
|
||||
0x51, 0x4d, 0xdf, 0xd7, 0xf8, 0x33, 0xfb, 0x2a,
|
||||
0x4f, 0x60, 0xed, 0x49, 0xdf, 0xc7, 0x9c, 0x07,
|
||||
0xb6, 0x9c, 0x37, 0xef, 0xd1, 0xa5, 0x97, 0xca,
|
||||
0x42, 0x76, 0x23, 0xff, 0xa1, 0x79, 0x49, 0xae,
|
||||
0xef, 0x6b, 0x38, 0x00, 0x44, 0x1d, 0xad, 0xba,
|
||||
0x3c, 0xe8, 0xba, 0xed, 0xcd, 0xf8, 0x49, 0x5c,
|
||||
0x91, 0x8d, 0x03, 0xd6, 0xf9, 0xb0, 0xb3, 0x39,
|
||||
0xda, 0x0f, 0x6d, 0xf5, 0xfc, 0xbb, 0x1a, 0x68,
|
||||
}};
|
||||
void *sampleReceiptsJson = readEntireFile(
|
||||
__DIR__ "/test_files/receipts.json", /* numBytes: */ NULL);
|
||||
|
@ -563,7 +563,7 @@ int main(void)
|
|||
printHexString(transactionHash, sizeof *transactionHash);
|
||||
printf("\n");
|
||||
|
||||
const ETHUInt256 *transactionChainId = ETHTransactionGetChainId(transaction);
|
||||
const uint64_t *transactionChainId = ETHTransactionGetChainId(transaction);
|
||||
printf(" - chain_id: ");
|
||||
printHexStringReversed(transactionChainId, sizeof *transactionChainId);
|
||||
printf("\n");
|
||||
|
@ -647,34 +647,32 @@ int main(void)
|
|||
const ETHAuthorizationList *transactionAuthorizationList =
|
||||
ETHTransactionGetAuthorizationList(transaction);
|
||||
printf(" - authorization_list:\n");
|
||||
int numAuthorizationTuples = ETHAuthorizationListGetCount(transactionAuthorizationList);
|
||||
for (int tupleIndex = 0; tupleIndex < numAuthorizationTuples; tupleIndex++) {
|
||||
const ETHAuthorizationTuple *authorizationTuple =
|
||||
int numAuthorizations = ETHAuthorizationListGetCount(transactionAuthorizationList);
|
||||
for (int tupleIndex = 0; tupleIndex < numAuthorizations; tupleIndex++) {
|
||||
const ETHAuthorization *authorization =
|
||||
ETHAuthorizationListGet(transactionAuthorizationList, tupleIndex);
|
||||
|
||||
const ETHExecutionAddress *address =
|
||||
ETHAuthorizationTupleGetAddress(authorizationTuple);
|
||||
const ETHExecutionAddress *authority = ETHAuthorizationGetAuthority(authorization);
|
||||
printf(" - ");
|
||||
printHexString(address, sizeof *address);
|
||||
printHexString(authority, sizeof *authority);
|
||||
printf("\n");
|
||||
|
||||
const ETHUInt256 *chainId = ETHAuthorizationTupleGetChainId(authorizationTuple);
|
||||
const uint64_t *chainId = ETHAuthorizationGetChainId(authorization);
|
||||
printf(" - chain_id: ");
|
||||
printHexStringReversed(chainId, sizeof *chainId);
|
||||
printf("\n");
|
||||
|
||||
const uint64_t *nonce = ETHAuthorizationTupleGetNonce(authorizationTuple);
|
||||
printf(" - nonce: %" PRIu64 "\n", *nonce);
|
||||
|
||||
const ETHExecutionAddress *authority =
|
||||
ETHAuthorizationTupleGetAuthority(authorizationTuple);
|
||||
printf(" - authority: ");
|
||||
printHexString(authority, sizeof *authority);
|
||||
const ETHExecutionAddress *address = ETHAuthorizationGetAddress(authorization);
|
||||
printf(" - address: ");
|
||||
printHexString(address, sizeof *address);
|
||||
printf("\n");
|
||||
|
||||
const uint64_t *nonce = ETHAuthorizationGetNonce(authorization);
|
||||
printf(" - nonce: %" PRIu64 "\n", *nonce);
|
||||
|
||||
int numSignatureBytes;
|
||||
const void *signatureBytes =
|
||||
ETHAuthorizationTupleGetSignatureBytes(authorizationTuple, &numSignatureBytes);
|
||||
ETHAuthorizationGetSignatureBytes(authorization, &numSignatureBytes);
|
||||
printf(" - signature: ");
|
||||
printHexString(signatureBytes, numSignatureBytes);
|
||||
printf("\n");
|
||||
|
|
|
@ -514,7 +514,7 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): EthHeader =
|
|||
Opt.some EthHash32(blck.parent_root.data)
|
||||
else:
|
||||
Opt.none(EthHash32)
|
||||
requestsRoot =
|
||||
requestsHash =
|
||||
when typeof(payload).kind >= ConsensusFork.Electra:
|
||||
Opt.some blck.body.execution_requests.computeRequestsTrieRoot()
|
||||
else:
|
||||
|
@ -541,7 +541,7 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): EthHeader =
|
|||
blobGasUsed : blobGasUsed, # EIP-4844
|
||||
excessBlobGas : excessBlobGas, # EIP-4844
|
||||
parentBeaconBlockRoot : parentBeaconBlockRoot, # EIP-4788
|
||||
requestsRoot : requestsRoot) # EIP-7685
|
||||
requestsHash : requestsHash) # EIP-7685
|
||||
|
||||
proc compute_execution_block_hash*(blck: ForkyBeaconBlock): Eth2Digest =
|
||||
rlpHash(blockToBlockHeader(blck)).to(Eth2Digest)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit bb76daa6d93d217f9ad61e547f097e2eb2f1afbb
|
||||
Subproject commit 171531fbf1a308c1bf4d2f6b88c6ee6924657437
|
Loading…
Reference in New Issue