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

Validator Fix #914

Merged
merged 3 commits into from
Nov 22, 2018
Merged

Validator Fix #914

merged 3 commits into from
Nov 22, 2018

Conversation

nisdas
Copy link
Member

@nisdas nisdas commented Nov 22, 2018

Resolves #903

This PR resolves the error by completely removing any appending of the specials records that occured when a new active state was calculated. Due to appending of 2 new special records each cycle transition, the first two active validators were logged out due to the following function in Casper

func ProcessSpecialRecords(slotNumber uint64, validators []*pb.ValidatorRecord, pendingSpecials []*pb.SpecialRecord) ([]*pb.ValidatorRecord, error) {
	// For each special record object in active state.
	for _, specialRecord := range pendingSpecials {

		// Covers validators submitted logouts from last cycle.
		if specialRecord.Kind == uint32(params.Logout) {
			validatorIndex := binary.BigEndian.Uint64(specialRecord.Data[0])
			exitedValidator := v.ExitValidator(validators[validatorIndex], slotNumber, false)
			validators[validatorIndex] = exitedValidator
			// TODO(#633): Verify specialRecord.Data[1] as signature. BLSVerify(pubkey=validator.pubkey, msg=hash(LOGOUT_MESSAGE + bytes8(version))
		}

	}
	return validators, nil
}

With special records added whenever CalculateNewActiveState was run, the following lines were removed to stop that from occuring

	_, proposerIndex, err := v.ProposerShardAndIndex(
		cState.ShardAndCommitteesForSlots(),
		cState.LastStateRecalculationSlot(),
		parentSlot)
	if err != nil {
		return nil, fmt.Errorf("could not get proposer index %v", err)
	}
	specialRecordData := make([][]byte, 2)
	for i := range specialRecordData {
		specialRecordData[i] = make([]byte, 32)
	}
	blockRandao := block.RandaoReveal()
	proposerIndexBytes := b.Bytes8(proposerIndex)
	specialRecordData[0] = proposerIndexBytes
	specialRecordData[1] = blockRandao[:]
 	newState.data.PendingSpecials = a.appendNewSpecialObject(&pb.SpecialRecord{
		Data: specialRecordData,
	})

@nisdas nisdas added Bug Something isn't working Priority: Critical Highest, immediate priority item labels Nov 22, 2018
@codecov
Copy link

codecov bot commented Nov 22, 2018

Codecov Report

Merging #914 into master will decrease coverage by 0.13%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #914      +/-   ##
==========================================
- Coverage   73.22%   73.08%   -0.14%     
==========================================
  Files          69       69              
  Lines        4575     4559      -16     
==========================================
- Hits         3350     3332      -18     
- Misses        895      897       +2     
  Partials      330      330

@terencechain
Copy link
Member

thanks a lot for the quick fix, we'll track adding special record back in #923

@terencechain terencechain merged commit 5329ef8 into prysmaticlabs:master Nov 22, 2018
@nisdas nisdas deleted the validatorFix branch November 23, 2018 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Priority: Critical Highest, immediate priority item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validator Client Unable to Find Index for Public Key
2 participants