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

lite2: modify TrustedValidatorSet func to return height #4473

Closed
melekes opened this issue Feb 25, 2020 · 3 comments · Fixed by #4479
Closed

lite2: modify TrustedValidatorSet func to return height #4473

melekes opened this issue Feb 25, 2020 · 3 comments · Fixed by #4479
Assignees
Labels
C:light Component: Light T:breaking Type: Breaking Change

Comments

@melekes
Copy link
Contributor

melekes commented Feb 25, 2020

If we're going to allow 0 height as an argument, returning height as a second param seems reasonable.

TrustedValidatorSet(0) => (*ValidatorSet, 10, nil)
TrustedValidatorSet(9) => (*ValidatorSet, 9, nil)
@melekes melekes added C:light Component: Light T:breaking Type: Breaking Change labels Feb 25, 2020
@melekes
Copy link
Contributor Author

melekes commented Feb 25, 2020

@cmwaters what do you think?

@cmwaters
Copy link
Contributor

cmwaters commented Feb 26, 2020

At the moment, TrustedValidatorSet doesn't have the behaviour where if you pass 0 as the height it will return the last validator set. Actually I modified it in callum/verify-bakwads so that it doesn't - will need to revert that then if we want this behaviour.

Anyway, this functionality is only useful if we want to know the latest validator set height (else we already have the height saved as input). Can't we just call c.LastTrustedHeight()

@melekes
Copy link
Contributor Author

melekes commented Feb 26, 2020

We can, but then the user will be forced to do

	latestHeight, err := c.LastTrustedHeight()
	if err != nil {
		return nil, err
	}
	if latestHeight == -1 {
		return nil, errors.New("no headers exist")
	}
	if height > latestHeight {
		return nil, errors.Errorf("unverified header requested (latest: %d)", latestHeight)
	}
	if height == 0 {
		height = latestHeight
	}

by herself. Don't you think it's bad?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:light Component: Light T:breaking Type: Breaking Change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants