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

update InitChainer to stake all vesting tokens #1

Merged
merged 3 commits into from
May 21, 2022

Conversation

yun-yeo
Copy link
Contributor

@yun-yeo yun-yeo commented May 19, 2022

This PR will make core to stake all vesting balance of all accounts.

The staking strategy is simply just rotate validators and vesting accounts and delegate sequentially.

To prevent the voting power from being skewed to one side, split staking balance of whale accounts to multiple validators

	stakeSplitCondition := sdk.NewInt(1_000_000_000_000)

	// if a vesting account has more staking token than `stakeSplitCondition`,
	// split staking balance to distribute staking power evenly
	// Ex) 2_200_000_000_000
	// stake 1_000_000_000_000 to val1
	// stake 1_000_000_000_000 to val2
	// stake 200_000_000_000 to val3
	for ; amt.GTE(sdk.OneInt()); amt = amt.Sub(stakeSplitCondition) {
		if _, err := app.StakingKeeper.Delegate(
			ctx,
			vestingAcc.GetAddress(),
			sdk.MinInt(amt, stakeSplitCondition),
			stakingtypes.Unbonded,
			validators[i%validatorLen],
			true,
		); err != nil {
			panic(err)
		}

		// increase index only when staking happened
		i++
	}

@yun-yeo yun-yeo requested review from hanjukim and kjessec May 19, 2022 11:41
@yun-yeo yun-yeo self-assigned this May 19, 2022
@yun-yeo yun-yeo changed the title update InitChainer to stake all vested tokens update InitChainer to stake all vesting tokens May 19, 2022
@yun-yeo yun-yeo force-pushed the feature/initchainer-enforced-staking branch 2 times, most recently from d8b50e0 to 823be04 Compare May 19, 2022 12:17
@yun-yeo yun-yeo force-pushed the feature/initchainer-enforced-staking branch from 823be04 to ef41ee2 Compare May 19, 2022 12:17
@hanjukim hanjukim merged commit 87c755d into main May 21, 2022
@yun-yeo yun-yeo deleted the feature/initchainer-enforced-staking branch July 13, 2022 04:42
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