From 7da6b70610fbd245af228a70dba7521c8016acde Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 24 May 2024 19:50:55 +0200 Subject: [PATCH 01/33] bump 'geth' to `v1.14.3` (#6309) - https://github.com/ethereum/go-ethereum/releases/tag/v1.14.3 --- scripts/geth_binaries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/geth_binaries.sh b/scripts/geth_binaries.sh index f1b34d181..52b25ff2c 100644 --- a/scripts/geth_binaries.sh +++ b/scripts/geth_binaries.sh @@ -21,7 +21,7 @@ source "${SCRIPTS_DIR}/bash_utils.sh" download_geth_stable() { if [[ ! -e "${STABLE_GETH_BINARY}" ]]; then - GETH_VERSION="1.14.0-87246f3c" # https://geth.ethereum.org/downloads + GETH_VERSION="1.14.3-ab48ba42" # https://geth.ethereum.org/downloads GETH_URL="https://gethstore.blob.core.windows.net/builds/" case "${OS}-${ARCH}" in From ad7daf6be7ff23658400ffb7e767faeb770e1766 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 24 May 2024 22:25:55 +0200 Subject: [PATCH 02/33] bump `nim-json-serialization` to `4d0b0662ed960ab2c5a1ddbd08f77048bac13ae7` (#6312) - Workaround Nim regression #23611 related to dirty template --- vendor/nim-json-serialization | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-json-serialization b/vendor/nim-json-serialization index 1ac1d69f9..4d0b0662e 160000 --- a/vendor/nim-json-serialization +++ b/vendor/nim-json-serialization @@ -1 +1 @@ -Subproject commit 1ac1d69f9512d55d15e8218a9dbdff129bf96ddb +Subproject commit 4d0b0662ed960ab2c5a1ddbd08f77048bac13ae7 From e4fcf5664896b21a2b666366e2550e22952157c4 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 24 May 2024 23:39:55 +0200 Subject: [PATCH 03/33] bump `nim-nat-traversal` to `54bf8aa2913e8550463779beeae4b469941e039c` (#6315) - bump `libnatpmp-upstream` to `007c3a53165a0551c877130eea4d966885ce19ae` --- vendor/nim-nat-traversal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-nat-traversal b/vendor/nim-nat-traversal index 4c4fc6f14..54bf8aa29 160000 --- a/vendor/nim-nat-traversal +++ b/vendor/nim-nat-traversal @@ -1 +1 @@ -Subproject commit 4c4fc6f1436b5e0468a6b3a7929bb603f0b43f33 +Subproject commit 54bf8aa2913e8550463779beeae4b469941e039c From e5b69bd688032383d563a90dd8f859d2f0efba28 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 24 May 2024 23:49:35 +0200 Subject: [PATCH 04/33] bump `nim-snappy` to `913c426d571cf82601452642e01cd11ea26f7ac6` (#6317) - bump `snappycpp` to `1.2.1` --- vendor/nim-snappy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-snappy b/vendor/nim-snappy index aaef74113..913c426d5 160000 --- a/vendor/nim-snappy +++ b/vendor/nim-snappy @@ -1 +1 @@ -Subproject commit aaef74113cadaaca690c6144eae0cf2c2a10db28 +Subproject commit 913c426d571cf82601452642e01cd11ea26f7ac6 From 1150aa3e11b9f967434030ff2af75184467b521e Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sat, 25 May 2024 00:33:34 +0200 Subject: [PATCH 05/33] bump `gnosis-chain-configs` to `9ed6c63314899d17e2c3f669adbe2bc915610982` (#6311) - Update spec --- vendor/gnosis-chain-configs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/gnosis-chain-configs b/vendor/gnosis-chain-configs index c115f3688..9ed6c6331 160000 --- a/vendor/gnosis-chain-configs +++ b/vendor/gnosis-chain-configs @@ -1 +1 @@ -Subproject commit c115f3688c19eb6153e22c1e76477db4ed27fae3 +Subproject commit 9ed6c63314899d17e2c3f669adbe2bc915610982 From ad2f14e76a6eddaaa22a7a1a273c16577f36c3dd Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sat, 25 May 2024 00:35:50 +0200 Subject: [PATCH 06/33] bump `nim-stint` to `9d2b382c5dc34f0d6bbd93b2a5d65dde85067e0f` (#6318) - Fix pointer deref issue on Macos and Nim >= 2.0 - Fix GCC-14 [-Wincompatible-pointer-types] issue. --- vendor/nim-stint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-stint b/vendor/nim-stint index 3c238df6c..9d2b382c5 160000 --- a/vendor/nim-stint +++ b/vendor/nim-stint @@ -1 +1 @@ -Subproject commit 3c238df6cd4b9c1f37a9f103383e7d2bbd420c13 +Subproject commit 9d2b382c5dc34f0d6bbd93b2a5d65dde85067e0f From de740199f589a526746a1f3e5622784529671107 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sat, 25 May 2024 00:36:08 +0200 Subject: [PATCH 07/33] bump `nim-kzg4844` to `f12616d0675d9f6346141ca95f0840ab227eb213` (#6313) - bump `csources` to `v1.0.2` --- vendor/nim-kzg4844 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-kzg4844 b/vendor/nim-kzg4844 index 4fbcfbe4c..f12616d06 160000 --- a/vendor/nim-kzg4844 +++ b/vendor/nim-kzg4844 @@ -1 +1 @@ -Subproject commit 4fbcfbe4c452313bd440936318a87ed708987d8b +Subproject commit f12616d0675d9f6346141ca95f0840ab227eb213 From 0efc81d96db57510e18ec5fbe9e19bd1cc9921af Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sat, 25 May 2024 07:30:05 +0200 Subject: [PATCH 08/33] use correct minimum size when reading block / state headers (#6263) `sizeof` also includes padding between fields, while SSZ defines `fixedPortionSize` (on type) or `sszSize` (on value) to denote required bytes to encode. Switch forked block/state readers to SSZ size. As blocks/states are much larger than the padding, this doesn't affect practical use cases but is slightly more correct this way. --- beacon_chain/spec/forks.nim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/beacon_chain/spec/forks.nim b/beacon_chain/spec/forks.nim index 63362d595..63ce8df4b 100644 --- a/beacon_chain/spec/forks.nim +++ b/beacon_chain/spec/forks.nim @@ -1360,19 +1360,19 @@ func readSszForkedHashedBeaconState*(cfg: RuntimeConfig, data: openArray[byte]): ForkedHashedBeaconState {.raises: [SerializationError].} = ## Read a state picking the right fork by first reading the slot from the byte ## source - if data.len() < sizeof(BeaconStateHeader): - raise (ref MalformedSszError)(msg: "Not enough data for BeaconState header") + const numHeaderBytes = fixedPortionSize(BeaconStateHeader) + if data.len() < numHeaderBytes: + raise (ref MalformedSszError)(msg: "Incomplete BeaconState header") let header = SSZ.decode( - data.toOpenArray(0, sizeof(BeaconStateHeader) - 1), - BeaconStateHeader) + data.toOpenArray(0, numHeaderBytes - 1), BeaconStateHeader) # TODO https://github.com/nim-lang/Nim/issues/19357 result = readSszForkedHashedBeaconState(cfg, header.slot, data) type ForkedBeaconBlockHeader = object - message*: uint32 # message offset - signature*: ValidatorSig + message: uint32 # message offset + signature: ValidatorSig slot: Slot # start of BeaconBlock func readSszForkedSignedBeaconBlock*( @@ -1380,11 +1380,11 @@ func readSszForkedSignedBeaconBlock*( ForkedSignedBeaconBlock {.raises: [SerializationError].} = ## Helper to read a header from bytes when it's not certain what kind of block ## it is - if data.len() < sizeof(ForkedBeaconBlockHeader): - raise (ref MalformedSszError)(msg: "Not enough data for SignedBeaconBlock header") + const numHeaderBytes = fixedPortionSize(ForkedBeaconBlockHeader) + if data.len() < numHeaderBytes: + raise (ref MalformedSszError)(msg: "Incomplete SignedBeaconBlock header") let header = SSZ.decode( - data.toOpenArray(0, sizeof(ForkedBeaconBlockHeader) - 1), - ForkedBeaconBlockHeader) + data.toOpenArray(0, numHeaderBytes - 1), ForkedBeaconBlockHeader) # TODO https://github.com/nim-lang/Nim/issues/19357 result = ForkedSignedBeaconBlock( From dc6951eee951282e47b773ab780170cdccb328e2 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Sat, 25 May 2024 11:13:30 +0200 Subject: [PATCH 09/33] bump `nim-web3` to `46b4b4c8bc42013196a6290ee53029131f97931a` (#6319) - CI do not install openssl on macos+nim devel anymore - Fixed encoding of (multidimentional) dynamic arrays --- vendor/nim-web3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 9aed14a73..46b4b4c8b 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 9aed14a7373f51715730712adfde39546708296f +Subproject commit 46b4b4c8bc42013196a6290ee53029131f97931a From 1cdb32222b6a883290620be9d2653b135bbdb5f1 Mon Sep 17 00:00:00 2001 From: Eugene Kabanov Date: Wed, 29 May 2024 13:07:39 +0300 Subject: [PATCH 10/33] VC: Add block scoring (#6303) * Add scoring for blocks. * Update Alltests. --- AllTests-mainnet.md | 6 +- beacon_chain/spec/forks.nim | 10 +++ beacon_chain/validator_client/api.nim | 98 ++++++++++++++++++----- beacon_chain/validator_client/scoring.nim | 32 ++++++++ tests/test_validator_client.nim | 47 ++++++++++- 5 files changed, 171 insertions(+), 22 deletions(-) diff --git a/AllTests-mainnet.md b/AllTests-mainnet.md index ebdb530e5..a27029e2e 100644 --- a/AllTests-mainnet.md +++ b/AllTests-mainnet.md @@ -905,12 +905,14 @@ OK: 1/1 Fail: 0/1 Skip: 0/1 + getAggregatedAttestationDataScore() test vectors OK + getAttestationDataScore() test vectors OK + getLiveness() response deserialization test OK ++ getProduceBlockResponseV3Score() default test OK ++ getProduceBlockResponseV3Score() test vectors OK + getSyncCommitteeContributionDataScore() test vectors OK + getSyncCommitteeMessageDataScore() test vectors OK + getUniqueVotes() test vectors OK + normalizeUri() test vectors OK ``` -OK: 12/12 Fail: 0/12 Skip: 0/12 +OK: 14/14 Fail: 0/14 Skip: 0/14 ## Validator change pool testing suite ```diff + addValidatorChangeMessage/getAttesterSlashingMessage OK @@ -1030,4 +1032,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2 OK: 9/9 Fail: 0/9 Skip: 0/9 ---TOTAL--- -OK: 687/692 Fail: 0/692 Skip: 5/692 +OK: 689/694 Fail: 0/694 Skip: 5/694 diff --git a/beacon_chain/spec/forks.nim b/beacon_chain/spec/forks.nim index 63ce8df4b..3c86b4926 100644 --- a/beacon_chain/spec/forks.nim +++ b/beacon_chain/spec/forks.nim @@ -1173,6 +1173,16 @@ template withForkyMaybeBlindedBlck*( template forkyMaybeBlindedBlck: untyped {.inject, used.} = b.phase0Data body +template shortLog*(x: ForkedMaybeBlindedBeaconBlock): auto = + withForkyMaybeBlindedBlck(x): + when consensusFork >= ConsensusFork.Deneb: + when isBlinded == true: + shortLog(forkyMaybeBlindedBlck) + else: + shortLog(forkyMaybeBlindedBlck.`block`) + else: + shortLog(forkyMaybeBlindedBlck) + template withStateAndBlck*( s: ForkedHashedBeaconState, b: ForkedBeaconBlock | ForkedSignedBeaconBlock | diff --git a/beacon_chain/validator_client/api.nim b/beacon_chain/validator_client/api.nim index 5762bf088..1e9b39316 100644 --- a/beacon_chain/validator_client/api.nim +++ b/beacon_chain/validator_client/api.nim @@ -39,14 +39,14 @@ type status*: ApiOperation data*: seq[ApiNodeResponse[T]] - ApiScore* = object + ApiScore*[T] = object index*: int - score*: Opt[float64] + score*: Opt[T] - BestNodeResponse*[T] = object + BestNodeResponse*[T, X] = object node*: BeaconNodeServerRef data*: ApiResponse[T] - score*: float64 + score*: X const ViableNodeStatus* = { @@ -56,7 +56,7 @@ const RestBeaconNodeStatus.Synced } -proc `$`*(s: ApiScore): string = +proc `$`*[T](s: ApiScore[T]): string = var res = Base10.toString(uint64(s.index)) res.add(": ") if s.score.isSome(): @@ -65,22 +65,27 @@ proc `$`*(s: ApiScore): string = res.add("") res -proc `$`*(ss: openArray[ApiScore]): string = +proc `$`*[T](ss: openArray[ApiScore[T]]): string = "[" & ss.mapIt($it).join(",") & "]" chronicles.formatIt(seq[ApiScore]): $it func init*(t: typedesc[ApiScore], node: BeaconNodeServerRef, - score: float64): ApiScore = - ApiScore(index: node.index, score: Opt.some(score)) + score: float64): ApiScore[float64] = + ApiScore[float64](index: node.index, score: Opt.some(score)) -func init*(t: typedesc[ApiScore], node: BeaconNodeServerRef): ApiScore = - ApiScore(index: node.index, score: Opt.none(float64)) +func init*(t: typedesc[ApiScore], node: BeaconNodeServerRef, + score: UInt256): ApiScore[UInt256] = + ApiScore[UInt256](index: node.index, score: Opt.some(score)) -func init*[T](t: typedesc[BestNodeResponse], node: BeaconNodeServerRef, - data: ApiResponse[T], score: float64): BestNodeResponse[T] = - BestNodeResponse[T](node: node, data: data, score: score) +func init*(tt: typedesc[ApiScore], + node: BeaconNodeServerRef, T: typedesc): ApiScore[T] = + ApiScore[T](index: node.index, score: Opt.none(T)) + +func init*[T, X](t: typedesc[BestNodeResponse], node: BeaconNodeServerRef, + data: ApiResponse[T], score: X): BestNodeResponse[T, X] = + BestNodeResponse[T, X](node: node, data: data, score: score) proc lazyWaiter(node: BeaconNodeServerRef, request: FutureBase, requestName: string, strategy: ApiStrategyKind) {.async.} = @@ -234,7 +239,7 @@ template firstSuccessParallel*( pendingNodes.del(index) let - node {.inject.} = beaconNode + node {.inject, used.} = beaconNode apiResponse {.inject.} = apiResponseOr[responseType](requestFut, timerFut, "Timeout exceeded while awaiting for the response") @@ -283,6 +288,7 @@ template bestSuccess*( vc: ValidatorClientRef, responseType: typedesc, handlerType: typedesc, + scoreType: typedesc, timeout: Duration, statuses: set[RestBeaconNodeStatus], roles: set[BeaconNodeRole], @@ -301,8 +307,8 @@ template bestSuccess*( var retRes: ApiResponse[handlerType] - scores: seq[ApiScore] - bestResponse: Opt[BestNodeResponse[handlerType]] + scores: seq[ApiScore[scoreType]] + bestResponse: Opt[BestNodeResponse[handlerType, scoreType]] block mainLoop: while true: @@ -395,7 +401,7 @@ template bestSuccess*( perfectScoreFound = true break else: - scores.add(ApiScore.init(node)) + scores.add(ApiScore.init(node, scoreType)) if perfectScoreFound: # lazyWait will cancel `pendingRequests` on timeout. @@ -1181,6 +1187,7 @@ proc getHeadBlockRoot*( let res = vc.bestSuccess( RestPlainResponse, GetBlockRootResponse, + float64, SlotDuration, ViableNodeStatus, {BeaconNodeRole.SyncCommitteeData}, @@ -1413,6 +1420,7 @@ proc produceAttestationData*( let res = vc.bestSuccess( RestPlainResponse, ProduceAttestationDataResponse, + float64, OneThirdDuration, ViableNodeStatus, {BeaconNodeRole.AttestationData}, @@ -1685,6 +1693,7 @@ proc getAggregatedAttestation*( let res = vc.bestSuccess( RestPlainResponse, GetAggregatedAttestationResponse, + float64, OneThirdDuration, ViableNodeStatus, {BeaconNodeRole.AggregatedData}, @@ -1818,6 +1827,7 @@ proc produceSyncCommitteeContribution*( let res = vc.bestSuccess( RestPlainResponse, ProduceSyncCommitteeContributionResponse, + float64, OneThirdDuration, ViableNodeStatus, {BeaconNodeRole.SyncCommitteeData}, @@ -2036,7 +2046,59 @@ proc produceBlockV3*( var failures: seq[ApiNodeFailure] case strategy - of ApiStrategyKind.First, ApiStrategyKind.Best: + of ApiStrategyKind.Best: + let res = vc.bestSuccess( + RestPlainResponse, + ProduceBlockResponseV3, + UInt256, + SlotDuration, + ViableNodeStatus, + {BeaconNodeRole.BlockProposalData}, + produceBlockV3Plain(it, slot, randao_reveal, graffiti, + builder_boost_factor), + getProduceBlockResponseV3Score(itresponse)): + if apiResponse.isErr(): + handleCommunicationError() + ApiResponse[ProduceBlockResponseV3].err(apiResponse.error) + else: + let response = apiResponse.get() + case response.status + of 200: + let + version = response.headers.getString("eth-consensus-version") + blinded = + response.headers.getString("eth-execution-payload-blinded") + executionValue = + response.headers.getString("eth-execution-payload-value") + consensusValue = + response.headers.getString("eth-consensus-block-value") + res = decodeBytes(ProduceBlockResponseV3, response.data, + response.contentType, version, blinded, + executionValue, consensusValue) + if res.isErr(): + handleUnexpectedData() + ApiResponse[ProduceBlockResponseV3].err($res.error) + else: + ApiResponse[ProduceBlockResponseV3].ok(res.get()) + of 400: + handle400() + ApiResponse[ProduceBlockResponseV3].err(ResponseInvalidError) + of 500: + handle500() + ApiResponse[ProduceBlockResponseV3].err(ResponseInternalError) + of 503: + handle503() + ApiResponse[ProduceBlockResponseV3].err( + ResponseNoSyncError) + else: + handleUnexpectedCode() + ApiResponse[ProduceBlockResponseV3].err( + ResponseUnexpectedError) + if res.isErr(): + raise (ref ValidatorApiError)(msg: res.error, data: failures) + return res.get() + + of ApiStrategyKind.First: let res = vc.firstSuccessParallel( RestPlainResponse, ProduceBlockResponseV3, diff --git a/beacon_chain/validator_client/scoring.nim b/beacon_chain/validator_client/scoring.nim index 2b401b25d..19448b94d 100644 --- a/beacon_chain/validator_client/scoring.nim +++ b/beacon_chain/validator_client/scoring.nim @@ -10,6 +10,7 @@ import std/strutils import ssz_serialization/[types, bitseqs] import stew/endians2 +import stint import nimcrypto/hash import "."/common @@ -24,6 +25,9 @@ const func perfectScore*(score: float64): bool = score == Inf +func perfectScore*(score: UInt256): bool = + score == high(UInt256) + proc shortScore*(score: float64): string = if score == Inf: "" @@ -32,6 +36,9 @@ proc shortScore*(score: float64): string = else: formatFloat(score, ffDecimal, 4) +proc shortScore*(score: UInt256): string = + $score + func getLexicographicScore(digest: Eth2Digest): float64 = # We calculate score on first 8 bytes of digest. let @@ -183,3 +190,28 @@ proc getUniqueVotes*(attestations: openArray[phase0.Attestation]): int = processVotes(attestation) res += count res + +proc getProduceBlockResponseV3Score*(blck: ProduceBlockResponseV3): UInt256 = + let (res, cv, ev) = + block: + var score256 = UInt256.zero + let + cvalue = + if blck.consensusValue.isSome(): + let value = blck.consensusValue.get() + score256 = score256 + value + $value + else: + "" + evalue = + if blck.executionValue.isSome(): + let value = blck.executionValue.get() + score256 = score256 + value + $value + else: + "" + (score256, cvalue, evalue) + + debug "Block score", blck = shortLog(blck), consensus_value = cv, + execution_value = ev, score = shortScore(res) + res diff --git a/tests/test_validator_client.nim b/tests/test_validator_client.nim index bbc5553ab..4caafee66 100644 --- a/tests/test_validator_client.nim +++ b/tests/test_validator_client.nim @@ -389,6 +389,7 @@ const ("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01", "0.9995"), ("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101", "0.0005"), ] + ContributionDataVectors = [ ("0xffffffffffffffffffffffffffff7f7f", "0.9844"), ("0xffffffffffffffffffffffff7f7f7f7f", "0.9688"), @@ -446,6 +447,15 @@ const ([("0xff01", Slot(0), 0'u64), ("0xff01", Slot(0), 1'u64)], 16) ] + UInt256ScoreVectors = [ + ("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "0x0000000000000000000000000000000000000000000000000000000000000001", + "0"), + ("0x10", + "0x10", + "32") + ] + proc init(t: typedesc[Eth2Digest], data: string): Eth2Digest = let length = len(data) var dst = Eth2Digest() @@ -755,6 +765,25 @@ suite "Validator Client test suite": score == "0.0000" isLowestScoreAggregatedAttestation(adata.data) == true + test "getProduceBlockResponseV3Score() default test": + let + bdata1 = ProduceBlockResponseV3() + bdata2 = ProduceBlockResponseV3( + consensusValue: Opt.some(UInt256.zero) + ) + bdata3 = ProduceBlockResponseV3( + executionValue: Opt.some(UInt256.zero), + ) + bdata4 = ProduceBlockResponseV3( + consensusValue: Opt.some(UInt256.zero), + executionValue: Opt.some(UInt256.zero) + ) + check: + shortScore(getProduceBlockResponseV3Score(bdata1)) == "0" + shortScore(getProduceBlockResponseV3Score(bdata2)) == "0" + shortScore(getProduceBlockResponseV3Score(bdata3)) == "0" + shortScore(getProduceBlockResponseV3Score(bdata4)) == "0" + test "getSyncCommitteeContributionDataScore() test vectors": for vector in ContributionDataVectors: let @@ -773,11 +802,24 @@ suite "Validator Client test suite": check: score == vector[5] + test "getProduceBlockResponseV3Score() test vectors": + for vector in UInt256ScoreVectors: + let + value1 = strictParse(vector[0], UInt256, 16).get() + value2 = strictParse(vector[1], UInt256, 16).get() + bdata = ProduceBlockResponseV3( + executionValue: Opt.some(value1), + consensusValue: Opt.some(value2) + ) + check shortScore(getProduceBlockResponseV3Score(bdata)) == vector[2] + test "getUniqueVotes() test vectors": for vector in AttestationBitsVectors: let - a1 = phase0.Attestation.init(vector[0][0][0], vector[0][0][1], vector[0][0][2]) - a2 = phase0.Attestation.init(vector[0][1][0], vector[0][1][1], vector[0][1][2]) + a1 = phase0.Attestation.init(vector[0][0][0], vector[0][0][1], + vector[0][0][2]) + a2 = phase0.Attestation.init(vector[0][1][0], vector[0][1][1], + vector[0][1][2]) check getUniqueVotes([a1, a2]) == vector[1] asyncTest "firstSuccessParallel() API timeout test": @@ -850,6 +892,7 @@ suite "Validator Client test suite": let response = vc.bestSuccess( RestPlainResponse, uint64, + float64, 100.milliseconds, AllBeaconNodeStatuses, {BeaconNodeRole.Duties}, From dc3eddde72e0eab0227d980d258820ebd95d37fd Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 29 May 2024 12:08:51 +0200 Subject: [PATCH 11/33] bump `nim-secp256k1` to `194b715b16766e383b5aef92dd779fb182faf45d` (#6316) - bump `secp256k1` to `v0.5.0` --- vendor/nim-secp256k1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-secp256k1 b/vendor/nim-secp256k1 index 2bc945cc9..194b715b1 160000 --- a/vendor/nim-secp256k1 +++ b/vendor/nim-secp256k1 @@ -1 +1 @@ -Subproject commit 2bc945cc9ebfae1b688f72ea59f78fd23873d1d4 +Subproject commit 194b715b16766e383b5aef92dd779fb182faf45d From a8108946359ad67187f295952ffcf97bd0bf84f3 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 29 May 2024 12:11:50 +0200 Subject: [PATCH 12/33] bump `nim-libp2p` to `2fa2c4425f4bb835c0517efc03009925dcd28239` (#6314) - fix(CI): rename branch from unstable to master in bumper workflow - fix(transport): various tcp transport races - chore(gossipsub): cleanups - fix(yamux): set EoF when remote peer half closes the stream in yamux --- vendor/nim-libp2p | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p index 21cbe3a91..2fa2c4425 160000 --- a/vendor/nim-libp2p +++ b/vendor/nim-libp2p @@ -1 +1 @@ -Subproject commit 21cbe3a91a70811522554e89e6a791172cebfef2 +Subproject commit 2fa2c4425f4bb835c0517efc03009925dcd28239 From 90cf1753bd472f8a65c691d2ef698204841437a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 29 May 2024 15:45:44 +0200 Subject: [PATCH 13/33] use self-hosted runners for Developer builds GH action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise we get: ``` Error: The operation was canceled. ``` Which is most probably due to OOM error. Signed-off-by: Jakub Sokołowski --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f8a85ef7..1bd584a67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -213,7 +213,7 @@ jobs: devbuild: name: "Developer builds" - runs-on: ubuntu-latest + runs-on: ['self-hosted','ubuntu-22.04'] steps: - name: Checkout uses: actions/checkout@v4 From d033ae0a347f7d45b2fd6a56dbf19e699592cda6 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 29 May 2024 18:38:23 +0200 Subject: [PATCH 14/33] hashtree: bump (#6292) Fixes compilation on osx/arm64 --- vendor/nim-ssz-serialization | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-ssz-serialization b/vendor/nim-ssz-serialization index 248f2bdca..f8b6e036a 160000 --- a/vendor/nim-ssz-serialization +++ b/vendor/nim-ssz-serialization @@ -1 +1 @@ -Subproject commit 248f2bdca2d65ff920920c72b764d0622d522596 +Subproject commit f8b6e036a00b227c8c0f7cae1394718b5c556f03 From ab892c1a042b83d9c9729c0507d69974797d7cb1 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Thu, 30 May 2024 11:28:16 +0200 Subject: [PATCH 15/33] bump `mainnet` to `f6b7882618a5ad2c1d2731ae35e5d16a660d5bb7` (#6310) * bump `mainnet` to `f6b7882618a5ad2c1d2731ae35e5d16a660d5bb7` - Initial commit * fix soft links --- .gitmodules | 10 +++++----- Makefile | 2 +- beacon_chain/libnimbus_lc/test_files/config.yaml | 2 +- beacon_chain/libnimbus_lc/test_files/genesis.ssz | 2 +- beacon_chain/networking/eth2_discovery.nim | 2 +- beacon_chain/networking/network_metadata.nim | 8 ++++---- beacon_chain/networking/network_metadata_mainnet.S | 2 +- tests/test_deposit_snapshots.nim | 2 +- vendor/eth2-networks | 1 - vendor/mainnet | 1 + 10 files changed, 16 insertions(+), 16 deletions(-) delete mode 160000 vendor/eth2-networks create mode 160000 vendor/mainnet diff --git a/.gitmodules b/.gitmodules index a42ebf3cc..08326638a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,6 +5,11 @@ # * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +[submodule "vendor/mainnet"] + path = vendor/mainnet + url = https://github.com/eth-clients/mainnet.git + ignore = untracked + branch = main [submodule "vendor/nim-eth2-scenarios"] path = vendor/nim-eth2-scenarios url = https://github.com/status-im/nim-eth2-scenarios @@ -170,11 +175,6 @@ url = https://github.com/status-im/nim-presto.git ignore = untracked branch = master -[submodule "vendor/eth2-networks"] - path = vendor/eth2-networks - url = https://github.com/eth-clients/eth2-networks.git - ignore = untracked - branch = master [submodule "vendor/nim-taskpools"] path = vendor/nim-taskpools url = https://github.com/status-im/nim-taskpools diff --git a/Makefile b/Makefile index 6607d92cf..06a2d6974 100644 --- a/Makefile +++ b/Makefile @@ -593,7 +593,7 @@ define MAKE_DEPOSIT build/deposit_contract sendDeposits \ $(2) \ - --deposit-contract=$$(cat vendor/eth2-networks/shared/$(1)/deposit_contract.txt) \ + --deposit-contract=$$(cat vendor/$(1)/metadata/deposit_contract.txt) \ --deposits-file=nbc-$(1)-deposits.json \ --min-delay=$(DEPOSITS_DELAY) \ --max-delay=$(DEPOSITS_DELAY) \ diff --git a/beacon_chain/libnimbus_lc/test_files/config.yaml b/beacon_chain/libnimbus_lc/test_files/config.yaml index cef4fd337..15d89fdc5 120000 --- a/beacon_chain/libnimbus_lc/test_files/config.yaml +++ b/beacon_chain/libnimbus_lc/test_files/config.yaml @@ -1 +1 @@ -../../../vendor/eth2-networks/shared/mainnet/config.yaml \ No newline at end of file +../../../vendor/mainnet/metadata/config.yaml \ No newline at end of file diff --git a/beacon_chain/libnimbus_lc/test_files/genesis.ssz b/beacon_chain/libnimbus_lc/test_files/genesis.ssz index 20f89e4e6..00c0fa1a6 120000 --- a/beacon_chain/libnimbus_lc/test_files/genesis.ssz +++ b/beacon_chain/libnimbus_lc/test_files/genesis.ssz @@ -1 +1 @@ -../../../vendor/eth2-networks/shared/mainnet/genesis.ssz \ No newline at end of file +../../../vendor/mainnet/metadata/genesis.ssz \ No newline at end of file diff --git a/beacon_chain/networking/eth2_discovery.nim b/beacon_chain/networking/eth2_discovery.nim index a8887aaf0..55ac6a28e 100644 --- a/beacon_chain/networking/eth2_discovery.nim +++ b/beacon_chain/networking/eth2_discovery.nim @@ -53,7 +53,7 @@ proc addBootstrapNode*(bootstrapAddr: string, return # Ignore comments in - # https://github.com/eth-clients/eth2-networks/blob/063f826a03676c33c95a66306916f18b690d35eb/shared/mainnet/bootstrap_nodes.txt + # https://github.com/eth-clients/mainnet/blob/main/metadata/bootstrap_nodes.txt let enrRes = parseBootstrapAddress(bootstrapAddr.split(" # ")[0]) if enrRes.isOk: bootstrapEnrs.add enrRes.value diff --git a/beacon_chain/networking/network_metadata.nim b/beacon_chain/networking/network_metadata.nim index 7c2160db0..7d7d8c954 100644 --- a/beacon_chain/networking/network_metadata.nim +++ b/beacon_chain/networking/network_metadata.nim @@ -117,8 +117,8 @@ proc loadEth2NetworkMetadata*( downloadGenesisFrom = none(DownloadInfo), useBakedInGenesis = none(string) ): Result[Eth2NetworkMetadata, string] {.raises: [IOError, PresetFileError].} = - # Load data in eth2-networks format - # https://github.com/eth-clients/eth2-networks + # Load data in mainnet format + # https://github.com/eth-clients/mainnet try: let @@ -292,14 +292,14 @@ elif const_preset == "mainnet": else: const mainnetGenesis* = slurp( - vendorDir & "/eth2-networks/shared/mainnet/genesis.ssz") + vendorDir & "/mainnet/metadata/genesis.ssz") sepoliaGenesis* = slurp( vendorDir & "/sepolia/bepolia/genesis.ssz") const mainnetMetadata = loadCompileTimeNetworkMetadata( - vendorDir & "/eth2-networks/shared/mainnet", + vendorDir & "/mainnet/metadata", some mainnet, useBakedInGenesis = some "mainnet") diff --git a/beacon_chain/networking/network_metadata_mainnet.S b/beacon_chain/networking/network_metadata_mainnet.S index 85e0f6153..aafa1dd8c 100644 --- a/beacon_chain/networking/network_metadata_mainnet.S +++ b/beacon_chain/networking/network_metadata_mainnet.S @@ -28,7 +28,7 @@ # name_size = 64-bit length in bytes eth2_mainnet_genesis_data: - .incbin "eth2-networks/shared/mainnet/genesis.ssz" + .incbin "mainnet/metadata/genesis.ssz" eth2_mainnet_genesis_end: .global cdecl(eth2_mainnet_genesis_size) .p2align 3 diff --git a/tests/test_deposit_snapshots.nim b/tests/test_deposit_snapshots.nim index c131c91e5..259727e36 100644 --- a/tests/test_deposit_snapshots.nim +++ b/tests/test_deposit_snapshots.nim @@ -39,7 +39,7 @@ proc ifNecessaryMigrateDCS(db: BeaconChainDB, db.putDepositContractSnapshot upgradeProc(oldSnapshot.get) # Hexlified copy of -# eth2-networks/shared/mainnet/genesis_deposit_contract_snapshot.ssz +# mainnet/metadata/genesis_deposit_contract_snapshot.ssz let ds1: seq[byte] = hexToSeqByte( """ eeea1373d4aa9e099d7c9deddb694db9aeb4577755ef83f9b6345ce4357d9abfca3bfce2c diff --git a/vendor/eth2-networks b/vendor/eth2-networks deleted file mode 160000 index ab581251b..000000000 --- a/vendor/eth2-networks +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ab581251bcda11e3cc120cc9e9ad1ad679340949 diff --git a/vendor/mainnet b/vendor/mainnet new file mode 160000 index 000000000..f6b788261 --- /dev/null +++ b/vendor/mainnet @@ -0,0 +1 @@ +Subproject commit f6b7882618a5ad2c1d2731ae35e5d16a660d5bb7 From 9afe538f3838859b7553cf075b13c26fdecf19af Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 5 Jun 2024 14:03:49 +0200 Subject: [PATCH 16/33] bump 'geth' to `v1.14.4` (#6326) - https://github.com/ethereum/go-ethereum/releases/tag/v1.14.4 --- scripts/geth_binaries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/geth_binaries.sh b/scripts/geth_binaries.sh index 52b25ff2c..6e3671d04 100644 --- a/scripts/geth_binaries.sh +++ b/scripts/geth_binaries.sh @@ -21,7 +21,7 @@ source "${SCRIPTS_DIR}/bash_utils.sh" download_geth_stable() { if [[ ! -e "${STABLE_GETH_BINARY}" ]]; then - GETH_VERSION="1.14.3-ab48ba42" # https://geth.ethereum.org/downloads + GETH_VERSION="1.14.4-5550d839" # https://geth.ethereum.org/downloads GETH_URL="https://gethstore.blob.core.windows.net/builds/" case "${OS}-${ARCH}" in From f97703e6ae64ec915504c96abc058c017d36fa94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 23:38:04 +0000 Subject: [PATCH 17/33] Bump tornado from 6.3.3 to 6.4.1 in /ncli (#6328) Bumps [tornado](https://github.com/tornadoweb/tornado) from 6.3.3 to 6.4.1. - [Changelog](https://github.com/tornadoweb/tornado/blob/master/docs/releases.rst) - [Commits](https://github.com/tornadoweb/tornado/compare/v6.3.3...v6.4.1) --- updated-dependencies: - dependency-name: tornado dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ncli/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ncli/requirements.txt b/ncli/requirements.txt index df3ee743c..9e488cb90 100644 --- a/ncli/requirements.txt +++ b/ncli/requirements.txt @@ -79,7 +79,7 @@ stack-data==0.1.4 terminado==0.12.1 testpath==0.5.0 tomli==1.2.3 -tornado==6.3.3 +tornado==6.4.1 traitlets==5.1.1 typing_extensions==4.0.1 wcwidth==0.2.5 From e7e69daf955267ef877f1070dd5a5c18893c9bcb Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 7 Jun 2024 02:37:04 +0200 Subject: [PATCH 18/33] bump 'geth' to `v1.14.5` (#6327) - https://github.com/ethereum/go-ethereum/releases/tag/v1.14.5 --- scripts/geth_binaries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/geth_binaries.sh b/scripts/geth_binaries.sh index 6e3671d04..abd112538 100644 --- a/scripts/geth_binaries.sh +++ b/scripts/geth_binaries.sh @@ -21,7 +21,7 @@ source "${SCRIPTS_DIR}/bash_utils.sh" download_geth_stable() { if [[ ! -e "${STABLE_GETH_BINARY}" ]]; then - GETH_VERSION="1.14.4-5550d839" # https://geth.ethereum.org/downloads + GETH_VERSION="1.14.5-0dd173a7" # https://geth.ethereum.org/downloads GETH_URL="https://gethstore.blob.core.windows.net/builds/" case "${OS}-${ARCH}" in From 0512d027666ae42d6a1adf5ddc3c2773d51e8725 Mon Sep 17 00:00:00 2001 From: Eugene Kabanov Date: Fri, 7 Jun 2024 18:04:29 +0300 Subject: [PATCH 19/33] VC enable block monitoring by default. (#6331) --- beacon_chain/conf.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index c79631c08..454878b3d 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -1047,7 +1047,7 @@ type monitoringType* {. desc: "Enable block monitoring which are seen by beacon node (BETA)" - defaultValue: BlockMonitoringType.Disabled + defaultValue: BlockMonitoringType.Event name: "block-monitor-type".}: BlockMonitoringType SigningNodeConf* = object From e3d4ad5d39a9ff9488139affe1e144eeebe2b2e9 Mon Sep 17 00:00:00 2001 From: tersec Date: Sun, 9 Jun 2024 17:37:41 +0000 Subject: [PATCH 20/33] properly (re)factor consolidation signature checking (#6334) --- beacon_chain/el/el_manager.nim | 1 - beacon_chain/spec/signatures.nim | 20 ++++++++++++++++++++ beacon_chain/spec/state_transition_block.nim | 20 +++++--------------- tests/testblockutil.nim | 2 -- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/beacon_chain/el/el_manager.nim b/beacon_chain/el/el_manager.nim index 5081772f4..e204f68db 100644 --- a/beacon_chain/el/el_manager.nim +++ b/beacon_chain/el/el_manager.nim @@ -1956,7 +1956,6 @@ proc startExchangeTransitionConfigurationLoop( while true: # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/paris.md#specification-3 - debug "Exchange transition configuration tick" await m.exchangeTransitionConfiguration() await sleepAsync(60.seconds) diff --git a/beacon_chain/spec/signatures.nim b/beacon_chain/spec/signatures.nim index 12f2a0c72..1fcb6ca9f 100644 --- a/beacon_chain/spec/signatures.nim +++ b/beacon_chain/spec/signatures.nim @@ -421,3 +421,23 @@ proc verify_bls_to_execution_change_signature*( let signing_root = compute_bls_to_execution_change_signing_root( genesisFork, genesis_validators_root, msg.message) blsVerify(pubkey, signing_root.data, signature) + +func compute_consolidation_signing_root( + genesisFork: Fork, genesis_validators_root: Eth2Digest, + msg: Consolidation): Eth2Digest = + # Uses genesis fork version regardless + doAssert genesisFork.current_version == genesisFork.previous_version + + let domain = compute_domain( + DOMAIN_CONSOLIDATION, genesisFork.current_version, + genesis_validators_root=genesis_validators_root) + compute_signing_root(msg, domain) + +proc verify_consolidation_signature*( + genesisFork: Fork, genesis_validators_root: Eth2Digest, + msg: SignedConsolidation | TrustedSignedConsolidation, + pubkeys: openArray[ValidatorPubKey]): bool = + withTrust(msg.signature): + let signing_root = compute_consolidation_signing_root( + genesisFork, genesis_validators_root, msg.message) + blsFastAggregateVerify(pubkeys, signing_root.data, msg.signature) diff --git a/beacon_chain/spec/state_transition_block.nim b/beacon_chain/spec/state_transition_block.nim index 8025331c5..91947856f 100644 --- a/beacon_chain/spec/state_transition_block.nim +++ b/beacon_chain/spec/state_transition_block.nim @@ -644,20 +644,11 @@ proc process_consolidation*( target_validator.withdrawal_credentials.data.toOpenArray(12, 31)): return err("Consolidation: source and target don't have same withdrawal address") - debugComment "this is per spec, near-verbatim, but Nimbus generally factors this out into spec/signatures.nim. so, create verify_consolidation_signature infra there, call here" # Verify consolidation is signed by the source and the target - let - domain = compute_domain( - DOMAIN_CONSOLIDATION, cfg.GENESIS_FORK_VERSION, - genesis_validators_root=state.genesis_validators_root) - signing_root = compute_signing_root(consolidation, domain) - pubkeys = [source_validator[].pubkey, target_validator.pubkey] - - debugComment "as a good example, this trustedsig hack typically/should live in spec/signatures.nim" - when not (signed_consolidation.signature is TrustedSig): - if not blsFastAggregateVerify( - pubkeys, signing_root.data, signed_consolidation.signature): - return err("Consolidation: invalid signature") + if not verify_consolidation_signature( + cfg.genesisFork, state.genesis_validators_root, signed_consolidation, + [source_validator[].pubkey, target_validator.pubkey]): + return err("Consolidation: invalid signature") # Initiate source validator exit and append pending consolidation source_validator[].exit_epoch = compute_consolidation_epoch_and_update_churn( @@ -667,8 +658,7 @@ proc process_consolidation*( debugComment "check HashList add return value" discard state.pending_consolidations.add(PendingConsolidation( source_index: consolidation.source_index, - target_index: consolidation.target_index - )) + target_index: consolidation.target_index)) ok() diff --git a/tests/testblockutil.nim b/tests/testblockutil.nim index 894faee58..c69a7c4b7 100644 --- a/tests/testblockutil.nim +++ b/tests/testblockutil.nim @@ -208,8 +208,6 @@ proc addTestBlock*( else: default(bellatrix.ExecutionPayloadForSigning) - debugComment "addTestBlock Electra attestation support" - makeBeaconBlock( cfg, state, From 598485ee1a11f645ea71166891e7482cc4b010d8 Mon Sep 17 00:00:00 2001 From: tersec Date: Mon, 10 Jun 2024 03:05:51 +0000 Subject: [PATCH 21/33] add consolidations block body packing plumbing and correct electra MEV block body htr override (#6335) --- beacon_chain/spec/datatypes/electra.nim | 2 +- beacon_chain/spec/state_transition.nim | 60 +++++++++---------- beacon_chain/validators/beacon_validators.nim | 2 + research/block_sim.nim | 4 +- research/wss_sim.nim | 1 + tests/testblockutil.nim | 3 + 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/beacon_chain/spec/datatypes/electra.nim b/beacon_chain/spec/datatypes/electra.nim index 95a247829..c16a0257e 100644 --- a/beacon_chain/spec/datatypes/electra.nim +++ b/beacon_chain/spec/datatypes/electra.nim @@ -7,7 +7,7 @@ {.push raises: [].} -# Types specific to Deneb (i.e. known to have changed across hard forks) - see +# Types specific to Electra (i.e. known to have changed across hard forks) - see # `base` for types and guidelines common across forks # TODO Careful, not nil analysis is broken / incomplete and the semantics will diff --git a/beacon_chain/spec/state_transition.nim b/beacon_chain/spec/state_transition.nim index 15bb9ad76..dc936631c 100644 --- a/beacon_chain/spec/state_transition.nim +++ b/beacon_chain/spec/state_transition.nim @@ -361,7 +361,8 @@ func partialBeaconBlock*( deposits: seq[Deposit], validator_changes: BeaconBlockValidatorChanges, sync_aggregate: SyncAggregate, - execution_payload: ForkyExecutionPayloadForSigning + execution_payload: ForkyExecutionPayloadForSigning, + consolidations: openArray[SignedConsolidation] ): auto = const consensusFork = typeof(state).kind @@ -411,12 +412,14 @@ func partialBeaconBlock*( deposits: seq[Deposit], validator_changes: BeaconBlockValidatorChanges, sync_aggregate: SyncAggregate, - execution_payload: ForkyExecutionPayloadForSigning + execution_payload: ForkyExecutionPayloadForSigning, + consolidations: seq[SignedConsolidation], ): auto = const consensusFork = typeof(state).kind + debugComment "re-enable attester slashing packing in electra" # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#preparing-for-a-beaconblock - var res = consensusFork.BeaconBlock( + consensusFork.BeaconBlock( slot: state.data.slot, proposer_index: proposer_index.uint64, parent_root: state.latest_block_root, @@ -429,28 +432,14 @@ func partialBeaconBlock*( attestations: List[electra.Attestation, Limit MAX_ATTESTATIONS_ELECTRA](attestations), deposits: List[Deposit, Limit MAX_DEPOSITS](deposits), - voluntary_exits: validator_changes.voluntary_exits)) - - # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/validator.md#preparing-a-beaconblock - when consensusFork >= ConsensusFork.Altair: - res.body.sync_aggregate = sync_aggregate - - # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/bellatrix/validator.md#block-proposal - when consensusFork >= ConsensusFork.Bellatrix: - res.body.execution_payload = execution_payload.executionPayload - - # https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/validator.md#block-proposal - when consensusFork >= ConsensusFork.Capella: - res.body.bls_to_execution_changes = - validator_changes.bls_to_execution_changes - - # https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/validator.md#constructing-the-beaconblockbody - when consensusFork >= ConsensusFork.Deneb: - res.body.blob_kzg_commitments = execution_payload.blobsBundle.commitments - - debugComment "either consolidate this within separate function or recombine, re when consensusFork >= foo and atts/attslashings; here to allow noninterference with pre-pectra" - - res + voluntary_exits: validator_changes.voluntary_exits, + sync_aggregate: sync_aggregate, + execution_payload: execution_payload.executionPayload, + bls_to_execution_changes: validator_changes.bls_to_execution_changes, + blob_kzg_commitments: execution_payload.blobsBundle.commitments, + consolidations: + List[SignedConsolidation, Limit MAX_CONSOLIDATIONS].init( + consolidations))) proc makeBeaconBlockWithRewards*( cfg: RuntimeConfig, @@ -464,6 +453,7 @@ proc makeBeaconBlockWithRewards*( validator_changes: BeaconBlockValidatorChanges, sync_aggregate: SyncAggregate, executionPayload: ForkyExecutionPayloadForSigning, + consolidations: seq[SignedConsolidation], rollback: RollbackForkedHashedProc, cache: var StateCache, # TODO: @@ -490,7 +480,7 @@ proc makeBeaconBlockWithRewards*( partialBeaconBlock( cfg, state.`kind Data`, proposer_index, randao_reveal, eth1_data, graffiti, attestations, deposits, validator_changes, sync_aggregate, - executionPayload)) + executionPayload, consolidations)) let res = process_block( cfg, state.`kind Data`.data, blck.`kind Data`.asSigVerified(), @@ -533,9 +523,8 @@ proc makeBeaconBlockWithRewards*( forkyState.data.latest_execution_payload_header.transactions_root = transactions_root.get - debugComment "makeBeaconBlock doesn't support Electra (i.e. check for missing beaconblock body fields)" when executionPayload is electra.ExecutionPayloadForSigning: - # https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody + # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/electra/beacon-chain.md#beaconblockbody forkyState.data.latest_block_header.body_root = hash_tree_root( [hash_tree_root(randao_reveal), hash_tree_root(eth1_data), @@ -550,7 +539,9 @@ proc makeBeaconBlockWithRewards*( hash_tree_root(sync_aggregate), execution_payload_root.get, hash_tree_root(validator_changes.bls_to_execution_changes), - hash_tree_root(kzg_commitments.get) + hash_tree_root(kzg_commitments.get), + hash_tree_root(List[SignedConsolidation, Limit MAX_CONSOLIDATIONS].init( + consolidations)) ]) else: raiseAssert "Attempt to use non-Electra payload with post-Deneb state" @@ -593,6 +584,7 @@ proc makeBeaconBlock*( validator_changes: BeaconBlockValidatorChanges, sync_aggregate: SyncAggregate, executionPayload: ForkyExecutionPayloadForSigning, + consolidations: seq[SignedConsolidation], rollback: RollbackForkedHashedProc, cache: var StateCache, verificationFlags: UpdateFlags, transactions_root: Opt[Eth2Digest], @@ -603,8 +595,8 @@ proc makeBeaconBlock*( ? makeBeaconBlockWithRewards( cfg, state, proposer_index, randao_reveal, eth1_data, graffiti, attestations, deposits, validator_changes, sync_aggregate, - executionPayload, rollback, cache, verificationFlags, transactions_root, - execution_payload_root, kzg_commitments) + executionPayload, consolidations, rollback, cache, verificationFlags, + transactions_root, execution_payload_root, kzg_commitments) ok(blockAndRewards.blck) proc makeBeaconBlock*( @@ -616,12 +608,13 @@ proc makeBeaconBlock*( validator_changes: BeaconBlockValidatorChanges, sync_aggregate: SyncAggregate, executionPayload: ForkyExecutionPayloadForSigning, + consolidations: seq[SignedConsolidation], rollback: RollbackForkedHashedProc, cache: var StateCache): Result[ForkedBeaconBlock, cstring] = makeBeaconBlock( cfg, state, proposer_index, randao_reveal, eth1_data, graffiti, attestations, deposits, validator_changes, sync_aggregate, - executionPayload, rollback, cache, + executionPayload, consolidations, rollback, cache, verificationFlags = {}, transactions_root = Opt.none Eth2Digest, execution_payload_root = Opt.none Eth2Digest, kzg_commitments = Opt.none KzgCommitments) @@ -635,13 +628,14 @@ proc makeBeaconBlock*( validator_changes: BeaconBlockValidatorChanges, sync_aggregate: SyncAggregate, executionPayload: ForkyExecutionPayloadForSigning, + consolidations: seq[SignedConsolidation], rollback: RollbackForkedHashedProc, cache: var StateCache, verificationFlags: UpdateFlags): Result[ForkedBeaconBlock, cstring] = makeBeaconBlock( cfg, state, proposer_index, randao_reveal, eth1_data, graffiti, attestations, deposits, validator_changes, sync_aggregate, - executionPayload, rollback, cache, + executionPayload, consolidations, rollback, cache, verificationFlags = verificationFlags, transactions_root = Opt.none Eth2Digest, execution_payload_root = Opt.none Eth2Digest, diff --git a/beacon_chain/validators/beacon_validators.nim b/beacon_chain/validators/beacon_validators.nim index c4375f3ca..9dfb19f6d 100644 --- a/beacon_chain/validators/beacon_validators.nim +++ b/beacon_chain/validators/beacon_validators.nim @@ -537,6 +537,7 @@ proc makeBeaconBlockForHeadAndSlot*( slot, validator_index return err("Unable to get execution payload") + debugComment "flesh out consolidations" let res = makeBeaconBlockWithRewards( node.dag.cfg, state[], @@ -549,6 +550,7 @@ proc makeBeaconBlockForHeadAndSlot*( exits, node.syncCommitteeMsgPool[].produceSyncAggregate(head.bid, slot), payload, + @[], # consolidations noRollback, # Temporary state - no need for rollback cache, verificationFlags = {}, diff --git a/research/block_sim.nim b/research/block_sim.nim index b7443f8d5..11fc531c7 100644 --- a/research/block_sim.nim +++ b/research/block_sim.nim @@ -85,7 +85,7 @@ proc makeSimulationBlock( var blck = partialBeaconBlock( cfg, state, proposer_index, randao_reveal, eth1_data, graffiti, - attestations, deposits, exits, sync_aggregate, execution_payload) + attestations, deposits, exits, sync_aggregate, execution_payload, @[]) let res = process_block( cfg, state.data, blck.asSigVerified(), verificationFlags, cache) @@ -128,7 +128,7 @@ proc makeSimulationBlock( var blck = partialBeaconBlock( cfg, state, proposer_index, randao_reveal, eth1_data, graffiti, - attestations, deposits, exits, sync_aggregate, execution_payload) + attestations, deposits, exits, sync_aggregate, execution_payload, @[]) let res = process_block( cfg, state.data, blck.asSigVerified(), verificationFlags, cache) diff --git a/research/wss_sim.nim b/research/wss_sim.nim index d0a390c4b..735eb6cf6 100644 --- a/research/wss_sim.nim +++ b/research/wss_sim.nim @@ -295,6 +295,7 @@ cli do(validatorsDir: string, secretsDir: string, BeaconBlockValidatorChanges(), syncAggregate, payload, + @[], # consolidations noRollback, cache).get() diff --git a/tests/testblockutil.nim b/tests/testblockutil.nim index c69a7c4b7..7820fb557 100644 --- a/tests/testblockutil.nim +++ b/tests/testblockutil.nim @@ -172,6 +172,8 @@ proc addTestBlock*( cfg, state, getStateField(state, slot) + 1, cache, info, flags).expect( "can advance 1") + debugComment "add consolidations support to addTestBlock" + let proposer_index = get_beacon_proposer_index( state, cache, getStateField(state, slot)).expect("valid proposer index") @@ -227,6 +229,7 @@ proc addTestBlock*( BeaconBlockValidatorChanges(), sync_aggregate, execution_payload, + @[], noRollback, cache, verificationFlags = {skipBlsValidation}) From de01ad4f9bdbe75fce36f4a78ac96e5fd54c12cb Mon Sep 17 00:00:00 2001 From: tersec Date: Mon, 10 Jun 2024 04:46:17 +0000 Subject: [PATCH 22/33] bump nim-stew (#6336) --- vendor/nim-stew | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-stew b/vendor/nim-stew index 104132fd0..72aab089a 160000 --- a/vendor/nim-stew +++ b/vendor/nim-stew @@ -1 +1 @@ -Subproject commit 104132fd0217e846b04dd26a5fbe3e43a4929a05 +Subproject commit 72aab089a2aa3d3e213f4268962d345d5261b483 From cccd81a47b77b0fb0775be2009aa38515963c6c9 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Mon, 10 Jun 2024 18:45:40 +0200 Subject: [PATCH 23/33] =?UTF-8?q?add=20ANSI=20art=20placeholder=20for=20El?= =?UTF-8?q?ectra=20=F0=9F=A6=92=20(#6338)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trigger ANSI art on upgrade to Electra Art created by http://beatscribe.com (beatscribe#1008 on Discord) --- .../consensus_object_pools/blockchain_dag.nim | 5 +++- .../vanity_logs/electra/color.ans | 28 +++++++++++++++++++ .../vanity_logs/electra/mono.txt | 28 +++++++++++++++++++ .../vanity_logs/vanity_logs.nim | 7 +++++ beacon_chain/nimbus_beacon_node.nim | 12 +++++--- 5 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 beacon_chain/consensus_object_pools/vanity_logs/electra/color.ans create mode 100644 beacon_chain/consensus_object_pools/vanity_logs/electra/mono.txt diff --git a/beacon_chain/consensus_object_pools/blockchain_dag.nim b/beacon_chain/consensus_object_pools/blockchain_dag.nim index 9445828be..69fcb661a 100644 --- a/beacon_chain/consensus_object_pools/blockchain_dag.nim +++ b/beacon_chain/consensus_object_pools/blockchain_dag.nim @@ -2408,7 +2408,7 @@ proc updateHead*( if dag.headState.kind > lastHeadKind: case dag.headState.kind - of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix, ConsensusFork.Electra: + of ConsensusFork.Phase0 .. ConsensusFork.Bellatrix: discard of ConsensusFork.Capella: if dag.vanityLogs.onUpgradeToCapella != nil: @@ -2416,6 +2416,9 @@ proc updateHead*( of ConsensusFork.Deneb: if dag.vanityLogs.onUpgradeToDeneb != nil: dag.vanityLogs.onUpgradeToDeneb() + of ConsensusFork.Electra: + if dag.vanityLogs.onUpgradeToElectra != nil: + dag.vanityLogs.onUpgradeToElectra() if dag.vanityLogs.onKnownBlsToExecutionChange != nil and checkBlsToExecutionChanges( diff --git a/beacon_chain/consensus_object_pools/vanity_logs/electra/color.ans b/beacon_chain/consensus_object_pools/vanity_logs/electra/color.ans new file mode 100644 index 000000000..aea0a7ad9 --- /dev/null +++ b/beacon_chain/consensus_object_pools/vanity_logs/electra/color.ans @@ -0,0 +1,28 @@ + +..-|\_/| +  text .-'..d :.: $ +(_: __. :::::$ +`-' ? :::: $ +\ :::: $ +\::::::$ +area\ :::::$ +|:.::: $ + `| :::: $..__ +`.::::::.::.`-. +|:::::::::::::`--. +here `.::::.:::::::::::`---..... +  `.:::::::::::::::::::::::`\ + |:::::::::::::::::::::::::| + |:::::::::::::::::::::::|:| +  |::::::::::::|::::::::::|:| +':::)___..----\ :::::| .`. \ +|:::| | :|`.::::|: : `.`. +() () O  O |:::| |. ||:::| `.: |:| +\ / \ /   |:::| | :|`.:::`. .:`.`. +() ()()  ()  () O () |:::| |: |::::| |::|`.`. +\  / \ // / / |:::| | :||:::| | :| ))) + () ()  O() O ()  () O  () |:::||.:.| () ()::| |:..;((( () +. \. /. \. // O. /. . \. /. \ /. . \ .'::.'|::'|. /. . /.|::|. ` :.\ `/ . +....()O...O()...\()()....()O...O.()....()|:::| |_M()()....()..:::|.()|: :()..() +\../...\./...\../....\../...\./....\../..|:::|\../....\../...|:::<...\_M/|..... + ():::::O:::::()::::::():::::O::::::():::|_N_|:()::::::()::::|_N_|::::()::::::: diff --git a/beacon_chain/consensus_object_pools/vanity_logs/electra/mono.txt b/beacon_chain/consensus_object_pools/vanity_logs/electra/mono.txt new file mode 100644 index 000000000..bfe25591e --- /dev/null +++ b/beacon_chain/consensus_object_pools/vanity_logs/electra/mono.txt @@ -0,0 +1,28 @@ + + ..-|\_/| + text .-'..d :.: $ + (_: __. :::::$ + `-' ? :::: $ + \ :::: $ + \::::::$ + area \ :::::$ + |:.::: $ + `| :::: $..__ + `.::::::.::.`-. + |:::::::::::::`--. + here `.::::.:::::::::::`---..... + `.:::::::::::::::::::::::`\ + |:::::::::::::::::::::::::| + |:::::::::::::::::::::::|:| + |::::::::::::|::::::::::|:| + ':::)___..----\ :::::| .`. \ + |:::| | :| `.::::|: : `.`. + () () O O |:::| |. | |:::| `.: |:| + \ / \ / |:::| | :| `.:::`. .:`.`. + () ()() () () O () |:::| |: | ::::| |::|`.`. + \ / \ / / / / |:::| | :| |:::| | :| ))) + () () O() O () () O () |:::||.:.| () ()::| |:..;((( () +. \. /. \. // O. /. . \. /. \ /. . \ .'::.'|::'|. /. . /.|::|. ` :.\ `/ . +....()O...O()...\()()....()O...O.()....()|:::| |_M()()....()..:::|.()|: :()..() +\../...\./...\../....\../...\./....\../..|:::|\../....\../...|:::<...\_M/|..... + ():::::O:::::()::::::():::::O::::::():::|_N_|:()::::::()::::|_N_|::::()::::::: diff --git a/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim b/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim index 111035bed..23f32f0fe 100644 --- a/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim +++ b/beacon_chain/consensus_object_pools/vanity_logs/vanity_logs.nim @@ -34,6 +34,10 @@ type # in case of chain reorgs around the upgrade. onUpgradeToDeneb*: LogProc + # Gets displayed on upgrade to Electra. May be displayed multiple times + # in case of chain reorgs around the upgrade. + onUpgradeToElectra*: LogProc + # Created by http://beatscribe.com/ (beatscribe#1008 on Discord) # These need to be the main body of the log not to be reformatted or escaped. @@ -47,3 +51,6 @@ proc capellaBlink*() = notice "\n" & staticRead("capella" / "blink.ans") proc denebMono*() = notice "\n" & staticRead("deneb" / "mono.txt") proc denebColor*() = notice "\n" & staticRead("deneb" / "color.ans") + +proc electraMono*() = notice "\n" & staticRead("electra" / "mono.txt") +proc electraColor*() = notice "\n" & staticRead("electra" / "color.ans") diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 6a7385105..185ff1b71 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -147,14 +147,16 @@ func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs = onFinalizedMergeTransitionBlock: bellatrixBlink, onUpgradeToCapella: capellaColor, onKnownBlsToExecutionChange: capellaBlink, - onUpgradeToDeneb: denebColor) + onUpgradeToDeneb: denebColor, + onUpgradeToElectra: electraColor) of StdoutLogKind.NoColors: VanityLogs( onMergeTransitionBlock: bellatrixMono, onFinalizedMergeTransitionBlock: bellatrixMono, onUpgradeToCapella: capellaMono, onKnownBlsToExecutionChange: capellaMono, - onUpgradeToDeneb: denebMono) + onUpgradeToDeneb: denebMono, + onUpgradeToElectra: electraMono) of StdoutLogKind.Json, StdoutLogKind.None: VanityLogs( onMergeTransitionBlock: @@ -166,12 +168,14 @@ func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs = onKnownBlsToExecutionChange: (proc() = notice "🦉 BLS to execution changed 🦉"), onUpgradeToDeneb: - (proc() = notice "🐟 Proto-Danksharding is ON 🐟")) + (proc() = notice "🐟 Proto-Danksharding is ON 🐟"), + onUpgradeToElectra: + (proc() = notice "🦒 [PH] Electra 🦒")) func getVanityMascot(consensusFork: ConsensusFork): string = case consensusFork of ConsensusFork.Electra: - " " + "🦒" of ConsensusFork.Deneb: "🐟" of ConsensusFork.Capella: From 45d50f041a5be9787b73cf01ecda1aabb4bf4a5c Mon Sep 17 00:00:00 2001 From: tersec Date: Mon, 10 Jun 2024 19:13:15 +0000 Subject: [PATCH 24/33] bump nim-bearssl for gcc-14 compatibility (#6337) * bump nim-bearssl for gcc-14 compatibility * Bump chronos. * Fix flaky test. --------- Co-authored-by: cheatfate --- tests/test_sync_manager.nim | 2 +- vendor/nim-bearssl | 2 +- vendor/nim-chronos | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_sync_manager.nim b/tests/test_sync_manager.nim index 65fa75cd0..5d7fa83cf 100644 --- a/tests/test_sync_manager.nim +++ b/tests/test_sync_manager.nim @@ -884,7 +884,7 @@ suite "SyncManager test suite": # Push a single request that will fail with all blocks being unviable var f11 = queue.push(r11, chain.getSlice(startSlot, r11), Opt.none(seq[BlobSidecars])) - discard await f11.withTimeout(100.milliseconds) + discard await f11.withTimeout(1.seconds) check: f11.finished == true diff --git a/vendor/nim-bearssl b/vendor/nim-bearssl index d81b37dc2..a806cbfab 160000 --- a/vendor/nim-bearssl +++ b/vendor/nim-bearssl @@ -1 +1 @@ -Subproject commit d81b37dc2011bf3a2bd93500489877c2ce8e6ac3 +Subproject commit a806cbfab5fe8de49c76139f8705fff79daf99ee diff --git a/vendor/nim-chronos b/vendor/nim-chronos index 8a306763c..1b9d9253e 160000 --- a/vendor/nim-chronos +++ b/vendor/nim-chronos @@ -1 +1 @@ -Subproject commit 8a306763cec8105fa83574b56734b0f66823f844 +Subproject commit 1b9d9253e89445d585d0fff39cc0d19254fdfd0d From 18a441d8bab973bfa7737348b0c9d9308543d767 Mon Sep 17 00:00:00 2001 From: Eugene Kabanov Date: Mon, 10 Jun 2024 23:29:50 +0300 Subject: [PATCH 25/33] Bump nim-nat-traversal. (#6339) --- vendor/nim-nat-traversal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-nat-traversal b/vendor/nim-nat-traversal index 54bf8aa29..9c7dc8c58 160000 --- a/vendor/nim-nat-traversal +++ b/vendor/nim-nat-traversal @@ -1 +1 @@ -Subproject commit 54bf8aa2913e8550463779beeae4b469941e039c +Subproject commit 9c7dc8c58ff9c3dfb11c2d333171b47659ed824c From fbf40542bef91bfa2f61aa6fadab0db5dee855f5 Mon Sep 17 00:00:00 2001 From: Eugene Kabanov Date: Mon, 10 Jun 2024 23:35:01 +0300 Subject: [PATCH 26/33] Bump nim-blscurve. (#6340) --- vendor/nim-blscurve | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-blscurve b/vendor/nim-blscurve index d091a579a..f29698d2e 160000 --- a/vendor/nim-blscurve +++ b/vendor/nim-blscurve @@ -1 +1 @@ -Subproject commit d091a579a2e7c4668140e675a6fb2c78b8c6dc57 +Subproject commit f29698d2e9a59453d99db7315a5af58add3c8715 From d3bbd4157058fa93e7451ff325b46cc494bb37ba Mon Sep 17 00:00:00 2001 From: tersec Date: Mon, 10 Jun 2024 21:33:52 +0000 Subject: [PATCH 27/33] bump nim-stew (#6341) --- vendor/nim-stew | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-stew b/vendor/nim-stew index 72aab089a..a0a53c911 160000 --- a/vendor/nim-stew +++ b/vendor/nim-stew @@ -1 +1 @@ -Subproject commit 72aab089a2aa3d3e213f4268962d345d5261b483 +Subproject commit a0a53c911606cace989074f6b806eb0546a64ef6 From 77d926525fc6a310d2930cddc7af93d42781a6b5 Mon Sep 17 00:00:00 2001 From: tersec Date: Tue, 11 Jun 2024 02:34:56 +0000 Subject: [PATCH 28/33] stop using deprecated stew/results (#6343) * stop using deprecated stew/results * exception tracking linting --- beacon_chain/gossip_processing/block_processor.nim | 1 - beacon_chain/gossip_processing/eth2_processor.nim | 4 ++-- beacon_chain/networking/eth2_discovery.nim | 2 +- beacon_chain/rpc/rest_beacon_api.nim | 2 +- beacon_chain/rpc/rest_event_api.nim | 1 - beacon_chain/rpc/rest_nimbus_api.nim | 4 +++- beacon_chain/rpc/rest_node_api.nim | 4 +++- beacon_chain/rpc/rest_validator_api.nim | 2 +- beacon_chain/sync/sync_manager.nim | 2 +- beacon_chain/sync/sync_queue.nim | 2 +- beacon_chain/trusted_node_sync.nim | 2 +- beacon_chain/validators/message_router.nim | 1 - tests/consensus_spec/altair/test_fixture_operations.nim | 1 - tests/consensus_spec/bellatrix/test_fixture_operations.nim | 1 - tests/consensus_spec/capella/test_fixture_operations.nim | 1 - tests/consensus_spec/deneb/test_fixture_operations.nim | 1 - tests/consensus_spec/electra/test_fixture_operations.nim | 1 - tests/consensus_spec/phase0/test_fixture_operations.nim | 1 - tests/consensus_spec/test_fixture_fork_choice.nim | 2 +- tests/consensus_spec/test_fixture_kzg.nim | 2 +- tests/slashing_protection/test_fixtures.nim | 1 - tests/slashing_protection/test_slashing_protection_db.nim | 4 ++-- tests/test_deposit_snapshots.nim | 3 ++- tests/test_serialization.nim | 2 +- 24 files changed, 21 insertions(+), 26 deletions(-) diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim index 082031211..1eb1b86b4 100644 --- a/beacon_chain/gossip_processing/block_processor.nim +++ b/beacon_chain/gossip_processing/block_processor.nim @@ -8,7 +8,6 @@ {.push raises: [].} import - stew/results, chronicles, chronos, metrics, ../spec/[forks, signatures, signatures_batch], ../sszdump diff --git a/beacon_chain/gossip_processing/eth2_processor.nim b/beacon_chain/gossip_processing/eth2_processor.nim index f055096d1..0fc759a3d 100644 --- a/beacon_chain/gossip_processing/eth2_processor.nim +++ b/beacon_chain/gossip_processing/eth2_processor.nim @@ -9,8 +9,8 @@ import std/tables, - stew/results, - chronicles, chronos, metrics, taskpools, + chronicles, chronos, metrics, + taskpools, ../spec/[helpers, forks], ../spec/datatypes/[altair, phase0, deneb], ../consensus_object_pools/[ diff --git a/beacon_chain/networking/eth2_discovery.nim b/beacon_chain/networking/eth2_discovery.nim index 55ac6a28e..d68d70e7e 100644 --- a/beacon_chain/networking/eth2_discovery.nim +++ b/beacon_chain/networking/eth2_discovery.nim @@ -9,7 +9,7 @@ import std/[algorithm, sequtils], - chronos, chronicles, stew/results, + chronos, chronicles, eth/p2p/discoveryv5/[enr, protocol, node, random2], ../spec/datatypes/altair, ../spec/eth2_ssz_serialization, diff --git a/beacon_chain/rpc/rest_beacon_api.nim b/beacon_chain/rpc/rest_beacon_api.nim index 7918f47b0..a43a2db84 100644 --- a/beacon_chain/rpc/rest_beacon_api.nim +++ b/beacon_chain/rpc/rest_beacon_api.nim @@ -9,7 +9,7 @@ import std/[typetraits, sequtils, sets], - stew/[results, base10], + stew/base10, chronicles, metrics, ./rest_utils, ./state_ttl_cache, diff --git a/beacon_chain/rpc/rest_event_api.nim b/beacon_chain/rpc/rest_event_api.nim index 9fa70a320..e331b2c09 100644 --- a/beacon_chain/rpc/rest_event_api.nim +++ b/beacon_chain/rpc/rest_event_api.nim @@ -9,7 +9,6 @@ import std/sequtils, - stew/results, chronicles, chronos/apps/http/httpserver, ./rest_utils, diff --git a/beacon_chain/rpc/rest_nimbus_api.nim b/beacon_chain/rpc/rest_nimbus_api.nim index e5e74ba2b..027ae72a6 100644 --- a/beacon_chain/rpc/rest_nimbus_api.nim +++ b/beacon_chain/rpc/rest_nimbus_api.nim @@ -5,9 +5,11 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} + import std/[sequtils], - stew/[results, base10], + stew/base10, chronicles, chronos/apps/http/httpdebug, libp2p/[multiaddress, multicodec, peerstore], diff --git a/beacon_chain/rpc/rest_node_api.nim b/beacon_chain/rpc/rest_node_api.nim index 54167d4c0..303a39e59 100644 --- a/beacon_chain/rpc/rest_node_api.nim +++ b/beacon_chain/rpc/rest_node_api.nim @@ -4,8 +4,10 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} + import - stew/[byteutils, results], + stew/byteutils, chronicles, eth/p2p/discoveryv5/enr, libp2p/[multiaddress, multicodec, peerstore], diff --git a/beacon_chain/rpc/rest_validator_api.nim b/beacon_chain/rpc/rest_validator_api.nim index 1c6250915..81429df51 100644 --- a/beacon_chain/rpc/rest_validator_api.nim +++ b/beacon_chain/rpc/rest_validator_api.nim @@ -7,7 +7,7 @@ {.push raises: [].} import std/[typetraits, sets, sequtils] -import stew/[results, base10], chronicles +import stew/base10, chronicles import ".."/[beacon_chain_db, beacon_node], ".."/networking/eth2_network, ".."/consensus_object_pools/[blockchain_dag, spec_cache, diff --git a/beacon_chain/sync/sync_manager.nim b/beacon_chain/sync/sync_manager.nim index 933e6c312..0e6fa9f3d 100644 --- a/beacon_chain/sync/sync_manager.nim +++ b/beacon_chain/sync/sync_manager.nim @@ -8,7 +8,7 @@ {.push raises: [].} import std/[strutils, sequtils, algorithm] -import stew/[results, base10], chronos, chronicles +import stew/base10, chronos, chronicles import ../spec/datatypes/[phase0, altair], ../spec/eth2_apis/rest_types, diff --git a/beacon_chain/sync/sync_queue.nim b/beacon_chain/sync/sync_queue.nim index 66d7bbc1b..10f0a9fb2 100644 --- a/beacon_chain/sync/sync_queue.nim +++ b/beacon_chain/sync/sync_queue.nim @@ -8,7 +8,7 @@ {.push raises: [].} import std/[heapqueue, tables, strutils, sequtils, math] -import stew/[results, base10], chronos, chronicles +import stew/base10, chronos, chronicles import ../spec/datatypes/[base, phase0, altair], ../spec/[helpers, forks], diff --git a/beacon_chain/trusted_node_sync.nim b/beacon_chain/trusted_node_sync.nim index 6cf436f76..380fcfcaf 100644 --- a/beacon_chain/trusted_node_sync.nim +++ b/beacon_chain/trusted_node_sync.nim @@ -8,7 +8,7 @@ {.push raises: [].} import - stew/[base10, results], + stew/base10, chronicles, chronos, eth/async_utils, ./sync/[light_client_sync_helpers, sync_manager], ./consensus_object_pools/[block_clearance, blockchain_dag], diff --git a/beacon_chain/validators/message_router.nim b/beacon_chain/validators/message_router.nim index 625057f78..1e40c450e 100644 --- a/beacon_chain/validators/message_router.nim +++ b/beacon_chain/validators/message_router.nim @@ -8,7 +8,6 @@ {.push raises: [].} import - stew/results, std/sequtils, chronicles, metrics, diff --git a/tests/consensus_spec/altair/test_fixture_operations.nim b/tests/consensus_spec/altair/test_fixture_operations.nim index 7187e1eb0..251bb3f29 100644 --- a/tests/consensus_spec/altair/test_fixture_operations.nim +++ b/tests/consensus_spec/altair/test_fixture_operations.nim @@ -12,7 +12,6 @@ import # Utilities chronicles, unittest2, - stew/results, # Beacon chain internals ../../../beacon_chain/spec/[beaconstate, state_transition_block], ../../../beacon_chain/spec/datatypes/altair, diff --git a/tests/consensus_spec/bellatrix/test_fixture_operations.nim b/tests/consensus_spec/bellatrix/test_fixture_operations.nim index 16aecc9d8..b24576037 100644 --- a/tests/consensus_spec/bellatrix/test_fixture_operations.nim +++ b/tests/consensus_spec/bellatrix/test_fixture_operations.nim @@ -12,7 +12,6 @@ import # Utilities chronicles, unittest2, - stew/results, # Beacon chain internals ../../../beacon_chain/spec/state_transition_block, ../../../beacon_chain/spec/datatypes/bellatrix, diff --git a/tests/consensus_spec/capella/test_fixture_operations.nim b/tests/consensus_spec/capella/test_fixture_operations.nim index b0c989cbc..d1a67c6b3 100644 --- a/tests/consensus_spec/capella/test_fixture_operations.nim +++ b/tests/consensus_spec/capella/test_fixture_operations.nim @@ -12,7 +12,6 @@ import # Utilities chronicles, unittest2, - stew/results, # Beacon chain internals ../../../beacon_chain/spec/state_transition_block, ../../../beacon_chain/spec/datatypes/capella, diff --git a/tests/consensus_spec/deneb/test_fixture_operations.nim b/tests/consensus_spec/deneb/test_fixture_operations.nim index 4006b5a2c..86e1e8de1 100644 --- a/tests/consensus_spec/deneb/test_fixture_operations.nim +++ b/tests/consensus_spec/deneb/test_fixture_operations.nim @@ -12,7 +12,6 @@ import # Utilities chronicles, unittest2, - stew/results, # Beacon chain internals ../../../beacon_chain/spec/state_transition_block, ../../../beacon_chain/spec/datatypes/deneb, diff --git a/tests/consensus_spec/electra/test_fixture_operations.nim b/tests/consensus_spec/electra/test_fixture_operations.nim index bb56d349a..f4bc3fe6d 100644 --- a/tests/consensus_spec/electra/test_fixture_operations.nim +++ b/tests/consensus_spec/electra/test_fixture_operations.nim @@ -12,7 +12,6 @@ import # Utilities chronicles, unittest2, - stew/results, # Beacon chain internals ../../../beacon_chain/spec/state_transition_block, ../../../beacon_chain/spec/datatypes/electra, diff --git a/tests/consensus_spec/phase0/test_fixture_operations.nim b/tests/consensus_spec/phase0/test_fixture_operations.nim index 7a6cb1d93..532897711 100644 --- a/tests/consensus_spec/phase0/test_fixture_operations.nim +++ b/tests/consensus_spec/phase0/test_fixture_operations.nim @@ -12,7 +12,6 @@ import # Utilities chronicles, unittest2, - stew/results, # Beacon chain internals ../../../beacon_chain/spec/[beaconstate, state_transition_block], ../../../beacon_chain/spec/datatypes/phase0, diff --git a/tests/consensus_spec/test_fixture_fork_choice.nim b/tests/consensus_spec/test_fixture_fork_choice.nim index 166a5e68e..8334ef825 100644 --- a/tests/consensus_spec/test_fixture_fork_choice.nim +++ b/tests/consensus_spec/test_fixture_fork_choice.nim @@ -10,7 +10,7 @@ import # Status libraries - stew/[byteutils, results], chronicles, + stew/byteutils, chronicles, taskpools, # Internals ../../beacon_chain/spec/[helpers, forks, state_transition_block], diff --git a/tests/consensus_spec/test_fixture_kzg.nim b/tests/consensus_spec/test_fixture_kzg.nim index 74ed97f11..94a0610d9 100644 --- a/tests/consensus_spec/test_fixture_kzg.nim +++ b/tests/consensus_spec/test_fixture_kzg.nim @@ -12,7 +12,7 @@ import std/json, yaml, kzg4844/kzg_ex, - stew/[byteutils, results], + stew/byteutils, ../testutil, ./fixtures_utils, ./os_ops diff --git a/tests/slashing_protection/test_fixtures.nim b/tests/slashing_protection/test_fixtures.nim index 7050a8f2f..addfa4ef6 100644 --- a/tests/slashing_protection/test_fixtures.nim +++ b/tests/slashing_protection/test_fixtures.nim @@ -10,7 +10,6 @@ import # Status lib - stew/results, chronicles, # Internal ../../beacon_chain/validators/[slashing_protection, slashing_protection_v2], diff --git a/tests/slashing_protection/test_slashing_protection_db.nim b/tests/slashing_protection/test_slashing_protection_db.nim index 67dca5108..173ea3572 100644 --- a/tests/slashing_protection/test_slashing_protection_db.nim +++ b/tests/slashing_protection/test_slashing_protection_db.nim @@ -10,10 +10,10 @@ import # Standard library - std/[os], + std/os, # Status lib eth/db/[kvstore, kvstore_sqlite3], - stew/[results, endians2], + stew/endians2, # Internal ../../beacon_chain/validators/slashing_protection, ../../beacon_chain/spec/[helpers], diff --git a/tests/test_deposit_snapshots.nim b/tests/test_deposit_snapshots.nim index 259727e36..350fa407d 100644 --- a/tests/test_deposit_snapshots.nim +++ b/tests/test_deposit_snapshots.nim @@ -10,7 +10,8 @@ import std/[json, os, random, sequtils, strutils, times], - chronos, stew/[base10, results], chronicles, unittest2, + chronos, + stew/base10, chronicles, unittest2, yaml, ../beacon_chain/beacon_chain_db, ../beacon_chain/spec/deposit_snapshots, diff --git a/tests/test_serialization.nim b/tests/test_serialization.nim index 68f5c433b..234a459a0 100644 --- a/tests/test_serialization.nim +++ b/tests/test_serialization.nim @@ -9,7 +9,7 @@ {.used.} import - stew/results, presto/client, + presto/client, testutils/unittests, chronicles, ../beacon_chain/spec/eth2_apis/[eth2_rest_serialization, rest_types], ./testutil From 741075aada223991552a3363254c51eec6329e42 Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Tue, 11 Jun 2024 19:50:08 +0200 Subject: [PATCH 29/33] Bump nim-eth module and add async raises for eth2 discovery (#6344) --- beacon_chain/networking/eth2_discovery.nim | 8 ++++---- beacon_chain/networking/eth2_network.nim | 2 +- vendor/nim-eth | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/beacon_chain/networking/eth2_discovery.nim b/beacon_chain/networking/eth2_discovery.nim index d68d70e7e..e9495e25a 100644 --- a/beacon_chain/networking/eth2_discovery.nim +++ b/beacon_chain/networking/eth2_discovery.nim @@ -127,7 +127,7 @@ proc queryRandom*( forkId: ENRForkID, wantedAttnets: AttnetBits, wantedSyncnets: SyncnetBits, - minScore: int): Future[seq[Node]] {.async.} = + minScore: int): Future[seq[Node]] {.async: (raises: [CancelledError]).} = ## Perform a discovery query for a random target ## (forkId) and matching at least one of the attestation subnets. @@ -143,7 +143,7 @@ proc queryRandom*( peerForkId = try: SSZ.decode(eth2FieldBytes, ENRForkID) - except SszError as e: + except SerializationError as e: debug "Could not decode the eth2 field of peer", peer = n.record.toURI(), exception = e.name, msg = e.msg continue @@ -156,7 +156,7 @@ proc queryRandom*( let attnetsNode = try: SSZ.decode(attnetsBytes.get(), AttnetBits) - except SszError as e: + except SerializationError as e: debug "Could not decode the attnets ERN bitfield of peer", peer = n.record.toURI(), exception = e.name, msg = e.msg continue @@ -170,7 +170,7 @@ proc queryRandom*( let syncnetsNode = try: SSZ.decode(syncnetsBytes.get(), SyncnetBits) - except SszError as e: + except SerializationError as e: debug "Could not decode the syncnets ENR bitfield of peer", peer = n.record.toURI(), exception = e.name, msg = e.msg continue diff --git a/beacon_chain/networking/eth2_network.nim b/beacon_chain/networking/eth2_network.nim index b3334ebf4..27616be19 100644 --- a/beacon_chain/networking/eth2_network.nim +++ b/beacon_chain/networking/eth2_network.nim @@ -1550,7 +1550,7 @@ proc getLowSubnets(node: Eth2Node, epoch: Epoch): (AttnetBits, SyncnetBits) = default(SyncnetBits) ) -proc runDiscoveryLoop(node: Eth2Node) {.async.} = +proc runDiscoveryLoop(node: Eth2Node) {.async: (raises: [CancelledError]).} = debug "Starting discovery loop" while true: diff --git a/vendor/nim-eth b/vendor/nim-eth index c482b4c5b..c3f9160fd 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit c482b4c5b658a77cc96b49d4a397aa6d98472ac7 +Subproject commit c3f9160fd23010f65b1d4756cfd5c04272c20264 From 27664291c4a6d99cba421e2b1716ed58ac49132e Mon Sep 17 00:00:00 2001 From: Eugene Kabanov Date: Tue, 11 Jun 2024 22:38:16 +0300 Subject: [PATCH 30/33] VC/NIMBUS-BN validators protection. (#6329) * Beacon node side implementation. * Validator client side implementation. * Address review comments and fix the test. * Only 400 errors could be IndexedErrorMessage, 500 errors are always ErrorMessage. * Remove VC shutdown functionality. * Remove magic constants. * Make arguments more visible and disable default values. * Address review comments. --- .../gossip_processing/eth2_processor.nim | 30 +++++++----- beacon_chain/nimbus_beacon_node.nim | 6 ++- beacon_chain/rpc/rest_beacon_api.nim | 15 ++++-- beacon_chain/validator_client/api.nim | 49 +++++++++++++------ .../validator_client/duties_service.nim | 6 +-- beacon_chain/validators/beacon_validators.nim | 21 +++++--- .../validators/keystore_management.nim | 2 +- beacon_chain/validators/message_router.nim | 18 +++++-- .../validators/message_router_mev.nim | 3 +- beacon_chain/validators/validator_pool.nim | 23 +++++++-- tests/test_validator_pool.nim | 8 +-- 11 files changed, 126 insertions(+), 55 deletions(-) diff --git a/beacon_chain/gossip_processing/eth2_processor.nim b/beacon_chain/gossip_processing/eth2_processor.nim index 0fc759a3d..216c644b9 100644 --- a/beacon_chain/gossip_processing/eth2_processor.nim +++ b/beacon_chain/gossip_processing/eth2_processor.nim @@ -122,7 +122,7 @@ type # ---------------------------------------------------------------- dag*: ChainDAGRef attestationPool*: ref AttestationPool - validatorPool: ref ValidatorPool + validatorPool*: ref ValidatorPool syncCommitteeMsgPool: ref SyncCommitteeMsgPool lightClientPool: ref LightClientPool @@ -366,7 +366,8 @@ proc checkForPotentialDoppelganger( proc processAttestation*( self: ref Eth2Processor, src: MsgSource, attestation: phase0.Attestation | electra.Attestation, subnet_id: SubnetId, - checkSignature: bool = true): Future[ValidationRes] {.async: (raises: [CancelledError]).} = + checkSignature, checkValidator: bool +): Future[ValidationRes] {.async: (raises: [CancelledError]).} = var wallTime = self.getCurrentBeaconTime() let (afterGenesis, wallSlot) = wallTime.toSlot() @@ -393,19 +394,26 @@ proc processAttestation*( let (attester_index, sig) = v.get() - self[].checkForPotentialDoppelganger(attestation, [attester_index]) + if checkValidator and (attester_index in self.validatorPool[]): + warn "A validator client has attempted to send an attestation from " & + "validator that is also managed by the beacon node", + validator_index = attester_index + errReject("An attestation could not be sent from a validator that is " & + "also managed by the beacon node") + else: + self[].checkForPotentialDoppelganger(attestation, [attester_index]) - trace "Attestation validated" - self.attestationPool[].addAttestation( - attestation, [attester_index], sig, wallTime) + trace "Attestation validated" + self.attestationPool[].addAttestation( + attestation, [attester_index], sig, wallTime) - self.validatorMonitor[].registerAttestation( - src, wallTime, attestation, attester_index) + self.validatorMonitor[].registerAttestation( + src, wallTime, attestation, attester_index) - beacon_attestations_received.inc() - beacon_attestation_delay.observe(delay.toFloatSeconds()) + beacon_attestations_received.inc() + beacon_attestation_delay.observe(delay.toFloatSeconds()) - ok() + ok() else: debug "Dropping attestation", reason = $v.error beacon_attestations_dropped.inc(1, [$v.error[0]]) diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 185ff1b71..0079690dc 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -1771,7 +1771,8 @@ proc installMessageValidators(node: BeaconNode) = ): Future[ValidationResult] {.async: (raises: [CancelledError]).} = return toValidationResult( await node.processor.processAttestation( - MsgSource.gossip, attestation, subnet_id))) + MsgSource.gossip, attestation, subnet_id, + checkSignature = true, checkValidator = false))) else: for it in SubnetId: closureScope: # Needed for inner `proc`; don't lift it out of loop. @@ -1782,7 +1783,8 @@ proc installMessageValidators(node: BeaconNode) = ): Future[ValidationResult] {.async: (raises: [CancelledError]).} = return toValidationResult( await node.processor.processAttestation( - MsgSource.gossip, attestation, subnet_id))) + MsgSource.gossip, attestation, subnet_id, + checkSignature = true, checkValidator = false))) # beacon_aggregate_and_proof # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof diff --git a/beacon_chain/rpc/rest_beacon_api.nim b/beacon_chain/rpc/rest_beacon_api.nim index a43a2db84..58aa5a881 100644 --- a/beacon_chain/rpc/rest_beacon_api.nim +++ b/beacon_chain/rpc/rest_beacon_api.nim @@ -911,10 +911,12 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) = when consensusFork >= ConsensusFork.Deneb: await node.router.routeSignedBeaconBlock( forkyBlck, Opt.some( - forkyBlck.create_blob_sidecars(kzg_proofs, blobs))) + forkyBlck.create_blob_sidecars(kzg_proofs, blobs)), + checkValidator = true) else: await node.router.routeSignedBeaconBlock( - forkyBlck, Opt.none(seq[BlobSidecar])) + forkyBlck, Opt.none(seq[BlobSidecar]), + checkValidator = true) if res.isErr(): return RestApiResponse.jsonError( @@ -966,10 +968,12 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) = when consensusFork >= ConsensusFork.Deneb: await node.router.routeSignedBeaconBlock( forkyBlck, Opt.some( - forkyBlck.create_blob_sidecars(kzg_proofs, blobs))) + forkyBlck.create_blob_sidecars(kzg_proofs, blobs)), + checkValidator = true) else: await node.router.routeSignedBeaconBlock( - forkyBlck, Opt.none(seq[BlobSidecar])) + forkyBlck, Opt.none(seq[BlobSidecar]), + checkValidator = true) if res.isErr(): return RestApiResponse.jsonError( @@ -1087,7 +1091,8 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) = let res = withBlck(forked): forkyBlck.root = hash_tree_root(forkyBlck.message) await node.router.routeSignedBeaconBlock( - forkyBlck, Opt.none(seq[BlobSidecar])) + forkyBlck, Opt.none(seq[BlobSidecar]), + checkValidator = true) if res.isErr(): return RestApiResponse.jsonError( diff --git a/beacon_chain/validator_client/api.nim b/beacon_chain/validator_client/api.nim index 1e9b39316..d02254aae 100644 --- a/beacon_chain/validator_client/api.nim +++ b/beacon_chain/validator_client/api.nim @@ -720,16 +720,30 @@ template firstSuccessSequential*( break proc getErrorMessage*(response: RestPlainResponse): string = - let res = decodeBytes(RestErrorMessage, response.data, - response.contentType) - if res.isOk(): - let errorObj = res.get() - if errorObj.stacktraces.isSome(): - errorObj.message & ": [" & errorObj.stacktraces.get().join("; ") & "]" - else: - errorObj.message + let res = + decodeBytes(RestErrorMessage, response.data, response.contentType).valueOr: + return "Unable to decode error response: [" & $error & "]" + + if res.stacktraces.isSome(): + res.message & ": [" & res.stacktraces.get().join("; ") & "]" else: - "Unable to decode error response: [" & $res.error & "]" + res.message + +proc unpackErrorMessage*(response: RestPlainResponse): RestIndexedErrorMessage = + decodeBytes(RestIndexedErrorMessage, response.data, + response.contentType).valueOr: + let message = "Unable to decode error response: [" & $error & "]" + return RestIndexedErrorMessage( + code: -1, + message: message, + failures: default(seq[RestIndexedErrorMessageItem])) + +proc getErrorMessage*(msg: RestIndexedErrorMessage): string = + if len(msg.failures) > 0: + msg.message & ": [" & + msg.failures.mapIt($it.index & ":" & it.message).join("; ") & "]" + else: + msg.message template handleCommunicationError(): untyped {.dirty.} = let failure = ApiNodeFailure.init(ApiFailure.Communication, RequestName, @@ -761,6 +775,13 @@ template handle400(): untyped {.dirty.} = node.updateStatus(RestBeaconNodeStatus.Incompatible, failure) failures.add(failure) +template handle400Indexed(): untyped {.dirty.} = + let failure = ApiNodeFailure.init(ApiFailure.Invalid, RequestName, + strategy, node, response.status, + response.unpackErrorMessage().getErrorMessage()) + node.updateStatus(RestBeaconNodeStatus.Incompatible, failure) + failures.add(failure) + template handle404(): untyped {.dirty.} = let failure = ApiNodeFailure.init(ApiFailure.NotFound, RequestName, strategy, node, response.status, response.getErrorMessage()) @@ -1522,7 +1543,7 @@ proc submitPoolAttestations*( of 200: ApiResponse[bool].ok(true) of 400: - handle400() + handle400Indexed() ApiResponse[bool].err(ResponseInvalidError) of 500: handle500() @@ -1550,7 +1571,7 @@ proc submitPoolAttestations*( of 200: return true of 400: - handle400() + handle400Indexed() false of 500: handle500() @@ -1597,7 +1618,7 @@ proc submitPoolSyncCommitteeSignature*( of 200: ApiResponse[bool].ok(true) of 400: - handle400() + handle400Indexed() ApiResponse[bool].err(ResponseInvalidError) of 500: handle500() @@ -1626,7 +1647,7 @@ proc submitPoolSyncCommitteeSignature*( of 200: return true of 400: - handle400() + handle400Indexed() false of 500: handle500() @@ -2284,7 +2305,7 @@ proc publishBlock*( return true of 202: debug BlockBroadcasted, node = node, - blck = shortLog(ForkedSignedBeaconBlock.init(data)) + blck = shortLog(ForkedSignedBeaconBlock.init(data)) return true of 400: handle400() diff --git a/beacon_chain/validator_client/duties_service.nim b/beacon_chain/validator_client/duties_service.nim index 1214302a3..d05b7da28 100644 --- a/beacon_chain/validator_client/duties_service.nim +++ b/beacon_chain/validator_client/duties_service.nim @@ -87,9 +87,9 @@ proc pollForValidatorIndices*(service: DutiesServiceRef) {.async.} = if validator.isNone(): missing.add(validatorLog(item.validator.pubkey, item.index)) else: - validator.get().updateValidator(Opt.some ValidatorAndIndex( - index: item.index, - validator: item.validator)) + vc.attachedValidators[].updateValidator(validator.get(), + Opt.some ValidatorAndIndex(index: item.index, + validator: item.validator)) updated.add(validatorLog(item.validator.pubkey, item.index)) list.add(validator.get()) diff --git a/beacon_chain/validators/beacon_validators.nim b/beacon_chain/validators/beacon_validators.nim index 9dfb19f6d..328075535 100644 --- a/beacon_chain/validators/beacon_validators.nim +++ b/beacon_chain/validators/beacon_validators.nim @@ -152,7 +152,7 @@ proc addValidatorsFromWeb3Signer( gasLimit = node.consensusManager[].getGasLimit(keystore.pubkey) v = node.attachedValidators[].addValidator(keystore, feeRecipient, gasLimit) - v.updateValidator(data) + node.attachedValidators[].updateValidator(v, data) proc addValidators*(node: BeaconNode) {.async: (raises: [CancelledError]).} = info "Loading validators", validatorsDir = node.config.validatorsDir(), @@ -174,7 +174,7 @@ proc addValidators*(node: BeaconNode) {.async: (raises: [CancelledError]).} = v = node.attachedValidators[].addValidator(keystore, feeRecipient, gasLimit) - v.updateValidator(data) + node.attachedValidators[].updateValidator(v, data) # We use `allFutures` because all failures are already reported as # user-visible warnings in `queryValidatorsSource`. @@ -363,10 +363,12 @@ proc createAndSendAttestation(node: BeaconNode, res = if consensusFork >= ConsensusFork.Electra: await node.router.routeAttestation( - registered.toElectraAttestation(signature), subnet_id, checkSignature = false) + registered.toElectraAttestation(signature), subnet_id, + checkSignature = false, checkValidator = false) else: await node.router.routeAttestation( - registered.toAttestation(signature), subnet_id, checkSignature = false) + registered.toAttestation(signature), subnet_id, + checkSignature = false, checkValidator = false) if not res.isOk(): return @@ -1294,7 +1296,8 @@ proc proposeBlockAux( else: Opt.none(seq[BlobSidecar]) newBlockRef = ( - await node.router.routeSignedBeaconBlock(signedBlock, blobsOpt) + await node.router.routeSignedBeaconBlock(signedBlock, blobsOpt, + checkValidator = false) ).valueOr: return head # Errors logged in router @@ -1871,7 +1874,7 @@ proc updateValidators( let v = node.attachedValidators[].getValidator(validators[i].pubkey).valueOr: continue - v.index = Opt.some ValidatorIndex(i) + node.attachedValidators[].setValidatorIndex(v, ValidatorIndex(i)) node.dutyValidatorCount = validators.len @@ -1881,10 +1884,12 @@ proc updateValidators( # Activation epoch can change after index is assigned.. let index = validator.index.get() if index < validators.lenu64: - validator.updateValidator( + node.attachedValidators[].updateValidator( + validator, Opt.some(ValidatorAndIndex( index: index, validator: validators[int index] - ))) + )) + ) proc handleFallbackAttestations(node: BeaconNode, lastSlot, slot: Slot) = # Neither block proposal nor sync committee duties can be done in this diff --git a/beacon_chain/validators/keystore_management.nim b/beacon_chain/validators/keystore_management.nim index 9610c439d..243fed9d3 100644 --- a/beacon_chain/validators/keystore_management.nim +++ b/beacon_chain/validators/keystore_management.nim @@ -1607,7 +1607,7 @@ proc addValidator*( if not isNil(host.getValidatorAndIdxFn): let data = host.getValidatorAndIdxFn(keystore.pubkey) - v.updateValidator(data) + host.validatorPool[].updateValidator(v, data) proc generateDeposits*(cfg: RuntimeConfig, rng: var HmacDrbgContext, diff --git a/beacon_chain/validators/message_router.nim b/beacon_chain/validators/message_router.nim index 1e40c450e..c70adb743 100644 --- a/beacon_chain/validators/message_router.nim +++ b/beacon_chain/validators/message_router.nim @@ -84,13 +84,22 @@ template getCurrentBeaconTime(router: MessageRouter): BeaconTime = type RouteBlockResult = Result[Opt[BlockRef], string] proc routeSignedBeaconBlock*( router: ref MessageRouter, blck: ForkySignedBeaconBlock, - blobsOpt: Opt[seq[BlobSidecar]]): + blobsOpt: Opt[seq[BlobSidecar]], checkValidator: bool): Future[RouteBlockResult] {.async: (raises: [CancelledError]).} = ## Validate and broadcast beacon block, then add it to the block database ## Returns the new Head when block is added successfully to dag, none when ## block passes validation but is not added, and error otherwise let wallTime = router[].getCurrentBeaconTime() + block: + let vindex = ValidatorIndex(blck.message.proposer_index) + if checkValidator and (vindex in router.processor.validatorPool[]): + warn "A validator client attempts to send a block from " & + "validator that is also manager by beacon node", + validator_index = vindex + return err("Block could not be sent from validator that is also " & + "managed by the beacon node") + # Start with a quick gossip validation check such that broadcasting the # block doesn't get the node into trouble block: @@ -192,13 +201,14 @@ proc routeSignedBeaconBlock*( proc routeAttestation*( router: ref MessageRouter, attestation: phase0.Attestation | electra.Attestation, - subnet_id: SubnetId, checkSignature: bool): + subnet_id: SubnetId, checkSignature, checkValidator: bool): Future[SendResult] {.async: (raises: [CancelledError]).} = ## Process and broadcast attestation - processing will register the it with ## the attestation pool block: let res = await router[].processor.processAttestation( - MsgSource.api, attestation, subnet_id, checkSignature) + MsgSource.api, attestation, subnet_id, + checkSignature = checkSignature, checkValidator = checkValidator) if not res.isGoodForSending: warn "Attestation failed validation", @@ -249,7 +259,7 @@ proc routeAttestation*( committee_index) return await router.routeAttestation( - attestation, subnet_id, checkSignature = true) + attestation, subnet_id, checkSignature = true, checkValidator = true) proc routeSignedAggregateAndProof*( router: ref MessageRouter, proof: phase0.SignedAggregateAndProof, diff --git a/beacon_chain/validators/message_router_mev.nim b/beacon_chain/validators/message_router_mev.nim index 5abdc64ef..76a2c44e3 100644 --- a/beacon_chain/validators/message_router_mev.nim +++ b/beacon_chain/validators/message_router_mev.nim @@ -143,7 +143,8 @@ proc unblindAndRouteBlockMEV*( blck = shortLog(signedBlock) let newBlockRef = - (await node.router.routeSignedBeaconBlock(signedBlock, blobsOpt)).valueOr: + (await node.router.routeSignedBeaconBlock( + signedBlock, blobsOpt, checkValidator = false)).valueOr: # submitBlindedBlock has run, so don't allow fallback to run return err("routeSignedBeaconBlock error") # Errors logged in router diff --git a/beacon_chain/validators/validator_pool.nim b/beacon_chain/validators/validator_pool.nim index 52a4d0741..98df8a2f5 100644 --- a/beacon_chain/validators/validator_pool.nim +++ b/beacon_chain/validators/validator_pool.nim @@ -8,7 +8,7 @@ {.push raises: [].} import - std/[tables, json, streams, sequtils, uri], + std/[tables, json, streams, sequtils, uri, sets], chronos, chronicles, metrics, json_serialization/std/net, presto/client, @@ -93,6 +93,7 @@ type ValidatorPool* = object validators*: Table[ValidatorPubKey, AttachedValidator] + indexSet*: HashSet[ValidatorIndex] slashingProtection*: SlashingProtectionDB doppelgangerDetectionEnabled*: bool @@ -223,10 +224,24 @@ func contains*(pool: ValidatorPool, pubkey: ValidatorPubKey): bool = ## Returns ``true`` if validator with key ``pubkey`` present in ``pool``. pool.validators.contains(pubkey) +proc contains*(pool: ValidatorPool, index: ValidatorIndex): bool = + ## Returns ``true`` if validator with index ``index`` present in ``pool``. + pool.indexSet.contains(index) + +proc setValidatorIndex*(pool: var ValidatorPool, validator: AttachedValidator, + index: ValidatorIndex) = + pool.indexSet.incl(index) + validator.index = Opt.some(index) + +proc removeValidatorIndex(pool: var ValidatorPool, index: ValidatorIndex) = + pool.indexSet.excl(index) + proc removeValidator*(pool: var ValidatorPool, pubkey: ValidatorPubKey) = ## Delete validator with public key ``pubkey`` from ``pool``. let validator = pool.validators.getOrDefault(pubkey) if not(isNil(validator)): + if validator.index.isSome(): + pool.removeValidatorIndex(validator.index.get) pool.validators.del(pubkey) case validator.kind of ValidatorKind.Local: @@ -243,8 +258,9 @@ proc removeValidator*(pool: var ValidatorPool, pubkey: ValidatorPubKey) = func needsUpdate*(validator: AttachedValidator): bool = validator.index.isNone() or validator.activationEpoch == FAR_FUTURE_EPOCH -proc updateValidator*( - validator: AttachedValidator, validatorData: Opt[ValidatorAndIndex]) = +proc updateValidator*(pool: var ValidatorPool, + validator: AttachedValidator, + validatorData: Opt[ValidatorAndIndex]) = defer: validator.updated = true let @@ -259,6 +275,7 @@ proc updateValidator*( ## Update activation information for a validator if validator.index != Opt.some data.index: + pool.setValidatorIndex(validator, data.index) validator.index = Opt.some data.index validator.validator = Opt.some data.validator diff --git a/tests/test_validator_pool.nim b/tests/test_validator_pool.nim index a79c8dca8..da3802b91 100644 --- a/tests/test_validator_pool.nim +++ b/tests/test_validator_pool.nim @@ -71,13 +71,14 @@ func checkResponse(a, b: openArray[KeystoreData]): bool = suite "Validator pool": test "Doppelganger for genesis validator": let + pool = newClone(ValidatorPool()) v = AttachedValidator(activationEpoch: FAR_FUTURE_EPOCH) check: not v.triggersDoppelganger(GENESIS_EPOCH) # no check not v.doppelgangerReady(GENESIS_EPOCH.start_slot) # no activation - v.updateValidator(makeValidatorAndIndex(ValidatorIndex(1), GENESIS_EPOCH)) + pool[].updateValidator(v, makeValidatorAndIndex(ValidatorIndex(1), GENESIS_EPOCH)) check: not v.triggersDoppelganger(GENESIS_EPOCH) # no check @@ -94,6 +95,7 @@ suite "Validator pool": test "Doppelganger for validator that activates in same epoch as check": let + pool = newClone(ValidatorPool()) v = AttachedValidator(activationEpoch: FAR_FUTURE_EPOCH) now = Epoch(10).start_slot() @@ -104,7 +106,7 @@ suite "Validator pool": not v.doppelgangerReady(GENESIS_EPOCH.start_slot) not v.doppelgangerReady(now) - v.updateValidator(makeValidatorAndIndex(ValidatorIndex(5), FAR_FUTURE_EPOCH)) + pool[].updateValidator(v, makeValidatorAndIndex(ValidatorIndex(5), FAR_FUTURE_EPOCH)) check: # We still don't know when validator activates so we wouldn't trigger not v.triggersDoppelganger(GENESIS_EPOCH) @@ -113,7 +115,7 @@ suite "Validator pool": not v.doppelgangerReady(GENESIS_EPOCH.start_slot) not v.doppelgangerReady(now) - v.updateValidator(makeValidatorAndIndex(ValidatorIndex(5), now.epoch())) + pool[].updateValidator(v, makeValidatorAndIndex(ValidatorIndex(5), now.epoch())) check: # No check done yet not v.triggersDoppelganger(GENESIS_EPOCH) From 238589868c9ff94487758efb68fdcc24a8ce53d0 Mon Sep 17 00:00:00 2001 From: andri lim Date: Wed, 12 Jun 2024 08:46:39 +0700 Subject: [PATCH 31/33] Bump nim-web3 and nim-eth (#6345) In nim-web3 all std.Option are replaced by results.Opt. The same goes in nim-eth, with additional fields name changes and GasInt changed from int64 to uint64. --- beacon_chain/beacon_node_light_client.nim | 2 +- .../consensus_manager.nim | 4 +- beacon_chain/el/deposit_contract.nim | 22 +++---- beacon_chain/el/el_manager.nim | 60 +++++++++---------- .../gossip_processing/block_processor.nim | 4 +- beacon_chain/libnimbus_lc/libnimbus_lc.nim | 55 +++++++++-------- beacon_chain/networking/network_metadata.nim | 34 +++++------ beacon_chain/nimbus_light_client.nim | 2 +- beacon_chain/spec/helpers.nim | 26 ++++---- ncli/ncli_testnet.nim | 24 ++++---- research/fakeee.nim | 4 +- research/wss_sim.nim | 2 +- tests/testblockutil.nim | 6 +- vendor/nim-eth | 2 +- vendor/nim-web3 | 2 +- 15 files changed, 123 insertions(+), 126 deletions(-) diff --git a/beacon_chain/beacon_node_light_client.nim b/beacon_chain/beacon_node_light_client.nim index 1df0ddb37..b6e15b06b 100644 --- a/beacon_chain/beacon_node_light_client.nim +++ b/beacon_chain/beacon_node_light_client.nim @@ -73,7 +73,7 @@ proc initLightClient*( headBlockHash = blckPayload.block_hash, safeBlockHash = beaconHead.safeExecutionBlockHash, finalizedBlockHash = beaconHead.finalizedExecutionBlockHash, - payloadAttributes = none attributes) + payloadAttributes = Opt.none attributes) case node.dag.cfg.consensusForkAtEpoch( forkyBlck.message.slot.epoch) diff --git a/beacon_chain/consensus_object_pools/consensus_manager.nim b/beacon_chain/consensus_object_pools/consensus_manager.nim index 50fcec775..b561e854e 100644 --- a/beacon_chain/consensus_object_pools/consensus_manager.nim +++ b/beacon_chain/consensus_object_pools/consensus_manager.nim @@ -184,7 +184,7 @@ proc updateExecutionClientHead*( headBlockHash = headExecutionBlockHash, safeBlockHash = newHead.safeExecutionBlockHash, finalizedBlockHash = newHead.finalizedExecutionBlockHash, - payloadAttributes = none attributes) + payloadAttributes = Opt.none attributes) # Can't use dag.head here because it hasn't been updated yet let @@ -374,7 +374,7 @@ proc runProposalForkchoiceUpdated*( let (status, _) = await self.elManager.forkchoiceUpdated( headBlockHash, safeBlockHash, beaconHead.finalizedExecutionBlockHash, - payloadAttributes = some fcPayloadAttributes) + payloadAttributes = Opt.some fcPayloadAttributes) debug "Fork-choice updated for proposal", status static: doAssert high(ConsensusFork) == ConsensusFork.Electra diff --git a/beacon_chain/el/deposit_contract.nim b/beacon_chain/el/deposit_contract.nim index 213907879..1dcdfccef 100644 --- a/beacon_chain/el/deposit_contract.nim +++ b/beacon_chain/el/deposit_contract.nim @@ -123,25 +123,25 @@ contract(DepositContract): proc deployContract*(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} = let tr = TransactionArgs( - `from`: web3.defaultAccount.some, - data: code.some, - gas: Quantity(3000000).some, - gasPrice: Quantity(1).some) + `from`: Opt.some web3.defaultAccount, + data: Opt.some code, + gas: Opt.some Quantity(3000000), + gasPrice: Opt.some Quantity(1)) let r = await web3.send(tr) result = await web3.getMinedTransactionReceipt(r) proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] = let tr = TransactionArgs( - `from`: web3.defaultAccount.some, + `from`: Opt.some web3.defaultAccount, # TODO: Force json-rpc to generate 'data' field # should not be needed anymore, new execution-api schema # is using `input` field - data: some(newSeq[byte]()), - gas: Quantity(3000000).some, - gasPrice: Quantity(1).some, - value: some(valueEth.u256 * 1000000000000000000.u256), - to: some(to)) + data: Opt.some(newSeq[byte]()), + gas: Opt.some Quantity(3000000), + gasPrice: Opt.some Quantity(1), + value: Opt.some(valueEth.u256 * 1000000000000000000.u256), + to: Opt.some(to)) web3.send(tr) type @@ -153,7 +153,7 @@ proc ethToWei(eth: UInt256): UInt256 = proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} = result = await newWeb3(web3Url) if privateKey.len != 0: - result.privateKey = some(PrivateKey.fromHex(privateKey)[]) + result.privateKey = Opt.some(PrivateKey.fromHex(privateKey)[]) else: let accounts = await result.provider.eth_accounts() doAssert(accounts.len > 0) diff --git a/beacon_chain/el/el_manager.nim b/beacon_chain/el/el_manager.nim index e204f68db..d2e754c87 100644 --- a/beacon_chain/el/el_manager.nim +++ b/beacon_chain/el/el_manager.nim @@ -106,7 +106,7 @@ type Running, Closing, Closed ELManager* = ref object - eth1Network: Option[Eth1Network] + eth1Network: Opt[Eth1Network] ## If this value is supplied the EL manager will check whether ## all configured EL nodes are connected to the same network. @@ -133,7 +133,7 @@ type ## also includes blocks without deposits because we must ## vote for a block only if it's part of our known history. - syncTargetBlock: Option[Eth1BlockNumber] + syncTargetBlock: Opt[Eth1BlockNumber] chainSyncingLoopFut: Future[void] exchangeTransitionConfigurationLoopFut: Future[void] @@ -177,7 +177,7 @@ type depositContractSyncStatus: DepositContractSyncStatus ## Are we sure that this EL has synced the deposit contract? - lastPayloadId: Option[PayloadID] + lastPayloadId: Opt[PayloadID] FullBlockId* = object number: Eth1BlockNumber @@ -419,7 +419,7 @@ func asConsensusType*(payloadWithValue: BellatrixExecutionPayloadWithValue): executionPayload: payloadWithValue.executionPayload.asConsensusType, blockValue: payloadWithValue.blockValue) -template maybeDeref[T](o: Option[T]): T = o.get +template maybeDeref[T](o: Opt[T]): T = o.get template maybeDeref[V](v: V): V = v func asConsensusType*(rpcExecutionPayload: ExecutionPayloadV1OrV2|ExecutionPayloadV2): @@ -779,15 +779,15 @@ func areSameAs(expectedParams: Option[NextExpectedPayloadParams], proc forkchoiceUpdated(rpcClient: RpcClient, state: ForkchoiceStateV1, - payloadAttributes: Option[PayloadAttributesV1] | - Option[PayloadAttributesV2] | - Option[PayloadAttributesV3]): + payloadAttributes: Opt[PayloadAttributesV1] | + Opt[PayloadAttributesV2] | + Opt[PayloadAttributesV3]): Future[ForkchoiceUpdatedResponse] = - when payloadAttributes is Option[PayloadAttributesV1]: + when payloadAttributes is Opt[PayloadAttributesV1]: rpcClient.engine_forkchoiceUpdatedV1(state, payloadAttributes) - elif payloadAttributes is Option[PayloadAttributesV2]: + elif payloadAttributes is Opt[PayloadAttributesV2]: rpcClient.engine_forkchoiceUpdatedV2(state, payloadAttributes) - elif payloadAttributes is Option[PayloadAttributesV3]: + elif payloadAttributes is Opt[PayloadAttributesV3]: rpcClient.engine_forkchoiceUpdatedV3(state, payloadAttributes) else: static: doAssert false @@ -817,7 +817,7 @@ proc getPayloadFromSingleEL( headBlockHash: headBlock.asBlockHash, safeBlockHash: safeBlock.asBlockHash, finalizedBlockHash: finalizedBlock.asBlockHash), - some PayloadAttributesV1( + Opt.some PayloadAttributesV1( timestamp: Quantity timestamp, prevRandao: FixedBytes[32] randomData.data, suggestedFeeRecipient: suggestedFeeRecipient)) @@ -827,7 +827,7 @@ proc getPayloadFromSingleEL( headBlockHash: headBlock.asBlockHash, safeBlockHash: safeBlock.asBlockHash, finalizedBlockHash: finalizedBlock.asBlockHash), - some PayloadAttributesV2( + Opt.some PayloadAttributesV2( timestamp: Quantity timestamp, prevRandao: FixedBytes[32] randomData.data, suggestedFeeRecipient: suggestedFeeRecipient, @@ -841,7 +841,7 @@ proc getPayloadFromSingleEL( headBlockHash: headBlock.asBlockHash, safeBlockHash: safeBlock.asBlockHash, finalizedBlockHash: finalizedBlock.asBlockHash), - some PayloadAttributesV3( + Opt.some PayloadAttributesV3( timestamp: Quantity timestamp, prevRandao: FixedBytes[32] randomData.data, suggestedFeeRecipient: suggestedFeeRecipient, @@ -1341,9 +1341,9 @@ proc sendNewPayload*( proc forkchoiceUpdatedForSingleEL( connection: ELConnection, state: ref ForkchoiceStateV1, - payloadAttributes: Option[PayloadAttributesV1] | - Option[PayloadAttributesV2] | - Option[PayloadAttributesV3] + payloadAttributes: Opt[PayloadAttributesV1] | + Opt[PayloadAttributesV2] | + Opt[PayloadAttributesV3] ): Future[PayloadStatusV1] {.async: (raises: [CatchableError]).} = let rpcClient = await connection.connectedRpcClient() @@ -1363,10 +1363,10 @@ proc forkchoiceUpdatedForSingleEL( proc forkchoiceUpdated*( m: ELManager, headBlockHash, safeBlockHash, finalizedBlockHash: Eth2Digest, - payloadAttributes: Option[PayloadAttributesV1] | - Option[PayloadAttributesV2] | - Option[PayloadAttributesV3] -): Future[(PayloadExecutionStatus, Option[BlockHash])] {. + payloadAttributes: Opt[PayloadAttributesV1] | + Opt[PayloadAttributesV2] | + Opt[PayloadAttributesV3] +): Future[(PayloadExecutionStatus, Opt[BlockHash])] {. async: (raises: [CancelledError]).} = doAssert not headBlockHash.isZero @@ -1383,16 +1383,16 @@ proc forkchoiceUpdated*( # payload (`Hash32()` if none yet finalized)" if m.elConnections.len == 0: - return (PayloadExecutionStatus.syncing, none BlockHash) + return (PayloadExecutionStatus.syncing, Opt.none BlockHash) - when payloadAttributes is Option[PayloadAttributesV3]: + when payloadAttributes is Opt[PayloadAttributesV3]: template payloadAttributesV3(): auto = if payloadAttributes.isSome: payloadAttributes.get else: # As timestamp and prevRandao are both 0, won't false-positive match (static(default(PayloadAttributesV3))) - elif payloadAttributes is Option[PayloadAttributesV2]: + elif payloadAttributes is Opt[PayloadAttributesV2]: template payloadAttributesV3(): auto = if payloadAttributes.isSome: PayloadAttributesV3( @@ -1404,7 +1404,7 @@ proc forkchoiceUpdated*( else: # As timestamp and prevRandao are both 0, won't false-positive match (static(default(PayloadAttributesV3))) - elif payloadAttributes is Option[PayloadAttributesV1]: + elif payloadAttributes is Opt[PayloadAttributesV1]: template payloadAttributesV3(): auto = if payloadAttributes.isSome: PayloadAttributesV3( @@ -1489,7 +1489,7 @@ proc forkchoiceUpdated*( pendingRequests.filterIt(not(it.finished())). mapIt(it.cancelAndWait()) await noCancel allFutures(pending) - return (PayloadExecutionStatus.invalid, none BlockHash) + return (PayloadExecutionStatus.invalid, Opt.none BlockHash) elif responseProcessor.selectedResponse.isSome: # We spawn task which will wait for all other responses which are # still pending, after 30.seconds all pending requests will be @@ -1504,7 +1504,7 @@ proc forkchoiceUpdated*( pendingRequests.filterIt(not(it.finished())). mapIt(it.cancelAndWait()) await noCancel allFutures(pending) - return (PayloadExecutionStatus.syncing, none BlockHash) + return (PayloadExecutionStatus.syncing, Opt.none BlockHash) if len(pendingRequests) == 0: # All requests failed, we will continue our attempts until deadline @@ -1762,7 +1762,7 @@ proc new*(T: type ELManager, depositContractBlockHash: Eth2Digest, db: BeaconChainDB, engineApiUrls: seq[EngineApiUrl], - eth1Network: Option[Eth1Network]): T = + eth1Network: Opt[Eth1Network]): T = let eth1Chain = Eth1Chain.init( cfg, db, depositContractBlockNumber, depositContractBlockHash) @@ -1847,8 +1847,8 @@ proc syncBlockRange( await connection.engineApiRequest( depositContract.getJsonLogs( DepositEvent, - fromBlock = some blockId(currentBlock), - toBlock = some blockId(maxBlockNumberRequested)), + fromBlock = Opt.some blockId(currentBlock), + toBlock = Opt.some blockId(maxBlockNumberRequested)), "getLogs", Moment.now(), 30.seconds) except CancelledError as exc: debug "Request for deposit logs was interrupted" @@ -2089,7 +2089,7 @@ proc syncEth1Chain( latestBlockNumber = latestBlock.number - m.syncTargetBlock = some( + m.syncTargetBlock = Opt.some( if latestBlock.number > m.cfg.ETH1_FOLLOW_DISTANCE.Eth1BlockNumber: latestBlock.number - m.cfg.ETH1_FOLLOW_DISTANCE else: diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim index 1eb1b86b4..bfef52d31 100644 --- a/beacon_chain/gossip_processing/block_processor.nim +++ b/beacon_chain/gossip_processing/block_processor.nim @@ -242,7 +242,7 @@ proc expectValidForkchoiceUpdated( headBlockHash = headBlockHash, safeBlockHash = safeBlockHash, finalizedBlockHash = finalizedBlockHash, - payloadAttributes = none headBlockPayloadAttributesType) + payloadAttributes = Opt.none headBlockPayloadAttributesType) receivedExecutionBlockHash = when typeof(receivedBlock).kind >= ConsensusFork.Bellatrix: receivedBlock.message.body.execution_payload.block_hash @@ -684,7 +684,7 @@ proc storeBlock( self.consensusManager[].optimisticExecutionBlockHash, safeBlockHash = newHead.get.safeExecutionBlockHash, finalizedBlockHash = newHead.get.finalizedExecutionBlockHash, - payloadAttributes = none attributes) + payloadAttributes = Opt.none attributes) let consensusFork = self.consensusManager.dag.cfg.consensusForkAtEpoch( newHead.get.blck.bid.slot.epoch) diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.nim b/beacon_chain/libnimbus_lc/libnimbus_lc.nim index b3ae420ab..c3aa4eac9 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.nim +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.nim @@ -9,7 +9,6 @@ import std/[json, sequtils, times], - stew/saturation_arith, eth/common/[eth_types_rlp, transaction], eth/keys, eth/p2p/discoveryv5/random2, @@ -1254,37 +1253,37 @@ proc ETHExecutionBlockHeaderCreateFromJson( coinbase: distinctBase(data.miner), stateRoot: data.stateRoot.asEth2Digest, txRoot: data.transactionsRoot.asEth2Digest, - receiptRoot: data.receiptsRoot.asEth2Digest, - bloom: distinctBase(data.logsBloom), + receiptsRoot: data.receiptsRoot.asEth2Digest, + logsBloom: distinctBase(data.logsBloom), difficulty: data.difficulty, - blockNumber: distinctBase(data.number).u256, - gasLimit: cast[int64](data.gasLimit), - gasUsed: cast[int64](data.gasUsed), - timestamp: EthTime(int64.saturate distinctBase(data.timestamp)), + number: distinctBase(data.number), + gasLimit: distinctBase(data.gasLimit), + gasUsed: distinctBase(data.gasUsed), + timestamp: EthTime(distinctBase(data.timestamp)), extraData: distinctBase(data.extraData), - mixDigest: data.mixHash.asEth2Digest, + mixHash: data.mixHash.asEth2Digest, nonce: distinctBase(data.nonce.get), - fee: data.baseFeePerGas, + baseFeePerGas: data.baseFeePerGas, withdrawalsRoot: if data.withdrawalsRoot.isSome: - some(data.withdrawalsRoot.get.asEth2Digest) + Opt.some(data.withdrawalsRoot.get.asEth2Digest) else: - none(ExecutionHash256), + Opt.none(ExecutionHash256), blobGasUsed: if data.blobGasUsed.isSome: - some distinctBase(data.blobGasUsed.get) + Opt.some distinctBase(data.blobGasUsed.get) else: - none(uint64), + Opt.none(uint64), excessBlobGas: if data.excessBlobGas.isSome: - some distinctBase(data.excessBlobGas.get) + Opt.some distinctBase(data.excessBlobGas.get) else: - none(uint64), + Opt.none(uint64), parentBeaconBlockRoot: if data.parentBeaconBlockRoot.isSome: - some distinctBase(data.parentBeaconBlockRoot.get.asEth2Digest) + Opt.some distinctBase(data.parentBeaconBlockRoot.get.asEth2Digest) else: - none(ExecutionHash256)) + Opt.none(ExecutionHash256)) if rlpHash(blockHeader) != executionHash[]: return nil @@ -1529,15 +1528,15 @@ proc ETHTransactionsCreateFromJson( chainId: data.chainId.get(0.Quantity).ChainId, nonce: distinctBase(data.nonce), gasPrice: data.gasPrice.GasInt, - maxPriorityFee: + maxPriorityFeePerGas: distinctBase(data.maxPriorityFeePerGas.get(data.gasPrice)).GasInt, - maxFee: distinctBase(data.maxFeePerGas.get(data.gasPrice)).GasInt, + maxFeePerGas: distinctBase(data.maxFeePerGas.get(data.gasPrice)).GasInt, gasLimit: distinctBase(data.gas).GasInt, to: if data.to.isSome: - some(distinctBase(data.to.get)) + Opt.some(distinctBase(data.to.get)) else: - none(EthAddress), + Opt.none(EthAddress), value: data.value, payload: data.input, accessList: @@ -1555,7 +1554,7 @@ proc ETHTransactionsCreateFromJson( ExecutionHash256(data: distinctBase(it))) else: @[], - V: data.v.int64, + V: data.v.uint64, R: data.r, S: data.s) rlpBytes = @@ -1567,7 +1566,7 @@ proc ETHTransactionsCreateFromJson( if data.hash.asEth2Digest != hash: return nil - template isEven(x: int64): bool = + template isEven(x: uint64): bool = (x and 1) == 0 # Compute from execution address @@ -1614,9 +1613,9 @@ proc ETHTransactionsCreateFromJson( chainId: distinctBase(tx.chainId).u256, `from`: ExecutionAddress(data: fromAddress), nonce: tx.nonce, - maxPriorityFeePerGas: tx.maxPriorityFee.uint64, - maxFeePerGas: tx.maxFee.uint64, - gas: tx.gasLimit.uint64, + maxPriorityFeePerGas: tx.maxPriorityFeePerGas, + maxFeePerGas: tx.maxFeePerGas, + gas: tx.gasLimit, destinationType: destinationType, to: ExecutionAddress(data: toAddress), value: tx.value, @@ -2178,7 +2177,7 @@ proc ETHReceiptsCreateFromJson( else: default(ExecutionHash256), cumulativeGasUsed: distinctBase(data.cumulativeGasUsed).GasInt, - bloom: distinctBase(data.logsBloom), + logsBloom: distinctBase(data.logsBloom), logs: data.logs.mapIt(Log( address: distinctBase(it.address), topics: it.topics.mapIt(distinctBase(it)), @@ -2198,7 +2197,7 @@ proc ETHReceiptsCreateFromJson( root: rec.hash, status: rec.status, gasUsed: distinctBase(data.gasUsed), # Validated during sanity checks. - logsBloom: BloomLogs(data: rec.bloom), + logsBloom: BloomLogs(data: rec.logsBloom), logs: rec.logs.mapIt(ETHLog( address: ExecutionAddress(data: it.address), topics: it.topics.mapIt(Eth2Digest(data: it)), diff --git a/beacon_chain/networking/network_metadata.nim b/beacon_chain/networking/network_metadata.nim index 7d7d8c954..3ba5f45b7 100644 --- a/beacon_chain/networking/network_metadata.nim +++ b/beacon_chain/networking/network_metadata.nim @@ -78,7 +78,7 @@ type # additional checks to ensure we are connecting to a web3 provider # serving data for the same network. The value can be set to `None` # for custom networks and testing purposes. - eth1Network*: Option[Eth1Network] + eth1Network*: Opt[Eth1Network] cfg*: RuntimeConfig # Parsing `enr.Records` is still not possible at compile-time @@ -112,10 +112,10 @@ proc readBootEnr*(path: string): seq[string] {.raises: [IOError].} = proc loadEth2NetworkMetadata*( path: string, - eth1Network = none(Eth1Network), + eth1Network = Opt.none(Eth1Network), isCompileTime = false, - downloadGenesisFrom = none(DownloadInfo), - useBakedInGenesis = none(string) + downloadGenesisFrom = Opt.none(DownloadInfo), + useBakedInGenesis = Opt.none(string) ): Result[Eth2NetworkMetadata, string] {.raises: [IOError, PresetFileError].} = # Load data in mainnet format # https://github.com/eth-clients/mainnet @@ -208,9 +208,9 @@ proc loadEth2NetworkMetadata*( proc loadCompileTimeNetworkMetadata( path: string, - eth1Network = none(Eth1Network), - useBakedInGenesis = none(string), - downloadGenesisFrom = none(DownloadInfo)): Eth2NetworkMetadata = + eth1Network = Opt.none(Eth1Network), + useBakedInGenesis = Opt.none(string), + downloadGenesisFrom = Opt.none(DownloadInfo)): Eth2NetworkMetadata = if fileExists(path & "/config.yaml"): try: let res = loadEth2NetworkMetadata( @@ -255,13 +255,13 @@ when const_preset == "gnosis": const gnosisMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/gnosis-chain-configs/mainnet", - none(Eth1Network), - useBakedInGenesis = some "gnosis") + Opt.none(Eth1Network), + useBakedInGenesis = Opt.some "gnosis") chiadoMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/gnosis-chain-configs/chiado", - none(Eth1Network), - useBakedInGenesis = some "chiado") + Opt.none(Eth1Network), + useBakedInGenesis = Opt.some "chiado") static: for network in [gnosisMetadata, chiadoMetadata]: @@ -300,20 +300,20 @@ elif const_preset == "mainnet": const mainnetMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/mainnet/metadata", - some mainnet, - useBakedInGenesis = some "mainnet") + Opt.some mainnet, + useBakedInGenesis = Opt.some "mainnet") holeskyMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/holesky/custom_config_data", - some holesky, - downloadGenesisFrom = some DownloadInfo( + Opt.some holesky, + downloadGenesisFrom = Opt.some DownloadInfo( url: "https://github.com/status-im/nimbus-eth2/releases/download/v23.9.1/holesky-genesis.ssz.sz", digest: Eth2Digest.fromHex "0x0ea3f6f9515823b59c863454675fefcd1d8b4f2dbe454db166206a41fda060a0")) sepoliaMetadata = loadCompileTimeNetworkMetadata( vendorDir & "/sepolia/bepolia", - some sepolia, - useBakedInGenesis = some "sepolia") + Opt.some sepolia, + useBakedInGenesis = Opt.some "sepolia") static: for network in [mainnetMetadata, sepoliaMetadata, holeskyMetadata]: diff --git a/beacon_chain/nimbus_light_client.nim b/beacon_chain/nimbus_light_client.nim index abd515bee..2f78df875 100644 --- a/beacon_chain/nimbus_light_client.nim +++ b/beacon_chain/nimbus_light_client.nim @@ -123,7 +123,7 @@ programMain: headBlockHash = payload.block_hash, safeBlockHash = payload.block_hash, # stub value finalizedBlockHash = ZERO_HASH, - payloadAttributes = none(consensusFork.PayloadAttributes)) + payloadAttributes = Opt.none(consensusFork.PayloadAttributes)) else: discard optimisticProcessor = initOptimisticProcessor( getBeaconTime, optimisticHandler) diff --git a/beacon_chain/spec/helpers.nim b/beacon_chain/spec/helpers.nim index b4521250a..ee376329d 100644 --- a/beacon_chain/spec/helpers.nim +++ b/beacon_chain/spec/helpers.nim @@ -484,24 +484,24 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = txRoot = payload.computeTransactionsTrieRoot() withdrawalsRoot = when typeof(payload).kind >= ConsensusFork.Capella: - some payload.computeWithdrawalsTrieRoot() + Opt.some payload.computeWithdrawalsTrieRoot() else: - none(ExecutionHash256) + Opt.none(ExecutionHash256) blobGasUsed = when typeof(payload).kind >= ConsensusFork.Deneb: - some payload.blob_gas_used + Opt.some payload.blob_gas_used else: - none(uint64) + Opt.none(uint64) excessBlobGas = when typeof(payload).kind >= ConsensusFork.Deneb: - some payload.excess_blob_gas + Opt.some payload.excess_blob_gas else: - none(uint64) + Opt.none(uint64) parentBeaconBlockRoot = when typeof(payload).kind >= ConsensusFork.Deneb: - some ExecutionHash256(data: blck.parent_root.data) + Opt.some ExecutionHash256(data: blck.parent_root.data) else: - none(ExecutionHash256) + Opt.none(ExecutionHash256) ExecutionBlockHeader( parentHash : payload.parent_hash, @@ -509,17 +509,17 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = coinbase : EthAddress payload.fee_recipient.data, stateRoot : payload.state_root, txRoot : txRoot, - receiptRoot : payload.receipts_root, - bloom : payload.logs_bloom.data, + receiptsRoot : payload.receipts_root, + logsBloom : payload.logs_bloom.data, difficulty : default(DifficultyInt), - blockNumber : payload.block_number.u256, + number : payload.block_number, gasLimit : cast[GasInt](payload.gas_limit), gasUsed : cast[GasInt](payload.gas_used), timestamp : EthTime(int64.saturate payload.timestamp), extraData : payload.extra_data.asSeq, - mixDigest : payload.prev_randao, # EIP-4399 `mixDigest` -> `prevRandao` + mixHash : payload.prev_randao, # EIP-4399 `mixHash` -> `prevRandao` nonce : default(BlockNonce), - fee : some payload.base_fee_per_gas, + baseFeePerGas : Opt.some payload.base_fee_per_gas, withdrawalsRoot : withdrawalsRoot, blobGasUsed : blobGasUsed, # EIP-4844 excessBlobGas : excessBlobGas, # EIP-4844 diff --git a/ncli/ncli_testnet.nim b/ncli/ncli_testnet.nim index b9e0bbb67..de8c98b65 100644 --- a/ncli/ncli_testnet.nim +++ b/ncli/ncli_testnet.nim @@ -289,7 +289,7 @@ template `as`(address: Eth1Address, T: type bellatrix.ExecutionAddress): T = template `as`(address: BlockHash, T: type Eth2Digest): T = asEth2Digest(address) -func getOrDefault[T](x: Option[T]): T = +func getOrDefault[T](x: Opt[T]): T = if x.isSome: x.get else: @@ -505,25 +505,25 @@ proc doCreateTestnet*(config: CliConfig, proc deployContract(web3: Web3, code: seq[byte]): Future[ReceiptObject] {.async.} = let tr = TransactionArgs( - `from`: web3.defaultAccount.some, - data: code.some, - gas: Quantity(3000000).some, - gasPrice: Quantity(1).some) + `from`: Opt.some web3.defaultAccount, + data: Opt.some code, + gas: Opt.some Quantity(3000000), + gasPrice: Opt.some Quantity(1)) let r = await web3.send(tr) result = await web3.getMinedTransactionReceipt(r) proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] = let tr = TransactionArgs( - `from`: web3.defaultAccount.some, + `from`: Opt.some web3.defaultAccount, # TODO: Force json-rpc to generate 'data' field # should not be needed anymore, new execution-api schema # is using `input` field - data: some(newSeq[byte]()), - gas: Quantity(3000000).some, - gasPrice: Quantity(1).some, - value: some(valueEth.u256 * 1000000000000000000.u256), - to: some(to)) + data: Opt.some(newSeq[byte]()), + gas: Opt.some Quantity(3000000), + gasPrice: Opt.some Quantity(1), + value: Opt.some(valueEth.u256 * 1000000000000000000.u256), + to: Opt.some(to)) web3.send(tr) type @@ -535,7 +535,7 @@ func ethToWei(eth: UInt256): UInt256 = proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} = result = await newWeb3(web3Url) if privateKey.len != 0: - result.privateKey = some(keys.PrivateKey.fromHex(privateKey)[]) + result.privateKey = Opt.some(keys.PrivateKey.fromHex(privateKey)[]) else: let accounts = await result.provider.eth_accounts() doAssert(accounts.len > 0) diff --git a/research/fakeee.nim b/research/fakeee.nim index 55f6a2842..c88ecc02a 100644 --- a/research/fakeee.nim +++ b/research/fakeee.nim @@ -57,7 +57,7 @@ proc setupEngineAPI*(server: RpcServer) = # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/paris.md#engine_forkchoiceupdatedv1 server.rpc("engine_forkchoiceUpdatedV1") do( update: ForkchoiceStateV1, - payloadAttributes: Option[PayloadAttributesV1]) -> ForkchoiceUpdatedResponse: + payloadAttributes: Opt[PayloadAttributesV1]) -> ForkchoiceUpdatedResponse: info "engine_forkchoiceUpdatedV1", update, payloadAttributes @@ -68,7 +68,7 @@ proc setupEngineAPI*(server: RpcServer) = # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/shanghai.md#engine_forkchoiceupdatedv2 server.rpc("engine_forkchoiceUpdatedV2") do( - forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributesV2]) -> ForkchoiceUpdatedResponse: + forkchoiceState: ForkchoiceStateV1, payloadAttributes: Opt[PayloadAttributesV2]) -> ForkchoiceUpdatedResponse: info "engine_forkchoiceUpdatedV2", forkchoiceState, payloadAttributes diff --git a/research/wss_sim.nim b/research/wss_sim.nim index 735eb6cf6..d93401f7c 100644 --- a/research/wss_sim.nim +++ b/research/wss_sim.nim @@ -134,7 +134,7 @@ cli do(validatorsDir: string, secretsDir: string, headBlockHash = payload.block_hash, safeBlockHash = payload.block_hash, finalizedBlockHash = ZERO_HASH, - payloadAttributes = none(consensusFork.PayloadAttributes)) + payloadAttributes = Opt.none(consensusFork.PayloadAttributes)) if status != PayloadExecutionStatus.valid: continue diff --git a/tests/testblockutil.nim b/tests/testblockutil.nim index 7820fb557..e3a1dba83 100644 --- a/tests/testblockutil.nim +++ b/tests/testblockutil.nim @@ -118,8 +118,6 @@ proc build_empty_merge_execution_payload(state: bellatrix.BeaconState): bellatrix.ExecutionPayloadForSigning(executionPayload: payload, blockValue: Wei.zero) -from stew/saturating_arith import saturate - proc build_empty_execution_payload( state: bellatrix.BeaconState, feeRecipient: Eth1Address): bellatrix.ExecutionPayloadForSigning = @@ -129,8 +127,8 @@ proc build_empty_execution_payload( latest = state.latest_execution_payload_header timestamp = compute_timestamp_at_slot(state, state.slot) randao_mix = get_randao_mix(state, get_current_epoch(state)) - base_fee = calcEip1599BaseFee(GasInt.saturate latest.gas_limit, - GasInt.saturate latest.gas_used, + base_fee = calcEip1599BaseFee(latest.gas_limit, + latest.gas_used, latest.base_fee_per_gas) var payload = bellatrix.ExecutionPayloadForSigning( diff --git a/vendor/nim-eth b/vendor/nim-eth index c3f9160fd..9b6497ed8 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit c3f9160fd23010f65b1d4756cfd5c04272c20264 +Subproject commit 9b6497ed8a05ba25ee47142f3fc1f61742b51a6c diff --git a/vendor/nim-web3 b/vendor/nim-web3 index 46b4b4c8b..b705f8164 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit 46b4b4c8bc42013196a6290ee53029131f97931a +Subproject commit b705f816439f0068ece8c234336bc7093222d00f From 3d65bdcb09e4ad6b5039dfc7beecae20f6924c0d Mon Sep 17 00:00:00 2001 From: tersec Date: Wed, 12 Jun 2024 12:30:17 +0000 Subject: [PATCH 32/33] Revert "bump nim-bearssl for gcc-14 compatibility (#6337)" (#6346) This reverts commit 45d50f041a5be9787b73cf01ecda1aabb4bf4a5c. --- tests/test_sync_manager.nim | 2 +- vendor/nim-bearssl | 2 +- vendor/nim-chronos | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_sync_manager.nim b/tests/test_sync_manager.nim index 5d7fa83cf..65fa75cd0 100644 --- a/tests/test_sync_manager.nim +++ b/tests/test_sync_manager.nim @@ -884,7 +884,7 @@ suite "SyncManager test suite": # Push a single request that will fail with all blocks being unviable var f11 = queue.push(r11, chain.getSlice(startSlot, r11), Opt.none(seq[BlobSidecars])) - discard await f11.withTimeout(1.seconds) + discard await f11.withTimeout(100.milliseconds) check: f11.finished == true diff --git a/vendor/nim-bearssl b/vendor/nim-bearssl index a806cbfab..d81b37dc2 160000 --- a/vendor/nim-bearssl +++ b/vendor/nim-bearssl @@ -1 +1 @@ -Subproject commit a806cbfab5fe8de49c76139f8705fff79daf99ee +Subproject commit d81b37dc2011bf3a2bd93500489877c2ce8e6ac3 diff --git a/vendor/nim-chronos b/vendor/nim-chronos index 1b9d9253e..8a306763c 160000 --- a/vendor/nim-chronos +++ b/vendor/nim-chronos @@ -1 +1 @@ -Subproject commit 1b9d9253e89445d585d0fff39cc0d19254fdfd0d +Subproject commit 8a306763cec8105fa83574b56734b0f66823f844 From d14293dec2079a805ed6777b3fabfb7bd7b136c7 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Thu, 13 Jun 2024 13:38:49 +0200 Subject: [PATCH 33/33] bump 'nim-serialization' to `005ee90cb6aa563cdd690910455ea05f916ead3f` - Work around Nim bug that erases type `{.pragma.}` when making alias --- vendor/nim-serialization | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/nim-serialization b/vendor/nim-serialization index afae13ada..005ee90cb 160000 --- a/vendor/nim-serialization +++ b/vendor/nim-serialization @@ -1 +1 @@ -Subproject commit afae13adac25b6fa98bacf4b9f38458dc64317b0 +Subproject commit 005ee90cb6aa563cdd690910455ea05f916ead3f