From 3cb7b9140a4a9b859add23a7299fec36f9478b5e Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Tue, 22 Oct 2024 05:41:01 +0200 Subject: [PATCH] Remove request details from LC (#6666) Requests are no longer exposed by execution data, remove from LC API. --- beacon_chain/libnimbus_lc/libnimbus_lc.h | 408 ------------------ beacon_chain/libnimbus_lc/libnimbus_lc.nim | 406 ----------------- beacon_chain/libnimbus_lc/test_libnimbus_lc.c | 99 ----- 3 files changed, 913 deletions(-) diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.h b/beacon_chain/libnimbus_lc/libnimbus_lc.h index 8635589db..5b3e89614 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.h +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.h @@ -1118,66 +1118,6 @@ ETH_RESULT_USE_CHECK const ETHRoot *ETHExecutionBlockHeaderGetRequestsHash( const ETHExecutionBlockHeader *executionBlockHeader); -/** - * Deposit request sequence. - */ -typedef struct ETHDepositRequests ETHDepositRequests; - -/** - * Obtains the deposit request sequence 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 - * header must not be released while the returned value is in use. - * - * @param executionBlockHeader Execution block header. - * - * @return Deposit request sequence. - */ -ETH_RESULT_USE_CHECK -const ETHDepositRequests *ETHExecutionBlockHeaderGetDepositRequests( - const ETHExecutionBlockHeader *executionBlockHeader); - -/** - * Withdrawal request sequence. - */ -typedef struct ETHWithdrawalRequests ETHWithdrawalRequests; - -/** - * Obtains the withdrawal request sequence 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 - * header must not be released while the returned value is in use. - * - * @param executionBlockHeader Execution block header. - * - * @return Withdrawal request sequence. - */ -ETH_RESULT_USE_CHECK -const ETHWithdrawalRequests *ETHExecutionBlockHeaderGetWithdrawalRequests( - const ETHExecutionBlockHeader *executionBlockHeader); - -/** - * Consolidation request sequence. - */ -typedef struct ETHConsolidationRequests ETHConsolidationRequests; - -/** - * Obtains the consolidation request sequence 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 - * header must not be released while the returned value is in use. - * - * @param executionBlockHeader Execution block header. - * - * @return Consolidation request sequence. - */ -ETH_RESULT_USE_CHECK -const ETHConsolidationRequests *ETHExecutionBlockHeaderGetConsolidationRequests( - const ETHExecutionBlockHeader *executionBlockHeader); - /** * Transaction sequence. */ @@ -2114,354 +2054,6 @@ const void *ETHWithdrawalGetBytes( const ETHWithdrawal *withdrawal, int *numBytes); -/** - * Indicates the total number of deposit requests - * in a deposit request sequence. - * - * - Individual deposit requests may be inspected using - * `ETHDepositRequestsGet`. - * - * @param requests Deposit request sequence. - * - * @return Number of available deposit requestss. - */ -ETH_RESULT_USE_CHECK -int ETHDepositRequestsGetCount(const ETHDepositRequests *requests); - -/** - * Deposit request. - */ -typedef struct ETHDepositRequest ETHDepositRequest; - -/** - * Obtains an individual deposit request by sequential index - * in a deposit request sequence. - * - * - The returned value is allocated in the given request sequence. - * It must neither be released nor written to, and the request - * sequence must not be released while the returned value is in use. - * - * @param requests Deposit request sequence. - * @param requestIndex Sequential deposit request index. - * - * @return Deposit request. - */ -ETH_RESULT_USE_CHECK -const ETHDepositRequest *ETHDepositRequestsGet( - const ETHDepositRequests *requests, - int requestIndex); - -/** - * Validator pubkey. - */ -typedef struct { - uint8_t bytes[48]; -} ETHValidatorPubkey; - -/** - * Obtains the pubkey of a deposit request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Deposit request. - * - * @return Pubkey. - */ -ETH_RESULT_USE_CHECK -const ETHValidatorPubkey *ETHDepositRequestGetPubkey( - const ETHDepositRequest *request); - -/** - * Withdrawal credentials. - */ -typedef struct { - uint8_t bytes[32]; -} ETHWithdrawalCredentials; - -/** - * Obtains the withdrawal credentials of a deposit request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Deposit request. - * - * @return Withdrawal credentials. - */ -ETH_RESULT_USE_CHECK -const ETHWithdrawalCredentials *ETHDepositRequestGetWithdrawalCredentials( - const ETHDepositRequest *request); - -/** - * Obtains the amount of a deposit request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Deposit request. - * - * @return Amount. - */ -ETH_RESULT_USE_CHECK -const uint64_t *ETHDepositRequestGetAmount( - const ETHDepositRequest *request); - -/** - * Validator signature. - */ -typedef struct { - uint8_t bytes[96]; -} ETHValidatorSignature; - -/** - * Obtains the signature of a deposit request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Deposit request. - * - * @return Signature. - */ -ETH_RESULT_USE_CHECK -const ETHValidatorSignature *ETHDepositRequestGetSignature( - const ETHDepositRequest *request); - -/** - * Obtains the index of a deposit request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Deposit request. - * - * @return Index. - */ -ETH_RESULT_USE_CHECK -const uint64_t *ETHDepositRequestGetIndex( - const ETHDepositRequest *request); - -/** - * Obtains the raw byte representation of a deposit request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Deposit request. - * @param[out] numBytes Length of buffer. - * - * @return Buffer with raw deposit request data. - */ -ETH_RESULT_USE_CHECK -const void *ETHDepositRequestGetBytes( - const ETHDepositRequest *request, - int *numBytes); - -/** - * Indicates the total number of withdrawal requests - * in a withdrawal request sequence. - * - * - Individual withdrawal requests may be inspected using - * `ETHWithdrawalRequestsGet`. - * - * @param requests Withdrawal request sequence. - * - * @return Number of available withdrawal requestss. - */ -ETH_RESULT_USE_CHECK -int ETHWithdrawalRequestsGetCount(const ETHWithdrawalRequests *requests); - -/** - * Withdrawal request. - */ -typedef struct ETHWithdrawalRequest ETHWithdrawalRequest; - -/** - * Obtains an individual withdrawal request by sequential index - * in a withdrawal request sequence. - * - * - The returned value is allocated in the given request sequence. - * It must neither be released nor written to, and the request - * sequence must not be released while the returned value is in use. - * - * @param requests Withdrawal request sequence. - * @param requestIndex Sequential withdrawal request index. - * - * @return Withdrawal request. - */ -ETH_RESULT_USE_CHECK -const ETHWithdrawalRequest *ETHWithdrawalRequestsGet( - const ETHWithdrawalRequests *requests, - int requestIndex); - -/** - * Obtains the source address of a withdrawal request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Withdrawal request. - * - * @return Source address. - */ -ETH_RESULT_USE_CHECK -const ETHExecutionAddress *ETHWithdrawalRequestGetSourceAddress( - const ETHWithdrawalRequest *request); - -/** - * Obtains the validator pubkey of a withdrawal request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Withdrawal request. - * - * @return Validator pubkey. - */ -ETH_RESULT_USE_CHECK -const ETHValidatorPubkey *ETHWithdrawalRequestGetValidatorPubkey( - const ETHWithdrawalRequest *request); - -/** - * Obtains the amount of a withdrawal request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Withdrawal request. - * - * @return Amount. - */ -ETH_RESULT_USE_CHECK -const uint64_t *ETHWithdrawalRequestGetAmount( - const ETHWithdrawalRequest *request); - -/** - * Obtains the raw byte representation of a withdrawal request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Withdrawal request. - * @param[out] numBytes Length of buffer. - * - * @return Buffer with raw withdrawal request data. - */ -ETH_RESULT_USE_CHECK -const void *ETHWithdrawalRequestGetBytes( - const ETHWithdrawalRequest *request, - int *numBytes); - -/** - * Indicates the total number of consolidation requests - * in a consolidation request sequence. - * - * - Individual consolidation requests may be inspected using - * `ETHConsolidationRequestsGet`. - * - * @param requests Consolidation request sequence. - * - * @return Number of available consolidation requestss. - */ -ETH_RESULT_USE_CHECK -int ETHConsolidationRequestsGetCount(const ETHConsolidationRequests *requests); - -/** - * Consolidation request. - */ -typedef struct ETHConsolidationRequest ETHConsolidationRequest; - -/** - * Obtains an individual consolidation request by sequential index - * in a consolidation request sequence. - * - * - The returned value is allocated in the given request sequence. - * It must neither be released nor written to, and the request - * sequence must not be released while the returned value is in use. - * - * @param requests Consolidation request sequence. - * @param requestIndex Sequential consolidation request index. - * - * @return Consolidation request. - */ -ETH_RESULT_USE_CHECK -const ETHConsolidationRequest *ETHConsolidationRequestsGet( - const ETHConsolidationRequests *requests, - int requestIndex); - -/** - * Obtains the source address of a consolidation request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Consolidation request. - * - * @return Source address. - */ -ETH_RESULT_USE_CHECK -const ETHExecutionAddress *ETHConsolidationRequestGetSourceAddress( - const ETHConsolidationRequest *request); - -/** - * Obtains the source pubkey of a consolidation request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Consolidation request. - * - * @return Source pubkey. - */ -ETH_RESULT_USE_CHECK -const ETHValidatorPubkey *ETHConsolidationRequestGetSourcePubkey( - const ETHConsolidationRequest *request); - -/** - * Obtains the target pubkey of a consolidation request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Consolidation request. - * - * @return Target pubkey. - */ -ETH_RESULT_USE_CHECK -const ETHValidatorPubkey *ETHConsolidationRequestGetTargetPubkey( - const ETHConsolidationRequest *request); - -/** - * Obtains the raw byte representation of a consolidation request. - * - * - The returned value is allocated in the given request. - * It must neither be released nor written to, and the request - * must not be released while the returned value is in use. - * - * @param request Consolidation request. - * @param[out] numBytes Length of buffer. - * - * @return Buffer with raw consolidation request data. - */ -ETH_RESULT_USE_CHECK -const void *ETHConsolidationRequestGetBytes( - const ETHConsolidationRequest *request, - int *numBytes); - #if __has_feature(nullability) #pragma clang assume_nonnull end #endif diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.nim b/beacon_chain/libnimbus_lc/libnimbus_lc.nim index e8f651cea..00f97515d 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.nim +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.nim @@ -1181,34 +1181,11 @@ type amount: uint64 bytes: seq[byte] - ETHDepositRequest = object - pubkey: ValidatorPubKey - withdrawalCredentials: array[32, byte] - amount: uint64 - signature: ValidatorSig - index: uint64 - bytes: seq[byte] - - ETHWithdrawalRequest = object - sourceAddress: ExecutionAddress - validatorPubkey: ValidatorPubKey - amount: uint64 - bytes: seq[byte] - - ETHConsolidationRequest = object - sourceAddress: ExecutionAddress - sourcePubkey: ValidatorPubKey - targetPubkey: ValidatorPubKey - bytes: seq[byte] - ETHExecutionBlockHeader = object transactionsRoot: Eth2Digest withdrawalsRoot: Eth2Digest withdrawals: seq[ETHWithdrawal] requestsHash: Eth2Digest - depositRequests: seq[ETHDepositRequest] - withdrawalRequests: seq[ETHWithdrawalRequest] - consolidationRequests: seq[ETHConsolidationRequest] template append*( w: var RlpWriter, v: @@ -1441,55 +1418,6 @@ func ETHExecutionBlockHeaderGetRequestsHash( ## * Execution requests hash. addr executionBlockHeader[].requestsHash -func ETHExecutionBlockHeaderGetDepositRequests( - executionBlockHeader: ptr ETHExecutionBlockHeader -): ptr seq[ETHDepositRequest] {.exported.} = - ## Obtains the deposit request sequence 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 - ## header must not be released while the returned value is in use. - ## - ## Parameters: - ## * `executionBlockHeader` - Execution block header. - ## - ## Returns: - ## * Deposit request sequence. - addr executionBlockHeader[].depositRequests - -func ETHExecutionBlockHeaderGetWithdrawalRequests( - executionBlockHeader: ptr ETHExecutionBlockHeader -): ptr seq[ETHWithdrawalRequest] {.exported.} = - ## Obtains the withdrawal request sequence 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 - ## header must not be released while the returned value is in use. - ## - ## Parameters: - ## * `executionBlockHeader` - Execution block header. - ## - ## Returns: - ## * Withdrawal request sequence. - addr executionBlockHeader[].withdrawalRequests - -func ETHExecutionBlockHeaderGetConsolidationRequests( - executionBlockHeader: ptr ETHExecutionBlockHeader -): ptr seq[ETHConsolidationRequest] {.exported.} = - ## Obtains the consolidation request sequence - ## 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 - ## header must not be released while the returned value is in use. - ## - ## Parameters: - ## * `executionBlockHeader` - Execution block header. - ## - ## Returns: - ## * Consolidation request sequence. - addr executionBlockHeader[].consolidationRequests - type DestinationType {.pure.} = enum Regular, @@ -2873,337 +2801,3 @@ func ETHWithdrawalGetBytes( const defaultBytes: cstring = "" return cast[ptr UncheckedArray[byte]](defaultBytes) cast[ptr UncheckedArray[byte]](addr distinctBase(withdrawal[].bytes)[0]) - -func ETHDepositRequestsGetCount( - requests: ptr seq[ETHDepositRequest]): cint {.exported.} = - ## Indicates the total number of deposit requests - ## in a deposit request sequence. - ## - ## * Individual deposit requests may be inspected using - ## `ETHDepositRequestsGet`. - ## - ## Parameters: - ## * `requests` - Deposit request sequence. - ## - ## Returns: - ## * Number of available deposit requests. - requests[].len.cint - -func ETHDepositRequestsGet( - requests: ptr seq[ETHDepositRequest], - requestIndex: cint): ptr ETHDepositRequest {.exported.} = - ## Obtains an individual deposit request by sequential index - ## in a deposit request sequence. - ## - ## * The returned value is allocated in the given request sequence. - ## It must neither be released nor written to, and the request - ## sequence must not be released while the returned value is in use. - ## - ## Parameters: - ## * `requests` - Deposit request sequence. - ## * `requestIndex` - Sequential deposit request index. - ## - ## Returns: - ## * Deposit request. - addr requests[][requestIndex.int] - -func ETHDepositRequestGetPubkey( - request: ptr ETHDepositRequest): ptr ValidatorPubKey {.exported.} = - ## Obtains the pubkey of a deposit request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Deposit request. - ## - ## Returns: - ## * Pubkey. - addr request[].pubkey - -func ETHDepositRequestGetWithdrawalCredentials( - request: ptr ETHDepositRequest): ptr array[32, byte] {.exported.} = - ## Obtains the withdrawal credentials of a deposit request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Deposit request. - ## - ## Returns: - ## * Withdrawal credentials. - addr request[].withdrawalCredentials - -func ETHDepositRequestGetAmount( - request: ptr ETHDepositRequest): ptr uint64 {.exported.} = - ## Obtains the amount of a deposit request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Deposit request. - ## - ## Returns: - ## * Amount. - addr request[].amount - -func ETHDepositRequestGetSignature( - request: ptr ETHDepositRequest): ptr ValidatorSig {.exported.} = - ## Obtains the signature of a deposit request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Deposit request. - ## - ## Returns: - ## * Signature. - addr request[].signature - -func ETHDepositRequestGetIndex( - request: ptr ETHDepositRequest): ptr uint64 {.exported.} = - ## Obtains the index of a deposit request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Deposit request. - ## - ## Returns: - ## * Index. - addr request[].index - -func ETHDepositRequestGetBytes( - request: ptr ETHDepositRequest, - numBytes #[out]#: ptr cint): ptr UncheckedArray[byte] {.exported.} = - ## Obtains the raw byte representation of a deposit request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Deposit request. - ## * `numBytes` [out] - Length of buffer. - ## - ## Returns: - ## * Buffer with raw deposit request data. - numBytes[] = distinctBase(request[].bytes).len.cint - if distinctBase(request[].bytes).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(request[].bytes)[0]) - -func ETHWithdrawalRequestsGetCount( - requests: ptr seq[ETHWithdrawalRequest]): cint {.exported.} = - ## Indicates the total number of withdrawal requests - ## in a withdrawal request sequence. - ## - ## * Individual withdrawal requests may be inspected using - ## `ETHWithdrawalRequestsGet`. - ## - ## Parameters: - ## * `requests` - Withdrawal request sequence. - ## - ## Returns: - ## * Number of available withdrawal requests. - requests[].len.cint - -func ETHWithdrawalRequestsGet( - requests: ptr seq[ETHWithdrawalRequest], - requestIndex: cint): ptr ETHWithdrawalRequest {.exported.} = - ## Obtains an individual withdrawal request by sequential index - ## in a withdrawal request sequence. - ## - ## * The returned value is allocated in the given request sequence. - ## It must neither be released nor written to, and the request - ## sequence must not be released while the returned value is in use. - ## - ## Parameters: - ## * `requests` - Withdrawal request sequence. - ## * `requestIndex` - Sequential withdrawal request index. - ## - ## Returns: - ## * Withdrawal request. - addr requests[][requestIndex.int] - -func ETHWithdrawalRequestGetSourceAddress( - request: ptr ETHWithdrawalRequest): ptr ExecutionAddress {.exported.} = - ## Obtains the source address of a withdrawal request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Withdrawal request. - ## - ## Returns: - ## * Source address. - addr request[].sourceAddress - -func ETHWithdrawalRequestGetValidatorPubkey( - request: ptr ETHWithdrawalRequest): ptr ValidatorPubKey {.exported.} = - ## Obtains the validator pubkey of a withdrawal request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Withdrawal request. - ## - ## Returns: - ## * Validator pubkey. - addr request[].validatorPubkey - -func ETHWithdrawalRequestGetAmount( - request: ptr ETHWithdrawalRequest): ptr uint64 {.exported.} = - ## Obtains the amount of a withdrawal request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Withdrawal request. - ## - ## Returns: - ## * Amount. - addr request[].amount - -func ETHWithdrawalRequestGetBytes( - request: ptr ETHWithdrawalRequest, - numBytes #[out]#: ptr cint): ptr UncheckedArray[byte] {.exported.} = - ## Obtains the raw byte representation of a withdrawal request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Withdrawal request. - ## * `numBytes` [out] - Length of buffer. - ## - ## Returns: - ## * Buffer with raw withdrawal request data. - numBytes[] = distinctBase(request[].bytes).len.cint - if distinctBase(request[].bytes).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(request[].bytes)[0]) - -func ETHConsolidationRequestsGetCount( - requests: ptr seq[ETHConsolidationRequest] -): cint {.exported.} = - ## Indicates the total number of consolidation requests - ## in a consolidation request sequence. - ## - ## * Individual consolidation requests may be inspected using - ## `ETHConsolidationRequestsGet`. - ## - ## Parameters: - ## * `requests` - Consolidation request sequence. - ## - ## Returns: - ## * Number of available consolidation requests. - requests[].len.cint - -func ETHConsolidationRequestsGet( - requests: ptr seq[ETHConsolidationRequest], - requestIndex: cint): ptr ETHConsolidationRequest {.exported.} = - ## Obtains an individual consolidation request by sequential index - ## in a consolidation request sequence. - ## - ## * The returned value is allocated in the given request sequence. - ## It must neither be released nor written to, and the request - ## sequence must not be released while the returned value is in use. - ## - ## Parameters: - ## * `requests` - Consolidation request sequence. - ## * `requestIndex` - Sequential consolidation request index. - ## - ## Returns: - ## * Consolidation request. - addr requests[][requestIndex.int] - -func ETHConsolidationRequestGetSourceAddress( - request: ptr ETHConsolidationRequest): ptr ExecutionAddress {.exported.} = - ## Obtains the source address of a consolidation request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Consolidation request. - ## - ## Returns: - ## * Source address. - addr request[].sourceAddress - -func ETHConsolidationRequestGetSourcePubkey( - request: ptr ETHConsolidationRequest): ptr ValidatorPubKey {.exported.} = - ## Obtains the source pubkey of a consolidation request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Consolidation request. - ## - ## Returns: - ## * Source pubkey. - addr request[].sourcePubkey - -func ETHConsolidationRequestGetTargetPubkey( - request: ptr ETHConsolidationRequest): ptr ValidatorPubKey {.exported.} = - ## Obtains the target pubkey of a consolidation request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Consolidation request. - ## - ## Returns: - ## * Target pubkey. - addr request[].targetPubkey - -func ETHConsolidationRequestGetBytes( - request: ptr ETHConsolidationRequest, - numBytes #[out]#: ptr cint): ptr UncheckedArray[byte] {.exported.} = - ## Obtains the raw byte representation of a consolidation request. - ## - ## * The returned value is allocated in the given request. - ## It must neither be released nor written to, and the request - ## must not be released while the returned value is in use. - ## - ## Parameters: - ## * `request` - Consolidation request. - ## * `numBytes` [out] - Length of buffer. - ## - ## Returns: - ## * Buffer with raw consolidation request data. - numBytes[] = distinctBase(request[].bytes).len.cint - if distinctBase(request[].bytes).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(request[].bytes)[0]) diff --git a/beacon_chain/libnimbus_lc/test_libnimbus_lc.c b/beacon_chain/libnimbus_lc/test_libnimbus_lc.c index 7e8150b05..825fc7158 100644 --- a/beacon_chain/libnimbus_lc/test_libnimbus_lc.c +++ b/beacon_chain/libnimbus_lc/test_libnimbus_lc.c @@ -423,105 +423,6 @@ int main(void) printHexString(executionRequestsHash, sizeof *executionRequestsHash); printf("\n"); - const ETHDepositRequests *depositRequests = - ETHExecutionBlockHeaderGetDepositRequests(executionBlockHeader); - int numRequests = ETHDepositRequestsGetCount(depositRequests); - printf(" - deposit_requests:\n"); - for (int requestIndex = 0; requestIndex < numRequests; requestIndex++) { - const ETHDepositRequest *request = - ETHDepositRequestsGet(depositRequests, requestIndex); - - const uint64_t *index = ETHDepositRequestGetIndex(request); - printf(" - index: %" PRIu64 "\n", *index); - - const ETHValidatorPubkey *pubkey = ETHDepositRequestGetPubkey(request); - printf(" - pubkey: "); - printHexString(pubkey, sizeof *pubkey); - printf("\n"); - - const ETHWithdrawalCredentials *withdrawalCredentials = - ETHDepositRequestGetWithdrawalCredentials(request); - printf(" - pubkey: "); - printHexString(withdrawalCredentials, sizeof *withdrawalCredentials); - printf("\n"); - - const uint64_t *amount = ETHDepositRequestGetAmount(request); - printf(" - amount: %" PRIu64 "\n", *amount); - - const ETHValidatorSignature *signature = ETHDepositRequestGetSignature(request); - printf(" - signature: "); - printHexString(signature, sizeof *signature); - printf("\n"); - - int numBytes; - const void *bytes = ETHDepositRequestGetBytes(request, &numBytes); - printf(" - bytes: "); - printHexString(bytes, numBytes); - printf("\n"); - } - - const ETHWithdrawalRequests *withdrawalRequests = - ETHExecutionBlockHeaderGetWithdrawalRequests(executionBlockHeader); - numRequests = ETHWithdrawalRequestsGetCount(withdrawalRequests); - printf(" - withdrawal_requests:\n"); - for (int requestIndex = 0; requestIndex < numRequests; requestIndex++) { - const ETHWithdrawalRequest *request = - ETHWithdrawalRequestsGet(withdrawalRequests, requestIndex); - - printf(" - index: %d\n", requestIndex); - - const ETHExecutionAddress *sourceAddress = ETHWithdrawalRequestGetSourceAddress(request); - printf(" - source_address: "); - printHexString(sourceAddress, sizeof *sourceAddress); - printf("\n"); - - const ETHValidatorPubkey *validatorPubkey = ETHWithdrawalRequestGetValidatorPubkey(request); - printf(" - validator_pubkey: "); - printHexString(validatorPubkey, sizeof *validatorPubkey); - printf("\n"); - - const uint64_t *amount = ETHWithdrawalRequestGetAmount(request); - printf(" - amount: %" PRIu64 "\n", *amount); - - int numBytes; - const void *bytes = ETHWithdrawalRequestGetBytes(request, &numBytes); - printf(" - bytes: "); - printHexString(bytes, numBytes); - printf("\n"); - } - - const ETHConsolidationRequests *consolidationRequests = - ETHExecutionBlockHeaderGetConsolidationRequests(executionBlockHeader); - numRequests = ETHConsolidationRequestsGetCount(consolidationRequests); - printf(" - consolidation_requests:\n"); - for (int requestIndex = 0; requestIndex < numRequests; requestIndex++) { - const ETHConsolidationRequest *request = - ETHConsolidationRequestsGet(consolidationRequests, requestIndex); - - printf(" - index: %d\n", requestIndex); - - const ETHExecutionAddress *sourceAddress = ETHConsolidationRequestGetSourceAddress(request); - printf(" - source_address: "); - printHexString(sourceAddress, sizeof *sourceAddress); - printf("\n"); - - const ETHValidatorPubkey *sourcePubkey = ETHConsolidationRequestGetSourcePubkey(request); - printf(" - source_pubkey: "); - printHexString(sourcePubkey, sizeof *sourcePubkey); - printf("\n"); - - const ETHValidatorPubkey *targetPubkey = ETHConsolidationRequestGetTargetPubkey(request); - printf(" - target_pubkey: "); - printHexString(targetPubkey, sizeof *targetPubkey); - printf("\n"); - - int numBytes; - const void *bytes = ETHConsolidationRequestGetBytes(request, &numBytes); - printf(" - bytes: "); - printHexString(bytes, numBytes); - printf("\n"); - } - ETHExecutionBlockHeaderDestroy(executionBlockHeader); ETHRoot sampleTransactionsRoot = {{