Skip to content

Commit

Permalink
chore: signer-signature -> signer-signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x committed Oct 18, 2024
1 parent eec8e70 commit 02c18b6
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 111 deletions.
4 changes: 2 additions & 2 deletions migrations/1729262745699_stacks_block_signer-signatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
exports.up = pgm => {

pgm.addColumn('blocks', {
signer_signature: {
signer_signatures: {
type: 'bytea[]',
}
});

pgm.createIndex('blocks', 'signer_signature', { method: 'gin' });
pgm.createIndex('blocks', 'signer_signatures', { method: 'gin' });

};
8 changes: 4 additions & 4 deletions src/api/routes/v2/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,17 @@ export const BlockRoutesV2: FastifyPluginAsync<
);

fastify.get(
'/:height_or_hash/signer-signature',
'/:height_or_hash/signer-signatures',
{
preHandler: handleBlockCache,
preValidation: (req, _reply, done) => {
cleanBlockHeightOrHashParam(req.params);
done();
},
schema: {
operationId: 'get_signer_signature_for_block',
summary: 'Get signer signature for block',
description: `Retrieves the "signer signature" (typically an array of signature byte strings) in a single block`,
operationId: 'get_signer_signatures_for_block',
summary: 'Get signer signatures for block',
description: `Retrieves the signer signatures (an array of signature byte strings) in a single block`,
tags: ['Blocks'],
params: BlockParamsSchema,
querystring: Type.Object({
Expand Down
4 changes: 2 additions & 2 deletions src/datastore/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface DbBlock {
tx_count: number;
block_time: number;
signer_bitvec: string | null;
signer_signature: string[] | null;
signer_signatures: string[] | null;
}

/** An interface representing the microblock data that can be constructed _only_ from the /new_microblocks payload */
Expand Down Expand Up @@ -1287,7 +1287,7 @@ export interface BlockInsertValues {
execution_cost_write_length: number;
tx_count: number;
signer_bitvec: string | null;
signer_signature: PgBytea[] | null;
signer_signatures: PgBytea[] | null;
}

export interface MicroblockInsertValues {
Expand Down
2 changes: 1 addition & 1 deletion src/datastore/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export function parseBlockQueryResult(row: BlockQueryResult): DbBlock {
execution_cost_write_length: Number.parseInt(row.execution_cost_write_length),
tx_count: row.tx_count,
signer_bitvec: row.signer_bitvec,
signer_signature: null, // this field is not queried from db by default due to size constraints
signer_signatures: null, // this field is not queried from db by default due to size constraints
};
return block;
}
Expand Down
8 changes: 4 additions & 4 deletions src/datastore/pg-store-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ export class PgStoreV2 extends BasePgStoreModule {
OR index_block_hash = ${normalizeHashString(blockId.hash)}
)`
: sql`block_height = ${blockId.height}`;
const blockQuery = await sql<{ signer_signature: string[]; total: number }[]>`
const blockQuery = await sql<{ signer_signatures: string[]; total: number }[]>`
SELECT
signer_signature[${offset + 1}:${offset + limit}] as signer_signature,
array_length(signer_signature, 1)::integer AS total
signer_signatures[${offset + 1}:${offset + limit}] as signer_signatures,
array_length(signer_signatures, 1)::integer AS total
FROM blocks
WHERE canonical = true AND ${filter}
LIMIT 1
Expand All @@ -263,7 +263,7 @@ export class PgStoreV2 extends BasePgStoreModule {
return {
limit,
offset,
results: blockQuery[0].signer_signature,
results: blockQuery[0].signer_signatures,
total: blockQuery[0].total,
};
});
Expand Down
4 changes: 2 additions & 2 deletions src/datastore/pg-write-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export class PgWriteStore extends PgStore {
execution_cost_write_length: block.execution_cost_write_length,
tx_count: block.tx_count,
signer_bitvec: block.signer_bitvec,
signer_signature: block.signer_signature,
signer_signatures: block.signer_signatures,
};
const result = await sql`
INSERT INTO blocks ${sql(values)}
Expand Down Expand Up @@ -3385,7 +3385,7 @@ export class PgWriteStore extends PgStore {
execution_cost_write_length: block.execution_cost_write_length,
tx_count: block.tx_count,
signer_bitvec: block.signer_bitvec,
signer_signature: block.signer_signature,
signer_signatures: block.signer_signatures,
}));
await sql`
INSERT INTO blocks ${sql(values)}
Expand Down
6 changes: 3 additions & 3 deletions src/event-stream/event-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ async function handleBlockMessage(
: null;

// Stacks-core does not include the '0x' prefix in the signer signature hex strings
const signerSignature =
const signerSignatures =
msg.signer_signature?.map(s => (s.startsWith('0x') ? s : '0x' + s)) ?? null;

const dbBlock: DbBlock = {
Expand All @@ -323,7 +323,7 @@ async function handleBlockMessage(
tx_count: msg.transactions.length,
block_time: blockData.block_time,
signer_bitvec: signerBitvec,
signer_signature: signerSignature,
signer_signatures: signerSignatures,
};

logger.debug(`Received block ${msg.block_hash} (${msg.block_height}) from node`, dbBlock);
Expand Down Expand Up @@ -1163,7 +1163,7 @@ export function parseNewBlockMessage(chainId: ChainID, msg: CoreNodeBlockMessage
execution_cost_write_length: totalCost.execution_cost_write_length,
tx_count: msg.transactions.length,
signer_bitvec: msg.signer_bitvec ?? null,
signer_signature: msg.signer_signature ?? null,
signer_signatures: msg.signer_signature ?? null,
};

const dbMinerRewards: DbMinerReward[] = [];
Expand Down
6 changes: 3 additions & 3 deletions tests/api/address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('address tests', () => {
execution_cost_write_length: 0,
tx_count: 1,
signer_bitvec: null,
signer_signature: null,
signer_signatures: null,
};
let indexIdIndex = 0;
const createStxTx = (
Expand Down Expand Up @@ -1170,7 +1170,7 @@ describe('address tests', () => {
execution_cost_write_length: 0,
tx_count: 1,
signer_bitvec: null,
signer_signature: null,
signer_signatures: null,
};

let indexIdIndex = 0;
Expand Down Expand Up @@ -2388,7 +2388,7 @@ describe('address tests', () => {
execution_cost_write_length: 0,
tx_count: 1,
signer_bitvec: null,
signer_signature: null,
signer_signatures: null,
};
const txBuilder = await makeContractCall({
contractAddress: 'ST11NJTTKGVT6D1HY4NJRVQWMQM7TVAR091EJ8P2Y',
Expand Down
10 changes: 5 additions & 5 deletions tests/api/block.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('block tests', () => {
execution_cost_write_length: 0,
tx_count: 1,
signer_bitvec: null,
signer_signature: null,
signer_signatures: null,
};
await db.updateBlock(client, block);
const tx: DbTxRaw = {
Expand Down Expand Up @@ -283,7 +283,7 @@ describe('block tests', () => {
expect(result.body).toEqual(expectedResp);
});

test('/block signer signature', async () => {
test('/block signer signatures', async () => {
const block_hash = '0x1234',
index_block_hash = '0xabcd',
tx_id = '0x12ff';
Expand All @@ -297,7 +297,7 @@ describe('block tests', () => {
index_block_hash,
// parent_index_block_hash: genesis_index_block_hash,
block_height: 1,
signer_signature: signerSignatures,
signer_signatures: signerSignatures,
})
.addTx({ block_hash, tx_id, index_block_hash })
.build();
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('block tests', () => {
expect(result.body).toEqual(expectedResp);

const sigReq = await supertest(api.server).get(
`/extended/v2/blocks/${block1.block.block_height}/signer-signature?limit=3&offset=70`
`/extended/v2/blocks/${block1.block.block_height}/signer-signatures?limit=3&offset=70`
);
const sigResult: BlockSignerSignatureResponse = sigReq.body;
expect(sigResult).toEqual({
Expand Down Expand Up @@ -619,7 +619,7 @@ describe('block tests', () => {
execution_cost_write_length: 0,
tx_count: 1,
signer_bitvec: null,
signer_signature: null,
signer_signatures: null,
};
const dbTx1: DbTxRaw = {
...dbBlock,
Expand Down
2 changes: 1 addition & 1 deletion tests/api/cache-control.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('cache-control tests', () => {
execution_cost_write_length: 0,
tx_count: 1,
signer_bitvec: null,
signer_signature: null,
signer_signatures: null,
};
const tx: DbTxRaw = {
tx_id: '0x1234',
Expand Down
Loading

0 comments on commit 02c18b6

Please sign in to comment.