Skip to content

Commit 6937df5

Browse files
authored
Merge pull request #5079 from stacks-network/chore/add-logs
chore: add warn logs for block validate rejections
2 parents 5321154 + fe3d7dc commit 6937df5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

stackslib/src/net/api/postblock_proposal.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ impl NakamotoBlockProposal {
215215

216216
let mainnet = self.chain_id == CHAIN_ID_MAINNET;
217217
if self.chain_id != chainstate.chain_id || mainnet != chainstate.mainnet {
218+
warn!(
219+
"Rejected block proposal";
220+
"reason" => "Wrong network/chain_id",
221+
"expected_chain_id" => chainstate.chain_id,
222+
"expected_mainnet" => chainstate.mainnet,
223+
"received_chain_id" => self.chain_id,
224+
"received_mainnet" => mainnet,
225+
);
218226
return Err(BlockValidateRejectReason {
219227
reason_code: ValidateRejectCode::InvalidBlock,
220228
reason: "Wrong network/chain_id".into(),
@@ -227,6 +235,10 @@ impl NakamotoBlockProposal {
227235
let expected_burn_opt =
228236
NakamotoChainState::get_expected_burns(&mut db_handle, chainstate.db(), &self.block)?;
229237
if expected_burn_opt.is_none() {
238+
warn!(
239+
"Rejected block proposal";
240+
"reason" => "Failed to find parent expected burns",
241+
);
230242
return Err(BlockValidateRejectReason {
231243
reason_code: ValidateRejectCode::UnknownParent,
232244
reason: "Failed to find parent expected burns".into(),
@@ -259,13 +271,25 @@ impl NakamotoBlockProposal {
259271
&parent_stacks_header.anchored_header
260272
{
261273
if self.block.header.timestamp <= parent_nakamoto_header.timestamp {
274+
warn!(
275+
"Rejected block proposal";
276+
"reason" => "Block timestamp is not greater than parent block",
277+
"block_timestamp" => self.block.header.timestamp,
278+
"parent_block_timestamp" => parent_nakamoto_header.timestamp,
279+
);
262280
return Err(BlockValidateRejectReason {
263281
reason_code: ValidateRejectCode::InvalidBlock,
264282
reason: "Block timestamp is not greater than parent block".into(),
265283
});
266284
}
267285
}
268286
if self.block.header.timestamp > get_epoch_time_secs() + 15 {
287+
warn!(
288+
"Rejected block proposal";
289+
"reason" => "Block timestamp is too far into the future",
290+
"block_timestamp" => self.block.header.timestamp,
291+
"current_time" => get_epoch_time_secs(),
292+
);
269293
return Err(BlockValidateRejectReason {
270294
reason_code: ValidateRejectCode::InvalidBlock,
271295
reason: "Block timestamp is too far into the future".into(),

0 commit comments

Comments
 (0)