Skip to content

Commit d0ce076

Browse files
Merge branch 'develop' of https://github.com/stacks-network/stacks-core into bugfix/signers-send-updates-after-timing-out-block
2 parents 03cc1d5 + fab1a15 commit d0ce076

File tree

8 files changed

+82
-14
lines changed

8 files changed

+82
-14
lines changed

CHANGELOG.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,28 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1111

1212
- Setup for epoch 3.4 and Clarity version 5. Epoch 3.4 is currently set to activate at Bitcoin height 3,400,000 (very far in the future) until an activation height is selected. Clarity will activate with epoch 3.4.
1313

14+
## [3.3.0.0.5]
15+
16+
### Added
17+
18+
- New endpoint `/v3/blocks/simulate/{block_id}` allows to simulate the execution of a specific block with a brand new set of transactions
19+
- Improved block validation in `stacks-inspect`.
20+
21+
### Changed
22+
23+
- Removed `validate-naka-block` option in `stacks-inspect`, merging it with `validate-block` so that users do not need to differentiate between the two.
24+
1425
## [3.3.0.0.4]
1526

1627
### Added
1728

1829
- New `/v3/tenures/tip_metadata` endpoint for returning some metadata along with the normal tenure tip information.
19-
- New endpoint `/v3/blocks/simulate/{block_id}` allows to simulate the execution of a specific block with a brand new set of transactions
2030

2131
## [3.3.0.0.3]
2232

2333
### Added
2434

2535
- In the `/v3/transaction/{txid}` RPC endpoint, added `block_height` and `is_canonical` to the response.
26-
- Improved block validation in `stacks-inspect`.
27-
28-
### Changed
29-
30-
- Removed `validate-naka-block` option in `stacks-inspect`, merging it with `validate-block` so that users do not need to differentiate between the two.
3136

3237
### Fixed
3338

clarity/src/vm/functions/post_conditions.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,8 @@ fn check_allowances(
477477
}
478478

479479
// Check STX movements
480-
if let Some(stx_moved) = assets.get_stx(owner) {
480+
let amount_moved = assets.get_stx(owner);
481+
if let Some(stx_moved) = amount_moved {
481482
if stx_allowances.is_empty() {
482483
// If there are no allowances for STX, any movement is a violation
483484
record_violation(MAX_ALLOWANCES as u128);
@@ -492,7 +493,8 @@ fn check_allowances(
492493
}
493494

494495
// Check STX burns
495-
if let Some(stx_burned) = assets.get_stx_burned(owner) {
496+
let amount_burned = assets.get_stx_burned(owner);
497+
if let Some(stx_burned) = amount_burned {
496498
if stx_allowances.is_empty() {
497499
// If there are no allowances for STX, any burn is a violation
498500
record_violation(MAX_ALLOWANCES as u128);
@@ -581,6 +583,26 @@ fn check_allowances(
581583
}
582584
}
583585

586+
if earliest_violation.is_none() {
587+
// Check combined STX burns and movements. If the total exceeds any allowance,
588+
// emit an error that makes this transaction invalid.
589+
let total_stx_change = amount_moved
590+
.unwrap_or(0)
591+
.checked_add(amount_burned.unwrap_or(0))
592+
.ok_or(VmInternalError::Expect(
593+
"STX movement and burn overflowed u128".into(),
594+
))?;
595+
if total_stx_change > 0 {
596+
for (_, allowance) in &stx_allowances {
597+
if total_stx_change > *allowance {
598+
return Err(VmExecutionError::Internal(VmInternalError::Expect(
599+
"Total STX movement and burn exceeds allowance".into(),
600+
)));
601+
}
602+
}
603+
}
604+
}
605+
584606
Ok(earliest_violation)
585607
}
586608

stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ use stacks::core::{
7979
PEER_VERSION_EPOCH_1_0, PEER_VERSION_EPOCH_2_0, PEER_VERSION_EPOCH_2_05,
8080
PEER_VERSION_EPOCH_2_1, PEER_VERSION_EPOCH_2_2, PEER_VERSION_EPOCH_2_3, PEER_VERSION_EPOCH_2_4,
8181
PEER_VERSION_EPOCH_2_5, PEER_VERSION_EPOCH_3_0, PEER_VERSION_EPOCH_3_1, PEER_VERSION_EPOCH_3_2,
82-
PEER_VERSION_TESTNET,
82+
PEER_VERSION_EPOCH_3_3, PEER_VERSION_TESTNET,
8383
};
8484
use stacks::libstackerdb::{SlotMetadata, StackerDBChunkData};
8585
use stacks::net::api::callreadonly::CallReadOnlyRequestBody;
@@ -237,7 +237,7 @@ lazy_static! {
237237
start_height: 253,
238238
end_height: STACKS_EPOCH_MAX,
239239
block_limit: HELIUM_BLOCK_LIMIT_20,
240-
network_epoch: PEER_VERSION_EPOCH_3_2
240+
network_epoch: PEER_VERSION_EPOCH_3_3
241241
},
242242
];
243243
}

stacks-signer/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to the versioning scheme outlined in the [README.md](README.md).
77

8-
98
## [Unreleased]
109

10+
## [3.3.0.0.5.0]
11+
1112
### Changed
1213

1314
- Reduced default tenure-extend idle timer from 120 seconds to 60 seconds

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4636,6 +4636,15 @@ impl NakamotoChainState {
46364636
));
46374637
}
46384638

