Skip to content

Commit 4417826

Browse files
committed
Merge branch 'pox-wf-integration' into feat/bitcoin-clarity
2 parents 7c6b7db + 1c7b8e6 commit 4417826

247 files changed

Lines changed: 5877 additions & 3222 deletions

File tree

Some content is hidden

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

Cargo.lock

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

clarity-types/src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl StandardPrincipalData {
123123
(version, bytes)
124124
}
125125

126-
pub fn is_mainnet(self) -> bool {
126+
pub fn is_mainnet(&self) -> bool {
127127
self.0 == C32_ADDRESS_VERSION_MAINNET_MULTISIG
128128
|| self.0 == C32_ADDRESS_VERSION_MAINNET_SINGLESIG
129129
}

libsigner/src/events.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,18 @@ impl<T: SignerEventTrait> TryFrom<StackerDBChunksEvent> for SignerEvent<T> {
551551
{
552552
let mut messages = vec![];
553553
for chunk in event.modified_slots {
554-
let Ok(msg) = T::consensus_deserialize(&mut chunk.data.as_slice()) else {
555-
continue;
556-
};
557-
messages.push(msg);
554+
match T::consensus_deserialize(&mut chunk.data.as_slice()) {
555+
Ok(msg) => messages.push(msg),
556+
Err(e) => {
557+
debug!(
558+
"Signer failed to deserialize miner chunk";
559+
"slot_id" => chunk.slot_id,
560+
"slot_version" => chunk.slot_version,
561+
"data_len" => chunk.data.len(),
562+
"error" => %e,
563+
);
564+
}
565+
}
558566
}
559567
SignerEvent::MinerMessages(messages)
560568
} else if event.contract_id.name.starts_with(SIGNERS_NAME) && event.contract_id.is_boot() {

stacks-common/src/types/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,11 @@ impl StacksEpochId {
628628
self >= &StacksEpochId::Epoch34
629629
}
630630

631+
/// Does this epoch use a mod-0 start for reward cycles?
632+
pub fn starts_reward_cycle_at_0(&self) -> bool {
633+
self >= &StacksEpochId::Epoch40
634+
}
635+
631636
/// What is the coinbase (in uSTX) to award for the given burnchain height?
632637
/// Applies prior to SIP-029
633638
fn coinbase_reward_pre_sip029(

stacks-node/src/event_dispatcher/payloads.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,29 @@ impl RewardSetEventPayload {
147147
}
148148
}
149149
pub fn from_reward_set(reward_set: &RewardSet) -> Self {
150-
Self {
151-
rewarded_addresses: reward_set.rewarded_addresses.clone(),
152-
start_cycle_state: reward_set.start_cycle_state.clone(),
153-
signers: reward_set
154-
.signers
155-
.as_ref()
156-
.map(|signers| signers.iter().map(Self::signer_entry_to_payload).collect()),
157-
pox_ustx_threshold: reward_set.pox_ustx_threshold,
150+
match reward_set {
151+
RewardSet::V0(v0) => Self {
152+
rewarded_addresses: v0.rewarded_addresses.clone(),
153+
start_cycle_state: v0.start_cycle_state.clone(),
154+
signers: v0
155+
.signers
156+
.as_ref()
157+
.map(|signers| signers.iter().map(Self::signer_entry_to_payload).collect()),
158+
pox_ustx_threshold: v0.pox_ustx_threshold,
159+
},
160+
RewardSet::Waterfall(wf) => Self {
161+
rewarded_addresses: vec![],
162+
start_cycle_state: PoxStartCycleInfo {
163+
missed_reward_slots: vec![],
164+
},
165+
signers: Some(
166+
wf.signers
167+
.iter()
168+
.map(Self::signer_entry_to_payload)
169+
.collect(),
170+
),
171+
pox_ustx_threshold: None,
172+
},
158173
}
159174
}
160175
}

stacks-node/src/nakamoto_node/miner.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,10 @@ impl BlockMinerThread {
16261626

16271627
parent_block_info.stacks_parent_header.microblock_tail = None;
16281628

1629-
let signer_bitvec_len = reward_set.rewarded_addresses.len().try_into().ok();
1629+
// Length of the per-block `pox_treatment` BitVec.
1630+
// Must be `> 0`:
1631+
// the BitVec codec rejects zero-length bitvecs at deserialization.
1632+
let signer_bitvec_len = reward_set.pox_treatment_bitvec_len();
16301633

16311634
if !self.validate_timestamp_info(
16321635
get_epoch_time_secs(),
@@ -1688,7 +1691,7 @@ impl BlockMinerThread {
16881691
// we'll invoke the event dispatcher ourselves so that it calculates the
16891692
// correct signer_signature_hash for `process_mined_nakamoto_block_event`
16901693
Some(&self.event_dispatcher),
1691-
signer_bitvec_len.unwrap_or(0),
1694+
signer_bitvec_len,
16921695
&replay_transactions,
16931696
)
16941697
.map_err(|e| {

stacks-node/src/nakamoto_node/relayer.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,13 +1125,20 @@ impl RelayerThread {
11251125
NakamotoNodeError::SnapshotNotFoundForChainTip
11261126
})?;
11271127

1128-
let commit_outs = if self
1129-
.burnchain
1130-
.is_in_prepare_phase(sort_tip.block_height + 1)
1131-
{
1132-
vec![PoxAddress::standard_burn_address(self.config.is_mainnet())]
1133-
} else {
1134-
RewardSetInfo::into_commit_outs(recipients, self.config.is_mainnet())
1128+
let commit_outs = match recipients.as_ref() {
1129+
// Under waterfall PoX, every block in the cycle (including
1130+
// prepare-phase blocks) commits to the cycle's sBTC address.
1131+
// Don't let the classic prepare-phase burn-output override clobber it.
1132+
Some(RewardSetInfo::Waterfall(_)) => {
1133+
RewardSetInfo::into_commit_outs(recipients, self.config.is_mainnet())
1134+
}
1135+
_ if self
1136+
.burnchain
1137+
.is_in_prepare_phase(sort_tip.block_height + 1) =>
1138+
{
1139+
vec![PoxAddress::standard_burn_address(self.config.is_mainnet())]
1140+
}
1141+
_ => RewardSetInfo::into_commit_outs(recipients, self.config.is_mainnet()),
11351142
};
11361143

11371144
// find the sortition that kicked off this tenure (it may be different from the sortition

stacks-node/src/nakamoto_node/stackerdb_listener.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl StackerDBListener {
176176
let signer_set =
177177
u32::try_from(reward_cycle_id % 2).expect("FATAL: reward cycle id % 2 exceeds u32");
178178

179-
let Some(ref reward_set_signers) = reward_set.signers else {
179+
let Some(reward_set_signers) = reward_set.signers() else {
180180
error!("Could not initialize signing coordinator for reward set without signer");
181181
debug!("reward set: {reward_set:?}");
182182
return Err(ChainstateError::NoRegisteredSigners(0));

0 commit comments

Comments
 (0)