forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* json container for getting blob bundles * spdx headers, formatting, npe fix Signed-off-by: Justin Florentine <justin+github@florentine.us> Co-authored-by: Jason Frame <jason.frame@consensys.net> Co-authored-by: garyschulte <garyschulte@gmail.com>
- Loading branch information
1 parent
8e3a912
commit 5fa9433
Showing
24 changed files
with
787 additions
and
31 deletions.
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
18 changes: 18 additions & 0 deletions
18
datatypes/src/main/java/org/hyperledger/besu/datatypes/Blob.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,18 @@ | ||
/* | ||
* Copyright Hyperledger Besu Contributors. | ||
* | ||
* 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.datatypes; | ||
|
||
public class Blob {} |
18 changes: 18 additions & 0 deletions
18
datatypes/src/main/java/org/hyperledger/besu/datatypes/KZGCommitment.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,18 @@ | ||
/* | ||
* Copyright Hyperledger Besu Contributors. | ||
* | ||
* 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.datatypes; | ||
|
||
public class KZGCommitment {} |
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
89 changes: 89 additions & 0 deletions
89
...hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetBlobsBundleV1.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,89 @@ | ||
/* | ||
* Copyright Hyperledger Besu Contributors. | ||
* | ||
* 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.consensus.merge.blockcreation.MergeMiningCoordinator; | ||
import org.hyperledger.besu.ethereum.ProtocolContext; | ||
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.response.JsonRpcResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlobsBundleV1; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory; | ||
import org.hyperledger.besu.ethereum.core.Block; | ||
import org.hyperledger.besu.ethereum.core.BlockWithReceipts; | ||
import org.hyperledger.besu.ethereum.core.Transaction; | ||
import org.hyperledger.besu.ethereum.mainnet.TimestampSchedule; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
import io.vertx.core.Vertx; | ||
import org.apache.tuweni.bytes.Bytes; | ||
|
||
public class EngineGetBlobsBundleV1 extends AbstractEngineGetPayload { | ||
|
||
public EngineGetBlobsBundleV1( | ||
final Vertx vertx, | ||
final ProtocolContext protocolContext, | ||
final MergeMiningCoordinator mergeMiningCoordinator, | ||
final BlockResultFactory blockResultFactory, | ||
final EngineCallListener engineCallListener, | ||
final TimestampSchedule schedule) { | ||
super( | ||
vertx, | ||
protocolContext, | ||
mergeMiningCoordinator, | ||
blockResultFactory, | ||
engineCallListener, | ||
schedule); | ||
} | ||
|
||
@Override | ||
protected JsonRpcResponse createResponse( | ||
final JsonRpcRequestContext request, final BlockWithReceipts blockWithReceipts) { | ||
|
||
return new JsonRpcSuccessResponse( | ||
request.getRequest().getId(), createResponse(blockWithReceipts.getBlock())); | ||
} | ||
|
||
private BlobsBundleV1 createResponse(final Block block) { | ||
|
||
List<Bytes> kzgs = | ||
block.getBody().getTransactions().stream() | ||
.map(Transaction::getBlobsWithCommitments) | ||
.filter(Optional::isPresent) | ||
.map(Optional::get) | ||
.flatMap(b -> b.getKzgCommitments().stream()) | ||
.collect(Collectors.toList()); | ||
|
||
List<Bytes> blobs = | ||
block.getBody().getTransactions().stream() | ||
.map(Transaction::getBlobsWithCommitments) | ||
.filter(Optional::isPresent) | ||
.map(Optional::get) | ||
.flatMap(b -> b.getBlobs().stream()) | ||
.collect(Collectors.toList()); | ||
|
||
return new BlobsBundleV1(block.getHash(), kzgs, blobs); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return RpcMethod.ENGINE_GET_BLOBS_BUNDLE_V1.getMethodName(); | ||
} | ||
} |
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
79 changes: 79 additions & 0 deletions
79
...org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV3.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,79 @@ | ||
/* | ||
* Copyright Hyperledger Besu Contributors. | ||
* | ||
* 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.consensus.merge.blockcreation.MergeMiningCoordinator; | ||
import org.hyperledger.besu.ethereum.ProtocolContext; | ||
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.response.JsonRpcResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory; | ||
import org.hyperledger.besu.ethereum.core.BlockWithReceipts; | ||
import org.hyperledger.besu.ethereum.mainnet.DefaultTimestampSchedule; | ||
import org.hyperledger.besu.ethereum.mainnet.TimestampSchedule; | ||
|
||
import io.vertx.core.Vertx; | ||
|
||
public class EngineGetPayloadV3 extends AbstractEngineGetPayload { | ||
|
||
public EngineGetPayloadV3( | ||
final Vertx vertx, | ||
final ProtocolContext protocolContext, | ||
final MergeMiningCoordinator mergeMiningCoordinator, | ||
final BlockResultFactory blockResultFactory, | ||
final EngineCallListener engineCallListener, | ||
final TimestampSchedule schedule) { | ||
super( | ||
vertx, | ||
protocolContext, | ||
mergeMiningCoordinator, | ||
blockResultFactory, | ||
engineCallListener, | ||
schedule); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return RpcMethod.ENGINE_GET_PAYLOAD_V3.getMethodName(); | ||
} | ||
|
||
@Override | ||
protected JsonRpcResponse createResponse( | ||
final JsonRpcRequestContext request, final BlockWithReceipts blockWithReceipts) { | ||
|
||
DefaultTimestampSchedule tsched = (DefaultTimestampSchedule) this.schedule.get(); | ||
long shanghaiTimestamp = tsched.scheduledAt("Shanghai"); | ||
long cancunTimestamp = tsched.scheduledAt("Cancun"); | ||
long builtAt = blockWithReceipts.getHeader().getTimestamp(); | ||
if (builtAt < shanghaiTimestamp) { | ||
return new JsonRpcSuccessResponse( | ||
request.getRequest().getId(), | ||
blockResultFactory.payloadTransactionCompleteV1(blockWithReceipts.getBlock())); | ||
} else if (builtAt >= shanghaiTimestamp && builtAt < cancunTimestamp) { | ||
return new JsonRpcSuccessResponse( | ||
request.getRequest().getId(), | ||
blockResultFactory.payloadTransactionCompleteV2(blockWithReceipts)); | ||
} else if (builtAt >= cancunTimestamp) { | ||
return new JsonRpcSuccessResponse( | ||
request.getRequest().getId(), | ||
blockResultFactory.payloadTransactionCompleteV3(blockWithReceipts)); | ||
} | ||
|
||
return new JsonRpcSuccessResponse( | ||
request.getRequest().getId(), | ||
blockResultFactory.payloadTransactionCompleteV3(blockWithReceipts)); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3.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 Hyperledger Besu Contributors. | ||
* | ||
* 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.consensus.merge.blockcreation.MergeMiningCoordinator; | ||
import org.hyperledger.besu.ethereum.ProtocolContext; | ||
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; | ||
import org.hyperledger.besu.ethereum.eth.manager.EthPeers; | ||
import org.hyperledger.besu.ethereum.mainnet.TimestampSchedule; | ||
|
||
import io.vertx.core.Vertx; | ||
|
||
public class EngineNewPayloadV3 extends AbstractEngineNewPayload { | ||
|
||
public EngineNewPayloadV3( | ||
final Vertx vertx, | ||
final TimestampSchedule timestampSchedule, | ||
final ProtocolContext protocolContext, | ||
final MergeMiningCoordinator mergeCoordinator, | ||
final EthPeers ethPeers, | ||
final EngineCallListener engineCallListener) { | ||
super( | ||
vertx, timestampSchedule, protocolContext, mergeCoordinator, ethPeers, engineCallListener); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return RpcMethod.ENGINE_NEW_PAYLOAD_V3.getMethodName(); | ||
} | ||
} |
Oops, something went wrong.