forked from Consensys/teku
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9deba9
commit 624d66c
Showing
17 changed files
with
324 additions
and
61 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
52 changes: 52 additions & 0 deletions
52
.../src/main/java/tech/pegasys/teku/validator/coordinator/ExecutionPayloadHeaderFactory.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,52 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2024 | ||
* | ||
* 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. | ||
*/ | ||
|
||
package tech.pegasys.teku.validator.coordinator; | ||
|
||
import tech.pegasys.teku.bls.BLSPublicKey; | ||
import tech.pegasys.teku.infrastructure.async.SafeFuture; | ||
import tech.pegasys.teku.infrastructure.unsigned.UInt64; | ||
import tech.pegasys.teku.spec.Spec; | ||
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; | ||
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateCache; | ||
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerBlockProductionManager; | ||
|
||
@SuppressWarnings("unused") | ||
public class ExecutionPayloadHeaderFactory { | ||
|
||
private final Spec spec; | ||
private final ExecutionLayerBlockProductionManager executionLayerBlockProductionManager; | ||
|
||
public ExecutionPayloadHeaderFactory( | ||
final Spec spec, | ||
final ExecutionLayerBlockProductionManager executionLayerBlockProductionManager) { | ||
this.spec = spec; | ||
this.executionLayerBlockProductionManager = executionLayerBlockProductionManager; | ||
} | ||
|
||
// EIP7732 TODO: implement | ||
public SafeFuture<ExecutionPayloadHeader> createUnsignedHeader( | ||
final BeaconState state, final UInt64 slot, final BLSPublicKey builderPublicKey) { | ||
int builderIndex = | ||
BeaconStateCache.getTransitionCaches(state) | ||
.getValidatorIndexCache() | ||
.getValidatorIndex(state, builderPublicKey) | ||
.orElseThrow( | ||
() -> | ||
new IllegalArgumentException( | ||
"There is no index assigned to a builder with a public key " | ||
+ builderPublicKey)); | ||
return SafeFuture.completedFuture(null); | ||
} | ||
} |
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
46 changes: 46 additions & 0 deletions
46
...ain/java/tech/pegasys/teku/validator/coordinator/publisher/ExecutionPayloadPublisher.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,46 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2024 | ||
* | ||
* 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. | ||
*/ | ||
|
||
package tech.pegasys.teku.validator.coordinator.publisher; | ||
|
||
import java.util.Optional; | ||
import tech.pegasys.teku.infrastructure.async.SafeFuture; | ||
import tech.pegasys.teku.networking.eth2.gossip.ExecutionPayloadGossipChannel; | ||
import tech.pegasys.teku.spec.datastructures.execution.SignedExecutionPayloadEnvelope; | ||
import tech.pegasys.teku.statetransition.execution.ExecutionPayloadManager; | ||
import tech.pegasys.teku.statetransition.validation.InternalValidationResult; | ||
|
||
public class ExecutionPayloadPublisher { | ||
|
||
private final ExecutionPayloadManager executionPayloadManager; | ||
private final ExecutionPayloadGossipChannel executionPayloadGossipChannel; | ||
|
||
public ExecutionPayloadPublisher( | ||
final ExecutionPayloadManager executionPayloadManager, | ||
final ExecutionPayloadGossipChannel executionPayloadGossipChannel) { | ||
this.executionPayloadManager = executionPayloadManager; | ||
this.executionPayloadGossipChannel = executionPayloadGossipChannel; | ||
} | ||
|
||
public SafeFuture<InternalValidationResult> sendExecutionPayload( | ||
final SignedExecutionPayloadEnvelope executionPayload) { | ||
return executionPayloadManager | ||
.validateAndImportExecutionPayload(executionPayload, Optional.empty()) | ||
.thenPeek( | ||
result -> { | ||
if (result.isAccept()) { | ||
executionPayloadGossipChannel.publishExecutionPayload(executionPayload); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.