Skip to content

Commit 884bcd7

Browse files
Merge pull request #807 from ava-labs/dev
v1.2.4
2 parents e285530 + 23196ed commit 884bcd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1607
-478
lines changed

.ci/after_success.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@ TRAVIS_IMAGE_TAG="$DOCKERHUB_REPO:travis-$TRAVIS_BUILD_NUMBER"
1919
docker tag "$AVALANCHE_IMAGE" "$TRAVIS_IMAGE_TAG"
2020

2121
if [[ $TRAVIS_BRANCH == "master" ]]; then
22+
echo "Tagging $AVALANCHE_IMAGE as $DOCKERHUB_REPO:latest"
2223
docker tag "$AVALANCHE_IMAGE" "$DOCKERHUB_REPO:latest"
2324
fi
2425

2526
if [[ $TRAVIS_BRANCH == "dev" ]]; then
27+
echo "Tagging $AVALANCHE_IMAGE as $DOCKERHUB_REPO:dev"
2628
docker tag "$AVALANCHE_IMAGE" "$DOCKERHUB_REPO:dev"
2729
fi
2830

2931
if [[ $TRAVIS_TAG != "" ]]; then
32+
echo "Tagging $AVALANCHE_IMAGE as $DOCKERHUB_REPO:$TRAVIS_TAG"
3033
docker tag "$AVALANCHE_IMAGE" "$DOCKERHUB_REPO:$TRAVIS_TAG"
3134
fi
3235

3336
echo "$DOCKER_PASS" | docker login --username "$DOCKER_USERNAME" --password-stdin
3437

3538
# following should push all tags
36-
docker push $DOCKERHUB_REPO
39+
docker push $DOCKERHUB_REPO

.github/workflows/build-linux-release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ jobs:
2929
run: ./scripts/build.sh
3030

3131
- name: Install aws cli
32-
run: sudo apt-get install awscli
32+
run: |
33+
sudo apt update
34+
sudo apt-get install awscli
3335
3436
- name: Install rpmbuild
3537
run: sudo apt-get install rpm

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ a blockchains platform with high throughput, and blazing fast transactions.
88

99
Avalanche is an incredibly lightweight protocol, so the minimum computer requirements are quite modest.
1010

