Skip to content
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

Move execution client logic to a separate module #5438

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dependencies {
implementation project(':infrastructure:time')
implementation project(':infrastructure:exceptions')
implementation project(':infrastructure:metrics')
implementation project(':infrastructure:unsigned')
implementation project(':infrastructure:time')
implementation project(':infrastructure:logging')
implementation project(':infrastructure:async')
implementation project(':infrastructure:events')
Expand All @@ -17,4 +17,9 @@ dependencies {

testImplementation testFixtures(project(':infrastructure:async'))
testImplementation testFixtures(project(':infrastructure:time'))
testImplementation testFixtures(project(':ethereum:spec'))

integrationTestImplementation testFixtures(project(':infrastructure:json'))
integrationTestImplementation testFixtures(project(':infrastructure:time'))
integrationTestImplementation 'com.squareup.okhttp3:mockwebserver'
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionlayer.client;
package tech.pegasys.teku.ethereum.executionclient;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.INTEGER;
Expand All @@ -33,13 +33,11 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import tech.pegasys.teku.ethereum.executionengine.Web3JClient;
import tech.pegasys.teku.ethereum.executionengine.Web3jClientBuilder;
import tech.pegasys.teku.ethereum.executionengine.schema.Response;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.BlindedBeaconBlockV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.BuilderBidV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.SignedMessage;
import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1;
import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.time.StubTimeProvider;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
Expand Down Expand Up @@ -95,7 +93,8 @@ void getPayload_shouldRoundtripWithMockedWebServer() throws Exception {
// double-check that what we are going to respond corresponds to the json data
final String serializedExecutionPayloadResponse =
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(executionPayloadResponse);
assertThat(serializedExecutionPayloadResponse).isEqualTo(jsonGetPayloadResponse);
assertThat(serializedExecutionPayloadResponse)
.isEqualToIgnoringNewLines(jsonGetPayloadResponse);

mockWebServer.enqueue(
new MockResponse()
Expand Down Expand Up @@ -124,7 +123,8 @@ void getPayload_shouldRoundtripWithMockedWebServer() throws Exception {
objectMapper
.writerWithDefaultPrettyPrinter()
.writeValueAsString(signedBlindedBeaconBlockRequest);
assertThat(serializedSignedBlindedBeaconBlockRequest).isEqualTo(jsonGetPayloadRequest);
assertThat(serializedSignedBlindedBeaconBlockRequest)
.isEqualToIgnoringNewLines(jsonGetPayloadRequest);
assertThat(serializedSignedBlindedBeaconBlockRequest)
.isEqualTo(requestBodyJsonNode.get("params").get(0).toPrettyString());

Expand All @@ -151,7 +151,8 @@ void getHeader_shouldRoundtripWithMockedWebServer() throws Exception {
// double-check that what we are going to respond corresponds to the json data
final String serializedSignedBuilderBidResponse =
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(signedBuilderBidV1);
assertThat(serializedSignedBuilderBidResponse).isEqualTo(jsonSignedBuilderBidResponse);
assertThat(serializedSignedBuilderBidResponse)
.isEqualToIgnoringNewLines(jsonSignedBuilderBidResponse);

mockWebServer.enqueue(
new MockResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionlayer.client;
package tech.pegasys.teku.ethereum.executionclient;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.INTEGER;
Expand All @@ -35,12 +35,10 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import tech.pegasys.teku.ethereum.executionengine.Web3JClient;
import tech.pegasys.teku.ethereum.executionengine.Web3jClientBuilder;
import tech.pegasys.teku.ethereum.executionengine.schema.Response;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceStateV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.PayloadAttributesV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceStateV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceUpdatedResult;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes20;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionengine;
package tech.pegasys.teku.ethereum.executionclient;

import static com.google.common.base.Preconditions.checkNotNull;

import java.nio.file.Path;
import java.time.Duration;
import java.util.Optional;
import org.web3j.protocol.Web3j;
import tech.pegasys.teku.ethereum.executionengine.auth.JwtConfig;
import tech.pegasys.teku.ethereum.executionengine.auth.JwtSecretKeyLoader;
import tech.pegasys.teku.ethereum.executionclient.auth.JwtConfig;
import tech.pegasys.teku.ethereum.executionclient.auth.JwtSecretKeyLoader;
import tech.pegasys.teku.infrastructure.time.TimeProvider;

public class DefaultExecutionClientProvider implements ExecutionClientProvider {
public class DefaultExecutionWeb3jClientProvider implements ExecutionWeb3jClientProvider {
private final String eeEndpoint;
private final TimeProvider timeProvider;
private final Optional<String> jwtSecretFile;
Expand All @@ -32,7 +32,7 @@ public class DefaultExecutionClientProvider implements ExecutionClientProvider {
private boolean alreadyBuilt = false;
private Web3JClient web3JClient;

DefaultExecutionClientProvider(
DefaultExecutionWeb3jClientProvider(
final String eeEndpoint,
final TimeProvider timeProvider,
final Duration timeout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionlayer.client;
package tech.pegasys.teku.ethereum.executionclient;

import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.bytes.Bytes48;
import tech.pegasys.teku.ethereum.executionengine.schema.Response;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.BlindedBeaconBlockV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.BuilderBidV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.GenericBuilderStatus;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.SignedMessage;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ValidatorRegistrationV1;
import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1;
import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionclient.schema.GenericBuilderStatus;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage;
import tech.pegasys.teku.ethereum.executionclient.schema.ValidatorRegistrationV1;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionlayer.client;
package tech.pegasys.teku.ethereum.executionclient;

import java.util.Optional;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.ethereum.executionengine.schema.Response;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadHeaderV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceStateV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.PayloadAttributesV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadHeaderV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceStateV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceUpdatedResult;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV1;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionengine;
package tech.pegasys.teku.ethereum.executionclient;

import static tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel.STUB_ENDPOINT_IDENTIFIER;

Expand All @@ -22,9 +22,9 @@
import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException;
import tech.pegasys.teku.infrastructure.time.TimeProvider;

public interface ExecutionClientProvider {
ExecutionClientProvider STUB =
new ExecutionClientProvider() {
public interface ExecutionWeb3jClientProvider {
ExecutionWeb3jClientProvider STUB =
new ExecutionWeb3jClientProvider() {
@Override
public Web3JClient getWeb3JClient() {
throw new InvalidConfigurationException("Stub provider");
Expand All @@ -46,7 +46,7 @@ public boolean isStub() {
}
};

static ExecutionClientProvider create(
static ExecutionWeb3jClientProvider create(
final String endpoint,
final TimeProvider timeProvider,
final Duration timeout,
Expand All @@ -55,7 +55,7 @@ static ExecutionClientProvider create(
if (endpoint.equals(STUB_ENDPOINT_IDENTIFIER)) {
return STUB;
} else {
return new DefaultExecutionClientProvider(
return new DefaultExecutionWeb3jClientProvider(
endpoint, timeProvider, timeout, jwtSecretFile, beaconDataDirectory);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionlayer.client;
package tech.pegasys.teku.ethereum.executionclient;

import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.bytes.Bytes48;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import tech.pegasys.teku.ethereum.executionengine.schema.Response;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.BlindedBeaconBlockV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.BuilderBidV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.GenericBuilderStatus;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.SignedMessage;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ValidatorRegistrationV1;
import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1;
import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionclient.schema.GenericBuilderStatus;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage;
import tech.pegasys.teku.ethereum.executionclient.schema.ValidatorRegistrationV1;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.async.ThrottlingTaskQueue;
import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionlayer.client;
package tech.pegasys.teku.ethereum.executionclient;

import java.util.Optional;
import org.apache.tuweni.bytes.Bytes32;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import tech.pegasys.teku.ethereum.executionengine.schema.Response;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadHeaderV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceStateV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.PayloadAttributesV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadHeaderV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceStateV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceUpdatedResult;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV1;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.async.ThrottlingTaskQueue;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionengine;
package tech.pegasys.teku.ethereum.executionclient;

import static tech.pegasys.teku.infrastructure.logging.EventLogger.EVENT_LOG;

Expand All @@ -22,7 +22,7 @@
import org.web3j.protocol.Web3j;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.Request;
import tech.pegasys.teku.ethereum.executionengine.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.time.TimeProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionlayer.client;
package tech.pegasys.teku.ethereum.executionclient;

import static tech.pegasys.teku.spec.config.Constants.NON_EXECUTION_TIMEOUT;

Expand All @@ -21,14 +21,13 @@
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.bytes.Bytes48;
import org.web3j.protocol.core.Request;
import tech.pegasys.teku.ethereum.executionengine.Web3JClient;
import tech.pegasys.teku.ethereum.executionengine.schema.Response;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.BlindedBeaconBlockV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.BuilderBidV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.GenericBuilderStatus;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.SignedMessage;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ValidatorRegistrationV1;
import tech.pegasys.teku.ethereum.executionclient.schema.BlindedBeaconBlockV1;
import tech.pegasys.teku.ethereum.executionclient.schema.BuilderBidV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionclient.schema.GenericBuilderStatus;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.SignedMessage;
import tech.pegasys.teku.ethereum.executionclient.schema.ValidatorRegistrationV1;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.ethereum.executionlayer.client;
package tech.pegasys.teku.ethereum.executionclient;

import static tech.pegasys.teku.spec.config.Constants.EXECUTION_TIMEOUT;
import static tech.pegasys.teku.spec.config.Constants.NON_EXECUTION_TIMEOUT;
Expand All @@ -25,15 +25,14 @@
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.methods.response.EthBlock;
import tech.pegasys.teku.ethereum.executionengine.Web3JClient;
import tech.pegasys.teku.ethereum.executionengine.schema.Response;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadHeaderV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceStateV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.ForkChoiceUpdatedResult;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.PayloadAttributesV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionlayer.client.schema.TransitionConfigurationV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadHeaderV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ExecutionPayloadV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceStateV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ForkChoiceUpdatedResult;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV1;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.ethereum.executionclient.schema.TransitionConfigurationV1;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes8;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
Expand Down
Loading