Skip to content

feat: implementing force replace command to replace nodes in a subnet #1648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

NikolaMilosa
Copy link
Contributor

This will be required for integration with new replacement calculation tooling.

Example usage:

// From subnet: 4zbus-z2bmt-ilreg-xakz4-6tyre-hsqj4-slb4g-zjwqo-snjcc-iqphi-3qe 
./target/debug/dre subnet force-replace --dry-run \
 --subnet-id 4zbus-z2bmt-ilreg-xakz4-6tyre-hsqj4-slb4g-zjwqo-snjcc-iqphi-3qe \
 --from oiso5-hxkkc-elqlo-iyoqg-7oux4-5mscl-zkvoh-b2432-ohrir-b5fcm-gae \
 --to 4l2e6-g2ujv-ksiel-cfrww-zwyhq-26nbr-f2jik-xhxfp-2xkd3-hmx23-6ae \
 --forum-post-link omit \
 --motivation "$(cat ~/Downloads/summary.md)" 

Example output:

 2025-07-16T22:13:52.530Z INFO  dre > Running version 0.6.4-b3427876-dirty
 2025-07-16T22:13:52.558Z INFO  dre::store > Using local registry path for network mainnet: /home/nikola/.cache/dre-store/local_registry/mainnet
 2025-07-16T22:13:58.703Z INFO  decentralization::network::request > Evaluating change in subnet 4zbus membership: removing (1 healthy + 0 unhealthy) and adding 1 node. Total available 0 healthy nodes.
Including user-provided nodes ["Node ID: 4l2e6"]
Removed nodes from subnet [oiso5-hxkkc-elqlo-iyoqg-7oux4-5mscl-zkvoh-b2432-ohrir-b5fcm-gae]
Nakamoto score before extension NakamotoScore: min 4.00 avg log2 2.2683 #crit nodes [5, 5] # crit uniq [13, 12] #crit coeff 0 avg linear 4.8333
 2025-07-16T22:13:58.934Z WARN  dre::ctx                           > Couldn't detect neuron due to: Hardware security key not found: No hardware security module detected.  Will fall back to anonymous in dry-run operations.
 2025-07-16T22:13:58.934Z INFO  dre::store                         > Using cached ic admin version: 5128134d24b7a5b8e24a3d5d40c4cce9d81fd375
 2025-07-16T22:13:58.934Z INFO  dre::store                         > Using ic-admin: /home/nikola/.cache/dre-store/ic-admin.revisions/5128134d24b7a5b8e24a3d5d40c4cce9d81fd375/ic-admin
 2025-07-16T22:13:58.935Z INFO  dre::ic_admin                      > Running ic-admin:
$ /home/nikola/.cache/dre-store/ic-admin.revisions/5128134d24b7a5b8e24a3d5d40c4cce9d81fd375/ic-admin \
    --secret-key-pem /home/nikola/.config/dfx/identity/test_neuron_1/identity.pem \
    --nns-urls https://ic0.app/ \
  propose-to-change-subnet-membership \
    --silence-notices \
    --proposal-title 'Replace a node in subnet 4zbus' \
    --summary '# Replace a node in subnet 4zbus

Motivation: ## Proposal Summary: Declustering UKR

Decentralization Nakamoto coefficient changes for subnet `4zbus-z2bmt-ilreg-xakz4-6tyre-hsqj4-slb4g-zjwqo-snjcc-iqphi-3qe`:
```
    node_provider: 5.00 -> 5.00    (+0%)
      data_center: 5.00 -> 5.00    (+0%)
data_center_owner: 5.00 -> 5.00    (+0%)
             area: 5.00 -> 5.00    (+0%)
          country: 5.00 -> 4.00   (-20%)
```

**Mean Nakamoto comparison:** 5.00 -> 4.83  (-3%)

Overall replacement impact: (gets worse) the average log2 of Nakamoto Coefficients across all features decreases from 2.3219 to 2.2683


# Details

Nodes removed:
- `oiso5-hxkkc-elqlo-iyoqg-7oux4-5mscl-zkvoh-b2432-ohrir-b5fcm-gae` [health: healthy]

Nodes added:
- `4l2e6-g2ujv-ksiel-cfrww-zwyhq-26nbr-f2jik-xhxfp-2xkd3-hmx23-6ae` [health: healthy]


