Skip to content

Commit

Permalink
Revert "try to disable msg validation"
Browse files Browse the repository at this point in the history
This reverts commit 38110a5.
  • Loading branch information
MatusKysel committed Jul 25, 2024
1 parent bfef66c commit aa6d263
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 15 additions & 11 deletions message/validation/genesis/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package validation
// validator.go contains main code for validation and most of the rule checks.

import (
"bytes"
"context"
"encoding/hex"
"fmt"
Expand Down Expand Up @@ -225,8 +226,11 @@ func (mv *messageValidator) Validate(_ context.Context, peerID peer.ID, pmsg *pu
return pubsub.ValidationReject
}

// skipping the error check for testing simplifying
decMsg, _ := genesisqueue.DecodeGenesisSSVMessage(msg)
decMsg, err := genesisqueue.DecodeGenesisSSVMessage(msg)
if err != nil {
mv.logger.Error("failed to decode network message", zap.Error(err))
return pubsub.ValidationReject
}
pmsg.ValidatorData = decMsg
return pubsub.ValidationAccept
}
Expand Down Expand Up @@ -387,13 +391,13 @@ func (mv *messageValidator) validateSSVMessage(msg *genesisqueue.GenesisSSVMessa
err.want = maxMessageSize
return nil, descriptor, err
}
// domain := mv.netCfg.DomainType()
// if !bytes.Equal(ssvMessage.MsgID.GetDomain(), domain[:]) {
// err := ErrWrongDomain
// err.got = hex.EncodeToString(ssvMessage.MsgID.GetDomain())
// err.want = hex.EncodeToString(domain[:])
// return nil, descriptor, err
// }
domain := mv.netCfg.DomainType()
if !bytes.Equal(ssvMessage.MsgID.GetDomain(), domain[:]) {
err := ErrWrongDomain
err.got = hex.EncodeToString(ssvMessage.MsgID.GetDomain())
err.want = hex.EncodeToString(domain[:])
return nil, descriptor, err
}

validatorPK := ssvMessage.GetID().GetPubKey()
role := ssvMessage.GetID().GetRoleType()
Expand Down Expand Up @@ -476,8 +480,8 @@ func (mv *messageValidator) validateSSVMessage(msg *genesisqueue.GenesisSSVMessa
}

partialSignatureMessage := msg.Body.(*spectypes.SignedPartialSignatureMessage)
// slot, err := mv.validatePartialSignatureMessage(share, partialSignatureMessage, msg.GetID(), signatureVerifier)
descriptor.Slot = partialSignatureMessage.Message.Slot
slot, err := mv.validatePartialSignatureMessage(share, partialSignatureMessage, msg.GetID(), signatureVerifier)
descriptor.Slot = slot
if err != nil {
return nil, descriptor, err
}
Expand Down
2 changes: 2 additions & 0 deletions network/p2p/p2p_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func (p *GenesisP2p) Broadcast(message *genesisspectypes.SSVMessage) error {
return fmt.Errorf("could not encode signed ssv message: %w", err)
}

message.MsgID.GetPubKey()

share := p.Network.nodeStorage.ValidatorStore().Validator(message.MsgID.GetPubKey())
if share == nil {
return fmt.Errorf("could not find validator: %x", message.MsgID.GetPubKey())
Expand Down

0 comments on commit aa6d263

Please sign in to comment.