[#1441] ir: Do not validate subnet removal

It is useless process since subnet owner is able to delete subnet without an
Alphabet approval. The Alphabet should only validate netmap state after
removal:
1. Update nodes' attributes if they were included in the deleted subnet;
2. Remove nodes without any subnet entrance.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-05-27 12:35:41 +03:00 committed by LeL
parent feef9a98f7
commit fdd54b0a03
3 changed files with 1 additions and 127 deletions

View file

@ -31,8 +31,6 @@ type subnetHandler struct {
morphClient morphsubnet.Client
putValidator irsubnet.PutValidator
delValidator irsubnet.DeleteValidator
}
// configuration of subnet component.
@ -272,52 +270,16 @@ func (s *Server) catchSubnetRemoval(e event.Event) {
s.handleSubnetRemoval(e)
})
if err != nil {
s.log.Error("subnet removal queue failure",
s.log.Error("subnet removal handling failure",
zap.String("error", err.Error()),
)
}
}
// implements irsubnet.Delete event interface required by irsubnet.DeleteValidator.
type deleteSubnetEvent struct {
ev subnetevents.Delete
}
// ReadID unmarshals subnet ID from a binary NeoFS API protocol's format.
func (x deleteSubnetEvent) ReadID(id *subnetid.ID) error {
return id.Unmarshal(x.ev.ID())
}
// handleSubnetRemoval handles event of subnet removal parsed via subnetevents.ParseDelete.
func (s *Server) handleSubnetRemoval(e event.Event) {
delEv := e.(subnetevents.Delete) // panic occurs only if we registered handler incorrectly
err := s.subnetHandler.delValidator.Assert(deleteSubnetEvent{
ev: delEv,
})
if err != nil {
s.log.Info("discard subnet removal",
zap.String("reason", err.Error()),
)
return
}
// send new transaction
var prm morphsubnet.DeletePrm
prm.SetID(delEv.ID())
prm.SetTxHash(delEv.TxHash())
_, err = s.subnetHandler.morphClient.Delete(prm)
if err != nil {
s.log.Error("approve subnet removal",
zap.String("error", err.Error()),
)
return
}
// handle subnet changes in netmap
candidates, err := s.netmapClient.GetCandidates()