Skip to content

Commit ba46d7b

Browse files
ceyonurjoshua-kim
andauthored
prepare release v0.5.10 (#1019)
* bump versions * change p2p network code * Revert "change p2p network code" This reverts commit 02add53. * Use `p2p.Network` (#384) --------- Co-authored-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
1 parent 58eb7ef commit ba46d7b

File tree

10 files changed

+71
-63
lines changed

10 files changed

+71
-63
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ The Subnet EVM runs in a separate process from the main AvalancheGo process and
5353
[v0.5.6] AvalancheGo@v1.10.9-v1.10.12 (Protocol Version: 28)
5454
[v0.5.7] AvalancheGo@v1.10.13-v1.10.14 (Protocol Version: 29)
5555
[v0.5.8] AvalancheGo@v1.10.13-v1.10.14 (Protocol Version: 29)
56-
[v0.5.9] AvalancheGo@v1.10.15 (Protocol Version: 30)
56+
[v0.5.9] AvalancheGo@v1.10.15-v1.10.17 (Protocol Version: 30)
57+
[v0.5.10] AvalancheGo@v1.10.15-v1.10.17 (Protocol Version: 30)
5758
```
5859

5960
## API

compatibility.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"rpcChainVMProtocolVersion": {
3+
"v0.5.10": 30,
34
"v0.5.9": 30,
45
"v0.5.8": 29,
56
"v0.5.7": 29,

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.20
55
require (
66
github.com/VictoriaMetrics/fastcache v1.10.0
77
github.com/ava-labs/avalanche-network-runner v1.7.4-0.20231127162258-2f3ceed8ae4b
8-
github.com/ava-labs/avalanchego v1.10.17-rc.14
8+
github.com/ava-labs/avalanchego v1.10.17
99
github.com/cespare/cp v0.1.0
1010
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811
1111
github.com/davecgh/go-spew v1.1.1
@@ -57,7 +57,7 @@ require (
5757
github.com/DataDog/zstd v1.5.2 // indirect
5858
github.com/Microsoft/go-winio v0.5.2 // indirect
5959
github.com/NYTimes/gziphandler v1.1.1 // indirect
60-
github.com/ava-labs/coreth v0.12.9-rc.6 // indirect
60+
github.com/ava-labs/coreth v0.12.9-rc.9 // indirect
6161
github.com/beorn7/perks v1.0.1 // indirect
6262
github.com/bits-and-blooms/bitset v1.7.0 // indirect
6363
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
6161
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
6262
github.com/ava-labs/avalanche-network-runner v1.7.4-0.20231127162258-2f3ceed8ae4b h1:iH6q+S7dmBOYCXrZx+nNlS1HBp72L2msiVCLs39Ls5A=
6363
github.com/ava-labs/avalanche-network-runner v1.7.4-0.20231127162258-2f3ceed8ae4b/go.mod h1:aeAm8dgJ1xucQKlYoRDMgYjA0UWGwmaICG9wL0WvseU=
64-
github.com/ava-labs/avalanchego v1.10.17-rc.14 h1:d/FqLg1imOxw+g4FnsWA1OjxBJxKkHbu945BTDoMtiQ=
65-
github.com/ava-labs/avalanchego v1.10.17-rc.14/go.mod h1:jSoodApNsJJCMAdUhzVXFrzq8QyBdVHJAwx5A46yd8w=
66-
github.com/ava-labs/coreth v0.12.9-rc.6 h1:GD+slRi9FrGDB8H9TNEIXAs8BnFVd2IrgrNonFnV+Dk=
67-
github.com/ava-labs/coreth v0.12.9-rc.6/go.mod h1:rECKQfGFDeodrwGPlJSvFUJDbVr30jSMIVjQLi6pNX4=
64+
github.com/ava-labs/avalanchego v1.10.17 h1:Ri01nU5ukKC38ZCkCh3namaMZtJkSuv1X/vC13uJguc=
65+
github.com/ava-labs/avalanchego v1.10.17/go.mod h1:A6f3877qlq7bePjCU4T0D60bZGecRMCk15pMpJGOb4Q=
66+
github.com/ava-labs/coreth v0.12.9-rc.9 h1:mvYxABdyPByXwwwIxnTBCiNO23dsE1Kfnd5H106lric=
67+
github.com/ava-labs/coreth v0.12.9-rc.9/go.mod h1:yrf2vEah4Fgj6sJ4UpHewo4DLolwdpf2bJuLRT80PGw=
6868
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
6969
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
7070
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=

peer/network.go

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ type Network interface {
7777
// TrackBandwidth should be called for each valid request with the bandwidth
7878
// (length of response divided by request time), and with 0 if the response is invalid.
7979
TrackBandwidth(nodeID ids.NodeID, bandwidth float64)
80+
81+
// NewAppProtocol reserves a protocol identifier and returns a corresponding
82+
// client to send messages with
83+
NewAppProtocol(protocol uint64, handler p2p.Handler, options ...p2p.ClientOption) (*p2p.Client, error)
8084
}
8185

8286
// network is an implementation of Network that processes message requests for
@@ -88,16 +92,16 @@ type network struct {
8892
outstandingRequestHandlers map[uint32]message.ResponseHandler // maps avalanchego requestID => message.ResponseHandler
8993
activeAppRequests *semaphore.Weighted // controls maximum number of active outbound requests
9094
activeCrossChainRequests *semaphore.Weighted // controls maximum number of active outbound cross chain requests
91-
router *p2p.Router // handles messages being sent to the generic networking SDK
92-
appSender common.AppSender // avalanchego AppSender for sending messages
93-
codec codec.Manager // Codec used for parsing messages
94-
crossChainCodec codec.Manager // Codec used for parsing cross chain messages
95-
appRequestHandler message.RequestHandler // maps request type => handler
96-
crossChainRequestHandler message.CrossChainRequestHandler // maps cross chain request type => handler
97-
gossipHandler message.GossipHandler // maps gossip type => handler
98-
peers *peerTracker // tracking of peers & bandwidth
99-
appStats stats.RequestHandlerStats // Provide request handler metrics
100-
crossChainStats stats.RequestHandlerStats // Provide cross chain request handler metrics
95+
network *p2p.Network
96+
appSender common.AppSender // avalanchego AppSender for sending messages
97+
codec codec.Manager // Codec used for parsing messages
98+
crossChainCodec codec.Manager // Codec used for parsing cross chain messages
99+
appRequestHandler message.RequestHandler // maps request type => handler
100+
crossChainRequestHandler message.CrossChainRequestHandler // maps cross chain request type => handler
101+
gossipHandler message.GossipHandler // maps gossip type => handler
102+
peers *peerTracker // tracking of peers & bandwidth
103+
appStats stats.RequestHandlerStats // Provide request handler metrics
104+
crossChainStats stats.RequestHandlerStats // Provide cross chain request handler metrics
101105

102106
// Set to true when Shutdown is called, after which all operations on this
103107
// struct are no-ops.
@@ -110,16 +114,16 @@ type network struct {
110114
closed utils.Atomic[bool]
111115
}
112116

113-
func NewNetwork(router *p2p.Router, appSender common.AppSender, codec codec.Manager, crossChainCodec codec.Manager, self ids.NodeID, maxActiveAppRequests int64, maxActiveCrossChainRequests int64) Network {
117+
func NewNetwork(p2pNetwork *p2p.Network, appSender common.AppSender, codec codec.Manager, crossChainCodec codec.Manager, self ids.NodeID, maxActiveAppRequests int64, maxActiveCrossChainRequests int64) Network {
114118
return &network{
115-
router: router,
116119
appSender: appSender,
117120
codec: codec,
118121
crossChainCodec: crossChainCodec,
119122
self: self,
120123
outstandingRequestHandlers: make(map[uint32]message.ResponseHandler),
121124
activeAppRequests: semaphore.NewWeighted(maxActiveAppRequests),
122125
activeCrossChainRequests: semaphore.NewWeighted(maxActiveCrossChainRequests),
126+
network: p2pNetwork,
123127
gossipHandler: message.NoopMempoolGossipHandler{},
124128
appRequestHandler: message.NoopRequestHandler{},
125129
crossChainRequestHandler: message.NoopCrossChainRequestHandler{},
@@ -326,8 +330,8 @@ func (n *network) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID u
326330

327331
var req message.Request
328332
if _, err := n.codec.Unmarshal(request, &req); err != nil {
329-
log.Trace("forwarding AppRequest to SDK router", "nodeID", nodeID, "requestID", requestID, "requestLen", len(request), "err", err)
330-
return n.router.AppRequest(ctx, nodeID, requestID, deadline, request)
333+
log.Trace("forwarding AppRequest to SDK network", "nodeID", nodeID, "requestID", requestID, "requestLen", len(request), "err", err)
334+
return n.network.AppRequest(ctx, nodeID, requestID, deadline, request)
331335
}
332336

333337
bufferedDeadline, err := calculateTimeUntilDeadline(deadline, n.appStats)
@@ -362,8 +366,8 @@ func (n *network) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID
362366

363367
handler, exists := n.markRequestFulfilled(requestID)
364368
if !exists {
365-
log.Trace("forwarding AppResponse to SDK router", "nodeID", nodeID, "requestID", requestID, "responseLen", len(response))
366-
return n.router.AppResponse(ctx, nodeID, requestID, response)
369+
log.Trace("forwarding AppResponse to SDK network", "nodeID", nodeID, "requestID", requestID, "responseLen", len(response))
370+
return n.network.AppResponse(ctx, nodeID, requestID, response)
367371
}
368372

369373
// We must release the slot
@@ -383,8 +387,8 @@ func (n *network) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, reque
383387

384388
handler, exists := n.markRequestFulfilled(requestID)
385389
if !exists {
386-
log.Trace("forwarding AppRequestFailed to SDK router", "nodeID", nodeID, "requestID", requestID)
387-
return n.router.AppRequestFailed(ctx, nodeID, requestID)
390+
log.Trace("forwarding AppRequestFailed to SDK network", "nodeID", nodeID, "requestID", requestID)
391+
return n.network.AppRequestFailed(ctx, nodeID, requestID)
388392
}
389393

390394
// We must release the slot
@@ -456,7 +460,7 @@ func (n *network) AppGossip(_ context.Context, nodeID ids.NodeID, gossipBytes []
456460
}
457461

458462
// Connected adds the given nodeID to the peer list so that it can receive messages
459-
func (n *network) Connected(_ context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error {
463+
func (n *network) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error {
460464
n.lock.Lock()
461465
defer n.lock.Unlock()
462466

@@ -469,11 +473,11 @@ func (n *network) Connected(_ context.Context, nodeID ids.NodeID, nodeVersion *v
469473
}
470474

471475
n.peers.Connected(nodeID, nodeVersion)
472-
return nil
476+
return n.network.Connected(ctx, nodeID, nodeVersion)
473477
}
474478

475479
// Disconnected removes given [nodeID] from the peer list
476-
func (n *network) Disconnected(_ context.Context, nodeID ids.NodeID) error {
480+
func (n *network) Disconnected(ctx context.Context, nodeID ids.NodeID) error {
477481
n.lock.Lock()
478482
defer n.lock.Unlock()
479483

@@ -482,7 +486,7 @@ func (n *network) Disconnected(_ context.Context, nodeID ids.NodeID) error {
482486
}
483487

484488
n.peers.Disconnected(nodeID)
485-
return nil
489+
return n.network.Disconnected(ctx, nodeID)
486490
}
487491

488492
// Shutdown disconnects all peers
@@ -535,6 +539,10 @@ func (n *network) TrackBandwidth(nodeID ids.NodeID, bandwidth float64) {
535539
n.peers.TrackBandwidth(nodeID, bandwidth)
536540
}
537541

542+
func (n *network) NewAppProtocol(protocol uint64, handler p2p.Handler, options ...p2p.ClientOption) (*p2p.Client, error) {
543+
return n.network.NewAppProtocol(protocol, handler, options...)
544+
}
545+
538546
// invariant: peer/network must use explicitly even request ids.
539547
// for this reason, [n.requestID] is initialized as zero and incremented by 2.
540548
// This is for backwards-compatibility while the SDK router exists with the

0 commit comments

Comments
 (0)