Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop deprecated code for 0.107.0 #3690

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 1 addition & 46 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,51 +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.

## GetPeers RPC server response type changes and RPC client support

GetPeers RPC command returns a list of Peers where the port type has changed from
string to uint16 to match C#. The RPC client currently supports unmarshalling both
formats.

Removal of Peer unmarshalling with string based ports is scheduled for Jun-Jul 2024
(~0.107.0 release).

## `NEOBalance` from stack item

We check struct items count before convert LastGasPerVote to let RPC client be compatible with
old versions.

Removal of this compatiblility code is scheduled for Jun-Jul 2024.

## `serv_node_version` Prometheus gauge metric

This metric is replaced by the new `neogo_version` and `server_id` Prometheus gauge
metrics with proper version formatting. `neogo_version` contains NeoGo version
hidden under `version` label and `server_id` contains network server ID hidden
under `server_id` label.

Removal of `serv_node_version` is scheduled for Jun-Jul 2024 (~0.107.0 release).

## RPC error codes returned by old versions and C#-nodes

NeoGo retains certain deprecated error codes: `neorpc.ErrCompatGeneric`,
`neorpc.ErrCompatNoOpenedWallet`. They returned by nodes not compliant with the
neo-project/proposals#156 (NeoGo pre-0.102.0 and all known C# versions).

Removal of the deprecated RPC error codes is planned for Jun-Jul 2024 (~0.107.0
release).

## 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 @@ -78,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.
12 changes: 5 additions & 7 deletions pkg/core/state/native_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
// FromStackItem converts stackitem.Item to NEOBalance.
func (s *NEOBalance) FromStackItem(item stackitem.Item) error {
structItem, ok := item.Value().([]stackitem.Item)
if !ok || len(structItem) < 3 {
if !ok || len(structItem) < 4 {
return errors.New("invalid stackitem length")
}
balance, err := structItem[0].TryInteger()
Expand All @@ -159,12 +159,10 @@
}
s.VoteTo = pub
}
if len(structItem) >= 4 {
lastGasPerVote, err := structItem[3].TryInteger()
if err != nil {
return fmt.Errorf("invalid last vote reward per neo stackitem: %w", err)
}
s.LastGasPerVote = *lastGasPerVote
lastGasPerVote, err := structItem[3].TryInteger()
if err != nil {
return fmt.Errorf("invalid last vote reward per neo stackitem: %w", err)

Check warning on line 164 in pkg/core/state/native_state.go

View check run for this annotation

Codecov / codecov/patch

pkg/core/state/native_state.go#L164

Added line #L164 was not covered by tests
}
s.LastGasPerVote = *lastGasPerVote
return nil
}
15 changes: 0 additions & 15 deletions pkg/neorpc/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,6 @@ const (
ErrExecutionFailedCode = -608
)

var (
// ErrCompatGeneric is an error returned by nodes not compliant with the neo-project/proposals#156
// (NeoGo pre-0.102.0 and all known C# versions).
// It can be returned for any call and doesn't have any specific meaning.
//
// Deprecated: to be removed after all nodes adopt new error standard.
ErrCompatGeneric = NewErrorWithCode(-100, "RPC error")

// ErrCompatNoOpenedWallet is an error code returned by nodes not compliant with the neo-project/proposals#156
// (all known C# versions, NeoGo never used this code). It can be returned for wallet-related operations.
//
// Deprecated: to be removed after all nodes adopt new error standard.
ErrCompatNoOpenedWallet = NewErrorWithCode(-400, "No opened wallet")
)

