nimbus-eth2/beacon_chain/spec
Etan Kissling c7d5ad78e1
avoid `--gc:arc` issue in validator key caching (#6203)
The current implementation of the validator key cache as introduced in
#5883 leads to issues when compiling with `--gc:arc`. Namely, the assert
in `injectdestructors.nim` > `destructiveMoveVar` is triggered:

```nim
assert n.kind != nkSym or not hasDestructor(c, n.sym.typ)
```

`cached == nkSym`, and `n.sym.typ == ref HashedValidatorPubKeyItem` with
`hasDestructor(c, n.sym.typ) == true`.

Inlining the `addr ...[]` avoids the problem and allows `--gc:arc`
compilation as part of LC wasm demo project.

Compilation command:

```sh
nim c \
    -d:disable_libbacktrace \
    -d:disableMarchNative \
    -d:disableLTO \
    -d:emscripten \
    -d:release \
    -d:useGcAssert \
    -d:useSysAssert \
    --debuginfo:off \
    --nimcache:nimcache \
    --os:linux \
    --cpu:wasm32 \
    --cc:clang \
    --clang.exe:emcc \
    --clang.linkerexe:emcc \
    --gc:arc \
    --exceptions:goto \
    --define:noSignalHandler \
    --define:danger \
    --panics:on \
    --passC:-fpic \
    --passL:-Os \
    --passL:-fpic \
    --passC:'-pthread' \
    --passL:'-pthread' \
    --passC:'-sASSERTIONS' \
    --passL:'-sASSERTIONS' \
    --passC:'-sINITIAL_MEMORY=256MB' \
    --passL:'-sINITIAL_MEMORY=256MB' \
    --passC:'-sSTACK_SIZE=128MB' \
    --passL:'-sSTACK_SIZE=128MB' \
    --passC:'-sUSE_PTHREADS=1' \
    --passL:'-sUSE_PTHREADS=1' \
    --passC:'-sPTHREAD_POOL_SIZE_STRICT=0' \
    --passL:'-sPTHREAD_POOL_SIZE_STRICT=0' \
    --passL:'-sEXPORTED_FUNCTIONS="[_free, _malloc, _NimMain, _ETHRandomNumberCreate, _ETHConsensusConfigCreateFromYaml, _ETHConsensusConfigGetConsensusVersionAtEpoch, _ETHBeaconStateCreateFromSsz, _ETHBeaconStateDestroy, _ETHBeaconStateCopyGenesisValidatorsRoot, _ETHRootDestroy, _ETHForkDigestsCreateFromState, _ETHBeaconClockCreateFromState, _ETHBeaconClockGetSlot, _ETHLightClientStoreCreateFromBootstrap, _ETHLightClientStoreDestroy, _kETHLcSyncKind_UpdatesByRange, _kETHLcSyncKind_FinalityUpdate, _kETHLcSyncKind_OptimisticUpdate, _ETHLightClientStoreGetNextSyncTask, _ETHLightClientStoreGetMillisecondsToNextSyncTask, _ETHLightClientStoreProcessUpdatesByRange, _ETHLightClientStoreProcessFinalityUpdate, _ETHLightClientStoreProcessOptimisticUpdate, _ETHLightClientStoreGetFinalizedHeader, _ETHLightClientStoreIsNextSyncCommitteeKnown, _ETHLightClientStoreGetOptimisticHeader, _ETHLightClientStoreGetSafetyThreshold, _ETHLightClientHeaderCreateCopy, _ETHLightClientHeaderDestroy, _ETHLightClientHeaderCopyBeaconRoot, _ETHLightClientHeaderGetBeacon, _ETHBeaconBlockHeaderGetSlot, _ETHBeaconBlockHeaderGetProposerIndex, _ETHBeaconBlockHeaderGetParentRoot, _ETHBeaconBlockHeaderGetStateRoot, _ETHBeaconBlockHeaderGetBodyRoot, _ETHLightClientHeaderCopyExecutionHash, _ETHLightClientHeaderGetExecution, _ETHExecutionPayloadHeaderGetParentHash, _ETHExecutionPayloadHeaderGetFeeRecipient, _ETHExecutionPayloadHeaderGetStateRoot, _ETHExecutionPayloadHeaderGetReceiptsRoot, _ETHExecutionPayloadHeaderGetLogsBloom, _ETHExecutionPayloadHeaderGetPrevRandao, _ETHExecutionPayloadHeaderGetBlockNumber, _ETHExecutionPayloadHeaderGetGasLimit, _ETHExecutionPayloadHeaderGetGasUsed, _ETHExecutionPayloadHeaderGetTimestamp, _ETHExecutionPayloadHeaderGetExtraDataBytes, _ETHExecutionPayloadHeaderGetBaseFeePerGas, _ETHExecutionPayloadHeaderGetBlobGasUsed, _ETHExecutionPayloadHeaderGetExcessBlobGas, _ETHExecutionBlockHeaderCreateFromJson, _ETHExecutionBlockHeaderDestroy, _ETHExecutionBlockHeaderGetTransactionsRoot, _ETHExecutionBlockHeaderGetWithdrawalsRoot, _ETHTransactionsCreateFromJson, _ETHTransactionsDestroy, _ETHTransactionsGetCount, _ETHTransactionsGet, _ETHTransactionGetHash, _ETHTransactionGetFrom, _ETHTransactionGetNonce, _ETHTransactionGetMaxPriorityFeePerGas, _ETHTransactionGetMaxFeePerGas, _ETHTransactionGetGas, _ETHTransactionIsCreatingContract, _ETHTransactionGetTo, _ETHTransactionGetValue, _ETHTransactionGetInputBytes, _ETHTransactionGetBytes, _ETHTransactionGetEip6493Root, _ETHTransactionGetEip6493Bytes, _ETHTransactionGetNumEip6493SnappyBytes, _ETHReceiptsCreateFromJson, _ETHReceiptsDestroy, _ETHReceiptsGet, _ETHReceiptHasStatus, _ETHReceiptGetBytes, _ETHReceiptGetEip6493Bytes, _ETHReceiptGetNumEip6493SnappyBytes]"' \
    --passL:'-sEXPORTED_RUNTIME_METHODS="[lengthBytesUTF8, stringToNewUTF8]"' \
    --passL:'-Wl,--no-entry' \
    --noMain:on \
    --passL:'-o libnimbus_lc.js' \
    nimbus-eth2/beacon_chain/libnimbus_lc/libnimbus_lc.nim
```
2024-04-16 11:47:18 +02:00
..
datatypes add Electra toSignedBlindedBlock tests (#6182) 2024-04-08 10:34:15 +02:00
eth2_apis produceBlockV3 call should send `execution_payload_blinded` value as boolean. (#6204) 2024-04-15 23:08:41 +00:00
mev support electra block proposals for internal BN validators (#6187) 2024-04-09 12:04:33 +02:00
presets automated consensus spec URL updating to v1.4.0 (#6074) 2024-03-14 07:26:36 +01:00
beacon_time.nim automated consensus spec URL updating to v1.4.0 (#6074) 2024-03-14 07:26:36 +01:00
beaconstate.nim block_sim runs electra (#6181) 2024-04-07 09:58:11 +02:00
block_id.nim verify `genesis_time` more strictly (fixes #1667) (#5694) 2024-01-06 15:26:56 +01:00
crypto.nim remove MIRACL Core support (#5941) 2024-02-22 16:13:31 +00:00
deposit_snapshots.nim fix `/eth/v1/beacon/deposit_snapshot` for EIP-4881 (#6038) 2024-03-08 14:22:03 +01:00
digest.nim add `{.push raises: [].}` to recently modified files (#5908) 2024-02-18 01:16:49 +00:00
engine_authentication.nim add `{.push raises: [].}` to recently modified files (#5908) 2024-02-18 01:16:49 +00:00
english_word_list.txt
eth2_merkleization.nim avoid `--gc:arc` issue in validator key caching (#6203) 2024-04-16 11:47:18 +02:00
eth2_ssz_serialization.nim Shared validator pubkey (#5883) 2024-02-21 20:06:19 +01:00
forks.nim add Electra support to beacon API produceBlindedBlock and produceBlockV3 endpoints; add further VC publish(Blinded)Block Electra support (#6190) 2024-04-10 10:54:00 +02:00
forks_light_client.nim add Electra to ConsensusFork enum (#6169) 2024-04-03 16:43:43 +02:00
helpers.nim make `Gwei` `distinct` (#6090) 2024-03-19 14:22:07 +01:00
keystore.nim remove some debugRaiseAsserts and fill in Electra functionality (#6177) 2024-04-05 21:30:06 +02:00
light_client_sync.nim add missing `std/` prefix to more imports (#5696) 2024-01-06 07:18:28 +01:00
network.nim automated consensus spec URL updating to v1.4.0 (#6074) 2024-03-14 07:26:36 +01:00
presets.nim add some push raises, ElectraBeaconStateNoImmutableValidators, and ELECTRA_FORK_VERSION/EPOCH (#5949) 2024-02-24 05:08:22 +00:00
signatures.nim support electra block proposals for internal BN validators (#6187) 2024-04-09 12:04:33 +02:00
signatures_batch.nim automated consensus spec URL updating to v1.4.0 (#6074) 2024-03-14 07:26:36 +01:00
ssz_codec.nim make `Gwei` `distinct` (#6090) 2024-03-19 14:22:07 +01:00
state_transition.nim block_sim runs electra (#6181) 2024-04-07 09:58:11 +02:00
state_transition_block.nim support electra block proposals for internal BN validators (#6187) 2024-04-09 12:04:33 +02:00
state_transition_epoch.nim rm unused parameters of get_state_exit_queue_info() (#6167) 2024-04-03 01:45:57 +00:00
validator.nim make `Gwei` `distinct` (#6090) 2024-03-19 14:22:07 +01:00
weak_subjectivity.nim make `Gwei` `distinct` (#6090) 2024-03-19 14:22:07 +01:00