Skip to content

Commit c7bc09a

Browse files
Merge pull request ava-labs#952 from ava-labs/grpc-update
2 parents cd7977f + cf14b56 commit c7bc09a

File tree

33 files changed

+2379
-284
lines changed

33 files changed

+2379
-284
lines changed

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
github.com/jackpal/gateway v1.0.6
3030
github.com/jackpal/go-nat-pmp v1.0.2
3131
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
32-
github.com/kr/pretty v0.2.0 // indirect
32+
github.com/kr/text v0.2.0 // indirect
3333
github.com/linxGnu/grocksdb v1.6.34
3434
github.com/mattn/go-colorable v0.1.8 // indirect
3535
github.com/mitchellh/go-homedir v1.1.0
@@ -55,6 +55,7 @@ require (
5555
gonum.org/v1/gonum v0.9.1
5656
google.golang.org/grpc v1.37.0
5757
google.golang.org/protobuf v1.27.1
58+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
5859
gopkg.in/yaml.v2 v2.4.0 // indirect
5960
gotest.tools v2.2.0+incompatible
6061
)

go.sum

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
6060
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
6161
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
6262
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
63+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
6364
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6465
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6566
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -216,11 +217,12 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6
216217
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
217218
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
218219
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
219-
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
220-
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
220+
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
221+
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
221222
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
222-
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
223223
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
224+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
225+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
224226
github.com/linxGnu/grocksdb v1.6.34 h1:fHNRbWepGN1zA4FFt/9LuiOPtSxDsr8mn4/RlU5+g1Q=
225227
github.com/linxGnu/grocksdb v1.6.34/go.mod h1:/+iSQrn7Izt6kFhHBQvcE6FkklsKXa8hc35pFyFDrDw=
226228
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
@@ -560,8 +562,9 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
560562
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
561563
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
562564
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
563-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
564565
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
566+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
567+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
565568
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
566569
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
567570
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=