4639+
if parent_chain_tip.stacks_block_height.saturating_add(1) != block.header.chain_length {
4640+
warn!("Error processing nakamoto block: Parent height does not agree with block chain length";
4641+
"parent_chain_tip.block_height" => %parent_chain_tip.stacks_block_height,
4642+
"block.header.chain_length" => &block.header.chain_length);
4643+
return Err(ChainstateError::InvalidStacksBlock(
4644+
"Parent block height does not agree with child block".into(),
4645+
));
4646+
}
4647+
46394648
// look up this block's sortition's burnchain block hash and height.
46404649
// It must exist in the same Bitcoin fork as our `burn_dbconn`.
46414650
let tenure_block_snapshot =

stackslib/src/net/api/postblock_proposal.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,21 @@ impl NakamotoBlockProposal {
546546
});
547547
}
548548

549+
if self.block.header.chain_length
550+
!= parent_stacks_header.stacks_block_height.saturating_add(1)
551+
{
552+
warn!(
553+
"Rejected block proposal";
554+
"reason" => "Block height is non-contiguous with parent",
555+
"block_height" => self.block.header.chain_length,
556+
"parent_block_height" => parent_stacks_header.stacks_block_height,
557+
);
558+
return Err(BlockValidateRejectReason {
559+
reason_code: ValidateRejectCode::InvalidBlock,
560+
reason: "Block height is non-contiguous with parent".into(),
561+
});
562+
}
563+
549564
let tenure_change = self
550565
.block
551566
.txs

stackslib/src/util_lib/bloom.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ use rand::thread_rng;
2323
use rusqlite::blob::Blob;
2424
use rusqlite::{params, Error as sqlite_error};
2525
use siphasher::sip::SipHasher; // this is SipHash-2-4
26-
use stacks_common::codec::{read_next, write_next, Error as codec_error, StacksMessageCodec};
26+
use stacks_common::codec::{
27+
read_next, write_next, Error as codec_error, StacksMessageCodec, MAX_MESSAGE_LEN,
28+
};
2729
use stacks_common::types::sqlite::NO_PARAMS;
2830
use stacks_common::util::hash::{to_hex, Sha512Trunc256Sum};
2931

@@ -112,6 +114,9 @@ fn decode_bitfield<R: Read>(fd: &mut R) -> Result<Vec<u8>, codec_error> {
112114
x if x == BitFieldEncoding::Sparse as u8 => {
113115
// sparse encoding
114116
let vec_len: u32 = read_next(fd)?;
117+
if vec_len > MAX_MESSAGE_LEN.saturating_sub(5) {
118+
return Err(codec_error::OverflowError("vec_len is too big".into()));
119+
}
115120
let num_filled: u32 = read_next(fd)?;
116121

117122
let mut ret = vec![0u8; vec_len as usize];
@@ -929,6 +934,17 @@ pub mod test {
929934
0x00, 0x00, 0x0f, 0x08
930935
]
931936
);
937+
938+
// vec_len too big
939+
let mut bitfield_too_big = vec![];
940+
encode_bitfield(&mut bitfield_too_big, &vec![0u8; MAX_MESSAGE_LEN as usize]).unwrap();
941+
let e = decode_bitfield(&mut &bitfield_too_big[..]);
942+
if let Err(codec_error::OverflowError(s)) = e {
943+
assert_eq!(s, "vec_len is too big".to_string());
944+
} else {
945+
error!("Unexpected decode_bitfield result: {e:?}");
946+
panic!();
947+
}
932948
}
933949

934950
#[test]

versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Update these values when a new release is created.
22
# `stacks-common/build.rs` will automatically update `versions.rs` with these values.
3-
stacks_node_version = "3.3.0.0.4"
4-
stacks_signer_version = "3.3.0.0.4.0"
3+
stacks_node_version = "3.3.0.0.5"
4+
stacks_signer_version = "3.3.0.0.5.0"

0 commit comments

Comments
 (0)