Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ func (i *Instance) HandleMessage(msg *common.Message, from common.NodeID) error
default:
}

if !i.started {
i.Config.Logger.Debug("Instance has not started, dropping message")
return nil
}

// We need to artificially wire the MSM and the cache to the block,
// in order to intercept the Verify() call.
switch {
Expand Down
17 changes: 17 additions & 0 deletions instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,23 @@ func TestNonValidatorBecomesValidator(t *testing.T) {
assertExpectedNodeIds(t, finalization.QC.Signers(), newValidatorSet.NodeIDs())
}

// TestInstanceDropsMessagesBeforeStart asserts that a message delivered before Start
// is dropped without error. A validator broadcasts the finalization only after
// indexing the block, so a node created on that commit can receive it before starting.
func TestInstanceDropsMessagesBeforeStart(t *testing.T) {
validator := newNodeMapping(1)
pChain := newTestPChain([]metadata.NodeBLSMapping{validator})
instance := NewInstance(Config{
PlatformChain: pChain,
Storage: newTestStorageWithGenesis(t),
Logger: testutil.MakeLogger(t, 1),
ID: validator.NodeID[:],
})

msg := &common.Message{Finalization: &common.Finalization{}}
require.NoError(t, instance.HandleMessage(msg, validator.NodeID[:]))
}

// TestValidator_ValidatorSetNotChanged tests that a P-chain height increase
// that does not have a unique validator set, does not create a new epoch
func TestValidator_ValidatorSetNotChanged(t *testing.T) {
Expand Down
Loading