network/peer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,6 @@ func (p *peer) Close() { p.once.Do(p.close) }
466466
// assumes only [peer.Close] calls this.
467467
// By the time this message returns, [p] has been removed from [p.net.peers]
468468
func (p *peer) close() {
469-
// Remove this node from the throttler.
470-
p.net.inboundMsgThrottler.RemoveNode(p.nodeID)
471-
472469
// If the connection is closing, we can immediately cancel the ticker
473470
// goroutines.
474471
close(p.tickerCloser)
@@ -479,6 +476,9 @@ func (p *peer) close() {
479476
p.net.log.Debug("closing connection to %s%s at %s resulted in an error: %s", constants.NodeIDPrefix, p.nodeID, p.getIP(), err)
480477
}
481478

479+
// Remove this node from the throttler.
480+
p.net.inboundMsgThrottler.RemoveNode(p.nodeID)
481+
482482
p.sendQueueCond.L.Lock()
483483
// Release the bytes of the unsent messages to the outbound message throttler
484484
for i := 0; i < len(p.sendQueue); i++ {

network/throttling/bandwidth_throttler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (t *bandwidthThrottler) Acquire(msgSize uint64, nodeID ids.ShortID) {
110110
t.lock.RUnlock()
111111
if !ok {
112112
// This should never happen. If it is, the caller is misusing this struct.
113-
t.log.Warn("tried to acquire %d bytes for %s but that node isn't registered", msgSize, nodeID.PrefixedString(constants.NodeIDPrefix))
113+
t.log.Debug("tried to acquire %d bytes for %s but that node isn't registered", msgSize, nodeID.PrefixedString(constants.NodeIDPrefix))
114114
return
115115
}
116116
// TODO Allow cancellation using context?

scripts/versions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
# Set up the versions to be used
99
# Don't export them as their used in the context of other calls
10-
coreth_version=${CORETH_VERSION:-'v0.7.2-rc.1'}
10+
coreth_version=${CORETH_VERSION:-'v0.7.3-rc.1'}

snow/engine/avalanche/bootstrap/bootstrapper.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,19 +496,19 @@ func (b *Bootstrapper) finish() error {
496496
}
497497

498498
// Connected implements the Engine interface.
499-
func (b *Bootstrapper) Connected(validatorID ids.ShortID) error {
500-
err := b.VM.Connected(validatorID)
499+
func (b *Bootstrapper) Connected(nodeID ids.ShortID) error {
500+
err := b.VM.Connected(nodeID)
501501
if err != nil {
502502
return err
503503
}
504-
return b.Bootstrapper.Connected(validatorID)
504+
return b.Bootstrapper.Connected(nodeID)
505505
}
506506

507507
// Disconnected implements the Engine interface.
508-
func (b *Bootstrapper) Disconnected(validatorID ids.ShortID) error {
509-
err := b.VM.Disconnected(validatorID)
508+
func (b *Bootstrapper) Disconnected(nodeID ids.ShortID) error {
509+
err := b.VM.Disconnected(nodeID)
510510
if err != nil {
511511
return err
512512
}
513-
return b.Bootstrapper.Disconnected(validatorID)
513+
return b.Bootstrapper.Disconnected(nodeID)
514514
}

snow/engine/avalanche/mocks/engine.go

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

snow/engine/avalanche/transitive.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,13 @@ func (t *Transitive) QueryFailed(vdr ids.ShortID, requestID uint32) error {
338338
}
339339

340340
// AppRequest implements the Engine interface
341-
func (t *Transitive) AppRequest(nodeID ids.ShortID, requestID uint32, request []byte) error {
341+
func (t *Transitive) AppRequest(nodeID ids.ShortID, requestID uint32, deadline time.Time, request []byte) error {
342342
if !t.Ctx.IsBootstrapped() {
343343
t.Ctx.Log.Debug("dropping AppRequest(%s, %d) due to bootstrapping", nodeID, requestID)
344344
return nil
345345
}
346346
// Notify the VM of this request
347-
return t.VM.AppRequest(nodeID, requestID, request)
347+
return t.VM.AppRequest(nodeID, requestID, deadline, request)
348348
}
349349

350350
// AppResponse implements the Engine interface

snow/engine/common/bootstrapper.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ func (b *Bootstrapper) Accepted(validatorID ids.ShortID, requestID uint32, conta
278278
}
279279

280280
// Connected implements the Engine interface.
281-
func (b *Bootstrapper) Connected(validatorID ids.ShortID) error {
281+
func (b *Bootstrapper) Connected(nodeID ids.ShortID) error {
282282
if b.started {
283283
return nil
284284
}
285-
weight, ok := b.Beacons.GetWeight(validatorID)
285+
weight, ok := b.Beacons.GetWeight(nodeID)
286286
if !ok {
287287
return nil
288288
}
@@ -298,8 +298,8 @@ func (b *Bootstrapper) Connected(validatorID ids.ShortID) error {
298298
}
299299

300300
// Disconnected implements the Engine interface.
301-
func (b *Bootstrapper) Disconnected(validatorID ids.ShortID) error {
302-
if weight, ok := b.Beacons.GetWeight(validatorID); ok {
301+
func (b *Bootstrapper) Disconnected(nodeID ids.ShortID) error {
302+
if weight, ok := b.Beacons.GetWeight(nodeID); ok {
303303
// TODO: Account for weight changes in a more robust manner.
304304

305305
// Sub64 should rarely error since only validators that have added their

snow/engine/common/engine.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package common
55

66
import (
7+
"time"
8+
79
"github.com/ava-labs/avalanchego/health"
810
"github.com/ava-labs/avalanchego/ids"
911
"github.com/ava-labs/avalanchego/snow"
@@ -131,14 +133,14 @@ type AcceptedHandler interface {
131133
type AppHandler interface {
132134
// Notify this engine of a request for data from [nodeID].
133135
// This node should send an AppResponse to [nodeID] in response to
134-
// this message using the same request ID.
136+
// this message using the same request ID and before the deadline.
135137
// The VM may choose to not send a response to this request.
136138
// The meaning of [request], and what should be sent in response to it,
137139
// is application (VM) defined.
138140
// It is not guaranteed that [request] is well-formed/valid.
139141
// The VM must do this validation.
140142
// A non-nil return value causes this engine to shutdown.
141-
AppRequest(nodeID ids.ShortID, requestID uint32, request []byte) error
143+
AppRequest(nodeID ids.ShortID, requestID uint32, deadline time.Time, request []byte) error
142144

143145
// Notify this engine that an AppRequest message it sent to
144146
// [nodeID] with request ID [requestID] failed.

0 commit comments

Comments
 (0)