Skip to content
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
Expand Up @@ -84,6 +84,25 @@ public void shouldReturnNetworkIdentityAltair() throws Exception {
"{\"seq_number\":\"4666673844721362956\",\"attnets\":\"0x0288000000000000\",\"syncnets\":\"0x0f\"}");
}

@Test
public void shouldReturnNetworkIdentityFulu() throws Exception {
startRestAPIAtGenesis(SpecMilestone.FULU);

final MetadataMessage metadataMessage =
spec.getGenesisSchemaDefinitions()
.getMetadataMessageSchema()
.create(seqnr, List.of(1, 11, 15), List.of(0, 1, 2, 3), Optional.of(UInt64.valueOf(4)));

when(eth2P2PNetwork.getMetadata()).thenReturn(metadataMessage);

final Response response = getResponse(GetIdentity.ROUTE);
assertThat(response.code()).isEqualTo(SC_OK);
checkResponseData(
response,
"{\"seq_number\":\"4666673844721362956\",\"attnets\":\"0x0288000000000000\",\"syncnets\":\"0x0f\","
+ "\"custody_group_count\":\"4\"}");
}

private void checkResponseData(final Response response, final String metadata)
throws IOException {
final JsonNode data = getResponseData(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
"pattern" : "^0x[a-fA-F0-9]{2,}$",
"description" : "Bitvector representing the node's persistent sync committee subnet subscriptions.",
"format" : "bytes"
},
"custody_group_count" : {
"type" : "string",
"description" : "Uint64 representing the node's custody group count. The metadata is present from the Fulu fork.",
"example" : "1",
"format" : "uint64"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ private static SerializableTypeDefinition<MetadataMessage> createMetadataType(
.withDescription(
"Bitvector representing the node's persistent sync committee subnet subscriptions."),
MetadataMessage::getOptionalSyncnets)
.withOptionalField(
"custody_group_count",
UINT64_TYPE.withDescription(
"Uint64 representing the node's custody group count. The metadata is present from the Fulu fork."),
MetadataMessage::getOptionalCustodyGroupCount)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_BODY_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_STATE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.METADATA_MESSAGE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_AGGREGATE_AND_PROOF_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BEACON_BLOCK_SCHEMA;

Expand All @@ -37,7 +38,7 @@
import tech.pegasys.teku.spec.datastructures.lightclient.LightClientHeaderSchema;
import tech.pegasys.teku.spec.datastructures.lightclient.LightClientUpdateResponseSchema;
import tech.pegasys.teku.spec.datastructures.lightclient.LightClientUpdateSchema;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.versions.altair.MetadataMessageSchemaAltair;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessageSchema;
import tech.pegasys.teku.spec.datastructures.operations.AggregateAndProof.AggregateAndProofSchema;
import tech.pegasys.teku.spec.datastructures.operations.Attestation;
import tech.pegasys.teku.spec.datastructures.operations.AttestationSchema;
Expand Down Expand Up @@ -69,7 +70,7 @@ public class SchemaDefinitionsAltair extends AbstractSchemaDefinitions {
private final SyncCommitteeContributionSchema syncCommitteeContributionSchema;
private final ContributionAndProofSchema contributionAndProofSchema;
private final SignedContributionAndProofSchema signedContributionAndProofSchema;
private final MetadataMessageSchemaAltair metadataMessageSchema;
private final MetadataMessageSchema<?> metadataMessageSchema;
private final LightClientHeaderSchema lightClientHeaderSchema;
private final LightClientBootstrapSchema lightClientBootstrapSchema;
private final LightClientUpdateSchema lightClientUpdateSchema;
Expand All @@ -92,7 +93,7 @@ public SchemaDefinitionsAltair(final SchemaRegistry schemaRegistry) {
ContributionAndProofSchema.create(syncCommitteeContributionSchema);
this.signedContributionAndProofSchema =
SignedContributionAndProofSchema.create(contributionAndProofSchema);
this.metadataMessageSchema = new MetadataMessageSchemaAltair(specConfig.getNetworkingConfig());
this.metadataMessageSchema = schemaRegistry.get(METADATA_MESSAGE_SCHEMA);
this.lightClientHeaderSchema = new LightClientHeaderSchema();
this.lightClientBootstrapSchema = new LightClientBootstrapSchema(specConfig);
this.lightClientUpdateSchema = new LightClientUpdateSchema(specConfig);
Expand Down Expand Up @@ -195,7 +196,7 @@ public BeaconBlockBodyBuilder createBeaconBlockBodyBuilder() {
}

@Override
public MetadataMessageSchemaAltair getMetadataMessageSchema() {
public MetadataMessageSchema<?> getMetadataMessageSchema() {
return metadataMessageSchema;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_BODY_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_STATE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.METADATA_MESSAGE_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_AGGREGATE_AND_PROOF_SCHEMA;
import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BEACON_BLOCK_SCHEMA;

Expand All @@ -31,7 +32,7 @@
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodyBuilder;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodySchema;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.phase0.BeaconBlockBodyBuilderPhase0;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.versions.phase0.MetadataMessageSchemaPhase0;
import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.MetadataMessageSchema;
import tech.pegasys.teku.spec.datastructures.operations.AggregateAndProof.AggregateAndProofSchema;
import tech.pegasys.teku.spec.datastructures.operations.Attestation;
import tech.pegasys.teku.spec.datastructures.operations.AttestationSchema;
Expand All @@ -53,13 +54,12 @@ public class SchemaDefinitionsPhase0 extends AbstractSchemaDefinitions {
private final BeaconStateSchema<? extends BeaconState, ? extends MutableBeaconState>
beaconStateSchema;
private final BeaconBlockBodySchema<?> beaconBlockBodySchema;
private final MetadataMessageSchemaPhase0 metadataMessageSchema;
private final MetadataMessageSchema<?> metadataMessageSchema;
private final BeaconBlockSchema beaconBlockSchema;
private final SignedBeaconBlockSchema signedBeaconBlockSchema;

public SchemaDefinitionsPhase0(final SchemaRegistry schemaRegistry) {
super(schemaRegistry);
final SpecConfig specConfig = schemaRegistry.getSpecConfig();
this.indexedAttestationSchema = schemaRegistry.get(SchemaTypes.INDEXED_ATTESTATION_SCHEMA);
this.attesterSlashingSchema = schemaRegistry.get(SchemaTypes.ATTESTER_SLASHING_SCHEMA);

Expand All @@ -68,7 +68,7 @@ public SchemaDefinitionsPhase0(final SchemaRegistry schemaRegistry) {
this.signedAggregateAndProofSchema = schemaRegistry.get(SIGNED_AGGREGATE_AND_PROOF_SCHEMA);
this.beaconStateSchema = schemaRegistry.get(BEACON_STATE_SCHEMA);
this.beaconBlockBodySchema = schemaRegistry.get(BEACON_BLOCK_BODY_SCHEMA);
this.metadataMessageSchema = new MetadataMessageSchemaPhase0(specConfig.getNetworkingConfig());
this.metadataMessageSchema = schemaRegistry.get(METADATA_MESSAGE_SCHEMA);
this.beaconBlockSchema = schemaRegistry.get(BEACON_BLOCK_SCHEMA);
this.signedBeaconBlockSchema = schemaRegistry.get(SIGNED_BEACON_BLOCK_SCHEMA);
}
Expand Down Expand Up @@ -164,7 +164,7 @@ public BeaconBlockBodyBuilder createBeaconBlockBodyBuilder() {
}

@Override
public MetadataMessageSchemaPhase0 getMetadataMessageSchema() {
public MetadataMessageSchema<?> getMetadataMessageSchema() {
return metadataMessageSchema;
}

Expand Down