diff --git a/ROADMAP.md b/ROADMAP.md index 90b3dbb29..0e3b0ded3 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -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 @@ -78,4 +33,4 @@ with greater flexibility: - `LocalsSlot` - `StaticsSlot`. -Removal of the `Dump*Slot()` methods are scheduled for the 0.108.0 release. \ No newline at end of file +Removal of the `Dump*Slot()` methods are scheduled for the 0.108.0 release. diff --git a/pkg/core/state/native_state.go b/pkg/core/state/native_state.go index fd93f7a27..388605419 100644 --- a/pkg/core/state/native_state.go +++ b/pkg/core/state/native_state.go @@ -133,7 +133,7 @@ func (s *NEOBalance) ToStackItem() (stackitem.Item, error) { // 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() @@ -159,12 +159,10 @@ func (s *NEOBalance) FromStackItem(item stackitem.Item) error { } 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) } + s.LastGasPerVote = *lastGasPerVote return nil } diff --git a/pkg/neorpc/errors.go b/pkg/neorpc/errors.go index b38d0b695..aaa7b9d8d 100644 --- a/pkg/neorpc/errors.go +++ b/pkg/neorpc/errors.go @@ -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") diff --git a/pkg/neorpc/result/peers.go b/pkg/neorpc/result/peers.go index 4b0759264..cf085acd3 100644 --- a/pkg/neorpc/result/peers.go +++ b/pkg/neorpc/result/peers.go @@ -1,7 +1,6 @@ package result import ( - "encoding/json" "net" "strconv" @@ -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) { diff --git a/pkg/neorpc/result/peers_test.go b/pkg/neorpc/result/peers_test.go index b5ae994a4..6317c9afc 100644 --- a/pkg/neorpc/result/peers_test.go +++ b/pkg/neorpc/result/peers_test.go @@ -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) diff --git a/pkg/network/prometheus.go b/pkg/network/prometheus.go index b0ed5982b..3d2631947 100644 --- a/pkg/network/prometheus.go +++ b/pkg/network/prometheus.go @@ -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", @@ -82,7 +72,6 @@ func init() { prometheus.MustRegister( estimatedNetworkSize, peersConnected, - servAndNodeVersion, neogoVersion, serverID, poolCount, @@ -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) } diff --git a/pkg/network/server.go b/pkg/network/server.go index 4916eb4d5..24aa8614d 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -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() diff --git a/pkg/rpcclient/neo/neo_test.go b/pkg/rpcclient/neo/neo_test.go index d99dc86f9..fb6252a78 100644 --- a/pkg/rpcclient/neo/neo_test.go +++ b/pkg/rpcclient/neo/neo_test.go @@ -105,6 +105,7 @@ func TestGetAccountState(t *testing.T) { stackitem.Make(100500), stackitem.Make(42), stackitem.Null{}, + stackitem.Make(0), }), }, } diff --git a/pkg/rpcclient/waiter/waiter.go b/pkg/rpcclient/waiter/waiter.go index 30d40d0de..e804cd88e 100644 --- a/pkg/rpcclient/waiter/waiter.go +++ b/pkg/rpcclient/waiter/waiter.go @@ -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 } @@ -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{}) @@ -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) } else { waitersActive++ go func() { @@ -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 @@ -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 @@ -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: @@ -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) }