forked from TrueCloudLab/frostfs-node
[#338] ir: Drop notaryless code from netmap
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
fb708b3a2d
commit
656fd7f376
5 changed files with 136 additions and 322 deletions
|
@ -19,16 +19,14 @@ func (np *Processor) processAddPeer(ev netmapEvent.AddPeer) {
|
|||
}
|
||||
|
||||
// check if notary transaction is valid, see #976
|
||||
if originalRequest := ev.NotaryRequest(); originalRequest != nil {
|
||||
tx := originalRequest.MainTransaction
|
||||
ok, err := np.netmapClient.MorphIsValidScript(tx.Script, tx.Signers)
|
||||
if err != nil || !ok {
|
||||
np.log.Warn(logs.NetmapNonhaltNotaryTransaction,
|
||||
zap.String("method", "netmap.AddPeer"),
|
||||
zap.String("hash", tx.Hash().StringLE()),
|
||||
zap.Error(err))
|
||||
return
|
||||
}
|
||||
tx := ev.NotaryRequest().MainTransaction
|
||||
ok, err := np.netmapClient.MorphIsValidScript(tx.Script, tx.Signers)
|
||||
if err != nil || !ok {
|
||||
np.log.Warn(logs.NetmapNonhaltNotaryTransaction,
|
||||
zap.String("method", "netmap.AddPeer"),
|
||||
zap.String("hash", tx.Hash().StringLE()),
|
||||
zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
// unmarshal node info
|
||||
|
@ -40,7 +38,7 @@ func (np *Processor) processAddPeer(ev netmapEvent.AddPeer) {
|
|||
}
|
||||
|
||||
// validate and update node info
|
||||
err := np.nodeValidator.VerifyAndUpdate(&nodeInfo)
|
||||
err = np.nodeValidator.VerifyAndUpdate(&nodeInfo)
|
||||
if err != nil {
|
||||
np.log.Warn(logs.NetmapCouldNotVerifyAndUpdateInformationAboutNetworkMapCandidate,
|
||||
zap.String("error", err.Error()),
|
||||
|
@ -71,20 +69,15 @@ func (np *Processor) processAddPeer(ev netmapEvent.AddPeer) {
|
|||
// See https://github.com/nspcc-dev/frostfs-contract/issues/154.
|
||||
const methodAddPeerNotary = "addPeerIR"
|
||||
|
||||
if nr := ev.NotaryRequest(); nr != nil {
|
||||
// create new notary request with the original nonce
|
||||
err = np.netmapClient.MorphNotaryInvoke(
|
||||
np.netmapClient.ContractAddress(),
|
||||
0,
|
||||
nr.MainTransaction.Nonce,
|
||||
nil,
|
||||
methodAddPeerNotary,
|
||||
nodeInfoBinary,
|
||||
)
|
||||
} else {
|
||||
// notification event case
|
||||
err = np.netmapClient.AddPeer(prm)
|
||||
}
|
||||
// create new notary request with the original nonce
|
||||
err = np.netmapClient.MorphNotaryInvoke(
|
||||
np.netmapClient.ContractAddress(),
|
||||
0,
|
||||
ev.NotaryRequest().MainTransaction.Nonce,
|
||||
nil,
|
||||
methodAddPeerNotary,
|
||||
nodeInfoBinary,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
np.log.Error(logs.NetmapCantInvokeNetmapAddPeer, zap.Error(err))
|
||||
|
@ -116,23 +109,7 @@ func (np *Processor) processUpdatePeer(ev netmapEvent.UpdatePeer) {
|
|||
}
|
||||
}
|
||||
|
||||
if nr := ev.NotaryRequest(); nr != nil {
|
||||
err = np.netmapClient.MorphNotarySignAndInvokeTX(nr.MainTransaction)
|
||||
} else {
|
||||
prm := netmapclient.UpdatePeerPrm{}
|
||||
|
||||
switch {
|
||||
case ev.Online():
|
||||
prm.SetOnline()
|
||||
case ev.Maintenance():
|
||||
prm.SetMaintenance()
|
||||
}
|
||||
|
||||
prm.SetKey(ev.PublicKey().Bytes())
|
||||
|
||||
err = np.netmapClient.UpdatePeerState(prm)
|
||||
}
|
||||
if err != nil {
|
||||
if err = np.netmapClient.MorphNotarySignAndInvokeTX(ev.NotaryRequest().MainTransaction); err != nil {
|
||||
np.log.Error(logs.NetmapCantInvokeNetmapUpdatePeer, zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue