[#973] ir/subnet: Remove alphabet re-signature of Delete
request
Subnet contract doesn't work with alphabet signatures. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
41eaa1e246
commit
52fc5bde6e
2 changed files with 7 additions and 62 deletions
|
@ -135,8 +135,6 @@ func (s *Server) listenSubnet() {
|
||||||
|
|
||||||
// subnet creation
|
// subnet creation
|
||||||
listenEvent(subnetCreateEvName, subnetevents.ParseNotaryPut, s.onlyAlphabetEventHandler(s.catchSubnetCreation))
|
listenEvent(subnetCreateEvName, subnetevents.ParseNotaryPut, s.onlyAlphabetEventHandler(s.catchSubnetCreation))
|
||||||
// subnet removal
|
|
||||||
listenEvent(subnetRemoveEvName, subnetevents.ParseNotaryDelete, s.onlyAlphabetEventHandler(s.catchSubnetRemoval))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) listenSubnetWithoutNotary() {
|
func (s *Server) listenSubnetWithoutNotary() {
|
||||||
|
@ -303,13 +301,6 @@ func (s *Server) handleSubnetRemoval(e event.Event) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
notaryMainTx := delEv.NotaryMainTx()
|
|
||||||
|
|
||||||
isNotary := notaryMainTx != nil
|
|
||||||
if isNotary {
|
|
||||||
// re-sign notary request
|
|
||||||
err = s.morphClient.NotarySignAndInvokeTX(notaryMainTx)
|
|
||||||
} else {
|
|
||||||
// send new transaction
|
// send new transaction
|
||||||
var prm morphsubnet.DeletePrm
|
var prm morphsubnet.DeletePrm
|
||||||
|
|
||||||
|
@ -317,11 +308,8 @@ func (s *Server) handleSubnetRemoval(e event.Event) {
|
||||||
prm.SetTxHash(delEv.TxHash())
|
prm.SetTxHash(delEv.TxHash())
|
||||||
|
|
||||||
_, err = s.subnetHandler.morphClient.Delete(prm)
|
_, err = s.subnetHandler.morphClient.Delete(prm)
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.Error("approve subnet removal",
|
s.log.Error("approve subnet removal",
|
||||||
zap.Bool("notary", isNotary),
|
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package subnetevents
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"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/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
@ -34,18 +33,6 @@ func (x Delete) TxHash() util.Uint256 {
|
||||||
return x.txHash
|
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
|
// ParseDelete parses the notification about the removal of a subnet which has been thrown
|
||||||
// by the appropriate method of the Subnet contract.
|
// 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)
|
return nil, fmt.Errorf("parse stack array: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const itemNumDelete = 1
|
||||||
|
|
||||||
if ln := len(items); ln != itemNumDelete {
|
if ln := len(items); ln != itemNumDelete {
|
||||||
return nil, event.WrongNumberOfParameters(itemNumDelete, ln)
|
return nil, event.WrongNumberOfParameters(itemNumDelete, ln)
|
||||||
}
|
}
|
||||||
|
@ -75,35 +64,3 @@ func ParseDelete(e *subscriptions.NotificationEvent) (event.Event, error) {
|
||||||
|
|
||||||
return ev, nil
|
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
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue