diff --git a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/node/GetIdentityIntegrationTest.java b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/node/GetIdentityIntegrationTest.java index 4d0f2e83fc8..9564e1f5aa6 100644 --- a/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/node/GetIdentityIntegrationTest.java +++ b/data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/node/GetIdentityIntegrationTest.java @@ -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); diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/MetaData.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/MetaData.json index bfe838e65ae..044c00c0434 100644 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/MetaData.json +++ b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/MetaData.json @@ -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" } } } \ No newline at end of file diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/node/GetIdentity.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/node/GetIdentity.java index cda8980fb79..d36c23cb73d 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/node/GetIdentity.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/node/GetIdentity.java @@ -139,6 +139,11 @@ private static SerializableTypeDefinition 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(); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsAltair.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsAltair.java index 8cc1fac6433..c9216dad196 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsAltair.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsAltair.java @@ -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; @@ -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; @@ -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; @@ -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); @@ -195,7 +196,7 @@ public BeaconBlockBodyBuilder createBeaconBlockBodyBuilder() { } @Override - public MetadataMessageSchemaAltair getMetadataMessageSchema() { + public MetadataMessageSchema getMetadataMessageSchema() { return metadataMessageSchema; } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsPhase0.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsPhase0.java index 3b4d97934e0..cb532973079 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsPhase0.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsPhase0.java @@ -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; @@ -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; @@ -53,13 +54,12 @@ public class SchemaDefinitionsPhase0 extends AbstractSchemaDefinitions { private final BeaconStateSchema 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); @@ -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); } @@ -164,7 +164,7 @@ public BeaconBlockBodyBuilder createBeaconBlockBodyBuilder() { } @Override - public MetadataMessageSchemaPhase0 getMetadataMessageSchema() { + public MetadataMessageSchema getMetadataMessageSchema() { return metadataMessageSchema; }