stacks-network / stacks-core

The Stacks blockchain implementation
https://docs.stacks.co
GNU General Public License v3.0
3.01k stars 672 forks source link

pox_is_active sometimes set to true when it shouldn't be #5282

Open CharlieC3 opened 1 month ago

CharlieC3 commented 1 month ago

It seems a node can sometimes find itself in a scenario where pox_is_active on /v2/pox shows true when the amount of stacked stacks is less than the pox activation threshold:

  "current_cycle": {
    "id": 224,
    "min_threshold_ustx": 2166760000000000,
    "stacked_ustx": 0,
    "is_pox_active": true
  },

This happened in a closed regtest deployment which resulted in a stall because of pox deactivating, so I'm not sure of the likelihood of this occurring in a bigger open network. But it's still a strange result. It seems internally the node is aware pox is deactivated but the data it displays externally is getting the status from elsewhere that doesn't get updated as frequently. Here's a link to a chainstate from the aforementioned stalled node in this state: https://drive.google.com/file/d/1NYceDhEEyPPx8FWMA25ce45QC8gzZ4c9/view?usp=sharing

Parikalp-Bhardwaj commented 1 month ago

Hi @CharlieC3 let cur_cycle_pox_active = sortdb.is_pox_active(burnchain, &burnchain_tip)?;

This line sets cur_cycle_pox_active based on the sortition database understanding of PoX activation. However, it seems that this method may return true even when stacked_ustx is below the activation threshold.

https://github.com/stacks-network/stacks-core/blob/master/stackslib/src/net/api/getpoxinfo.rs

Am i right? @obycode

jcnelson commented 1 month ago

PoX is always active in Nakamoto -- there is no activation threshold, unlike in 2.x.

CharlieC3 commented 1 month ago

Good to know, thanks @jcnelson . Does that also mean the network could not have stalled because stacked_ustx was lower than the min_threshold_ustx?