```
    node_provider                                                              data_center            data_center_owner            area                        country
    -------------                                                              -----------            -----------------            ----                        -------
    3oqw6-vmpk2-mlwlx-52z5x-e3p7u-fjlcw-yxc34-lf2zq-6ub2f-v63hk-lae  1 -> 0    at2               1    Anonstake               1    Brussels Capital       1    BE            1
    4dibr-2alzr-h6kva-bvwn2-yqgsl-o577t-od46o-v275p-a2zov-tcw4f-eae       1    br2               1    AtlasEdge               1    Bucuresti              1    CA            1
    6nbcy-kprg6-ax3db-kh3cz-7jllk-oceyh-jznhs-riguq-fvk6z-6tsds-rqe       1    bu1               1    Cyxtera                 1    Georgia                1    CH            1
    6r5lw-l7db7-uwixn-iw5en-yy55y-ilbtq-e6gcv-g22r2-j3g6q-y37jk-jqe       1    hk1               1    DataHouse               1    HongKong               1    ES       1 -> 0
    7at4h-nhtvt-a4s55-jigss-wr2ha-ysxkn-e6w7x-7ggnm-qd3d5-ry66r-cae       1    lj2               1    Datasite                1    Ljubljana              1    HK            1
    bvcsg-3od6r-jnydw-eysln-aql7w-td5zn-ay5m6-sibd2-jzojt-anwag-mqe       1    ma3          1 -> 0    Digital Realty          1    Madrid            1 -> 0    JP            1
    diyay-s4rfq-xnx23-zczwi-nptra-5254n-e4zn6-p7tqe-vqhzr-sd4gd-bqe       1    pl1          0 -> 1    Equinix                 1    Ontario                1    KR            1
    dodsd-rsjlg-sgekb-gr6mi-l6fck-tscwk-4jzgl-fwk4q-ncoyu-ulx53-aqe  0 -> 1    sg1               1    Flexential         0 -> 1    Oregon            0 -> 1    PL            1
    g2ax6-jrkmb-3zuh3-jibtb-q5xoq-njrgo-5utbc-j2o7g-zfq2w-yyhky-dqe       1    sh1               1    Green.ch                1    Seoul                  1    RO            1
    i7dto-bgkj2-xo5dx-cyrb7-zkk5y-q46eh-gz6iq-qkgyc-w4qte-scgtb-6ae       1    sl1               1    IPCore             1 -> 0    Singapore              1    SE            1
    kos24-5xact-6aror-uofg2-tnvt6-dq3bk-c2c5z-jtptt-jbqvc-lmegy-qae       1    to2               1    M247                    1    Stockholm              1    SG            1
    rbn2y-6vfsb-gv35j-4cyvy-pzbdu-e5aum-jzjg6-5b4n5-vuguf-ycubq-zae       1    ty1               1    Megazone Cloud          1    Tokyo                  1    SI            1
    sixix-2nyqd-t2k2v-vlsyz-dssko-ls4hl-hyij4-y7mdp-ja6cj-nsmpf-yae       1    wa3               1    Telin                   1    Warszawa               1    US       1 -> 2
    sma3p-ivkif-hz7nu-ngmvq-ibnjg-nubke-zf6gh-wbnfc-2dlng-l3die-zqe       1    zh6               1    Unicom                  1    Zurich                 1
```

' \
    --subnet-id 4zbus-z2bmt-ilreg-xakz4-6tyre-hsqj4-slb4g-zjwqo-snjcc-iqphi-3qe \
    --node-ids-add 4l2e6-g2ujv-ksiel-cfrww-zwyhq-26nbr-f2jik-xhxfp-2xkd3-hmx23-6ae \
    --node-ids-remove oiso5-hxkkc-elqlo-iyoqg-7oux4-5mscl-zkvoh-b2432-ohrir-b5fcm-gae \
    --proposer 123 \
    --dry-run
Using NNS URLs: ["https://ic0.app/"]
Title: Replace a node in subnet 4zbus

Summary: # Replace a node in subnet 4zbus

Motivation: ## Proposal Summary: Declustering UKR

Decentralization Nakamoto coefficient changes for subnet `4zbus-z2bmt-ilreg-xakz4-6tyre-hsqj4-slb4g-zjwqo-snjcc-iqphi-3qe`:
```
    node_provider: 5.00 -> 5.00    (+0%)
      data_center: 5.00 -> 5.00    (+0%)
data_center_owner: 5.00 -> 5.00    (+0%)
             area: 5.00 -> 5.00    (+0%)
          country: 5.00 -> 4.00   (-20%)
```

**Mean Nakamoto comparison:** 5.00 -> 4.83  (-3%)

