bnb-chain / bnc-cosmos-sdk

Mozilla Public License 2.0
42 stars 30 forks source link

if the voting power of new validator is greater than previous one, it will delete the previous one #154

Closed unclezoro closed 11 months ago

unclezoro commented 5 years ago

precedure: ./bnbcli create-validator --from bob --deposit "100000000000:BNB" --pubkey bcap1zcjduepqadxkdq5np7ds9hu94xghwmhdsxzc50cpp7zyn06pk5zv068pz49snkpuug --commission-rate=0 --commission-max-rate=0 --commission-max-change-rate=0 --moniker=testnode --amount "1000000000000:BNB" --voting-period=30 --chain-id bnbchain-1000 --trust-node --node http://127.0.0.1:26657 --home testnodecli

./bnbcli gov vote --proposal-id 1 --option yes --from alice --chain-id bnbchain-1000 --trust-node --node http://127.0.0.1:26657 --home testnodecli

./bnbcli create-validator --from bob --pubkey bcap1zcjduepqadxkdq5np7ds9hu94xghwmhdsxzc50cpp7zyn06pk5zv068pz49snkpuug --commission-rate=0 --commission-max-rate=0 --commission-max-change-rate=0 --moniker=testnode --amount "1000000000000:BNB" --proposal-id 1 --chain-id bnbchain-1000 --trust-node --node http://127.0.0.1:26657 --home testnodecli

Then curl 127.0.0.1:26657/valdiators, you will find the previous validator is just replaced.

unclezoro commented 5 years ago

@rickyyangz @HaoyangLiu

abelliumnt commented 5 years ago

I have located the issue. The ValidatorByPowerIndex key of new validator is the same as the old one. As a result, the power index key of the old validator is overwritten. There is some bugs in building ValidatorByPowerIndex key. I'm working on how to fix it.

abelliumnt commented 5 years ago

https://github.com/binance-chain/node/pull/515 https://github.com/binance-chain/bnc-cosmos-sdk/pull/100 Previously, I have create a PR to fix this issue. But I postponed it and forgot it later. It is my fault.