11-
- Hardware: 2 GHz or faster CPU, 4 GB RAM, 2 GB hard disk.
11+
- Hardware: 2 GHz or faster CPU, 4 GB RAM, 20 GB hard disk.
1212
- OS: Ubuntu >= 18.04 or Mac OS X >= Catalina.
1313
- Software: [Go](https://golang.org/doc/install) version >= 1.15.5 and set up [`$GOPATH`](https://github.com/golang/go/wiki/SettingGOPATH).
1414
- Network: IPv4 or IPv6 network connection, with an open public port.

api/health/service.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import (
99

1010
stdjson "encoding/json"
1111

12-
"github.com/gorilla/rpc/v2"
13-
14-
health "github.com/AppsFlyer/go-sundheit"
15-
1612
"github.com/ava-labs/avalanchego/snow/engine/common"
1713
"github.com/ava-labs/avalanchego/utils/json"
1814
"github.com/ava-labs/avalanchego/utils/logging"
15+
"github.com/gorilla/rpc/v2"
16+
"github.com/prometheus/client_golang/prometheus"
1917

18+
health "github.com/AppsFlyer/go-sundheit"
2019
healthlib "github.com/ava-labs/avalanchego/health"
2120
)
2221

@@ -29,11 +28,15 @@ type Service interface {
2928
Handler() (*common.HTTPHandler, error)
3029
}
3130

32-
func NewService(checkFreq time.Duration, log logging.Logger) Service {
31+
func NewService(checkFreq time.Duration, log logging.Logger, namespace string, registry prometheus.Registerer) (Service, error) {
32+
service, err := healthlib.NewService(checkFreq, log, namespace, registry)
33+
if err != nil {
34+
return nil, err
35+
}
3336
return &apiServer{
34-
Service: healthlib.NewService(checkFreq, log),
37+
Service: service,
3538
log: log,
36-
}
39+
}, nil
3740
}
3841

3942
// APIServer serves HTTP for a health service

cache/cache.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,29 @@
33

44
package cache
55

6-
import (
7-
"github.com/ava-labs/avalanchego/ids"
8-
)
9-
10-
// Cacher acts as a best effort key value store
6+
// Cacher acts as a best effort key value store. Keys must be comparable, as
7+
// defined by https://golang.org/ref/spec#Comparison_operators.
118
type Cacher interface {
129
// Put inserts an element into the cache. If spaced is required, elements will
1310
// be evicted.
14-
Put(key ids.ID, value interface{})
11+
Put(key, value interface{})
1512

1613
// Get returns the entry in the cache with the key specified, if no value
1714
// exists, false is returned.
18-
Get(key ids.ID) (interface{}, bool)
15+
Get(key interface{}) (interface{}, bool)
1916

2017
// Evict removes the specified entry from the cache
21-
Evict(key ids.ID)
18+
Evict(key interface{})
2219

2320
// Flush removes all entries from the cache
2421
Flush()
2522
}
2623

2724
// Evictable allows the object to be notified when it is evicted
2825
type Evictable interface {
29-
ID() ids.ID
26+
// Key must return a comparable value as defined by
27+
// https://golang.org/ref/spec#Comparison_operators.
28+
Key() interface{}
3029
Evict()
3130
}
3231

cache/lru_cache.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ package cache
66
import (
77
"container/list"
88
"sync"
9-
10-
"github.com/ava-labs/avalanchego/ids"
119
)
1210

1311
const (
1412
minCacheSize = 32
1513
)
1614

1715
type entry struct {
18-
Key ids.ID
16+
Key interface{}
1917
Value interface{}
2018
}
2119

@@ -24,29 +22,29 @@ type entry struct {
2422
// done, based on evicting the least recently used value.
2523
type LRU struct {
2624
lock sync.Mutex
27-
entryMap map[ids.ID]*list.Element
25+
entryMap map[interface{}]*list.Element
2826
entryList *list.List
2927
Size int
3028
}
3129

3230
// Put implements the cache interface
33-
func (c *LRU) Put(key ids.ID, value interface{}) {
31+
func (c *LRU) Put(key, value interface{}) {
3432
c.lock.Lock()
3533
defer c.lock.Unlock()
3634

3735
c.put(key, value)
3836
}
3937

4038
// Get implements the cache interface
41-
func (c *LRU) Get(key ids.ID) (interface{}, bool) {
39+
func (c *LRU) Get(key interface{}) (interface{}, bool) {
4240
c.lock.Lock()
4341
defer c.lock.Unlock()
4442

4543
return c.get(key)
4644
}
4745

4846
// Evict implements the cache interface
49-
func (c *LRU) Evict(key ids.ID) {
47+
func (c *LRU) Evict(key interface{}) {
5048
c.lock.Lock()
5149
defer c.lock.Unlock()
5250

@@ -63,7 +61,7 @@ func (c *LRU) Flush() {
6361

6462
func (c *LRU) init() {
6563
if c.entryMap == nil {
66-
c.entryMap = make(map[ids.ID]*list.Element, minCacheSize)
64+
c.entryMap = make(map[interface{}]*list.Element, minCacheSize)
6765
}
6866
if c.entryList == nil {
6967
c.entryList = list.New()
@@ -83,7 +81,7 @@ func (c *LRU) resize() {
8381
}
8482
}
8583

86-
func (c *LRU) put(key ids.ID, value interface{}) {
84+
func (c *LRU) put(key, value interface{}) {
8785
c.init()
8886
c.resize()
8987

@@ -111,7 +109,7 @@ func (c *LRU) put(key ids.ID, value interface{}) {
111109
}
112110
}
113111

114-
func (c *LRU) get(key ids.ID) (interface{}, bool) {
112+
func (c *LRU) get(key interface{}) (interface{}, bool) {
115113
c.init()
116114
c.resize()
117115

@@ -124,7 +122,7 @@ func (c *LRU) get(key ids.ID) (interface{}, bool) {
124122
return struct{}{}, false
125123
}
126124

127-
func (c *LRU) evict(key ids.ID) {
125+
func (c *LRU) evict(key interface{}) {
128126
c.init()
129127
c.resize()
130128

@@ -137,6 +135,6 @@ func (c *LRU) evict(key ids.ID) {
137135
func (c *LRU) flush() {
138136
c.init()
139137

140-
c.entryMap = make(map[ids.ID]*list.Element, minCacheSize)
138+
c.entryMap = make(map[interface{}]*list.Element, minCacheSize)
141139
c.entryList = list.New()
142140
}

cache/metercacher/cache.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/prometheus/client_golang/prometheus"
88

99
"github.com/ava-labs/avalanchego/cache"
10-
"github.com/ava-labs/avalanchego/ids"
1110
"github.com/ava-labs/avalanchego/utils/timer"
1211
)
1312

@@ -26,14 +25,14 @@ func New(
2625
return meterCache, meterCache.metrics.Initialize(namespace, registerer)
2726
}
2827

29-
func (c *Cache) Put(key ids.ID, value interface{}) {
28+
func (c *Cache) Put(key, value interface{}) {
3029
start := c.clock.Time()
3130
c.cache.Put(key, value)
3231
end := c.clock.Time()
3332
c.put.Observe(float64(end.Sub(start)))
3433
}
3534

36-
func (c *Cache) Get(key ids.ID) (interface{}, bool) {
35+
func (c *Cache) Get(key interface{}) (interface{}, bool) {
3736
start := c.clock.Time()
3837
value, has := c.cache.Get(key)
3938
end := c.clock.Time()
@@ -47,7 +46,7 @@ func (c *Cache) Get(key ids.ID) (interface{}, bool) {
4746
return value, has
4847
}
4948

50-
func (c *Cache) Evict(key ids.ID) {
49+
func (c *Cache) Evict(key interface{}) {
5150
start := c.clock.Time()
5251
c.cache.Evict(key)
5352
end := c.clock.Time()

cache/metercacher/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/prometheus/client_golang/prometheus"
1010

11-
"github.com/ava-labs/avalanchego/utils/timer"
11+
"github.com/ava-labs/avalanchego/utils"
1212
"github.com/ava-labs/avalanchego/utils/wrappers"
1313
)
1414

@@ -17,7 +17,7 @@ func newHistogramMetric(namespace, name string) prometheus.Histogram {
1717
Namespace: namespace,
1818
Name: name,
1919
Help: fmt.Sprintf("Latency of a %s call in nanoseconds", name),
20-
Buckets: timer.NanosecondsBuckets,
20+
Buckets: utils.NanosecondsBuckets,
2121
})
2222
}
2323

cache/unique_cache.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ package cache
66
import (
77
"container/list"
88
"sync"
9-
10-
"github.com/ava-labs/avalanchego/ids"
119
)
1210

1311
// EvictableLRU is an LRU cache that notifies the objects when they are evicted.
1412
type EvictableLRU struct {
1513
lock sync.Mutex
16-
entryMap map[ids.ID]*list.Element
14+
entryMap map[interface{}]*list.Element
1715
entryList *list.List
1816
Size int
1917
}
@@ -36,7 +34,7 @@ func (c *EvictableLRU) Flush() {
3634

3735
func (c *EvictableLRU) init() {
3836
if c.entryMap == nil {
39-
c.entryMap = make(map[ids.ID]*list.Element)
37+
c.entryMap = make(map[interface{}]*list.Element)
4038
}
4139
if c.entryList == nil {
4240
c.entryList = list.New()
@@ -52,7 +50,7 @@ func (c *EvictableLRU) resize() {
5250
c.entryList.Remove(e)
5351

5452
val := e.Value.(Evictable)
55-
delete(c.entryMap, val.ID())
53+
delete(c.entryMap, val.Key())
5654
val.Evict()
5755
}
5856
}
@@ -61,14 +59,14 @@ func (c *EvictableLRU) deduplicate(value Evictable) Evictable {
6159
c.init()
6260
c.resize()
6361

64-
key := value.ID()
62+
key := value.Key()
6563
if e, ok := c.entryMap[key]; !ok {
6664
if c.entryList.Len() >= c.Size {
6765
e = c.entryList.Front()
6866
c.entryList.MoveToBack(e)
6967

7068
val := e.Value.(Evictable)
71-
delete(c.entryMap, val.ID())
69+
delete(c.entryMap, val.Key())
7270
val.Evict()
7371

7472
e.Value = value

cache/unique_cache_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ type evictable struct {
1414
evicted int
1515
}
1616

17-
func (e *evictable) ID() ids.ID { return e.id }
18-
func (e *evictable) Evict() { e.evicted++ }
17+
func (e *evictable) Key() interface{} { return e.id }
18+
func (e *evictable) Evict() { e.evicted++ }
1919

2020
func TestEvictableLRU(t *testing.T) {
2121
cache := EvictableLRU{}

0 commit comments

Comments
 (0)