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

cmd/gaia/app.CollectStdTxs() does not validate delegator address against genesis initial state #3003

Closed
4 tasks
alessio opened this issue Dec 5, 2018 · 0 comments
Labels
C:genesis relating to chain genesis T:Bug

Comments

@alessio
Copy link
Contributor

alessio commented Dec 5, 2018

The following snippet checks whether the validator address is in the state and if the validator holds enough coins to submit the initial delegation:

		// validate the validator address and funds against the accounts in the state
		msg := msgs[0].(stake.MsgCreateValidator)
		addr := string(sdk.AccAddress(msg.ValidatorAddr))
		acc, ok := addrMap[addr]

		if !ok {
			return appGenTxs, persistentPeers, fmt.Errorf(
				"account %v not in genesis.json: %+v", addr, addrMap)
		}

		if acc.Coins.AmountOf(msg.Delegation.Denom).LT(msg.Delegation.Amount) {
			return appGenTxs, persistentPeers, fmt.Errorf(
				"insufficient fund for delegation %v: %v < %v",
				acc.Address, acc.Coins.AmountOf(msg.Delegation.Denom), msg.Delegation.Amount,
			)
		}

That works with self-delegations. It doesn't work when delegator != validator.
Solution seems to be easy:

  1. both delegator and validator addresses must be checked against the state
  2. delegation must be validated against delegator's funds

@jackzampolin @cwgoes @zmanian


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:genesis relating to chain genesis T:Bug
Projects
None yet
Development

No branches or pull requests

1 participant