-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change skip_randao_verification
param to string
#8338
Changes from 13 commits
7004354
daeabe1
a522f7d
21e98ef
35600b5
0fa52b1
3401cff
6ec7d32
12e172d
73cfe23
035b248
8f29351
a88f5f4
52fdec6
2883e18
efa5b69
6278f89
683724a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,7 @@ public class EndpointMetadata { | |
private final Map<String, StringValueTypeDefinition<?>> pathParams; | ||
private final Map<String, StringValueTypeDefinition<?>> requiredQueryParams; | ||
private final Map<String, StringValueTypeDefinition<?>> queryParams; | ||
private final Map<String, StringValueTypeDefinition<?>> queryParamsAllowEmpty; | ||
private final Map<String, StringValueTypeDefinition<?>> queryListParams; | ||
private final Map<String, StringValueTypeDefinition<?>> requiredHeaders; | ||
private final Map<String, StringValueTypeDefinition<?>> headers; | ||
|
@@ -105,6 +106,7 @@ private EndpointMetadata( | |
final List<String> tags, | ||
final Map<String, StringValueTypeDefinition<?>> pathParams, | ||
final Map<String, StringValueTypeDefinition<?>> queryParams, | ||
final Map<String, StringValueTypeDefinition<?>> queryParamsAllowEmpty, | ||
final Map<String, StringValueTypeDefinition<?>> requiredQueryParams, | ||
final Map<String, StringValueTypeDefinition<?>> queryListParams, | ||
final Map<String, StringValueTypeDefinition<?>> requiredHeaders, | ||
|
@@ -124,6 +126,7 @@ private EndpointMetadata( | |
this.tags = tags; | ||
this.pathParams = pathParams; | ||
this.queryParams = queryParams; | ||
this.queryParamsAllowEmpty = queryParamsAllowEmpty; | ||
this.requiredQueryParams = requiredQueryParams; | ||
this.queryListParams = queryListParams; | ||
this.requiredHeaders = requiredHeaders; | ||
|
@@ -223,12 +226,15 @@ public StringValueTypeDefinition<?> getQueryParameterDefinition(final String par | |
checkArgument( | ||
requiredQueryParams.containsKey(parameterName) | ||
|| queryParams.containsKey(parameterName) | ||
|| queryParamsAllowEmpty.containsKey(parameterName) | ||
|| queryListParams.containsKey(parameterName), | ||
"Query parameter " + parameterName + " was not found in endpoint metadata"); | ||
if (requiredQueryParams.containsKey(parameterName)) { | ||
return requiredQueryParams.get(parameterName); | ||
} else if (queryParams.containsKey(parameterName)) { | ||
return queryParams.get(parameterName); | ||
} else if (queryParamsAllowEmpty.containsKey(parameterName)) { | ||
return queryParamsAllowEmpty.get(parameterName); | ||
} | ||
|
||
return queryListParams.get(parameterName); | ||
|
@@ -308,19 +314,21 @@ public void writeOpenApi(final JsonGenerator gen) throws IOException { | |
if (deprecated) { | ||
gen.writeBooleanField("deprecated", true); | ||
} | ||
if (pathParams.size() > 0 | ||
|| queryParams.size() > 0 | ||
|| requiredQueryParams.size() > 0 | ||
|| queryListParams.size() > 0 | ||
|| requiredHeaders.size() > 0 | ||
|| headers.size() > 0) { | ||
if (!pathParams.isEmpty() | ||
|| !queryParams.isEmpty() | ||
|| !queryParamsAllowEmpty.isEmpty() | ||
|| !requiredQueryParams.isEmpty() | ||
|| !queryListParams.isEmpty() | ||
|| !requiredHeaders.isEmpty() | ||
|| !headers.isEmpty()) { | ||
gen.writeArrayFieldStart("parameters"); | ||
writeParameters(gen, pathParams, "path", true, false); | ||
writeParameters(gen, requiredQueryParams, "query", true, false); | ||
writeParameters(gen, queryParams, "query", false, false); | ||
writeParameters(gen, queryListParams, "query", false, true); | ||
writeParameters(gen, requiredHeaders, "header", true, false); | ||
writeParameters(gen, headers, "header", false, false); | ||
writeParameters(gen, pathParams, "path", true, false, false); | ||
writeParameters(gen, requiredQueryParams, "query", true, false, false); | ||
writeParameters(gen, queryParams, "query", false, false, false); | ||
writeParameters(gen, queryParamsAllowEmpty, "query", false, false, true); | ||
writeParameters(gen, queryListParams, "query", false, true, false); | ||
writeParameters(gen, requiredHeaders, "header", true, false, false); | ||
writeParameters(gen, headers, "header", false, false, false); | ||
gen.writeEndArray(); | ||
} | ||
|
||
|
@@ -364,14 +372,18 @@ private void writeParameters( | |
final Map<String, StringValueTypeDefinition<?>> fields, | ||
final String parameterUsedIn, | ||
final boolean isMandatoryField, | ||
final boolean isList) | ||
final boolean isList, | ||
final boolean allowEmptyValue) | ||
throws IOException { | ||
for (Map.Entry<String, StringValueTypeDefinition<?>> entry : fields.entrySet()) { | ||
gen.writeStartObject(); | ||
gen.writeObjectField("name", entry.getKey()); | ||
if (isMandatoryField) { | ||
gen.writeObjectField("required", true); | ||
} | ||
if (allowEmptyValue) { | ||
gen.writeObjectField("allowEmptyValue", true); | ||
} | ||
gen.writeObjectField("in", parameterUsedIn); | ||
gen.writeFieldName("schema"); | ||
if (isList) { // Handle list parameter | ||
|
@@ -384,6 +396,7 @@ private void writeParameters( | |
} else { // Handle regular parameter | ||
entry.getValue().serializeOpenApiTypeOrReference(gen); | ||
} | ||
|
||
gen.writeEndObject(); | ||
} | ||
} | ||
|
@@ -430,6 +443,8 @@ public static class EndpointMetaDataBuilder { | |
private boolean requiredRequestBody = true; | ||
private final Map<String, StringValueTypeDefinition<?>> pathParams = new LinkedHashMap<>(); | ||
private final Map<String, StringValueTypeDefinition<?>> queryParams = new LinkedHashMap<>(); | ||
private final Map<String, StringValueTypeDefinition<?>> queryParamsAllowEmpty = | ||
new LinkedHashMap<>(); | ||
private final Map<String, StringValueTypeDefinition<?>> requiredQueryParams = | ||
new LinkedHashMap<>(); | ||
private final Map<String, StringValueTypeDefinition<?>> queryListParams = new LinkedHashMap<>(); | ||
|
@@ -464,21 +479,27 @@ public EndpointMetaDataBuilder pathParam(final ParameterMetadata<?> parameterMet | |
|
||
public EndpointMetaDataBuilder queryParam(final ParameterMetadata<?> parameterMetadata) { | ||
final String param = parameterMetadata.getName(); | ||
if (queryParams.containsKey(param) | ||
|| requiredQueryParams.containsKey(param) | ||
|| queryListParams.containsKey(param)) { | ||
if (queryParamAlreadyAdded(param)) { | ||
throw new IllegalStateException("Query parameters already contains " + param); | ||
} | ||
queryParams.put(parameterMetadata.getName(), parameterMetadata.getType()); | ||
return this; | ||
} | ||
|
||
public EndpointMetaDataBuilder queryParamAllowsEmpty( | ||
final ParameterMetadata<?> parameterMetadata) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. intelliJ suggesting to move to a dedicated method this snippet:
makes sense to me There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh i thought this was used somewhere - technically a list could be expressed as anyway - TL/DR, lets not do this. |
||
final String param = parameterMetadata.getName(); | ||
if (queryParamAlreadyAdded(param)) { | ||
throw new IllegalStateException("Query parameters already contains " + param); | ||
} | ||
queryParamsAllowEmpty.put(parameterMetadata.getName(), parameterMetadata.getType()); | ||
return this; | ||
} | ||
|
||
public EndpointMetaDataBuilder queryParamRequired( | ||
final ParameterMetadata<?> parameterMetadata) { | ||
final String param = parameterMetadata.getName(); | ||
if (queryParams.containsKey(param) | ||
|| requiredQueryParams.containsKey(param) | ||
|| queryListParams.containsKey(param)) { | ||
if (queryParamAlreadyAdded(param)) { | ||
throw new IllegalStateException("Query parameters already contains " + param); | ||
} | ||
requiredQueryParams.put(parameterMetadata.getName(), parameterMetadata.getType()); | ||
|
@@ -487,15 +508,20 @@ public EndpointMetaDataBuilder queryParamRequired( | |
|
||
public EndpointMetaDataBuilder queryListParam(final ParameterMetadata<?> parameterMetadata) { | ||
final String param = parameterMetadata.getName(); | ||
if (queryParams.containsKey(param) | ||
|| requiredQueryParams.containsKey(param) | ||
|| queryListParams.containsKey(param)) { | ||
if (queryParamAlreadyAdded(param)) { | ||
throw new IllegalStateException("Query parameters already contains " + param); | ||
} | ||
queryListParams.put(parameterMetadata.getName(), parameterMetadata.getType()); | ||
return this; | ||
} | ||
|
||
private boolean queryParamAlreadyAdded(final String param) { | ||
return queryParams.containsKey(param) | ||
|| queryParamsAllowEmpty.containsKey(param) | ||
|| requiredQueryParams.containsKey(param) | ||
|| queryListParams.containsKey(param); | ||
} | ||
|
||
public EndpointMetaDataBuilder headerRequired(final ParameterMetadata<?> headerMetadata) { | ||
checkRequestHeader(headerMetadata); | ||
requiredHeaders.put(headerMetadata.getName(), headerMetadata.getType()); | ||
|
@@ -752,6 +778,7 @@ public EndpointMetadata build() { | |
tags, | ||
pathParams, | ||
queryParams, | ||
queryParamsAllowEmpty, | ||
requiredQueryParams, | ||
queryListParams, | ||
requiredHeaders, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a must here - do we care?
i'm wondering if we check that at all, im guessing not. i'd just truncate before 'if this flag is set'
Skip verification of the randao_reveal value. Ignored in the Teku implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't care based on this comment: ethereum/beacon-APIs#222 (comment). Cehcked the other impl blockV2 and blinded_block didn't care about this param.
Changed the description as you suggested.