Skip to content

Commit

Permalink
waiter: remove compat code for block-based waiting
Browse files Browse the repository at this point in the history
A part of #3454 for 0.107.0 release.

Signed-off-by: Roman Khimov <[email protected]>
  • Loading branch information
roman-khimov committed Nov 19, 2024
1 parent aeee733 commit 7db189e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
13 changes: 1 addition & 12 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ APIs/commands/configurations will be removed and here is a list of scheduled
breaking changes. Consider changing your code/scripts/configurations if you're
using anything mentioned here.

## Block based web-socket waiter transaction awaiting

Web-socket RPC based `waiter.EventWaiter` uses `header_of_added_block` notifications
subscription to manage transaction awaiting. To support old NeoGo RPC servers
(older than 0.105.0) that do not have block headers subscription ability,
event-based waiter fallbacks to the old way of block monitoring with
`block_added` notifications subscription.

Removal of stale RPC server compatibility code from `waiter.EventWaiter` is
scheduled for Jun-Jul 2024 (~0.107.0 release).

## Dump*Slot() methods of `vm.Context`

The following new methods have been exposed to give access to VM context slot contents
Expand All @@ -44,4 +33,4 @@ with greater flexibility:
- `LocalsSlot`
- `StaticsSlot`.

Removal of the `Dump*Slot()` methods are scheduled for the 0.108.0 release.
Removal of the `Dump*Slot()` methods are scheduled for the 0.108.0 release.
33 changes: 1 addition & 32 deletions pkg/rpcclient/waiter/waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ type (
RPCPollingBased

ReceiveHeadersOfAddedBlocks(flt *neorpc.BlockFilter, rcvr chan<- *block.Header) (string, error)
ReceiveBlocks(flt *neorpc.BlockFilter, rcvr chan<- *block.Block) (string, error)
ReceiveExecutions(flt *neorpc.ExecutionFilter, rcvr chan<- *state.AppExecResult) (string, error)
Unsubscribe(id string) error
}
Expand Down Expand Up @@ -282,7 +281,6 @@ func (w *EventBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.Uin
wsWaitErr error
waitersActive int
hRcvr = make(chan *block.Header, 2)
bRcvr = make(chan *block.Block, 2)
aerRcvr = make(chan *state.AppExecResult, len(hashes))
unsubErrs = make(chan error)
exit = make(chan struct{})
Expand All @@ -292,13 +290,7 @@ func (w *EventBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.Uin
since := vub
blocksID, err := w.ws.ReceiveHeadersOfAddedBlocks(&neorpc.BlockFilter{Since: &since}, hRcvr)
if err != nil {
// Falling back to block-based subscription.
if errors.Is(err, neorpc.ErrInvalidParams) {
blocksID, err = w.ws.ReceiveBlocks(&neorpc.BlockFilter{Since: &since}, bRcvr)
}
}
if err != nil {
wsWaitErr = fmt.Errorf("failed to subscribe for new blocks/headers: %w", err)
wsWaitErr = fmt.Errorf("failed to subscribe for new headers: %w", err)

Check warning on line 293 in pkg/rpcclient/waiter/waiter.go

View check run for this annotation

Codecov / codecov/patch

pkg/rpcclient/waiter/waiter.go#L293

Added line #L293 was not covered by tests
} else {
waitersActive++
go func() {
Expand Down Expand Up @@ -348,17 +340,6 @@ func (w *EventBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.Uin
if !ok {
// We're toast, retry with non-ws client.
hRcvr = nil
bRcvr = nil
aerRcvr = nil
wsWaitErr = ErrMissedEvent
break
}
waitErr = ErrTxNotAccepted
case _, ok := <-bRcvr:
if !ok {
// We're toast, retry with non-ws client.
hRcvr = nil
bRcvr = nil
aerRcvr = nil
wsWaitErr = ErrMissedEvent
break
Expand All @@ -368,7 +349,6 @@ func (w *EventBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.Uin
if !ok {
// We're toast, retry with non-ws client.
hRcvr = nil
bRcvr = nil
aerRcvr = nil
wsWaitErr = ErrMissedEvent
break
Expand All @@ -390,19 +370,11 @@ func (w *EventBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.Uin
case _, ok := <-hRcvr:
if !ok { // Missed event means both channels are closed.
hRcvr = nil
bRcvr = nil
aerRcvr = nil
}
case _, ok := <-bRcvr:
if !ok { // Missed event means both channels are closed.
hRcvr = nil
bRcvr = nil
aerRcvr = nil
}
case _, ok := <-aerRcvr:
if !ok { // Missed event means both channels are closed.
hRcvr = nil
bRcvr = nil
aerRcvr = nil
}
case unsubErr := <-unsubErrs:
Expand All @@ -426,9 +398,6 @@ func (w *EventBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.Uin
if hRcvr != nil {
close(hRcvr)
}
if bRcvr != nil {
close(bRcvr)
}
if aerRcvr != nil {
close(aerRcvr)
}
Expand Down

0 comments on commit 7db189e

Please sign in to comment.