Skip to content

Commit b1ab0ec

Browse files
committed
Merge branch 'master' into post-state-validators
2 parents 781a584 + 11720af commit b1ab0ec

File tree

23 files changed

+216
-62
lines changed

23 files changed

+216
-62
lines changed

beacon/validator/src/jmh/java/tech/pegasys/teku/validator/coordinator/duties/AttesterDutiesGeneraterBenchmark.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
import org.openjdk.jmh.infra.Blackhole;
3737
import tech.pegasys.teku.benchmarks.gen.KeyFileGenerator;
3838
import tech.pegasys.teku.bls.BLSKeyPair;
39+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
40+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuty;
3941
import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition;
4042
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
4143
import tech.pegasys.teku.spec.Spec;
4244
import tech.pegasys.teku.spec.TestSpecFactory;
4345
import tech.pegasys.teku.spec.datastructures.interop.GenesisStateBuilder;
4446
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateBellatrix;
4547
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.MutableBeaconStateBellatrix;
46-
import tech.pegasys.teku.validator.api.AttesterDuties;
47-
import tech.pegasys.teku.validator.api.AttesterDuty;
4848

4949
@Fork(1)
5050
@State(Scope.Thread)

beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import tech.pegasys.teku.bls.BLSPublicKey;
4848
import tech.pegasys.teku.bls.BLSSignature;
4949
import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData;
50+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
5051
import tech.pegasys.teku.ethereum.json.types.validator.BeaconCommitteeSelectionProof;
5152
import tech.pegasys.teku.ethereum.json.types.validator.ProposerDuties;
5253
import tech.pegasys.teku.ethereum.json.types.validator.ProposerDuty;
@@ -91,7 +92,6 @@
9192
import tech.pegasys.teku.statetransition.synccommittee.SyncCommitteeMessagePool;
9293
import tech.pegasys.teku.statetransition.validation.InternalValidationResult;
9394
import tech.pegasys.teku.storage.client.CombinedChainDataClient;
94-
import tech.pegasys.teku.validator.api.AttesterDuties;
9595
import tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest;
9696
import tech.pegasys.teku.validator.api.NodeSyncingException;
9797
import tech.pegasys.teku.validator.api.SendSignedBlockResult;

beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/duties/AttesterDutiesGenerator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
import java.util.Map;
2020
import java.util.Optional;
2121
import org.apache.tuweni.bytes.Bytes32;
22+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
23+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuty;
2224
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
2325
import tech.pegasys.teku.spec.Spec;
2426
import tech.pegasys.teku.spec.datastructures.state.CommitteeAssignment;
2527
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
2628
import tech.pegasys.teku.spec.logic.common.helpers.BeaconStateAccessors;
27-
import tech.pegasys.teku.validator.api.AttesterDuties;
28-
import tech.pegasys.teku.validator.api.AttesterDuty;
2929