Overall replacement impact: (gets worse) the average log2 of Nakamoto Coefficients across all features decreases from 2.3219 to 2.2683


# Details

Nodes removed:
- `oiso5-hxkkc-elqlo-iyoqg-7oux4-5mscl-zkvoh-b2432-ohrir-b5fcm-gae` [health: healthy]

Nodes added:
- `4l2e6-g2ujv-ksiel-cfrww-zwyhq-26nbr-f2jik-xhxfp-2xkd3-hmx23-6ae` [health: healthy]


```
    node_provider                                                              data_center            data_center_owner            area                        country
    -------------                                                              -----------            -----------------            ----                        -------
    3oqw6-vmpk2-mlwlx-52z5x-e3p7u-fjlcw-yxc34-lf2zq-6ub2f-v63hk-lae  1 -> 0    at2               1    Anonstake               1    Brussels Capital       1    BE            1
    4dibr-2alzr-h6kva-bvwn2-yqgsl-o577t-od46o-v275p-a2zov-tcw4f-eae       1    br2               1    AtlasEdge               1    Bucuresti              1    CA            1
    6nbcy-kprg6-ax3db-kh3cz-7jllk-oceyh-jznhs-riguq-fvk6z-6tsds-rqe       1    bu1               1    Cyxtera                 1    Georgia                1    CH            1
    6r5lw-l7db7-uwixn-iw5en-yy55y-ilbtq-e6gcv-g22r2-j3g6q-y37jk-jqe       1    hk1               1    DataHouse               1    HongKong               1    ES       1 -> 0
    7at4h-nhtvt-a4s55-jigss-wr2ha-ysxkn-e6w7x-7ggnm-qd3d5-ry66r-cae       1    lj2               1    Datasite                1    Ljubljana              1    HK            1
    bvcsg-3od6r-jnydw-eysln-aql7w-td5zn-ay5m6-sibd2-jzojt-anwag-mqe       1    ma3          1 -> 0    Digital Realty          1    Madrid            1 -> 0    JP            1
    diyay-s4rfq-xnx23-zczwi-nptra-5254n-e4zn6-p7tqe-vqhzr-sd4gd-bqe       1    pl1          0 -> 1    Equinix                 1    Ontario                1    KR            1
    dodsd-rsjlg-sgekb-gr6mi-l6fck-tscwk-4jzgl-fwk4q-ncoyu-ulx53-aqe  0 -> 1    sg1               1    Flexential         0 -> 1    Oregon            0 -> 1    PL            1
    g2ax6-jrkmb-3zuh3-jibtb-q5xoq-njrgo-5utbc-j2o7g-zfq2w-yyhky-dqe       1    sh1               1    Green.ch                1    Seoul                  1    RO            1
    i7dto-bgkj2-xo5dx-cyrb7-zkk5y-q46eh-gz6iq-qkgyc-w4qte-scgtb-6ae       1    sl1               1    IPCore             1 -> 0    Singapore              1    SE            1
    kos24-5xact-6aror-uofg2-tnvt6-dq3bk-c2c5z-jtptt-jbqvc-lmegy-qae       1    to2               1    M247                    1    Stockholm              1    SG            1
    rbn2y-6vfsb-gv35j-4cyvy-pzbdu-e5aum-jzjg6-5b4n5-vuguf-ycubq-zae       1    ty1               1    Megazone Cloud          1    Tokyo                  1    SI            1
    sixix-2nyqd-t2k2v-vlsyz-dssko-ls4hl-hyij4-y7mdp-ja6cj-nsmpf-yae       1    wa3               1    Telin                   1    Warszawa               1    US       1 -> 2
    sma3p-ivkif-hz7nu-ngmvq-ibnjg-nubke-zf6gh-wbnfc-2dlng-l3die-zqe       1    zh6               1    Unicom                  1    Zurich                 1
```



URL:

Payload: ChangeSubnetMembershipPayload {
    subnet_id: 4zbus-z2bmt-ilreg-xakz4-6tyre-hsqj4-slb4g-zjwqo-snjcc-iqphi-3qe,
    node_ids_add: [
        4l2e6-g2ujv-ksiel-cfrww-zwyhq-26nbr-f2jik-xhxfp-2xkd3-hmx23-6ae,
    ],
    node_ids_remove: [
        oiso5-hxkkc-elqlo-iyoqg-7oux4-5mscl-zkvoh-b2432-ohrir-b5fcm-gae,
    ],
}

));
}

// Ensure that the `to` nodes are not in any subnet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also need to check open proposals

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, you are right. Fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants