Do Not Propose if Assigned to Genesis Slot (#1989)

* do not propose if assigned to genesis

* fix bitset

* revert bitset

* regress test

* rem commented blocks
This commit is contained in:
Raul Jordan 2019-03-14 10:13:57 -04:00 committed by GitHub
parent d5c05f083b
commit ef8232ae2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -23,6 +23,10 @@ import (
// the state root computation, and finally signed by the validator before being
// sent back to the beacon node for broadcasting.
func (v *validator) ProposeBlock(ctx context.Context, slot uint64) {
if slot == params.BeaconConfig().GenesisSlot {
log.Info("Assigned to genesis slot, skipping proposal")
return
}
ctx, span := trace.StartSpan(ctx, "validator.ProposeBlock")
defer span.End()
log.Info("Proposing...")

View File

@ -43,6 +43,15 @@ func setup(t *testing.T) (*validator, *mocks, func()) {
return validator, m, ctrl.Finish
}
func TestProposeBlock_DoesNotProposeGenesisBlock(t *testing.T) {
hook := logTest.NewGlobal()
validator, _, finish := setup(t)
defer finish()
validator.ProposeBlock(context.Background(), params.BeaconConfig().GenesisSlot)
testutil.AssertLogsContain(t, hook, "Assigned to genesis slot, skipping proposal")
}
func TestProposeBlock_LogsCanonicalHeadFailure(t *testing.T) {
hook := logTest.NewGlobal()
validator, m, finish := setup(t)