Skip to content
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

set_controller should check if session keys are set and move refcounts if they are #469

Open
lsaether opened this issue Oct 15, 2020 · 1 comment
Labels
I2-bug The node fails to follow expected behavior.

Comments

@lsaether
Copy link

lsaether commented Oct 15, 2020

I'm investigating an issue related to the Polkadot account 165mqgdi4qRCtob1RHf3QgigoA15JY8XqmDcu5jyrSfKwXJK. This account has an existing refcount and cannot be reaped, however all available methods to remove the refcount are unable to be called.

You can check that this account has a refcount by querying system.account:

image

However for each of the three ways on Polkadot to remove a refcount, none of them can be called:

  • session.purge_keys which fails for this account because it does not have an attached stash account (and there are no keys in state if you query session.nextKeys. This can be checked by querying staking.ledger with the target account:

image

  • staking.withdraw_unbonded which fails for the same reason as above (ledger does not exist).

  • A balance lock which does not exist for this account.

After looking through the account's transaction history I believe what happened is the following:

  1. Stash bonds to Controller.
  2. Controller calls set_keys which sets Controller's refcount to 1.
  3. Stash calls set_controller to change the controller.
  4. Old Controller still has the refcount with no way to remove it.

What we could do here is call set_controller again to Old Controller and then call purge_keys from Old Controller to remove it, but this seems wrong. Further, this could possibly be exploited to artificially reduce the refcounts on an account by repeating the process of set_controller and purge_keys.

When set_controller is called, it should check if keys are added in Session and dec_ref of the old controller and inc_ref the new controller if they exist.

@kianenigma
Copy link
Contributor

excellent catch. Your description and suggestion both seem broadly correct me, without looking into the code yet. We need to do a sweep and make sure before fixing this, we cover all the accounts that have the same issue.

@juangirini juangirini transferred this issue from paritytech/substrate Aug 24, 2023
@the-right-joyce the-right-joyce added I2-bug The node fails to follow expected behavior. and removed I3-bug labels Aug 25, 2023
claravanstaden pushed a commit to Snowfork/polkadot-sdk that referenced this issue Dec 8, 2023
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Mar 26, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Mar 26, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Mar 27, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Mar 27, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of paritytech#469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
bkchr pushed a commit that referenced this issue Apr 10, 2024
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of #469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
jonathanudd pushed a commit to jonathanudd/polkadot-sdk that referenced this issue Apr 10, 2024
…roveMessages` (paritytech#469)

* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I2-bug The node fails to follow expected behavior.
Projects
Status: 📕 Backlog
Development

No branches or pull requests

3 participants