diff --git a/src/endpoints/blocks/entities/block.proof.ts b/src/endpoints/blocks/entities/block.proof.ts new file mode 100644 index 000000000..74a772239 --- /dev/null +++ b/src/endpoints/blocks/entities/block.proof.ts @@ -0,0 +1,37 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class BlockProofDto { + constructor(init?: Partial) { + Object.assign(this, init); + } + + @ApiProperty({ + type: String, + description: "Bitmap representing public keys involved in the proof", + example: "7702", + }) + pubKeysBitmap?: string; + + @ApiProperty({ + type: String, + description: "Aggregated BLS signature for the proof", + example: "50224d66a42a019991d16f25dba375b581f279d4394d4c254876c1484f61bed90fb20456f8af107c54e4eed1763e2a92", + }) + aggregatedSignature?: string; + + @ApiProperty({ + type: String, + description: "Hash of the block header being proven", + example: "414d526161587ae9f53453aa0392971272c48dbb3cc54a33448972d388e0deeb", + }) + headerHash?: string; + + @ApiProperty({type: Number, description: "Epoch number of the block header", example: 130}) + headerEpoch?: number; + + @ApiProperty({type: Number, description: "Nonce value of the block header", example: 13137}) + headerNonce?: number; + + @ApiProperty({type: Number, description: "Round number of the block header", example: 13163}) + headerRound?: number; +} diff --git a/src/endpoints/blocks/entities/block.ts b/src/endpoints/blocks/entities/block.ts index 52ed4e1e7..ed5dc51e7 100644 --- a/src/endpoints/blocks/entities/block.ts +++ b/src/endpoints/blocks/entities/block.ts @@ -1,6 +1,7 @@ import { ApiUtils } from "@multiversx/sdk-nestjs-http"; import { ApiProperty } from "@nestjs/swagger"; import { Identity } from "src/endpoints/identities/entities/identity"; +import { BlockProofDto } from "./block.proof"; export class Block { constructor(init?: Partial) { @@ -64,6 +65,12 @@ export class Block { @ApiProperty({ type: String, nullable: true, required: false }) scheduledRootHash: string | undefined = undefined; + @ApiProperty({ type: BlockProofDto, nullable: true, required: false }) + previousHeaderProof: BlockProofDto | undefined = undefined; + + @ApiProperty({ type: BlockProofDto, nullable: true, required: false }) + proof: BlockProofDto | undefined = undefined; + static mergeWithElasticResponse(newBlock: T, blockRaw: any): T { blockRaw.shard = blockRaw.shardId; diff --git a/src/test/unit/services/blocks.spec.ts b/src/test/unit/services/blocks.spec.ts index 2c65d6a5f..9730e0ddb 100644 --- a/src/test/unit/services/blocks.spec.ts +++ b/src/test/unit/services/blocks.spec.ts @@ -9,6 +9,7 @@ import { BlsService } from "src/endpoints/bls/bls.service"; import { IdentitiesService } from "src/endpoints/identities/identities.service"; import { NodeService } from "src/endpoints/nodes/node.service"; import { CacheInfo } from "src/utils/cache.info"; +import { BlockProofDto } from "../../../endpoints/blocks/entities/block.proof"; describe('Block Service', () => { let blockService: BlockService; @@ -128,6 +129,15 @@ describe('Block Service', () => { gasPenalized: 0, maxGasLimit: 15000000000, scheduledRootHash: undefined, + proof: undefined, + previousHeaderProof: new BlockProofDto({ + pubKeysBitmap: '7702', + aggregatedSignature: '50224d66a42a019991d16f25dba375b581f279d4394d4c254876c1484f61bed90fb20456f8af107c54e4eed1763e2a92', + headerHash: '414d526161587ae9f53453aa0392971272c48dbb3cc54a33448972d388e0deeb', + headerEpoch: 100, + headerRound: 12500, + headerNonce: 10500, + }), }; it('should call cachingService.getOrSet with the correct arguments and return the result', async () => { @@ -173,7 +183,7 @@ describe('Block Service', () => { ); }); - it('should retur current epoch', async () => { + it('should return current epoch', async () => { blockService.getBlocks = jest.fn().mockResolvedValue([block]); const result = await blockService.getCurrentEpoch();