Skip to content

Commit 521558f

Browse files
committed
Merge branch 'develop' of https://github.com/stacks-network/stacks-core into chore/add-vm-error-to-transaction-event-payload
2 parents 01922ea + a7646f9 commit 521558f

File tree

6 files changed

+71
-42
lines changed

6 files changed

+71
-42
lines changed

CHANGELOG.md

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

1010
### Added
1111

12-
- Added field `vm_error` to EventObserver transaction output
12+
- Added field `vm_error` to EventObserver transaction outputs
13+
14+
### Changed
15+
16+
- Reduce the default `block_rejection_timeout_steps` configuration so that miners will retry faster when blocks fail to reach 70% approved or 30% rejected.
1317

1418
## [3.1.0.0.8]
1519

libsigner/src/tests/mod.rs

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@ fn test_simple_signer() {
142142
chunks.push(chunk_event);
143143
}
144144

145-
chunks.sort_by(|ev1, ev2| {
146-
ev1.modified_slots[0]
147-
.slot_id
148-
.partial_cmp(&ev2.modified_slots[0].slot_id)
149-
.unwrap()
150-
});
151-
152145
let thread_chunks = chunks.clone();
153146

154147
// simulate a node that's trying to push data
@@ -186,41 +179,45 @@ fn test_simple_signer() {
186179

187180
let sent_events: Vec<SignerEvent<SignerMessage>> = chunks
188181
.iter()
189-
.map(|chunk| {
190-
let msg = chunk.modified_slots[0].data.clone();
191-
let pubkey = chunk.modified_slots[0]
192-
.recover_pk()
193-
.expect("Faield to recover public key of slot");
194-
let signer_message = read_next::<SignerMessage, _>(&mut &msg[..]).unwrap();
182+
.map(|event| {
183+
let messages: Vec<(StacksPublicKey, SignerMessage)> = event
184+
.modified_slots
185+
.iter()
186+
.filter_map(|chunk| {
187+
Some((
188+
chunk.recover_pk().ok()?,
189+
read_next::<SignerMessage, _>(&mut &chunk.data[..]).ok()?,
190+
))
191+
})
192+
.collect();
195193
SignerEvent::SignerMessages {
196194
signer_set: 0,
197-
messages: vec![(pubkey, signer_message)],
195+
messages,
198196
received_time: SystemTime::now(),
199197
}
200198
})
201199
.collect();
202200

203-
for (sent_event, accepted_event) in sent_events.iter().zip(accepted_events.iter()) {
201+
for event in sent_events {
204202
let SignerEvent::SignerMessages {
205-
signer_set,
206-
messages,
207-
received_time,
208-
} = sent_event
203+
signer_set: sent_signer_set,
204+
messages: sent_messages,
205+
..
206+
} = event
209207
else {
210-
panic!("BUG: should not have sent anything but a signer message");
208+
panic!("We expect ONLY signer messages");
211209
};
212-
let SignerEvent::SignerMessages {
213-
signer_set: accepted_signer_set,
214-
messages: accepted_messages,
215-
received_time: accepted_time,
216-
} = accepted_event
217-
else {
218-
panic!("BUG: should not have accepted anything but a signer message");
219-
};
220-
221-
assert_eq!(signer_set, accepted_signer_set);
222-
assert_eq!(messages, accepted_messages);
223-
assert_ne!(received_time, accepted_time);
210+
assert!(accepted_events.iter().any(|e| {
211+
let SignerEvent::SignerMessages {
212+
signer_set: accepted_signer_set,
213+
messages: accepted_messages,
214+
..
215+
} = e
216+
else {
217+
panic!("We expect ONLY signer messages");
218+
};
219+
*accepted_signer_set == sent_signer_set && *accepted_messages == sent_messages
220+
}))
224221
}
225222
mock_stacks_node.join().unwrap();
226223
}

stacks-signer/src/runloop.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,15 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug> RunLo
466466
// We are either the current or a future reward cycle, so we are not stale.
467467
continue;
468468
}
469-
if let ConfiguredSigner::RegisteredSigner(signer) = signer {
470-
if !signer.has_unprocessed_blocks() {
471-
debug!("{signer}: Signer's tenure has completed.");
469+
match signer {
470+
ConfiguredSigner::RegisteredSigner(signer) => {
471+
if !signer.has_unprocessed_blocks() {
472+
debug!("{signer}: Signer's tenure has completed.");
473+
to_delete.push(*idx);
474+
}
475+
}
476+
ConfiguredSigner::NotRegistered { .. } => {
477+
debug!("{signer}: Unregistered signer's tenure has completed.");
472478
to_delete.push(*idx);
473479
}
474480
}

stackslib/src/config/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,9 +2244,9 @@ impl Default for MinerConfig {
22442244

22452245
block_rejection_timeout_steps: {
22462246
let mut rejections_timeouts_default_map = HashMap::<u32, Duration>::new();
2247-
rejections_timeouts_default_map.insert(0, Duration::from_secs(600));
2248-
rejections_timeouts_default_map.insert(10, Duration::from_secs(300));
2249-
rejections_timeouts_default_map.insert(20, Duration::from_secs(150));
2247+
rejections_timeouts_default_map.insert(0, Duration::from_secs(180));
2248+
rejections_timeouts_default_map.insert(10, Duration::from_secs(90));
2249+
rejections_timeouts_default_map.insert(20, Duration::from_secs(45));
22502250
rejections_timeouts_default_map.insert(30, Duration::from_secs(0));
22512251
rejections_timeouts_default_map
22522252
},
@@ -2835,6 +2835,7 @@ impl MinerConfigFile {
28352835
})
28362836
}
28372837
}
2838+
28382839
#[derive(Clone, Deserialize, Default, Debug)]
28392840
#[serde(deny_unknown_fields)]
28402841
pub struct AtlasConfigFile {

testnet/stacks-node/src/nakamoto_node/miner.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,16 @@ impl BlockMinerThread {
704704
)?
705705
.ok_or_else(|| NakamotoNodeError::UnexpectedChainState)?;
706706

707-
if processed {
707+
// Once the block has been processed and the miner is no longer
708+
// blocked, we can continue mining.
709+
if processed
710+
&& !(*self
711+
.globals
712+
.get_miner_status()
713+
.lock()
714+
.expect("FATAL: mutex poisoned"))
715+
.is_blocked()
716+
{
708717
break;
709718
}
710719

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12115,8 +12115,20 @@ fn repeated_rejection() {
1211512115
let send_amt = 100;
1211612116
let send_fee = 180;
1211712117
let recipient = PrincipalData::from(StacksAddress::burn_address(false));
12118-
let mut signer_test: SignerTest<SpawnedSigner> =
12119-
SignerTest::new(num_signers, vec![(sender_addr, (send_amt + send_fee) * 3)]);
12118+
let mut signer_test: SignerTest<SpawnedSigner> = SignerTest::new_with_config_modifications(
12119+
num_signers,
12120+
vec![(sender_addr, (send_amt + send_fee) * 3)],
12121+
|_| {},
12122+
|config| {
12123+
config.miner.block_rejection_timeout_steps.clear();
12124+
config
12125+
.miner
12126+
.block_rejection_timeout_steps
12127+
.insert(0, Duration::from_secs(120));
12128+
},
12129+
None,
12130+
None,
12131+
);
1212012132
let http_origin = format!("http://{}", &signer_test.running_nodes.conf.node.rpc_bind);
1212112133
signer_test.boot_to_epoch_3();
1212212134

0 commit comments

Comments
 (0)