Skip to content

Commit 82f3bfc

Browse files
authored
Merge pull request #710 from dashpay/release_0.13.4
chore(release): update changelog and bump version to 0.13.4
2 parents b767c5d + cddc1fa commit 82f3bfc

File tree

6 files changed

+61
-4
lines changed

6 files changed

+61
-4
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
## [0.13.4] - 2023-12-11
2+
3+
### Bug Fixes
4+
5+
- Ordered map race condition (#708)
6+
7+
### Performance
8+
9+
- Increase web socket channels capacity (#709)
10+
111
## [0.13.3] - 2023-10-16
212

313
### Bug Fixes
414

515
- Issue with GMP not properly being linked on mac (#698)
616
- Always propose with current app version (#697)
717

18+
### Miscellaneous Tasks
19+
20+
- Update changelog and version to 0.13.3
21+
822
## [0.13.2] - 2023-10-09
923

1024
### Bug Fixes

internal/rpc/core/events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
const (
1919
// Buffer on the Tendermint (server) side to allow some slowness in clients.
20-
subBufferSize = 100
20+
subBufferSize = 500
2121

2222
// maxQueryLength is the maximum length of a query string that will be
2323
// accepted. This is just a safety check to avoid outlandish queries.

libs/ds/ordered_map.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package ds
22

3+
import "sync"
4+
35
// OrderedMap is a map with a deterministic iteration order
4-
// this datastructure is not thread-safe
6+
// this datastructure is thread-safe
57
type OrderedMap[T comparable, V any] struct {
68
len int
79
keys map[T]int
810
values []V
11+
mtx sync.RWMutex
912
}
1013

1114
// NewOrderedMap returns a new OrderedMap
@@ -17,6 +20,9 @@ func NewOrderedMap[T comparable, V any]() *OrderedMap[T, V] {
1720

1821
// Put adds a key-value pair to the map
1922
func (m *OrderedMap[T, V]) Put(key T, val V) {
23+
m.mtx.Lock()
24+
defer m.mtx.Unlock()
25+
2026
i, ok := m.keys[key]
2127
if ok {
2228
m.values[i] = val
@@ -33,6 +39,9 @@ func (m *OrderedMap[T, V]) Put(key T, val V) {
3339

3440
// Get returns the value for a given key
3541
func (m *OrderedMap[T, V]) Get(key T) (V, bool) {
42+
m.mtx.RLock()
43+
defer m.mtx.RUnlock()
44+
3645
i, ok := m.keys[key]
3746
if !ok {
3847
var v V
@@ -43,12 +52,18 @@ func (m *OrderedMap[T, V]) Get(key T) (V, bool) {
4352

4453
// Has returns true if the map contains the given key
4554
func (m *OrderedMap[T, V]) Has(key T) bool {
55+
m.mtx.RLock()
56+
defer m.mtx.RUnlock()
57+
4658
_, ok := m.keys[key]
4759
return ok
4860
}
4961

5062
// Delete removes a key-value pair from the map
5163
func (m *OrderedMap[T, V]) Delete(key T) {
64+
m.mtx.Lock()
65+
defer m.mtx.Unlock()
66+
5267
i, ok := m.keys[key]
5368
if !ok {
5469
return
@@ -63,11 +78,17 @@ func (m *OrderedMap[T, V]) Delete(key T) {
6378

6479
// Values returns all values in the map
6580
func (m *OrderedMap[T, V]) Values() []V {
81+
m.mtx.RLock()
82+
defer m.mtx.RUnlock()
83+
6684
return append([]V{}, m.values[0:m.len]...)
6785
}
6886

6987
// Keys returns all keys in the map
7088
func (m *OrderedMap[T, V]) Keys() []T {
89+
m.mtx.RLock()
90+
defer m.mtx.RUnlock()
91+
7192
keys := make([]T, len(m.keys))
7293
for k, v := range m.keys {
7394
keys[v] = k
@@ -77,5 +98,8 @@ func (m *OrderedMap[T, V]) Keys() []T {
7798

7899
// Len returns a number of the map
79100
func (m *OrderedMap[T, V]) Len() int {
101+
m.mtx.RLock()
102+
defer m.mtx.RUnlock()
103+
80104
return m.len
81105
}

libs/ds/ordered_map_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package ds
22

33
import (
4+
"strconv"
5+
"sync"
46
"testing"
57

68
"github.com/stretchr/testify/require"
@@ -40,3 +42,20 @@ func TestOrderedMap(t *testing.T) {
4042
// delete unknown key
4143
om.Delete("c")
4244
}
45+
46+
// / Run TestOrderedMap in parallel
47+
func TestOrderedMapMultithread(t *testing.T) {
48+
threads := 100
49+
50+
wg := sync.WaitGroup{}
51+
wg.Add(threads)
52+
53+
for i := 0; i < threads; i++ {
54+
go func(id int) {
55+
t.Run(strconv.FormatInt(int64(id), 10), TestOrderedMap)
56+
wg.Done()
57+
}(i)
58+
}
59+
60+
wg.Wait()
61+
}

rpc/jsonrpc/server/ws_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
// WebSocket handler
1818

1919
const (
20-
defaultWSWriteChanCapacity = 100
20+
defaultWSWriteChanCapacity = 500
2121
defaultWSWriteWait = 10 * time.Second
2222
defaultWSReadWait = 30 * time.Second
2323
defaultWSPingPeriod = (defaultWSReadWait * 9) / 10

version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var (
99
const (
1010
// TMVersionDefault is the used as the fallback version for Tenderdash
1111
// when not using git describe. It is formatted with semantic versioning.
12-
TMVersionDefault = "0.13.3"
12+
TMVersionDefault = "0.13.4"
1313
// ABCISemVer is the semantic version of the ABCI library
1414
ABCISemVer = "0.23.0"
1515

0 commit comments

Comments
 (0)