Skip to content

Commit 42ef4bd

Browse files
authored
fix: detect and ignore BlockPreCommit messages (#92)
1 parent 1c0471c commit 42ef4bd

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/event-stream/msg-parsing.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,20 @@ export interface StateMachineUpdate extends ChunkMetadata {
102102
// local_supported_signer_protocol_version: u64,
103103
}
104104

105+
// https://github.com/stacks-network/stacks-core/blob/develop/libsigner/src/v0/messages.rs#L191
106+
export interface BlockPreCommitChunkType extends ChunkMetadata {
107+
messageType: 'BlockPreCommit';
108+
}
109+
105110
export type ParsedStackerDbChunk =
106111
| BlockProposalChunkType
107112
| BlockResponseChunkType
108113
| BlockPushedChunkType
109114
| MockProposalChunkType
110115
| MockSignatureChunkType
111116
| MockBlockChunkType
112-
| StateMachineUpdate;
117+
| StateMachineUpdate
118+
| BlockPreCommitChunkType;
113119

114120
export function parseStackerDbChunk(chunk: StackerDbChunk): ParsedStackerDbChunk[] {
115121
return chunk.modified_slots.flatMap(msg => {
@@ -144,6 +150,7 @@ enum SignerMessageTypePrefix {
144150
MockSignature = 4,
145151
MockBlock = 5,
146152
StateMachineUpdate = 6,
153+
BlockPreCommit = 7,
147154
}
148155

149156
// https://github.com/stacks-network/stacks-core/blob/cd702e7dfba71456e4983cf530d5b174e34507dc/libsigner/src/v0/messages.rs#L206
@@ -186,6 +193,10 @@ function parseSignerMessage(msg: Buffer) {
186193
return {
187194
messageType: 'StateMachineUpdate',
188195
} as const;
196+
case SignerMessageTypePrefix.BlockPreCommit:
197+
return {
198+
messageType: 'BlockPreCommit',
199+
} as const;
189200
default:
190201
throw new Error(`Unknown message type prefix: ${messageType}`);
191202
}

src/pg/ingestion/pg-write-store.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ export class PgWriteStore extends BasePgStoreModule {
106106
// ignore
107107
break;
108108
}
109+
case 'BlockPreCommit': {
110+
// ignore
111+
break;
112+
}
109113
default: {
110114
this.logger.error(chunk, `Unknown StackerDB event type`);
111115
break;

0 commit comments

Comments
 (0)