Skip to content

Commit

Permalink
Merge pull request #1218 from bloxapp/stage
Browse files Browse the repository at this point in the history
`v1.1.1`
  • Loading branch information
Lior Rutenberg authored Nov 22, 2023
2 parents 955e804 + 6dafce3 commit 5cfca80
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Deploy nodes to prod:
# +---------------------------+
# | 🟠 Deploy SSV Prater nodes |
# +---------------------------+
#- .k8/production/prater/scripts/deploy-cluster-1--4.sh $DOCKER_REPO_INFRA_PROD $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_PROD blox-infra-prod kubernetes-admin@blox-infra-prod ssv.network $K8S_API_VERSION $PROD_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT_V3 $SSV_NODES_MEM_LIMIT_V3
- .k8/production/prater/scripts/deploy-cluster-1--4.sh $DOCKER_REPO_INFRA_PROD $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_PROD blox-infra-prod kubernetes-admin@blox-infra-prod ssv.network $K8S_API_VERSION $PROD_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT_V3 $SSV_NODES_MEM_LIMIT_V3
#
# +----------------------------+
# | 🔴 Deploy SSV Mainnet nodes |
Expand Down Expand Up @@ -196,7 +196,7 @@ Deploy exporter to prod:
# +------------------------------+
# | 🟠 Deploy Prater exporter |
# +------------------------------+
# - .k8/production/prater/scripts/deploy-exporters.sh $DOCKER_REPO_INFRA_PROD $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_PROD blox-infra-prod kubernetes-admin@blox-infra-prod ssv.network $K8S_API_VERSION $SSV_EXPORTER_CPU_LIMIT $SSV_EXPORTER_MEM_LIMIT
- .k8/production/prater/scripts/deploy-exporters.sh $DOCKER_REPO_INFRA_PROD $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_PROD blox-infra-prod kubernetes-admin@blox-infra-prod ssv.network $K8S_API_VERSION $SSV_EXPORTER_CPU_LIMIT $SSV_EXPORTER_MEM_LIMIT
#
# +------------------------------+
# │ 🔴 Deploy Mainnet exporter |
Expand Down
2 changes: 1 addition & 1 deletion message/validation/consensus_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (mv *messageValidator) validateSignerBehaviorConsensus(
return err
}

if !(msgSlot > signerState.Slot || msgSlot == signerState.Slot && msgRound > signerState.Round) {
if msgSlot == signerState.Slot && msgRound == signerState.Round {
if mv.hasFullData(signedMsg) && signerState.ProposalData != nil && !bytes.Equal(signerState.ProposalData, signedMsg.FullData) {
return ErrDuplicatedProposalWithDifferentData
}
Expand Down
22 changes: 20 additions & 2 deletions message/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,14 @@ type messageValidator struct {
dutyStore *dutystore.Store
ownOperatorID spectypes.OperatorID
operatorIDToPubkeyCache *hashmap.Map[spectypes.OperatorID, *rsa.PublicKey]
selfPID peer.ID
selfAccept bool

// validationLocks is a map of lock per SSV message ID to
// prevent concurrent access to the same state.
validationLocks map[spectypes.MessageID]*sync.Mutex
validationMutex sync.Mutex

selfPID peer.ID
selfAccept bool
}

// NewMessageValidator returns a new MessageValidator with the given network configuration and options.
Expand All @@ -88,6 +94,7 @@ func NewMessageValidator(netCfg networkconfig.NetworkConfig, opts ...Option) Mes
metrics: &nopMetrics{},
netCfg: netCfg,
operatorIDToPubkeyCache: hashmap.New[spectypes.OperatorID, *rsa.PublicKey](),
validationLocks: make(map[spectypes.MessageID]*sync.Mutex),
}

for _, opt := range opts {
Expand Down Expand Up @@ -431,6 +438,17 @@ func (mv *messageValidator) validateSSVMessage(ssvMessage *spectypes.SSVMessage,
return nil, descriptor, e
}

// Lock this SSV message ID to prevent concurrent access to the same state.
mv.validationMutex.Lock()
mutex, ok := mv.validationLocks[msg.GetID()]
if !ok {
mutex = &sync.Mutex{}
mv.validationLocks[msg.GetID()] = mutex
}
mutex.Lock()
defer mutex.Unlock()
mv.validationMutex.Unlock()

descriptor.SSVMessageType = ssvMessage.MsgType

if mv.nodeStorage != nil {
Expand Down
3 changes: 1 addition & 2 deletions protocol/v2/ssv/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ type BaseRunner struct {
BeaconRoleType spectypes.BeaconRole

// implementation vars
TimeoutF TimeoutF `json:"-"`
VerifySignatures bool `json:"-"`
TimeoutF TimeoutF `json:"-"`

// highestDecidedSlot holds the highest decided duty slot and gets updated after each decided is reached
highestDecidedSlot spec.Slot
Expand Down
14 changes: 6 additions & 8 deletions protocol/v2/ssv/runner/runner_signatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@ func (b *BaseRunner) validatePartialSigMsgForSlot(
return errors.New("invalid partial sig slot")
}

if b.VerifySignatures {
if err := types.VerifyByOperators(signedMsg.GetSignature(), signedMsg, b.Share.DomainType, spectypes.PartialSignatureType, b.Share.Committee); err != nil {
return errors.Wrap(err, "failed to verify PartialSignature")
}
if err := types.VerifyByOperators(signedMsg.GetSignature(), signedMsg, b.Share.DomainType, spectypes.PartialSignatureType, b.Share.Committee); err != nil {
return errors.Wrap(err, "failed to verify PartialSignature")
}

for _, msg := range signedMsg.Message.Messages {
if err := b.verifyBeaconPartialSignature(msg); err != nil {
return errors.Wrap(err, "could not verify Beacon partial Signature")
}
for _, msg := range signedMsg.Message.Messages {
if err := b.verifyBeaconPartialSignature(msg); err != nil {
return errors.Wrap(err, "could not verify Beacon partial Signature")
}
}

Expand Down
2 changes: 0 additions & 2 deletions protocol/v2/ssv/spectest/msg_processing_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ func RunMsgProcessing(t *testing.T, test *MsgProcessingSpecTest) {
}

func (test *MsgProcessingSpecTest) RunAsPartOfMultiTest(t *testing.T, logger *zap.Logger) {
test.Runner.GetBaseRunner().VerifySignatures = true

v := ssvtesting.BaseValidator(logger, spectestingutils.KeySetForShare(test.Runner.GetBaseRunner().Share))
v.DutyRunners[test.Runner.GetBaseRunner().BeaconRoleType] = test.Runner
v.Network = test.Runner.GetNetwork().(specqbft.Network) // TODO need to align
Expand Down

0 comments on commit 5cfca80

Please sign in to comment.