Skip to content

Commit

Permalink
Merge pull request #712 from dashpay/master
Browse files Browse the repository at this point in the history
chore: port 0.13.4  to 0.14-dev
  • Loading branch information
lklimek authored Dec 14, 2023
2 parents 0e02be3 + 82f3bfc commit e32466a
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 17 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
## [0.13.4] - 2023-12-11

### Bug Fixes

- Ordered map race condition (#708)

### Performance

- Increase web socket channels capacity (#709)

## [0.13.3] - 2023-10-16

### Bug Fixes

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

### Miscellaneous Tasks

- Update changelog and version to 0.13.3

## [0.13.2] - 2023-10-09

### Bug Fixes

- Log-file-path setting does not work (#691)

### Miscellaneous Tasks

- Update changelog and version to 0.13.2

## [0.13.1] - 2023-09-14

### Bug Fixes

- Send evidence only once (#683)
- Panic verifying evidence due to missing pubkey (#684)

### Miscellaneous Tasks

- Update changelog and version to 0.13.1

## [0.13.0] - 2023-09-13

### Bug Fixes
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ CGO_CXXFLAGS ?= -I$(BLS_DIR)/build/depends/relic/include \
-I$(BLS_DIR)/src/depends/relic/include \
-I$(BLS_DIR)/src/include

OS := $(shell uname)

ifeq ($(OS),Darwin) # macOS
GMP_PREFIX := $(shell brew --prefix gmp 2>/dev/null)
CGO_LDFLAGS += -L$(GMP_PREFIX)/lib
CGO_CXXFLAGS += -I$(GMP_PREFIX)/include
endif

GO := CGO_ENABLED=$(CGO_ENABLED) CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go

# handle ARM builds
Expand Down
2 changes: 1 addition & 1 deletion internal/rpc/core/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

const (
// Buffer on the Tendermint (server) side to allow some slowness in clients.
subBufferSize = 100
subBufferSize = 500

// maxQueryLength is the maximum length of a query string that will be
// accepted. This is just a safety check to avoid outlandish queries.
Expand Down
5 changes: 0 additions & 5 deletions internal/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,6 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
return nil, CurrentRoundState{}, fmt.Errorf("create proposal block: %w", err)
}

// Pass proposed app version only if it's higher than current network app version
if proposedAppVersion <= state.Version.Consensus.App {
proposedAppVersion = 0
}

txs := blockExec.mempool.ReapMaxBytesMaxGas(maxDataBytes, maxGas)
block := state.MakeBlock(height, txs, commit, evidence, proposerProTxHash, proposedAppVersion)

Expand Down
8 changes: 0 additions & 8 deletions internal/state/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ func validateBlock(state State, block *types.Block) error {
)
}

// Validate proposed app version
if block.Header.ProposedAppVersion > 0 && block.Header.ProposedAppVersion <= state.Version.Consensus.App {
return fmt.Errorf("wrong block.Header.ProposedAppVersion must be higher than %v, is %d",
state.Version.Consensus.App,
block.Header.ProposedAppVersion,
)
}

// Validate prev block info.
if !block.LastBlockID.Equals(state.LastBlockID) {
return fmt.Errorf("wrong Block.Header.LastBlockID. Expected %v, got %v",
Expand Down
26 changes: 25 additions & 1 deletion libs/ds/ordered_map.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package ds

import "sync"

// OrderedMap is a map with a deterministic iteration order
// this datastructure is not thread-safe
// this datastructure is thread-safe
type OrderedMap[T comparable, V any] struct {
len int
keys map[T]int
values []V
mtx sync.RWMutex
}

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

// Put adds a key-value pair to the map
func (m *OrderedMap[T, V]) Put(key T, val V) {
m.mtx.Lock()
defer m.mtx.Unlock()

i, ok := m.keys[key]
if ok {
m.values[i] = val
Expand All @@ -33,6 +39,9 @@ func (m *OrderedMap[T, V]) Put(key T, val V) {

// Get returns the value for a given key
func (m *OrderedMap[T, V]) Get(key T) (V, bool) {
m.mtx.RLock()
defer m.mtx.RUnlock()

i, ok := m.keys[key]
if !ok {
var v V
Expand All @@ -43,12 +52,18 @@ func (m *OrderedMap[T, V]) Get(key T) (V, bool) {

// Has returns true if the map contains the given key
func (m *OrderedMap[T, V]) Has(key T) bool {
m.mtx.RLock()
defer m.mtx.RUnlock()

_, ok := m.keys[key]
return ok
}

// Delete removes a key-value pair from the map
func (m *OrderedMap[T, V]) Delete(key T) {
m.mtx.Lock()
defer m.mtx.Unlock()

i, ok := m.keys[key]
if !ok {
return
Expand All @@ -63,11 +78,17 @@ func (m *OrderedMap[T, V]) Delete(key T) {

// Values returns all values in the map
func (m *OrderedMap[T, V]) Values() []V {
m.mtx.RLock()
defer m.mtx.RUnlock()

return append([]V{}, m.values[0:m.len]...)
}

// Keys returns all keys in the map
func (m *OrderedMap[T, V]) Keys() []T {
m.mtx.RLock()
defer m.mtx.RUnlock()

keys := make([]T, len(m.keys))
for k, v := range m.keys {
keys[v] = k
Expand All @@ -77,5 +98,8 @@ func (m *OrderedMap[T, V]) Keys() []T {

// Len returns a number of the map
func (m *OrderedMap[T, V]) Len() int {
m.mtx.RLock()
defer m.mtx.RUnlock()

return m.len
}
19 changes: 19 additions & 0 deletions libs/ds/ordered_map_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ds

import (
"strconv"
"sync"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -40,3 +42,20 @@ func TestOrderedMap(t *testing.T) {
// delete unknown key
om.Delete("c")
}

// / Run TestOrderedMap in parallel
func TestOrderedMapMultithread(t *testing.T) {
threads := 100

wg := sync.WaitGroup{}
wg.Add(threads)

for i := 0; i < threads; i++ {
go func(id int) {
t.Run(strconv.FormatInt(int64(id), 10), TestOrderedMap)
wg.Done()
}(i)
}

wg.Wait()
}
2 changes: 1 addition & 1 deletion rpc/jsonrpc/server/ws_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// WebSocket handler

const (
defaultWSWriteChanCapacity = 100
defaultWSWriteChanCapacity = 500
defaultWSWriteWait = 10 * time.Second
defaultWSReadWait = 30 * time.Second
defaultWSPingPeriod = (defaultWSReadWait * 9) / 10
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var (
const (
// TMVersionDefault is the used as the fallback version for Tenderdash
// when not using git describe. It is formatted with semantic versioning.
TMVersionDefault = "0.13.1"
TMVersionDefault = "0.13.4"
// ABCISemVer is the semantic version of the ABCI library
ABCISemVer = "0.23.0"

Expand Down

0 comments on commit e32466a

Please sign in to comment.