Skip to content

Commit 0d0e3b2

Browse files
committed
Merge branch 'develop' into feat/propagate-vm-error
2 parents 320e8f0 + d16bd3a commit 0d0e3b2

35 files changed

+2029
-246
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
99

1010
### Added
1111

12+
- Added new `ValidateRejectCode` values to the `/v3/block_proposal` endpoint
1213
- Include a reason string in the transaction receipt when a transaction is rolled back due to a post-condition. This should help users in understanding what went wrong.
1314

1415
### Changed
1516

1617
- Reduce the default `block_rejection_timeout_steps` configuration so that miners will retry faster when blocks fail to reach 70% approved or 30% rejected.
18+
- Added index for `next_ready_nakamoto_block()` which improves block processing performance.
19+
- Added a new field, `parent_burn_block_hash`, to the payload that is included in the `/new_burn_block` event observer payload.
1720

1821
## [3.1.0.0.8]
1922

@@ -29,7 +32,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
2932

3033
- When a miner times out waiting for signatures, it will re-propose the same block instead of building a new block ([#5877](https://github.com/stacks-network/stacks-core/pull/5877))
3134
- Improve tenure downloader trace verbosity applying proper logging level depending on the tenure state ("debug" if unconfirmed, "info" otherwise) ([#5871](https://github.com/stacks-network/stacks-core/issues/5871))
32-
- Remove warning log about missing UTXOs when a node is configured as `miner` with `mock_mining` mode enabled ([#5841](https://github.com/stacks-network/stacks-core/issues/5841))
35+
- Remove warning log about missing UTXOs when a node is configured as `miner` with `mock_mining` mode enabled ([#5841](https://github.com/stacks-network/stacks-core/issues/5841))
3336
- Deprecated the `wait_on_interim_blocks` option in the miner config file. This option is no longer needed, as the miner will always wait for interim blocks to be processed before mining a new block. To wait extra time in between blocks, use the `min_time_between_blocks_ms` option instead. ([#5979](https://github.com/stacks-network/stacks-core/pull/5979))
3437
- Added `empty_mempool_sleep_ms` to the miner config file to control the time to wait in between mining attempts when the mempool is empty. If not set, the default sleep time is 2.5s. ([#5997](https://github.com/stacks-network/stacks-core/pull/5997))
3538

Cargo.lock

Lines changed: 30 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/event-dispatcher.md

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ These events are sent to the configured endpoint at two URLs:
2727
This payload includes data related to a newly processed block,
2828
and any events emitted from Stacks transactions during the block.
2929

30-
If the transaction originally comes from the parent microblock stream
30+
If the transaction originally comes from the parent microblock stream
3131
preceding this block, the microblock related fields will be filled in.
3232

3333
If the `raw_tx` field for a particular transaction is "0x00", that indicates
34-
that it is a burnchain operation. A burnchain operation is a transaction that
34+
that it is a burnchain operation. A burnchain operation is a transaction that
3535
is executed on the Stacks network, but was sent through the Bitcoin network.
36-
The Stacks network supports a few specific burnchain operations. You can read
36+
The Stacks network supports a few specific burnchain operations. You can read
3737
more about them [here](https://github.com/stacksgov/sips/blob/main/sips/sip-007/sip-007-stacking-consensus.md#stx-operations-on-bitcoin).
3838
The section below has example json encodings for each of the burnchain operations.
3939

@@ -152,8 +152,8 @@ Example:
152152
}
153153
```
154154

155-
#### Example json values for burnchain operations
156-
- TransferStx
155+
#### Example json values for burnchain operations
156+
- TransferStx
157157
```json
158158
{
159159
"transfer_stx": {
@@ -233,6 +233,8 @@ Example:
233233
```json
234234
{
235235
"burn_block_hash": "0x4eaabcd105865e471f697eff5dd5bd85d47ecb5a26a3379d74fae0ae87c40904",
236+
"consensus_hash": "0x53c166a709a9abd64a92a57f928a8b26aad08992",
237+
"parent_burn_block_hash": "0x6eaebcd105865e471f697eff5dd5bd85d47ecb5a26a3379d74fae0ae87c40904",
236238
"burn_block_height": 331,
237239
"reward_recipients": [
238240
{
@@ -258,8 +260,8 @@ Example:
258260

259261
### `POST /new_microblocks`
260262

261-
This payload includes data related to one or more microblocks that are either emmitted by the
262-
node itself, or received through the network.
263+
This payload includes data related to one or more microblocks that are either emmitted by the
264+
node itself, or received through the network.
263265

264266
Example:
265267

@@ -311,9 +313,9 @@ Example:
311313
}
312314
```
313315

314-
* `burn_block_{}` are the stats related to the burn block that is associated with the stacks
316+
* `burn_block_{}` are the stats related to the burn block that is associated with the stacks
315317
block that precedes this microblock stream.
316-
* Each transaction json object includes information about the microblock the transaction was packaged into.
318+
* Each transaction json object includes information about the microblock the transaction was packaged into.
317319

318320
### `POST /new_mempool_tx`
319321

@@ -384,23 +386,23 @@ Example:
384386
"tx_events": [
385387
{
386388
"Success": {
387-
"txid": "3e04ada5426332bfef446ba0a06d124aace4ade5c11840f541bf88e2e919faf6",
388-
"fee": 0,
389-
"execution_cost": {
390-
"write_length": 0,
391-
"write_count": 0,
392-
"read_length": 0,
393-
"read_count": 0,
389+
"txid": "3e04ada5426332bfef446ba0a06d124aace4ade5c11840f541bf88e2e919faf6",
390+
"fee": 0,
391+
"execution_cost": {
392+
"write_length": 0,
393+
"write_count": 0,
394+
"read_length": 0,
395+
"read_count": 0,
394396
"runtime": 0
395-
},
397+
},
396398
"result": {
397-
"ResponseData":
399+
"ResponseData":
398400
{
399401
"committed": true,
400402
"data": true
401403
}
402404
}
403-
}},
405+
}},
404406
{
405407
"ProcessingError": {
406408
"txid": "eef9f46b20fb637bd07ec92ad3ec175a5a4bdf3e8799259fc5b16a272090d4de",
@@ -432,23 +434,23 @@ Example:
432434
"tx_events": [
433435
{
434436
"Success": {
435-
"txid": "3e04ada5426332bfef446ba0a06d124aace4ade5c11840f541bf88e2e919faf6",
436-
"fee": 0,
437-
"execution_cost": {
438-
"write_length": 10,
439-
"write_count": 10,
440-
"read_length": 20,
441-
"read_count": 10,
437+
"txid": "3e04ada5426332bfef446ba0a06d124aace4ade5c11840f541bf88e2e919faf6",
438+
"fee": 0,
439+
"execution_cost": {
440+
"write_length": 10,
441+
"write_count": 10,
442+
"read_length": 20,
443+
"read_count": 10,
442444
"runtime": 1290
443-
},
445+
},
444446
"result": {
445-
"ResponseData":
447+
"ResponseData":
446448
{
447449
"committed": true,
448450
"data": true
449451
}
450452
}
451-
}},
453+
}},
452454
{
453455
"Skipped": {
454456
"txid": "eef9f46b20fb637bd07ec92ad3ec175a5a4bdf3e8799259fc5b16a272090d4de",

stacks-signer/src/client/stacks_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ impl StacksClient {
313313
let block_proposal = NakamotoBlockProposal {
314314
block,
315315
chain_id: self.chain_id,
316+
replay_txs: None,
316317
};
317318
let timer = crate::monitoring::actions::new_rpc_call_timer(
318319
&self.block_proposal_path(),

stackslib/src/chainstate/coordinator/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ pub trait BlockEventDispatcher {
195195
burns: u64,
196196
reward_recipients: Vec<PoxAddress>,
197197
consensus_hash: &ConsensusHash,
198+
parent_burn_block_hash: &BurnchainHeaderHash,
198199
);
199200
}
200201

@@ -964,6 +965,7 @@ pub fn dispatcher_announce_burn_ops<T: BlockEventDispatcher>(
964965
paid_rewards.burns,
965966
recipients,
966967
consensus_hash,
968+
&burn_header.parent_block_hash,
967969
);
968970
}
969971

stackslib/src/chainstate/coordinator/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ impl BlockEventDispatcher for NullEventDispatcher {
446446
_burns: u64,
447447
_slot_holders: Vec<PoxAddress>,
448448
_consensus_hash: &ConsensusHash,
449+
_parent_burn_block_hash: &BurnchainHeaderHash,
449450
) {
450451
}
451452
}

stackslib/src/chainstate/nakamoto/staging_blocks.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ pub const NAKAMOTO_STAGING_DB_SCHEMA_3: &[&str] = &[
160160
r#"UPDATE db_version SET version = 3"#,
161161
];
162162

163-
pub const NAKAMOTO_STAGING_DB_SCHEMA_LATEST: u32 = 3;
163+
pub const NAKAMOTO_STAGING_DB_SCHEMA_4: &[&str] = &[
164+
r#"CREATE INDEX nakamoto_staging_blocks_by_ready_and_height ON nakamoto_staging_blocks(burn_attachable, orphaned, processed, height);"#,
165+
r#"UPDATE db_version SET version = 4"#,
166+
];
167+
168+
pub const NAKAMOTO_STAGING_DB_SCHEMA_LATEST: u32 = 4;
164169

165170
pub struct NakamotoStagingBlocksConn(rusqlite::Connection);
166171

@@ -796,6 +801,15 @@ impl StacksChainState {
796801
assert_eq!(version, 3, "Nakamoto staging DB migration failure");
797802
debug!("Migrated Nakamoto staging blocks DB to schema 3");
798803
}
804+
3 => {
805+
debug!("Migrate Nakamoto staging blocks DB to schema 3");
806+
for cmd in NAKAMOTO_STAGING_DB_SCHEMA_4.iter() {
807+
conn.execute(cmd, NO_PARAMS)?;
808+
}
809+
let version = Self::get_nakamoto_staging_blocks_db_version(conn)?;
810+
assert_eq!(version, 4, "Nakamoto staging DB migration failure");
811+
debug!("Migrated Nakamoto staging blocks DB to schema 3");
812+
}
799813
NAKAMOTO_STAGING_DB_SCHEMA_LATEST => {
800814
break;
801815
}

stackslib/src/chainstate/stacks/db/blocks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ impl BlockEventDispatcher for DummyEventDispatcher {
205205
_burns: u64,
206206
_slot_holders: Vec<PoxAddress>,
207207
_consensus_hash: &ConsensusHash,
208+
_parent_burn_block_hash: &BurnchainHeaderHash,
208209
) {
209210
error!("We should never try to announce to the dummy dispatcher");
210211
panic!();

stackslib/src/core/test_util.rs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use clarity::codec::StacksMessageCodec;
55
use clarity::types::chainstate::{
66
BlockHeaderHash, ConsensusHash, StacksAddress, StacksPrivateKey, StacksPublicKey,
77
};
8+
use clarity::vm::costs::ExecutionCost;
89
use clarity::vm::tests::BurnStateDB;
910
use clarity::vm::types::PrincipalData;
1011
use clarity::vm::{ClarityName, ClarityVersion, ContractName, Value};
@@ -269,17 +270,29 @@ pub fn to_addr(sk: &StacksPrivateKey) -> StacksAddress {
269270
StacksAddress::p2pkh(false, &StacksPublicKey::from_private(sk))
270271
}
271272

272-
pub fn make_stacks_transfer(
273+
pub fn make_stacks_transfer_tx(
273274
sender: &StacksPrivateKey,
274275
nonce: u64,
275276
tx_fee: u64,
276277
chain_id: u32,
277278
recipient: &PrincipalData,
278279
amount: u64,
279-
) -> Vec<u8> {
280+
) -> StacksTransaction {
280281
let payload =
281282
TransactionPayload::TokenTransfer(recipient.clone(), amount, TokenTransferMemo([0; 34]));
282-
let tx = sign_standard_single_sig_tx(payload, sender, nonce, tx_fee, chain_id);
283+
sign_standard_single_sig_tx(payload, sender, nonce, tx_fee, chain_id)
284+
}
285+
286+
/// Make a stacks transfer transaction, returning the serialized transaction bytes
287+
pub fn make_stacks_transfer_serialized(
288+
sender: &StacksPrivateKey,
289+
nonce: u64,
290+
tx_fee: u64,
291+
chain_id: u32,
292+
recipient: &PrincipalData,
293+
amount: u64,
294+
) -> Vec<u8> {
295+
let tx = make_stacks_transfer_tx(sender, nonce, tx_fee, chain_id, recipient, amount);
283296
let mut tx_bytes = vec![];
284297
tx.consensus_serialize(&mut tx_bytes).unwrap();
285298
tx_bytes
@@ -512,3 +525,25 @@ pub fn insert_tx_in_mempool(
512525
.execute(sql, args)
513526
.expect("Failed to insert transaction into mempool");
514527
}
528+
529+
/// Generate source code for a contract that exposes a public function
530+
/// `big-tx`. This function uses `proportion` of read_count when called
531+
pub fn make_big_read_count_contract(limit: ExecutionCost, proportion: u64) -> String {
532+
let read_count = (limit.read_count * proportion) / 100;
533+
534+
let read_lines = (0..read_count)
535+
.map(|_| format!("(var-get my-var)"))
536+
.collect::<Vec<_>>()
537+
.join("\n");
538+
539+
format!(
540+
"
541+
(define-data-var my-var uint u0)
542+
(define-public (big-tx)
543+
(begin
544+
{}
545+
(ok true)))
546+
",
547+
read_lines
548+
)
549+
}

stackslib/src/core/tests/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use crate::core::mempool::{
6565
db_get_all_nonces, MemPoolSyncData, MemPoolWalkSettings, MemPoolWalkTxTypes, TxTag,
6666
BLOOM_COUNTER_DEPTH, BLOOM_COUNTER_ERROR_RATE, MAX_BLOOM_COUNTER_TXS,
6767
};
68-
use crate::core::test_util::{insert_tx_in_mempool, make_stacks_transfer, to_addr};
68+
use crate::core::test_util::{insert_tx_in_mempool, make_stacks_transfer_serialized, to_addr};
6969
use crate::core::{FIRST_BURNCHAIN_CONSENSUS_HASH, FIRST_STACKS_BLOCK_HASH};
7070
use crate::net::Error as NetError;
7171
use crate::util_lib::bloom::test::setup_bloom_counter;
@@ -2795,7 +2795,7 @@ fn large_mempool() {
27952795
let sender_addr = to_addr(sender_sk);
27962796
let fee = thread_rng().gen_range(180..2000);
27972797
let transfer_tx =
2798-
make_stacks_transfer(sender_sk, *nonce, fee, 0x80000000, &recipient, 1);
2798+
make_stacks_transfer_serialized(sender_sk, *nonce, fee, 0x80000000, &recipient, 1);
27992799
insert_tx_in_mempool(
28002800
&mempool_tx,
28012801
transfer_tx,

0 commit comments

Comments
 (0)