Skip to content

Commit

Permalink
21.10.9 release (#3305)
Browse files Browse the repository at this point in the history
* make ethFeeHistory accept hex values for blockCount (#3302)

Signed-off-by: garyschulte <[email protected]>

* updated changelog

Signed-off-by: Justin Florentine <[email protected]>

Co-authored-by: Diego López León <[email protected]>
Co-authored-by: garyschulte <[email protected]>
  • Loading branch information
3 people authored Jan 19, 2022
1 parent e0e9596 commit 8f465c0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 21.10.9

### Bug Fixes
- Fix regression on cors-origin star value
- Fix for ethFeeHistory accepting hex values for blockCount

## 21.10.8

### Additions and Improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ private String buildCorsRegexFromConfig() {
return "";
}
if (config.getCorsAllowedDomains().contains("*")) {
return "*";
return ".*";
} else {
final StringJoiner stringJoiner = new StringJoiner("|");
config.getCorsAllowedDomains().stream().filter(s -> !s.isEmpty()).forEach(stringJoiner::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
Expand Down Expand Up @@ -64,7 +65,11 @@ public String getName() {
public JsonRpcResponse response(final JsonRpcRequestContext request) {
final Object requestId = request.getRequest().getId();

final long blockCount = request.getRequiredParameter(0, Long.class);
final long blockCount =
Optional.of(request.getRequiredParameter(0, UnsignedLongParameter.class))
.map(UnsignedLongParameter::getValue)
.orElse(0L);

if (blockCount < 1 || blockCount > 1024) {
return new JsonRpcErrorResponse(requestId, JsonRpcError.INVALID_PARAMS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public UnsignedLongParameter(final String value) {
checkArgument(this.value >= 0);
}

@JsonCreator
public UnsignedLongParameter(final long value) {
this.value = value;
checkArgument(this.value >= 0);
}

public long getValue() {
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ public void requestWithAnyOriginShouldSucceedWhenCorsIsStart() throws Exception
}
}

@Test
public void requestFromBrowserExtensionShouldSucceedWhenCorsIsStar() throws Exception {
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("*");

final Request request =
new Request.Builder()
.url(jsonRpcHttpService.url())
.header("Origin", "moz-extension://802123e4-a916-2d4e-bebf-384b0e2e86dd")
.build();

try (final Response response = client.newCall(request).execute()) {
assertThat(response.isSuccessful()).isTrue();
}
}

@Test
public void requestWithAccessControlRequestMethodShouldReturnAllowedHeaders() throws Exception {
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("http://foo.io");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public void params() {
feeHistoryRequest(1, "latest");
// should pass because both required params and optional param given
feeHistoryRequest(1, "latest", new double[] {1, 20.4});
// should pass because both required params and optional param given
feeHistoryRequest("0x1", "latest", new double[] {1, 20.4});
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=21.10.9-SNAPSHOT
version=21.10.9

# Workaround for Java 16 and spotless bug 834 https://github.com/diffplug/spotless/issues/834
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
Expand Down

0 comments on commit 8f465c0

Please sign in to comment.