Skip to content

Commit 9dbce2d

Browse files
committed
*: always subscribe to TransactionAdded for notary pools
And drop all related logic for checking the type of event. We never care about removed requests. Fixes #2672. Signed-off-by: Roman Khimov <[email protected]>
1 parent b9b5146 commit 9dbce2d

File tree

7 files changed

+16
-35
lines changed

7 files changed

+16
-35
lines changed

pkg/innerring/deploy.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import (
55
"sync"
66

77
"github.com/nspcc-dev/neo-go/pkg/core/block"
8+
"github.com/nspcc-dev/neo-go/pkg/core/mempoolevent"
89
"github.com/nspcc-dev/neo-go/pkg/core/state"
910
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
11+
"github.com/nspcc-dev/neo-go/pkg/neorpc"
1012
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
1113
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
1214
"github.com/nspcc-dev/neo-go/pkg/rpcclient/notary"
@@ -74,9 +76,12 @@ func (x *fsChain) SubscribeToNewBlocks() (<-chan *block.Block, error) {
7476
// SubscribeToNotaryRequests implements [deploy.Blockchain] interface.
7577
func (x *fsChain) SubscribeToNotaryRequests() (<-chan *result.NotaryRequestEvent, error) {
7678
if x.wsClient != nil {
77-
ch := make(chan *result.NotaryRequestEvent)
79+
var (
80+
ch = make(chan *result.NotaryRequestEvent)
81+
evtype = mempoolevent.TransactionAdded
82+
)
7883

79-
sub, err := x.wsClient.ReceiveNotaryRequests(nil, ch)
84+
sub, err := x.wsClient.ReceiveNotaryRequests(&neorpc.NotaryRequestFilter{Type: &evtype}, ch)
8085
if err != nil {
8186
return nil, fmt.Errorf("listen to notary requests over Neo RPC WebSocket: %w", err)
8287
}

pkg/innerring/processors/container/processor.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66

7-
"github.com/nspcc-dev/neo-go/pkg/core/mempoolevent"
87
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
98
"github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid"
109
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
@@ -108,7 +107,6 @@ func (cp *Processor) ListenerNotaryParsers() []event.NotaryParserInfo {
108107
pp = make([]event.NotaryParserInfo, 0, 4)
109108
)
110109

111-
p.SetMempoolType(mempoolevent.TransactionAdded)
112110
p.SetScriptHash(cp.cnrClient.ContractAddress())
113111

114112
// container put
@@ -143,7 +141,6 @@ func (cp *Processor) ListenerNotaryHandlers() []event.NotaryHandlerInfo {
143141
)
144142

145143
h.SetScriptHash(cp.cnrClient.ContractAddress())
146-
h.SetMempoolType(mempoolevent.TransactionAdded)
147144

148145
// container put
149146
h.SetRequestType(containerEvent.PutNotaryEvent)

pkg/innerring/processors/netmap/processor.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66

7-
"github.com/nspcc-dev/neo-go/pkg/core/mempoolevent"
87
"github.com/nspcc-dev/neofs-node/pkg/innerring/processors/netmap/nodevalidation/state"
98
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
109
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
@@ -188,7 +187,6 @@ func (np *Processor) ListenerNotaryParsers() []event.NotaryParserInfo {
188187
pp = make([]event.NotaryParserInfo, 0, 2)
189188
)
190189

191-
p.SetMempoolType(mempoolevent.TransactionAdded)
192190
p.SetScriptHash(np.netmapClient.ContractAddress())
193191

194192
// new peer
@@ -212,7 +210,6 @@ func (np *Processor) ListenerNotaryHandlers() []event.NotaryHandlerInfo {
212210
hh = make([]event.NotaryHandlerInfo, 0, 2)
213211
)
214212

215-
h.SetMempoolType(mempoolevent.TransactionAdded)
216213
h.SetScriptHash(np.netmapClient.ContractAddress())
217214

218215
// new peer

pkg/innerring/processors/reputation/processor.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66

7-
"github.com/nspcc-dev/neo-go/pkg/core/mempoolevent"
87
repClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
98
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
109
reputationEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/reputation"
@@ -94,7 +93,6 @@ func (rp *Processor) ListenerNotificationHandlers() []event.NotificationHandlerI
9493
func (rp *Processor) ListenerNotaryParsers() []event.NotaryParserInfo {
9594
var p event.NotaryParserInfo
9695

97-
p.SetMempoolType(mempoolevent.TransactionAdded)
9896
p.SetRequestType(reputationEvent.PutNotaryEvent)
9997
p.SetScriptHash(rp.reputationWrp.ContractAddress())
10098
p.SetParser(reputationEvent.ParsePutNotary)
@@ -106,7 +104,6 @@ func (rp *Processor) ListenerNotaryParsers() []event.NotaryParserInfo {
106104
func (rp *Processor) ListenerNotaryHandlers() []event.NotaryHandlerInfo {
107105
var h event.NotaryHandlerInfo
108106

109-
h.SetMempoolType(mempoolevent.TransactionAdded)
110107
h.SetRequestType(reputationEvent.PutNotaryEvent)
111108
h.SetScriptHash(rp.reputationWrp.ContractAddress())
112109
h.SetHandler(rp.handlePutReputation)

pkg/morph/client/notifications.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ func (c *Client) ReceiveNotaryRequests(txSigner util.Uint160) error {
142142
return nil
143143
}
144144

145-
// ReceiveAllNotaryRequests subscribes to all notary request events coming from
146-
// the Neo blockchain the Client connected to. Events are sent to the channel
147-
// returned from [Client.Notifications].
145+
// ReceiveAllNotaryRequests subscribes to all [mempoolevent.TransactionAdded]
146+
// notary pool events coming from the Neo blockchain the Client is connected to.
147+
// Events are sent to the channel returned from [Client.Notifications].
148148
//
149149
// See also [Client.ReceiveNotaryRequests].
150150
func (c *Client) ReceiveAllNotaryRequests() error {
@@ -161,7 +161,9 @@ func (c *Client) ReceiveAllNotaryRequests() error {
161161
return nil
162162
}
163163

164-
_, err := conn.client.ReceiveNotaryRequests(nil, conn.notaryChan)
164+
nrAddedType := mempoolevent.TransactionAdded
165+
filter := &neorpc.NotaryRequestFilter{Type: &nrAddedType}
166+
_, err := conn.client.ReceiveNotaryRequests(filter, conn.notaryChan)
165167
if err != nil {
166168
return fmt.Errorf("subscribe to notary requests RPC: %w", err)
167169
}
@@ -286,7 +288,9 @@ func (c *Client) restoreSubscriptions(conn *connection, resCh chan<- bool) {
286288

287289
// notary notification events restoration
288290
if c.subs.subscribedToAllNotaryEvents {
289-
_, err = conn.client.ReceiveNotaryRequests(nil, conn.notaryChan)
291+
nrAddedType := mempoolevent.TransactionAdded
292+
filter := &neorpc.NotaryRequestFilter{Type: &nrAddedType}
293+
_, err = conn.client.ReceiveNotaryRequests(filter, conn.notaryChan)
290294
if err != nil {
291295
c.logger.Error("could not restore notary notification subscription after RPC switch",
292296
zap.Error(err))

pkg/morph/event/listener.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ func (l *listener) parseAndHandleNotary(nr *result.NotaryRequestEvent) {
348348
)
349349

350350
notaryKey := notaryRequestTypes{}
351-
notaryKey.SetMempoolType(nr.Type)
352351
notaryKey.SetRequestType(notaryEvent.Type())
353352
notaryKey.SetScriptHash(notaryEvent.ScriptHash())
354353

@@ -485,7 +484,6 @@ func (l *listener) SetNotaryParser(pi NotaryParserInfo) {
485484
}
486485

487486
log := l.log.With(
488-
zap.Stringer("mempool_type", pi.GetMempoolType()),
489487
zap.String("contract", pi.ScriptHash().StringLE()),
490488
zap.Stringer("notary_type", pi.RequestType()),
491489
)
@@ -525,7 +523,6 @@ func (l *listener) RegisterNotaryHandler(hi NotaryHandlerInfo) {
525523
}
526524

527525
log := l.log.With(
528-
zap.Stringer("mempool_type", hi.GetMempoolType()),
529526
zap.String("contract", hi.ScriptHash().StringLE()),
530527
zap.Stringer("notary type", hi.RequestType()),
531528
)

pkg/morph/event/utils.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66

7-
"github.com/nspcc-dev/neo-go/pkg/core/mempoolevent"
87
"github.com/nspcc-dev/neo-go/pkg/core/state"
98
"github.com/nspcc-dev/neo-go/pkg/util"
109
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
@@ -27,7 +26,6 @@ type scriptHashWithType struct {
2726
}
2827

2928
type notaryRequestTypes struct {
30-
notaryRequestMempoolType
3129
notaryScriptWithHash
3230
}
3331

@@ -36,24 +34,10 @@ type notaryScriptWithHash struct {
3634
scriptHashValue
3735
}
3836

39-
type notaryRequestMempoolType struct {
40-
mempoolTyp mempoolevent.Type
41-
}
42-
4337
type notaryRequestType struct {
4438
notaryType NotaryType
4539
}
4640

47-
// GetMempoolType is a notary request mempool type getter.
48-
func (n notaryRequestMempoolType) GetMempoolType() mempoolevent.Type {
49-
return n.mempoolTyp
50-
}
51-
52-
// SetMempoolType is a notary request mempool type setter.
53-
func (n *notaryRequestMempoolType) SetMempoolType(typ mempoolevent.Type) {
54-
n.mempoolTyp = typ
55-
}
56-
5741
// RequestType is a notary request type getter.
5842
func (n notaryRequestType) RequestType() NotaryType {
5943
return n.notaryType

0 commit comments

Comments
 (0)