Skip to content

Commit

Permalink
Fix assemble again
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Dec 9, 2024
1 parent 553eedc commit 40efa62
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.bellatrix.BeaconStateSchemaBellatrix;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.capella.BeaconStateSchemaCapella;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.deneb.BeaconStateSchemaDeneb;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0;
import tech.pegasys.teku.spec.logic.common.forktransition.StateUpgrade;

Expand Down Expand Up @@ -65,6 +66,10 @@ private void processUpgrade(final TestDefinition testDefinition, final SpecMiles
BeaconStateSchemaDeneb.create(
previousMilestoneSpecVersion.getConfig(),
previousMilestoneSpecVersion.getSchemaDefinitions().getSchemaRegistry());
case EIP7732 ->
BeaconStateSchemaElectra.create(
previousMilestoneSpecVersion.getConfig(),
previousMilestoneSpecVersion.getSchemaDefinitions().getSchemaRegistry());
default ->
throw new IllegalStateException(
"Unhandled fork upgrade for test "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ private void processUpgrade(final TestDefinition testDefinition, final MetaData
.capellaBuilder(c -> c.capellaForkEpoch(UInt64.ZERO))
.denebBuilder(d -> d.denebForkEpoch(UInt64.ZERO))
.electraBuilder(e -> e.electraForkEpoch(forkEpoch));
case EIP7732 ->
builder
.altairBuilder(a -> a.altairForkEpoch(UInt64.ZERO))
.bellatrixBuilder(b -> b.bellatrixForkEpoch(UInt64.ZERO))
.capellaBuilder(c -> c.capellaForkEpoch(UInt64.ZERO))
.denebBuilder(d -> d.denebForkEpoch(UInt64.ZERO))
.electraBuilder(e -> e.electraForkEpoch(UInt64.ZERO))
.eip7732Builder(e -> e.eip7732ForkEpoch(forkEpoch));
default ->
throw new IllegalStateException(
"Unhandled fork transition for test "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.kzg.KZG;
import tech.pegasys.teku.networking.eth2.peers.Eth2Peer;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.BlobSidecarsResponseInvalidResponseException.InvalidResponseType;
import tech.pegasys.teku.networking.p2p.rpc.RpcResponseListener;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.TestSpecContext;
Expand Down Expand Up @@ -68,6 +69,7 @@ void setUp(final SpecContext specContext) {
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7732 -> TestSpecFactory.createMinimalWithEip7732ForkEpoch(currentForkEpoch);
};
currentForkFirstSlot = spec.computeStartSlotAtEpoch(currentForkEpoch);
dataStructureUtil = new DataStructureUtil(spec);
Expand Down Expand Up @@ -95,10 +97,7 @@ void blobSidecarFailsKzgVerification() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_KZG_VERIFICATION_FAILED
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_KZG_VERIFICATION_FAILED.describe());
}

@TestTemplate
Expand All @@ -120,9 +119,7 @@ void blobSidecarFailsInclusionProofVerification() {
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_INCLUSION_PROOF_VERIFICATION_FAILED
.describe());
InvalidResponseType.BLOB_SIDECAR_INCLUSION_PROOF_VERIFICATION_FAILED.describe());
}

@TestTemplate
Expand All @@ -142,10 +139,7 @@ void blobSidecarSlotSmallerThanFromSlot() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_SLOT_NOT_IN_RANGE
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_SLOT_NOT_IN_RANGE.describe());
}

@TestTemplate
Expand Down Expand Up @@ -222,10 +216,7 @@ void blobSidecarSlotGreaterThanToSlot() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_SLOT_NOT_IN_RANGE
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_SLOT_NOT_IN_RANGE.describe());
}

@TestTemplate
Expand All @@ -250,10 +241,7 @@ void blobSidecarParentRootDoesNotMatch() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_UNKNOWN_PARENT
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_UNKNOWN_PARENT.describe());
}

@TestTemplate
Expand Down Expand Up @@ -285,10 +273,7 @@ void blobSidecarIndexIsGreaterOrEqualThanMaxBlobs() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_UNEXPECTED_INDEX
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_UNEXPECTED_INDEX.describe());
}

@TestTemplate
Expand All @@ -314,10 +299,7 @@ void blobSidecarIndexIsInTheSameBlockButNotNext() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_UNEXPECTED_INDEX
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_UNEXPECTED_INDEX.describe());
}

@TestTemplate
Expand Down Expand Up @@ -361,10 +343,7 @@ void firstBlobSidecarIndexIsINotZero() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_UNEXPECTED_INDEX
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_UNEXPECTED_INDEX.describe());
}

@TestTemplate
Expand All @@ -391,10 +370,7 @@ void firstBlobSidecarIndexInNextBlockIsNotZero() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_UNEXPECTED_INDEX
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_UNEXPECTED_INDEX.describe());
}

@TestTemplate
Expand All @@ -418,9 +394,6 @@ void blobSidecarUnexpectedSlot() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_UNEXPECTED_SLOT
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_UNEXPECTED_SLOT.describe());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.networking.eth2.peers.Eth2Peer;
import tech.pegasys.teku.networking.eth2.peers.RequestApproval;
import tech.pegasys.teku.networking.eth2.peers.RequestApproval.RequestApprovalBuilder;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.BeaconChainMethodIds;
import tech.pegasys.teku.networking.eth2.rpc.core.ResponseCallback;
import tech.pegasys.teku.networking.eth2.rpc.core.RpcException;
import tech.pegasys.teku.networking.eth2.rpc.core.RpcException.ResourceUnavailableException;
import tech.pegasys.teku.networking.eth2.rpc.core.encodings.RpcEncoding;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.TestSpecContext;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.TestSpecInvocationContextProvider;
import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext;
import tech.pegasys.teku.spec.config.SpecConfigDeneb;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
Expand All @@ -68,7 +70,7 @@
public class BlobSidecarsByRangeMessageHandlerTest {

private static final RequestApproval ZERO_OBJECTS_REQUEST_APPROVAL =
new RequestApproval.RequestApprovalBuilder().timeSeconds(ZERO).objectsCount(0).build();
new RequestApprovalBuilder().timeSeconds(ZERO).objectsCount(0).build();
private static final RpcEncoding RPC_ENCODING =
RpcEncoding.createSszSnappyEncoding(
TestSpecFactory.createDefault().getNetworkingConfig().getMaxChunkSize());
Expand All @@ -87,8 +89,7 @@ public class BlobSidecarsByRangeMessageHandlerTest {
private final String protocolId =
BeaconChainMethodIds.getBlobSidecarsByRangeMethodId(1, RPC_ENCODING);
private final Optional<RequestApproval> allowedObjectsRequest =
Optional.of(
new RequestApproval.RequestApprovalBuilder().objectsCount(100).timeSeconds(ZERO).build());
Optional.of(new RequestApprovalBuilder().objectsCount(100).timeSeconds(ZERO).build());

private SpecMilestone specMilestone;
private Spec spec;
Expand All @@ -99,7 +100,7 @@ public class BlobSidecarsByRangeMessageHandlerTest {
private UInt64 startSlot;

@BeforeEach
public void setUp(final TestSpecInvocationContextProvider.SpecContext specContext) {
public void setUp(final SpecContext specContext) {
specMilestone = specContext.getSpecMilestone();
spec =
switch (specContext.getSpecMilestone()) {
Expand All @@ -110,6 +111,7 @@ public void setUp(final TestSpecInvocationContextProvider.SpecContext specContex
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7732 -> TestSpecFactory.createMinimalWithEip7732ForkEpoch(currentForkEpoch);
};

dataStructureUtil = new DataStructureUtil(spec);
Expand Down Expand Up @@ -231,8 +233,7 @@ public void shouldSendResourceUnavailableIfBlobSidecarsAreNotAvailable() {
// available from epoch 5010
verify(listener)
.completeWithErrorResponse(
new RpcException.ResourceUnavailableException(
"Requested blob sidecars are not available."));
new ResourceUnavailableException("Requested blob sidecars are not available."));
}

@TestTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.kzg.KZG;
import tech.pegasys.teku.networking.eth2.peers.Eth2Peer;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.methods.BlobSidecarsResponseInvalidResponseException.InvalidResponseType;
import tech.pegasys.teku.networking.p2p.rpc.RpcResponseListener;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.TestSpecContext;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.TestSpecInvocationContextProvider;
import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.BlobIdentifier;
Expand All @@ -57,7 +58,7 @@ public class BlobSidecarsByRootListenerValidatingProxyTest {
private BlobSidecarsByRootListenerValidatingProxy listenerWrapper;

@BeforeEach
void setUp(final TestSpecInvocationContextProvider.SpecContext specContext) {
void setUp(final SpecContext specContext) {
spec =
switch (specContext.getSpecMilestone()) {
case PHASE0 -> throw new IllegalArgumentException("Phase0 is an unsupported milestone");
Expand All @@ -67,6 +68,7 @@ void setUp(final TestSpecInvocationContextProvider.SpecContext specContext) {
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7732 -> TestSpecFactory.createMinimalWithEip7732ForkEpoch(currentForkEpoch);
};
dataStructureUtil = new DataStructureUtil(spec);
currentForkFirstSlot = spec.computeStartSlotAtEpoch(currentForkEpoch);
Expand Down Expand Up @@ -140,10 +142,7 @@ void blobSidecarIdentifierNotRequested() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_UNEXPECTED_IDENTIFIER
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_UNEXPECTED_IDENTIFIER.describe());
}

@TestTemplate
Expand All @@ -166,10 +165,7 @@ void blobSidecarFailsKzgVerification() {
assertThatThrownBy(result::get)
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_KZG_VERIFICATION_FAILED
.describe());
.hasMessageContaining(InvalidResponseType.BLOB_SIDECAR_KZG_VERIFICATION_FAILED.describe());
}

@TestTemplate
Expand All @@ -193,8 +189,6 @@ void blobSidecarFailsInclusionProofVerification() {
.hasCauseExactlyInstanceOf(BlobSidecarsResponseInvalidResponseException.class);
assertThatThrownBy(result::get)
.hasMessageContaining(
BlobSidecarsResponseInvalidResponseException.InvalidResponseType
.BLOB_SIDECAR_INCLUSION_PROOF_VERIFICATION_FAILED
.describe());
InvalidResponseType.BLOB_SIDECAR_INCLUSION_PROOF_VERIFICATION_FAILED.describe());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.networking.eth2.peers.Eth2Peer;
import tech.pegasys.teku.networking.eth2.peers.RequestApproval;
import tech.pegasys.teku.networking.eth2.peers.RequestApproval.RequestApprovalBuilder;
import tech.pegasys.teku.networking.eth2.rpc.beaconchain.BeaconChainMethodIds;
import tech.pegasys.teku.networking.eth2.rpc.core.ResponseCallback;
import tech.pegasys.teku.networking.eth2.rpc.core.RpcException;
Expand All @@ -48,7 +49,7 @@
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.TestSpecContext;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.TestSpecInvocationContextProvider;
import tech.pegasys.teku.spec.TestSpecInvocationContextProvider.SpecContext;
import tech.pegasys.teku.spec.config.SpecConfigDeneb;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecar;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
Expand All @@ -71,8 +72,7 @@ public class BlobSidecarsByRootMessageHandlerTest {
private final ArgumentCaptor<RpcException> rpcExceptionCaptor =
ArgumentCaptor.forClass(RpcException.class);
private final Optional<RequestApproval> allowedObjectsRequest =
Optional.of(
new RequestApproval.RequestApprovalBuilder().objectsCount(100).timeSeconds(ZERO).build());
Optional.of(new RequestApprovalBuilder().objectsCount(100).timeSeconds(ZERO).build());

@SuppressWarnings("unchecked")
private final ResponseCallback<BlobSidecar> callback = mock(ResponseCallback.class);
Expand All @@ -91,7 +91,7 @@ public class BlobSidecarsByRootMessageHandlerTest {
private Spec spec;

@BeforeEach
public void setup(final TestSpecInvocationContextProvider.SpecContext specContext) {
public void setup(final SpecContext specContext) {
specMilestone = specContext.getSpecMilestone();
spec =
switch (specContext.getSpecMilestone()) {
Expand All @@ -102,6 +102,7 @@ public void setup(final TestSpecInvocationContextProvider.SpecContext specContex
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7732 -> TestSpecFactory.createMinimalWithEip7732ForkEpoch(currentForkEpoch);
};
dataStructureUtil = new DataStructureUtil(spec);
messageSchema =
Expand Down
Loading

0 comments on commit 40efa62

Please sign in to comment.