Re-enabled requireAllFields after a fix in nim-json-serialization (#3871)

* Re-enabled requireAllFields after a fix in nim-json-serialization

The problem was that `Option[T]` fields were not treated as optional
when requireAllFields is set to true. This is now fixed in NJS.

* Add makefile targets for recreating the Jenkins simulation runs

* Fix a discrepancy with the REST spec
This commit is contained in:
zah 2022-07-15 03:19:19 +03:00 committed by GitHub
parent 798fa69647
commit 20d45e69b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 19 deletions

13
Jenkinsfile vendored
View File

@ -49,17 +49,8 @@ def runStages(nodeDir) {
stage("Testnet finalization") { timeout(75) { stage("Testnet finalization") { timeout(75) {
// EXECUTOR_NUMBER will be 0 or 1, since we have 2 executors per Jenkins node // EXECUTOR_NUMBER will be 0 or 1, since we have 2 executors per Jenkins node
sh """#!/bin/bash sh """#!/bin/bash
set -e make local-testnet-minimal
./scripts/launch_local_testnet.sh --preset minimal --nodes 4 --stop-at-epoch 5 --disable-htop --enable-logtrace \ make local-testnet-mainnet
--data-dir local_testnet0_data --base-port \$(( 9000 + EXECUTOR_NUMBER * 100 )) --base-rest-port \
\$(( 7000 + EXECUTOR_NUMBER * 100 )) --base-metrics-port \$(( 8008 + EXECUTOR_NUMBER * 100 )) --timeout 600 \
--kill-old-processes --light-clients 1 \
-- --verify-finalization --discv5:no
./scripts/launch_local_testnet.sh --nodes 4 --stop-at-epoch 5 --disable-htop --enable-logtrace \
--data-dir local_testnet1_data --base-port \$(( 9000 + EXECUTOR_NUMBER * 100 )) --base-rest-port \
\$(( 7000 + EXECUTOR_NUMBER * 100 )) --base-metrics-port \$(( 8008 + EXECUTOR_NUMBER * 100 )) --timeout 2400 \
--kill-old-processes --light-clients 1 \
-- --verify-finalization --discv5:no
""" """
} } } }
} catch(e) { } catch(e) {

View File

@ -157,6 +157,41 @@ restapi-test:
--resttest-delay 30 \ --resttest-delay 30 \
--kill-old-processes --kill-old-processes
local-testnet-minimal:
./scripts/launch_local_testnet.sh \
--preset minimal \
--nodes 4 \
--stop-at-epoch 5 \
--disable-htop \
--enable-logtrace \
--data-dir local_testnet0_data \
--base-port $$(( 9100 + EXECUTOR_NUMBER * 100 )) \
--base-rest-port $$(( 7100 + EXECUTOR_NUMBER * 100 )) \
--base-metrics-port $$(( 8108 + EXECUTOR_NUMBER * 100 )) \
--timeout 600 \
--kill-old-processes \
--light-clients 1 \
-- \
--verify-finalization \
--discv5:no
local-testnet-mainnet:
./scripts/launch_local_testnet.sh \
--nodes 4 \
--stop-at-epoch 5 \
--disable-htop \
--enable-logtrace \
--data-dir local_testnet1_data \
--base-port $$(( 9100 + EXECUTOR_NUMBER * 100 )) \
--base-rest-port $$(( 7100 + EXECUTOR_NUMBER * 100 )) \
--base-metrics-port $$(( 8108 + EXECUTOR_NUMBER * 100 )) \
--timeout 2400 \
--kill-old-processes \
--light-clients 1 \
-- \
--verify-finalization \
--discv5:no
# test binaries that can output an XML report # test binaries that can output an XML report
XML_TEST_BINARIES := \ XML_TEST_BINARIES := \
consensus_spec_tests_mainnet \ consensus_spec_tests_mainnet \

View File

@ -2179,11 +2179,12 @@ proc decodeBody*[T](t: typedesc[T],
let data = let data =
try: try:
RestJson.decode(body.data, T, RestJson.decode(body.data, T,
requireAllFields = false, requireAllFields = true,
allowUnknownFields = true) allowUnknownFields = true)
except SerializationError as exc: except SerializationError as exc:
debug "Failed to deserialize REST JSON data", debug "Failed to deserialize REST JSON data",
err = exc.formatMsg("<data>") err = exc.formatMsg("<data>"),
data = string.fromBytes(body.data)
return err("Unable to deserialize data") return err("Unable to deserialize data")
except CatchableError: except CatchableError:
return err("Unexpected deserialization error") return err("Unexpected deserialization error")
@ -2233,11 +2234,12 @@ proc decodeBytes*[T: DecodeTypes](t: typedesc[T], value: openArray[byte],
of "application/json": of "application/json":
try: try:
ok RestJson.decode(value, T, ok RestJson.decode(value, T,
requireAllFields = false, requireAllFields = true,
allowUnknownFields = true) allowUnknownFields = true)
except SerializationError as exc: except SerializationError as exc:
debug "Failed to deserialize REST JSON data", debug "Failed to deserialize REST JSON data",
err = exc.formatMsg("<data>") err = exc.formatMsg("<data>"),
data = string.fromBytes(value)
err("Serialization error") err("Serialization error")
else: else:
err("Content-Type not supported") err("Content-Type not supported")

View File

@ -560,7 +560,7 @@ type
GetStateValidatorBalancesResponse* = DataEnclosedObject[seq[RestValidatorBalance]] GetStateValidatorBalancesResponse* = DataEnclosedObject[seq[RestValidatorBalance]]
GetStateValidatorResponse* = DataEnclosedObject[RestValidator] GetStateValidatorResponse* = DataEnclosedObject[RestValidator]
GetStateValidatorsResponse* = DataEnclosedObject[seq[RestValidator]] GetStateValidatorsResponse* = DataEnclosedObject[seq[RestValidator]]
GetSyncCommitteeDutiesResponse* = DataRootEnclosedObject[seq[RestSyncCommitteeDuty]] GetSyncCommitteeDutiesResponse* = DataEnclosedObject[seq[RestSyncCommitteeDuty]]
GetSyncingStatusResponse* = DataEnclosedObject[RestSyncInfo] GetSyncingStatusResponse* = DataEnclosedObject[RestSyncInfo]
GetVersionResponse* = DataEnclosedObject[RestNodeVersion] GetVersionResponse* = DataEnclosedObject[RestNodeVersion]
GetEpochSyncCommitteesResponse* = DataEnclosedObject[RestEpochSyncCommittee] GetEpochSyncCommitteesResponse* = DataEnclosedObject[RestEpochSyncCommittee]

@ -1 +1 @@
Subproject commit 5a7f9a86cb201606ae669ed4f7f605047c26628c Subproject commit 97cf1841190277ed985d1ead88e7712aaf0f3f74

@ -1 +1 @@
Subproject commit 1d33fa3ced6bc274ed43d99345ceb9cd6bb4dd24 Subproject commit 493d18b8292fc03aa4f835fd825dea1183f97466

2
vendor/nim-stew vendored

@ -1 +1 @@
Subproject commit 4cab7b08793d25c311efe88d54f948815643bc41 Subproject commit b55c5a6d7496159a261186807d9bbe3f6f5dac38