3030
public class AttesterDutiesGenerator {
3131
private final Spec spec;

beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandlerTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
import tech.pegasys.teku.bls.BLSPublicKey;
6262
import tech.pegasys.teku.bls.BLSSignature;
6363
import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData;
64+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
65+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuty;
6466
import tech.pegasys.teku.ethereum.json.types.validator.ProposerDuties;
6567
import tech.pegasys.teku.ethereum.json.types.validator.ProposerDuty;
6668
import tech.pegasys.teku.ethereum.performance.trackers.BlockProductionPerformance;
@@ -121,8 +123,6 @@
121123
import tech.pegasys.teku.statetransition.validation.InternalValidationResult;
122124
import tech.pegasys.teku.statetransition.validation.ValidationResultCode;
123125
import tech.pegasys.teku.storage.client.CombinedChainDataClient;
124-
import tech.pegasys.teku.validator.api.AttesterDuties;
125-
import tech.pegasys.teku.validator.api.AttesterDuty;
126126
import tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest;
127127
import tech.pegasys.teku.validator.api.NodeSyncingException;
128128
import tech.pegasys.teku.validator.api.SendSignedBlockResult;

data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/validator/PostAttesterDutiesIntegrationTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import tech.pegasys.teku.beacon.sync.events.SyncState;
2929
import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest;
3030
import tech.pegasys.teku.beaconrestapi.handlers.v1.validator.PostAttesterDuties;
31+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
3132
import tech.pegasys.teku.infrastructure.async.SafeFuture;
3233
import tech.pegasys.teku.spec.SpecMilestone;
33-
import tech.pegasys.teku.validator.api.AttesterDuties;
3434

3535
public class PostAttesterDutiesIntegrationTest extends AbstractDataBackedRestAPIIntegrationTest {
3636

data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostAttesterDuties.java

+3-33
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@
1414
package tech.pegasys.teku.beaconrestapi.handlers.v1.validator;
1515

1616
import static tech.pegasys.teku.beaconrestapi.BeaconRestApiTypes.EPOCH_PARAMETER;
17-
import static tech.pegasys.teku.ethereum.json.types.EthereumTypes.PUBLIC_KEY_TYPE;
17+
import static tech.pegasys.teku.ethereum.json.types.validator.AttesterDutiesBuilder.ATTESTER_DUTIES_RESPONSE_TYPE;
1818
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK;
1919
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_SERVICE_UNAVAILABLE;
20-
import static tech.pegasys.teku.infrastructure.http.RestApiConstants.EXECUTION_OPTIMISTIC;
2120
import static tech.pegasys.teku.infrastructure.http.RestApiConstants.TAG_VALIDATOR;
2221
import static tech.pegasys.teku.infrastructure.http.RestApiConstants.TAG_VALIDATOR_REQUIRED;
23-
import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.BOOLEAN_TYPE;
24-
import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.BYTES32_TYPE;
2522
import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.INTEGER_TYPE;
26-
import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.UINT64_TYPE;
2723

2824
import com.fasterxml.jackson.core.JsonProcessingException;
2925
import it.unimi.dsi.fastutil.ints.IntArrayList;
@@ -33,46 +29,20 @@
3329
import tech.pegasys.teku.api.DataProvider;
3430
import tech.pegasys.teku.api.SyncDataProvider;
3531
import tech.pegasys.teku.api.ValidatorDataProvider;
32+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
3633
import tech.pegasys.teku.infrastructure.async.SafeFuture;
3734
import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition;
38-
import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition;
3935
import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse;
4036
import tech.pegasys.teku.infrastructure.restapi.endpoints.EndpointMetadata;
4137
import tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiEndpoint;
4238
import tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest;
4339
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
44-
import tech.pegasys.teku.validator.api.AttesterDuties;
45-
import tech.pegasys.teku.validator.api.AttesterDuty;
4640

4741
public class PostAttesterDuties extends RestApiEndpoint {
4842
public static final String ROUTE = "/eth/v1/validator/duties/attester/{epoch}";
4943
private final ValidatorDataProvider validatorDataProvider;
5044
private final SyncDataProvider syncDataProvider;
5145

52-
private static final SerializableTypeDefinition<AttesterDuty> ATTESTER_DUTY_TYPE =
53-
SerializableTypeDefinition.object(AttesterDuty.class)
54-
.name("AttesterDuty")
55-
.withField("pubkey", PUBLIC_KEY_TYPE, AttesterDuty::getPublicKey)
56-
.withField("validator_index", INTEGER_TYPE, AttesterDuty::getValidatorIndex)
57-
.withField("committee_index", INTEGER_TYPE, AttesterDuty::getCommitteeIndex)
58-
.withField("committee_length", INTEGER_TYPE, AttesterDuty::getCommitteeLength)
59-
.withField("committees_at_slot", INTEGER_TYPE, AttesterDuty::getCommitteesAtSlot)
60-
.withField(
61-
"validator_committee_index", INTEGER_TYPE, AttesterDuty::getValidatorCommitteeIndex)
62-
.withField("slot", UINT64_TYPE, AttesterDuty::getSlot)
63-
.build();
64-
65-
private static final SerializableTypeDefinition<AttesterDuties> RESPONSE_TYPE =
66-
SerializableTypeDefinition.object(AttesterDuties.class)
67-
.name("GetAttesterDutiesResponse")
68-
.withField("dependent_root", BYTES32_TYPE, AttesterDuties::getDependentRoot)
69-
.withField(EXECUTION_OPTIMISTIC, BOOLEAN_TYPE, AttesterDuties::isExecutionOptimistic)
70-
.withField(
71-
"data",
72-
SerializableTypeDefinition.listOf(ATTESTER_DUTY_TYPE),
73-
AttesterDuties::getDuties)
74-
.build();
75-
7646
public PostAttesterDuties(final DataProvider dataProvider) {
7747
this(dataProvider.getSyncDataProvider(), dataProvider.getValidatorDataProvider());
7848
}
@@ -100,7 +70,7 @@ public PostAttesterDuties(final DataProvider dataProvider) {
10070
.tags(TAG_VALIDATOR, TAG_VALIDATOR_REQUIRED)
10171
.requestBodyType(DeserializableTypeDefinition.listOf(INTEGER_TYPE, 1))
10272
.pathParam(EPOCH_PARAMETER)
103-
.response(SC_OK, "Success response", RESPONSE_TYPE)
73+
.response(SC_OK, "Success response", ATTESTER_DUTIES_RESPONSE_TYPE)
10474
.withServiceUnavailableResponse()
10575
.build());
10676
this.validatorDataProvider = validatorDataProvider;

data/beaconrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostAttesterDutiesTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
import org.junit.jupiter.api.Test;
3636
import tech.pegasys.teku.beacon.sync.events.SyncState;
3737
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest;
38+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
39+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuty;
3840
import tech.pegasys.teku.infrastructure.async.SafeFuture;
3941
import tech.pegasys.teku.infrastructure.http.HttpErrorResponse;
4042
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
41-
import tech.pegasys.teku.validator.api.AttesterDuties;
42-
import tech.pegasys.teku.validator.api.AttesterDuty;
4343

4444
public class PostAttesterDutiesTest extends AbstractMigratedBeaconHandlerTest {
4545
final AttesterDuty duty =

data/provider/src/main/java/tech/pegasys/teku/api/ValidatorDataProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import tech.pegasys.teku.api.schema.electra.SignedBlindedBeaconBlockElectra;
3939
import tech.pegasys.teku.api.schema.phase0.SignedBeaconBlockPhase0;
4040
import tech.pegasys.teku.bls.BLSSignature;
41+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
4142
import tech.pegasys.teku.ethereum.json.types.validator.ProposerDuties;
4243
import tech.pegasys.teku.infrastructure.async.SafeFuture;
4344
import tech.pegasys.teku.infrastructure.ssz.SszList;
@@ -60,7 +61,6 @@
6061
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsAltair;
6162
import tech.pegasys.teku.storage.client.ChainDataUnavailableException;
6263
import tech.pegasys.teku.storage.client.CombinedChainDataClient;
63-
import tech.pegasys.teku.validator.api.AttesterDuties;
6464
import tech.pegasys.teku.validator.api.CommitteeSubscriptionRequest;
6565
import tech.pegasys.teku.validator.api.SendSignedBlockResult;
6666
import tech.pegasys.teku.validator.api.SubmitDataError;

data/provider/src/test/java/tech/pegasys/teku/api/ValidatorDataProviderTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
import tech.pegasys.teku.bls.BLSPublicKey;
6262
import tech.pegasys.teku.bls.BLSSignature;
6363
import tech.pegasys.teku.bls.BLSTestUtil;
64+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
65+
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuty;
6466
import tech.pegasys.teku.infrastructure.async.SafeFuture;
6567
import tech.pegasys.teku.infrastructure.async.SafeFutureAssert;
6668
import tech.pegasys.teku.infrastructure.ssz.SszList;
@@ -79,8 +81,6 @@
7981
import tech.pegasys.teku.spec.util.DataStructureUtil;
8082
import tech.pegasys.teku.storage.client.ChainDataUnavailableException;
8183
import tech.pegasys.teku.storage.client.CombinedChainDataClient;
82-
import tech.pegasys.teku.validator.api.AttesterDuties;
83-
import tech.pegasys.teku.validator.api.AttesterDuty;
8484
import tech.pegasys.teku.validator.api.SendSignedBlockResult;
8585
import tech.pegasys.teku.validator.api.SubmitDataError;
8686
import tech.pegasys.teku.validator.api.ValidatorApiChannel;

validator/api/src/main/java/tech/pegasys/teku/validator/api/AttesterDuties.java ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/validator/AttesterDuties.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* specific language governing permissions and limitations under the License.
1212
*/
1313

14-
package tech.pegasys.teku.validator.api;
14+
package tech.pegasys.teku.ethereum.json.types.validator;
1515

1616
import com.google.common.base.MoreObjects;
1717
import java.util.List;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright Consensys Software Inc., 2024
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package tech.pegasys.teku.ethereum.json.types.validator;
15+
16+
import static tech.pegasys.teku.ethereum.json.types.validator.AttesterDutyBuilder.ATTESTER_DUTY_TYPE;
17+
import static tech.pegasys.teku.infrastructure.http.RestApiConstants.EXECUTION_OPTIMISTIC;
18+
import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.BOOLEAN_TYPE;
19+
import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.BYTES32_TYPE;
20+
21+
import java.util.List;
22+
import org.apache.tuweni.bytes.Bytes32;
23+
import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition;
24+
25+
public class AttesterDutiesBuilder {
26+
public static final DeserializableTypeDefinition<AttesterDuties> ATTESTER_DUTIES_RESPONSE_TYPE =
27+
DeserializableTypeDefinition.object(AttesterDuties.class, AttesterDutiesBuilder.class)
28+
.name("GetAttesterDutiesResponse")
29+
.initializer(AttesterDutiesBuilder::new)
30+
.finisher(AttesterDutiesBuilder::build)
31+
.withField(
32+
"dependent_root",
33+
BYTES32_TYPE,
34+
AttesterDuties::getDependentRoot,
35+
AttesterDutiesBuilder::dependentRoot)
36+
.withField(
37+
EXECUTION_OPTIMISTIC,
38+
BOOLEAN_TYPE,
39+
AttesterDuties::isExecutionOptimistic,
40+
AttesterDutiesBuilder::executionOptimistic)
41+
.withField(
42+
"data",
43+
DeserializableTypeDefinition.listOf(ATTESTER_DUTY_TYPE),
44+
AttesterDuties::getDuties,
45+
AttesterDutiesBuilder::duties)
46+
.build();
47+
48+
private boolean executionOptimistic;
49+
private Bytes32 dependentRoot;
50+
private List<AttesterDuty> duties;
51+
52+
public AttesterDutiesBuilder executionOptimistic(boolean executionOptimistic) {
53+
this.executionOptimistic = executionOptimistic;
54+
return this;
55+
}
56+
57+
public AttesterDutiesBuilder dependentRoot(Bytes32 dependentRoot) {
58+
this.dependentRoot = dependentRoot;
59+
return this;
60+
}
61+
62+
public AttesterDutiesBuilder duties(List<AttesterDuty> duties) {
63+
this.duties = duties;
64+
return this;
65+
}
66+
67+
public AttesterDuties build() {
68+
return new AttesterDuties(executionOptimistic, dependentRoot, duties);
69+
}
70+
}

validator/api/src/main/java/tech/pegasys/teku/validator/api/AttesterDuty.java ethereum/json-types/src/main/java/tech/pegasys/teku/ethereum/json/types/validator/AttesterDuty.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* specific language governing permissions and limitations under the License.
1212
*/
1313

14-
package tech.pegasys.teku.validator.api;
14+
package tech.pegasys.teku.ethereum.json.types.validator;
1515

1616
import com.google.common.base.MoreObjects;
1717
import java.util.Objects;

0 commit comments

Comments
 (0)