Skip to content

Commit 5321154

Browse files
authored
Merge pull request #5040 from stacks-network/fix/multi-miner-fixes-jude
Fix/multi miner fixes jude
2 parents 3a81438 + 572c547 commit 5321154

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2354
-704
lines changed

.github/workflows/bitcoin-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
- tests::signer::v0::signer_set_rollover
9797
- tests::signer::v0::miner_forking
9898
- tests::signer::v0::reloads_signer_set_in
99+
- tests::signer::v0::signers_broadcast_signed_blocks
99100
- tests::nakamoto_integrations::stack_stx_burn_op_integration_test
100101
- tests::nakamoto_integrations::check_block_heights
101102
- tests::nakamoto_integrations::clarity_burn_state

docs/rpc-endpoints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ Determine whether a given trait is implemented within the specified contract (ei
427427

428428
See OpenAPI [spec](./rpc/openapi.yaml) for details.
429429

430-
### POST /v2/block_proposal
430+
### POST /v3/block_proposal
431431

432432
Used by miner to validate a proposed Stacks block using JSON encoding.
433433

libsigner/src/runloop.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub trait SignerRunLoop<R: Send, CMD: Send, T: SignerEventTrait> {
5353
&mut self,
5454
event: Option<SignerEvent<T>>,
5555
cmd: Option<CMD>,
56-
res: Sender<R>,
56+
res: &Sender<R>,
5757
) -> Option<R>;
5858

5959
/// This is the main loop body for the signer. It continuously receives events from
@@ -70,6 +70,7 @@ pub trait SignerRunLoop<R: Send, CMD: Send, T: SignerEventTrait> {
7070
result_send: Sender<R>,
7171
mut event_stop_signaler: EVST,
7272
) -> Option<R> {
73+
info!("Signer runloop begin");
7374
loop {
7475
let poll_timeout = self.get_event_timeout();
7576
let next_event_opt = match event_recv.recv_timeout(poll_timeout) {
@@ -83,7 +84,7 @@ pub trait SignerRunLoop<R: Send, CMD: Send, T: SignerEventTrait> {
8384
// Do not block for commands
8485
let next_command_opt = command_recv.try_recv().ok();
8586
if let Some(final_state) =
86-
self.run_one_pass(next_event_opt, next_command_opt, result_send.clone())
87+
self.run_one_pass(next_event_opt, next_command_opt, &result_send)
8788
{
8889
info!("Runloop exit; signaling event-receiver to stop");
8990
event_stop_signaler.send();

libsigner/src/tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<T: SignerEventTrait> SignerRunLoop<Vec<SignerEvent<T>>, Command, T> for Sim
7676
&mut self,
7777
event: Option<SignerEvent<T>>,
7878
_cmd: Option<Command>,
79-
_res: Sender<Vec<SignerEvent<T>>>,
79+
_res: &Sender<Vec<SignerEvent<T>>>,
8080
) -> Option<Vec<SignerEvent<T>>> {
8181
debug!("Got event: {:?}", &event);
8282
if let Some(event) = event {

stacks-signer/src/client/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ pub(crate) mod tests {
570570
db_path: config.db_path.clone(),
571571
first_proposal_burn_block_timing: config.first_proposal_burn_block_timing,
572572
block_proposal_timeout: config.block_proposal_timeout,
573+
broadcast_signed_blocks: true,
573574
}
574575
}
575576

stacks-signer/src/client/stacks_client.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,13 @@ impl StacksClient {
685685
pub fn post_block(&self, block: &NakamotoBlock) -> Result<bool, ClientError> {
686686
let response = self
687687
.stacks_node_client
688-
.post(format!("{}{}", self.http_origin, postblock_v3::PATH))
688+
.post(format!(
689+
"{}{}?broadcast=1",
690+
self.http_origin,
691+
postblock_v3::PATH
692+
))
689693
.header("Content-Type", "application/octet-stream")
694+
.header(AUTHORIZATION, self.auth_password.clone())
690695
.body(block.serialize_to_vec())
691696
.send()?;
692697
if !response.status().is_success() {
@@ -789,7 +794,7 @@ impl StacksClient {
789794
}
790795

791796
fn block_proposal_path(&self) -> String {
792-
format!("{}/v2/block_proposal", self.http_origin)
797+
format!("{}/v3/block_proposal", self.http_origin)
793798
}
794799

795800
fn sortition_info_path(&self) -> String {
@@ -814,7 +819,7 @@ impl StacksClient {
814819
}
815820

816821
fn reward_set_path(&self, reward_cycle: u64) -> String {
817-
format!("{}/v2/stacker_set/{reward_cycle}", self.http_origin)
822+
format!("{}/v3/stacker_set/{reward_cycle}", self.http_origin)
818823
}
819824

820825
fn fees_transaction_path(&self) -> String {

stacks-signer/src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ pub struct SignerConfig {
157157
pub first_proposal_burn_block_timing: Duration,
158158
/// How much time to wait for a miner to propose a block following a sortition
159159
pub block_proposal_timeout: Duration,
160+
/// Broadcast a block to the node if we gather enough signatures from other signers
161+
pub broadcast_signed_blocks: bool,
160162
}
161163

162164
/// The parsed configuration for the signer
@@ -201,6 +203,8 @@ pub struct GlobalConfig {
201203
pub first_proposal_burn_block_timing: Duration,
202204
/// How much time to wait for a miner to propose a block following a sortition
203205
pub block_proposal_timeout: Duration,
206+
/// Broadcast a block to the node if we gather enough signatures from other signers
207+
pub broadcast_signed_blocks: bool,
204208
}
205209

206210
/// Internal struct for loading up the config file
@@ -357,6 +361,7 @@ impl TryFrom<RawConfigFile> for GlobalConfig {
357361
metrics_endpoint,
358362
first_proposal_burn_block_timing,
359363
block_proposal_timeout,
364+
broadcast_signed_blocks: true,
360365
})
361366
}
362367
}

stacks-signer/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub trait Signer<T: SignerEventTrait>: Debug + Display {
6969
stacks_client: &StacksClient,
7070
sortition_state: &mut Option<SortitionsView>,
7171
event: Option<&SignerEvent<T>>,
72-
res: Sender<Vec<SignerResult>>,
72+
res: &Sender<Vec<SignerResult>>,
7373
current_reward_cycle: u64,
7474
);
7575
/// Process a command

stacks-signer/src/runloop.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug> RunLo
335335
max_tx_fee_ustx: self.config.max_tx_fee_ustx,
336336
db_path: self.config.db_path.clone(),
337337
block_proposal_timeout: self.config.block_proposal_timeout,
338+
broadcast_signed_blocks: self.config.broadcast_signed_blocks,
338339
}))
339340
}
340341

@@ -497,7 +498,7 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug>
497498
&mut self,
498499
event: Option<SignerEvent<T>>,
499500
cmd: Option<RunLoopCommand>,
500-
res: Sender<Vec<SignerResult>>,
501+
res: &Sender<Vec<SignerResult>>,
501502
) -> Option<Vec<SignerResult>> {
502503
debug!(
503504
"Running one pass for the signer. state={:?}, cmd={cmd:?}, event={event:?}",
@@ -548,7 +549,7 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug>
548549
&self.stacks_client,
549550
&mut self.sortition_state,
550551
event.as_ref(),
551-
res.clone(),
552+
res,
552553
current_reward_cycle,
553554
);
554555
// After processing event, run the next command for each signer

0 commit comments

Comments
 (0)