Commit Graph

4062 Commits

Author SHA1 Message Date
tersec 867995acd1
some consensus spec v1.4.0 spec URL updates (#6208) 2024-04-17 05:51:16 +02:00
tersec bb2ca747bc
move Attestation-related types/logging from base to phase0 types (#6207) 2024-04-16 19:01:30 +00:00
tersec bd3c9af0f8
implement EIP-7002 (#6206)
* implement EIP-7002

* fix linting
2024-04-16 18:09:39 +00:00
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
Eugene Kabanov c5f04dd237
produceBlockV3 call should send `execution_payload_blinded` value as boolean. (#6204)
* Fix `execution_payload_blinded` in produceBlockV3 response should be boolean not string.

* Address review comments.
2024-04-15 23:08:41 +00:00
Etan Kissling c57fcb426a
bump `nim-libp2p` to `89cad5a3ba9088cc721682469a10917903da25a0` (#6199)
- add support for setting protocol handlers with `{.raises.}` annotation
- fix: valueOr and withValue utilities
- fix: remove explicit param from GossipSubParams constructor
2024-04-12 11:12:44 +02:00
tersec e51c5ec783
add Electra blob support to block/blob quarantines, block processor, and request manager (#6201) 2024-04-11 09:31:39 +00:00
tersec 205d63a897
fill in executionpayload for/from GetPayloadV4 (#6200) 2024-04-10 23:34:34 +00:00
Etan Kissling 9bffc51cf6
allow frontfilling finalized CP block from era file (#6164)
Add support for using era file for the initial checkpoint block.
This should also avoid an error when the beacon node is restarted
before the backfill process has made any progress (#6059).
2024-04-10 14:11:07 +02:00
Etan Kissling a561024d88
rank peers by their score instead of their memory address (#6149)
The `<` function to compare peers was not exported, leading to the same
peer be acquired over and over again until kick. `mixin` doesn't pull it
into `peerCmp` without `*` export, and with the export no mixin needed.
2024-04-10 14:09:37 +02:00
tersec e7dede344a
bump nim-web3 to get updated Pectra GetPayloadV4 types (#6191) 2024-04-10 11:38:38 +02:00
tersec 1bf4058e22
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
tersec 8a30cffbcc
initial VC Electra publishBlock support (#6189) 2024-04-09 16:54:05 +02:00
tersec 749a45695f
support engine_newPayloadV4 (#6188) 2024-04-09 12:44:03 +02:00
tersec 6ce5d5814c
support electra block proposals for internal BN validators (#6187) 2024-04-09 12:04:33 +02:00
tersec ba45a1821c
implement Electra beacon API publishBlindedBlock (#6185) 2024-04-08 18:03:20 +02:00
Etan Kissling 41a3b62fe2
update `wss_sim` for Bellatrix, Capella and Deneb (#6170)
The `wss_sim` was not properly maintained since Bellatrix. The missing
functionality is now added, including:

- Bellatrix: Connect to an EL for execution payload production
- Capella: Correct withdrawals processing, is mandatory to do
- Deneb: Dump blob sidecars into the output directory

See https://ethresear.ch/t/insecura-my-consensus-for-the-pyrmont-network/11833
2024-04-08 15:28:46 +02:00
tersec 97bfca4b88
implement Electra beacon API getBlindedBlock (#6183) 2024-04-08 14:49:03 +02:00
tersec 361be082ae
add Electra toSignedBlindedBlock tests (#6182) 2024-04-08 10:34:15 +02:00
tersec 937cc62b85
block_sim runs electra (#6181) 2024-04-07 09:58:11 +02:00
tersec 27921406e9
remove some debugRaiseAsserts and fill in Electra functionality (#6179) 2024-04-06 15:11:47 +02:00
tersec 0d534224b3
remove some debugRaiseAsserts and fill in Electra functionality (#6178) 2024-04-06 07:46:02 +00:00
tersec 06894dd2f6
remove some debugRaiseAsserts and fill in Electra functionality (#6177) 2024-04-05 21:30:06 +02:00
Etan Kissling 86a265308a
filter out `nil` values when iterating peers (#6151)
Iterating peers should only yield peers present in registry, otherwise
`nil` pointers are returned and depending on comparison function it will
break, see #6149.
2024-04-05 16:38:04 +02:00
tersec 08d6dc347e
rm payload transaction value calculation for Bellatrix engine API (#6173) 2024-04-04 06:33:08 +02:00
tersec 0b6f75b88b
remove some debugRaiseAsserts and fill in actual Electra functionality (#6172) 2024-04-04 05:17:31 +02:00
tersec 13a70e9d69
rm built-in Goerli beacon chain support (#6057) 2024-04-03 23:25:36 +00:00
Etan Kissling df0ff5f0fb
fix initialization of sync committee cache after loading non-epoch state (#6160)
When initializing from a state that's not aligned to an epoch boundary,
an earlier state is loaded that's epoch aligned, and subsequently topped
up with the missing blocks. `dag.headSyncCommittee` is initialized prior
to topping up the missing blocks, though. If the sync committee changes
while applying the blocks (e.g., a sync committee period boundary hits),
the cached information becomes unlinked from `dag.head`, leading to
valid blocks based on that chain being rejected. To fix this, move cache
initialization after the top up with blocks. This has been observed on
Goerli by initializing from 7919502 and attempting to top up 7920111.
The block gets rejected with an invalid state root on nodes that have
restarted after setting 7920111 as head, while it gets accepted by all
other nodes. Error message is `block: state root verification failed`.
The incorrect initialization behaviour was introduced in #4592, before
which the sync committee cache was initialized after applying blocks.
2024-04-03 23:03:06 +02:00
Etan Kissling 96e27d9d35
avoid modifying blobless collection during iteration in edge case (#6168)
The fallback when blobless quarantine contains a block with all blobs
modifies collection while iterating, potentially asserting if reachable.
Using a second loop to process this situation resolves that.
2024-04-03 23:02:24 +02:00
tersec 7fa32b7f02
add Electra to ConsensusFork enum (#6169)
* add Electra to ConsensusFork enum

* fix gnosis check
2024-04-03 16:43:43 +02:00
Etan Kissling 6a318d0f1a
avoid rejecting empty era file in verification (#6163)
`batchVerify`'s precondition is a non-empty signature list:

```nim
  if input.len == 0:
    # Spec precondition
    return false
```

This means that in eras without any blocks (as has happened on Goerli),
calling it leads to era files being reported as invalid.
2024-04-03 10:06:21 +02:00
Etan Kissling 0000f81df0
remove unused and redundant `PayloadID` type definition (#6165)
`PayloadID` is defined in `nim-web3` and our own Bellatrix definition
can be removed.
2024-04-03 07:27:00 +02:00
tersec 27ec2893ff
rm unused parameters of get_state_exit_queue_info() (#6167) 2024-04-03 01:45:57 +00:00
Etan Kissling 5f4fa9ae69
avoid code repetition across forks for signed block contents (#6150)
Use forks sugar to make `RestPublishedSignedBlockContents` more concise.
2024-04-03 02:05:29 +02:00
tersec 109007dc93
avoid quadratic behavior exiting validators (#6161)
* avoid quadratic behavior exiting validators

* fix libnfuzz callers
2024-04-02 12:18:40 +00:00
tersec 4457334dd0
Add support for Pectra ExecutionPayload representations (#6158) 2024-03-29 13:37:27 +01:00
tersec 3ceb26ba23
Merge remote-tracking branch 'origin/stable' into unstable 2024-03-28 06:19:26 +00:00
tersec b21bc1d478
Version v24.3.0 2024-03-28 05:23:23 +00:00
tersec 17279f261b
detect invalid REST blocks (#6152) 2024-03-28 03:34:06 +00:00
tersec df9112d663
detect invalid REST blocks (#6152) 2024-03-28 03:32:33 +00:00
diegomrsantos 885989f3df
bump libp2p (#6148) 2024-03-27 15:53:02 +00:00
diegomrsantos edad7c8a4c
bump libp2p (#6132) 2024-03-27 11:16:57 +01:00
tersec 7a3edb6961
more initialize_validator_exit optimization (#6146) 2024-03-27 09:18:50 +01:00
tersec f9e5294802
dump EL-INVALID blocks if requested the same way as CL-INVALID blocks; optimize epoch transition validator exit (#6144) 2024-03-27 04:34:56 +01:00
tersec 605bf99344
remove macOS/aarch64 workaround from proposeBlockAux (#6138) 2024-03-26 23:05:49 +00:00
tersec 21daaad754
support special characters in network metadata paths (#6141) 2024-03-26 22:47:42 +01:00
Etan Kissling 2dbe24c740
move split view catchup to research branch (#6133)
Using a dedicated branch for researching the effectiveness of split view
scenario handling simplifies testing and avoids having partial work on
`unstable`. If we want, we can reintroduce it under a `--debug` flag at
a later time. But for now, Goerli is a rare opoprtunity to test this,
maybe just for another week or so.

- https://github.com/status-im/infra-nimbus/pull/179
2024-03-25 19:09:31 +01:00
Etan Kissling fc9bc1da3a
add branch discovery module for supporting chain stall situation (#6125)
In split view situation, the canonical chain may only be served by a
tiny amount of peers, and branches may span long durations. Minority
branches may still have a large weight from attestations and should
be discovered. To assist with that, add a branch discovery module that
assists in such a situation by specifically targeting peers with unknown
histories and downloading from them, in addition to sync manager work
which handles popular branches.
2024-03-24 08:41:47 +00:00
Etan Kissling 66a9304fea
use separate state when catching up to perform validator duties (#6131)
There are situations where all states in the `blockchain_dag` are
occupied and cannot be borrowed.

- headState: Many assumptions in the code that it cannot be advanced
- clearanceState: Resets every time a new block gets imported, including
  blocks from non-canonical branches
- epochRefState: Used even more frequently than clearanceState

This means that during the catch-up mechanic where the head state is
slowly advanced to wall clock to catch up on validator duties in the
situation where the canonical head is way behind non-canonical heads,
we cannot use any of the three existing states. In that situation,
Nimbus already consumes an increased amount of memory due to all the
`BlockRef`, fork choice states and so on, so experience is degraded.
It seems reasonable to allocate a fourth state temporarily during that
mechanic, until a new proposal could be made on the canonical chain.

Note that currently, on `unstable`, proposals _do_ happen every couple
hours because sync manager doesn't manage to discover additional heads
in a split-view scenario on Goerli. However, with the branch discovery
module, new blocks are discovered all the time, and the clearanceState
may no longer be borrowed as it is reset to different branch too often.

The extra state could also find other uses in the future, e.g., for
incremental computations as in reindexing the database, or online
collection of historical light client data.
2024-03-24 07:18:33 +01:00
Etan Kissling c4a5bca629
update block quarantine eviction order to FIFO (#6129)
Use the same eviction policy for blocks as already the case for blobs.
FIFO makes more sense, because it favors keeping ancestors of blocks
which need to be applied to the DAG before their children get eligible.
2024-03-24 06:03:51 +01:00