var (
// ErrInvalidParams represents a generic "Invalid params" error.
ErrInvalidParams = NewInvalidParamsError("Invalid params")
Expand Down
32 changes: 0 additions & 32 deletions pkg/neorpc/result/peers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package result

import (
"encoding/json"
"net"
"strconv"

Expand Down Expand Up @@ -86,37 +85,6 @@ func (p *Peers) addConnectedPeers(connectedPeers []network.PeerInfo) {
}
}

func (p *Peer) UnmarshalJSON(data []byte) error {
type NewPeer Peer
var np NewPeer

err := json.Unmarshal(data, &np)
if err == nil {
*p = Peer(np)
return nil
}

type OldPeer struct {
Address string `json:"address"`
Port string `json:"port"`
}
var op OldPeer

err = json.Unmarshal(data, &op)
if err == nil {
port, err := strconv.ParseUint(op.Port, 10, 16)
if err != nil {
return err
}

*p = Peer{
Address: op.Address,
Port: uint16(port),
}
}
return err
}

// parseHostPort parses host and port from the given address.
// An improperly formatted port string will return zero port.
func parseHostPort(addr string) (string, uint16, error) {
Expand Down
5 changes: 1 addition & 4 deletions pkg/neorpc/result/peers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ func TestGetPeers(t *testing.T) {
require.Equal(t, uint16(20333), gp.Bad[0].Port)

gps := GetPeers{}
oldPeerFormat := `{"unconnected": [{"address": "20.109.188.128","port": "10333"},{"address": "27.188.182.47","port": "10333"}],"connected": [{"address": "54.227.43.72","port": "10333"},{"address": "157.90.177.38","port": "10333"}],"bad": [{"address": "5.226.142.226","port": "10333"}]}`
err := json.Unmarshal([]byte(oldPeerFormat), &gps)
require.NoError(t, err)
newPeerFormat := `{"unconnected": [{"address": "20.109.188.128","port": 10333},{"address": "27.188.182.47","port": 10333}],"connected": [{"address": "54.227.43.72","port": 10333},{"address": "157.90.177.38","port": 10333}],"bad": [{"address": "5.226.142.226","port": 10333},{"address": "54.208.117.178","port": 10333}]}`
err = json.Unmarshal([]byte(newPeerFormat), &gps)
err := json.Unmarshal([]byte(newPeerFormat), &gps)
require.NoError(t, err)
badIntFormat := `{"unconnected": [{"address": "20.109.188.128","port": 65536}],"connected": [],"bad": []}`
err = json.Unmarshal([]byte(badIntFormat), &gps)
Expand Down
17 changes: 0 additions & 17 deletions pkg/network/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ var (
},
)

// Deprecated: please, use neogoVersion and serverID instead.
servAndNodeVersion = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Help: "Server and Node versions",
Name: "serv_node_version",
Namespace: "neogo",
},
[]string{"description", "value"},
)

neogoVersion = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Help: "NeoGo version",
Expand Down Expand Up @@ -82,7 +72,6 @@ func init() {
prometheus.MustRegister(
estimatedNetworkSize,
peersConnected,
servAndNodeVersion,
neogoVersion,
serverID,
poolCount,
Expand Down Expand Up @@ -122,12 +111,6 @@ func updatePeersConnectedMetric(pConnected int) {
peersConnected.Set(float64(pConnected))
}

// Deprecated: please, use setNeoGoVersion and setSeverID instead.
func setServerAndNodeVersions(nodeVer string, serverID string) {
servAndNodeVersion.WithLabelValues("Node version: ", nodeVer).Add(0)
servAndNodeVersion.WithLabelValues("Server id: ", serverID).Add(0)
}

func setNeoGoVersion(nodeVer string) {
neogoVersion.WithLabelValues(nodeVer).Add(1)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/network/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ func (s *Server) Start() {
for _, tr := range s.transports {
go tr.Accept()
}
setServerAndNodeVersions(s.UserAgent, strconv.FormatUint(uint64(s.id), 10))
setNeoGoVersion(config.Version)
setSeverID(strconv.FormatUint(uint64(s.id), 10))
go s.run()
Expand Down
1 change: 1 addition & 0 deletions pkg/rpcclient/neo/neo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func TestGetAccountState(t *testing.T) {
stackitem.Make(100500),
stackitem.Make(42),
stackitem.Null{},
stackitem.Make(0),
}),
},
}
Expand Down
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
if hRcvr != nil {
close(hRcvr)
}
if bRcvr != nil {
close(bRcvr)
}
if aerRcvr != nil {
close(aerRcvr)
}
Expand Down
Loading