From 52fc5bde6ecb4fec3256561be77fc279c95d5da7 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Sun, 28 Nov 2021 12:31:09 +0300 Subject: [PATCH] [#973] ir/subnet: Remove alphabet re-signature of `Delete` request Subnet contract doesn't work with alphabet signatures. Signed-off-by: Leonard Lyubich --- pkg/innerring/subnet.go | 22 ++++----------- pkg/morph/event/subnet/delete.go | 47 ++------------------------------ 2 files changed, 7 insertions(+), 62 deletions(-) diff --git a/pkg/innerring/subnet.go b/pkg/innerring/subnet.go index d709ce28b..40c86452b 100644 --- a/pkg/innerring/subnet.go +++ b/pkg/innerring/subnet.go @@ -135,8 +135,6 @@ func (s *Server) listenSubnet() { // subnet creation listenEvent(subnetCreateEvName, subnetevents.ParseNotaryPut, s.onlyAlphabetEventHandler(s.catchSubnetCreation)) - // subnet removal - listenEvent(subnetRemoveEvName, subnetevents.ParseNotaryDelete, s.onlyAlphabetEventHandler(s.catchSubnetRemoval)) } func (s *Server) listenSubnetWithoutNotary() { @@ -303,25 +301,15 @@ func (s *Server) handleSubnetRemoval(e event.Event) { return } - notaryMainTx := delEv.NotaryMainTx() + // send new transaction + var prm morphsubnet.DeletePrm - isNotary := notaryMainTx != nil - if isNotary { - // re-sign notary request - err = s.morphClient.NotarySignAndInvokeTX(notaryMainTx) - } else { - // send new transaction - var prm morphsubnet.DeletePrm - - prm.SetID(delEv.ID()) - prm.SetTxHash(delEv.TxHash()) - - _, err = s.subnetHandler.morphClient.Delete(prm) - } + prm.SetID(delEv.ID()) + prm.SetTxHash(delEv.TxHash()) + _, err = s.subnetHandler.morphClient.Delete(prm) if err != nil { s.log.Error("approve subnet removal", - zap.Bool("notary", isNotary), zap.String("error", err.Error()), ) diff --git a/pkg/morph/event/subnet/delete.go b/pkg/morph/event/subnet/delete.go index 4c174abb0..5d2a3def9 100644 --- a/pkg/morph/event/subnet/delete.go +++ b/pkg/morph/event/subnet/delete.go @@ -3,7 +3,6 @@ package subnetevents import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/util" @@ -34,18 +33,6 @@ func (x Delete) TxHash() util.Uint256 { return x.txHash } -// NotaryMainTx returns main transaction of the request in the Notary service. -// Returns nil in non-notary environments. -func (x Delete) NotaryMainTx() *transaction.Transaction { - if x.notaryRequest != nil { - return x.notaryRequest.MainTransaction - } - - return nil -} - -const itemNumDelete = 1 - // ParseDelete parses the notification about the removal of a subnet which has been thrown // by the appropriate method of the Subnet contract. // @@ -61,6 +48,8 @@ func ParseDelete(e *subscriptions.NotificationEvent) (event.Event, error) { return nil, fmt.Errorf("parse stack array: %w", err) } + const itemNumDelete = 1 + if ln := len(items); ln != itemNumDelete { return nil, event.WrongNumberOfParameters(itemNumDelete, ln) } @@ -75,35 +64,3 @@ func ParseDelete(e *subscriptions.NotificationEvent) (event.Event, error) { return ev, nil } - -// ParseNotaryDelete parses the notary notification about the removal of a subnet which has been -// thrown by the appropriate method of the Subnet contract. -// -// Resulting event is of Delete type. -func ParseNotaryDelete(e event.NotaryEvent) (event.Event, error) { - var ev Delete - - ev.notaryRequest = e.Raw() - if ev.notaryRequest == nil { - panic(fmt.Sprintf("nil %T in notary environment", ev.notaryRequest)) - } - - var ( - err error - - prms = e.Params() - ) - - if ln := len(prms); ln != itemNumDelete { - return nil, event.WrongNumberOfParameters(itemNumDelete, ln) - } - - ev.id, err = event.BytesFromOpcode(prms[0]) - if err != nil { - return nil, fmt.Errorf("id param: %w", err) - } - - ev.notaryRequest = e.Raw() - - return ev, nil -}