-
Notifications
You must be signed in to change notification settings - Fork 834
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
implement engine_getBlobsV1 #7553
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5fa9138
implement engine_getBlobsV1
pinges 0a8de78
merge main
pinges d9c272b
fix java doc
pinges 9c3f51f
Merge branch 'main' of github.com:hyperledger/besu into engine_getBlobV1
pinges c4324c3
Update ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/j…
pinges e944868
fix test
pinges 5d51a16
Merge branch 'main' of github.com:hyperledger/besu into engine_getBlobV1
pinges 8350a15
Merge branch 'engine_getBlobV1' of github.com:pinges/besu into engine…
pinges c1e1a46
Merge branch 'main' of github.com:hyperledger/besu into engine_getBlobV1
pinges 300a035
move logic into transaction pool
pinges 110d6bd
changes after reviews
pinges 4ca1dc1
Merge branch 'main' of github.com:hyperledger/besu into engine_getBlobV1
pinges cdec0d1
remove unused mock
pinges bdbd0cc
spotless
pinges a066ed7
move chnagelog entry
pinges 5797063
merge main
pinges File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...a/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetBlobsV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright contributors to Hyperledger Besu. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine; | ||
|
||
import org.hyperledger.besu.datatypes.BlobsWithCommitments; | ||
import org.hyperledger.besu.datatypes.VersionedHash; | ||
import org.hyperledger.besu.ethereum.ProtocolContext; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlobAndProofV1; | ||
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
import io.vertx.core.Vertx; | ||
|
||
/** | ||
* #### Specification | ||
* | ||
* <p>1. Given an array of blob versioned hashes client software **MUST** respond with an array of | ||
* `BlobAndProofV1` objects with matching versioned hashes, respecting the order of versioned hashes | ||
* in the input array. | ||
* | ||
* <p>2. Client software **MUST** place responses in the order given in the request, using `null` | ||
* for any missing blobs. For instance, if the request is `[A_versioned_hash, B_versioned_hash, | ||
* C_versioned_hash]` and client software has data for blobs `A` and `C`, but doesn't have data for | ||
* `B`, the response **MUST** be `[A, null, C]`. | ||
* | ||
* <p>3. Client software **MUST** support request sizes of at least 128 blob versioned hashes. The | ||
* client **MUST** return `-38004: Too large request` error if the number of requested blobs is too | ||
* large. | ||
* | ||
* <p>4. Client software **MAY** return an array of all `null` entries if syncing or otherwise | ||
* unable to serve blob pool data. | ||
* | ||
* <p>5. Callers **MUST** consider that execution layer clients may prune old blobs from their pool, | ||
* and will respond with `null` if a blob has been pruned. | ||
*/ | ||
public class EngineGetBlobsV1 extends ExecutionEngineJsonRpcMethod { | ||
|
||
private final TransactionPool transactionPool; | ||
|
||
public EngineGetBlobsV1( | ||
final Vertx vertx, | ||
final ProtocolContext protocolContext, | ||
final EngineCallListener engineCallListener, | ||
final TransactionPool transactionPool) { | ||
super(vertx, protocolContext, engineCallListener); | ||
this.transactionPool = transactionPool; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "engine_getBlobsV1"; | ||
} | ||
|
||
@Override | ||
public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) { | ||
final VersionedHash[] versionedHashes; | ||
try { | ||
versionedHashes = requestContext.getRequiredParameter(0, VersionedHash[].class); | ||
} catch (JsonRpcParameter.JsonRpcParameterException e) { | ||
throw new InvalidJsonRpcParameters( | ||
"Invalid versioned hashes parameter (index 0)", | ||
RpcErrorType.INVALID_VERSIONED_HASHES_PARAMS, | ||
e); | ||
} | ||
|
||
if (versionedHashes.length > 128) { | ||
return new JsonRpcErrorResponse( | ||
requestContext.getRequest().getId(), | ||
RpcErrorType.INVALID_ENGINE_GET_BLOBS_V1_TOO_LARGE_REQUEST); | ||
} | ||
|
||
final List<BlobAndProofV1> result = getBlobV1Result(versionedHashes); | ||
|
||
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result); | ||
} | ||
|
||
private @Nonnull List<BlobAndProofV1> getBlobV1Result(final VersionedHash[] versionedHashes) { | ||
return Arrays.stream(versionedHashes) | ||
.map(transactionPool::getBlobQuad) | ||
.map(this::getBlobAndProofV1) | ||
.toList(); | ||
} | ||
|
||
private @Nullable BlobAndProofV1 getBlobAndProofV1(final BlobsWithCommitments.BlobQuad bq) { | ||
if (bq == null) { | ||
return null; | ||
} | ||
return new BlobAndProofV1( | ||
bq.blob().getData().toHexString(), bq.kzgProof().getData().toHexString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlobAndProofV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright contributors to Hyperledger Besu. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
|
||
/** | ||
* The result of the eth_getBlobAndProofV1 JSON-RPC method contains an array of BlobAndProofV1. | ||
* BlobAndProofV1 contains the blob data and the kzg proof for the blob. | ||
*/ | ||
@JsonPropertyOrder({"blob", "proof"}) | ||
public class BlobAndProofV1 { | ||
|
||
private final String blob; | ||
|
||
private final String proof; | ||
|
||
public BlobAndProofV1(final String blob, final String proof) { | ||
this.blob = blob; | ||
this.proof = proof; | ||
} | ||
|
||
public String getProof() { | ||
return proof; | ||
} | ||
|
||
public String getBlob() { | ||
return blob; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
typo