Skip to content

Commit

Permalink
Merge pull request #893 from dashpay/release_1.2.1-dev.1
Browse files Browse the repository at this point in the history
chore(release): update changelog and bump version to 1.2.1-dev.1
  • Loading branch information
lklimek committed Aug 29, 2024
2 parents eac51c1 + 5a3cbdb commit 5bfd633
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 7,309 deletions.
7,267 changes: 26 additions & 7,241 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ func (cfg BaseConfig) LoadNodeKeyID() (types.NodeID, error) {
if err != nil {
return "", err
}

if err = nodeKey.Validate(); err != nil {
return "", fmt.Errorf("invalid node key file %s: %w", cfg.NodeKeyFile(), err)
}

nodeKey.ID = types.NodeIDFromPubKey(nodeKey.PubKey())
return nodeKey.ID, nil
}
Expand Down
37 changes: 37 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"os"
"reflect"
"testing"
"time"
Expand Down Expand Up @@ -223,3 +224,39 @@ func TestP2PConfigValidateBasic(t *testing.T) {
reflect.ValueOf(cfg).Elem().FieldByName(fieldName).SetInt(0)
}
}

// Given some invalid node key file, when I try to load it, I get an error
func TestLoadNodeKeyID(t *testing.T) {

testCases := []string{
`{
"type": "tendermint/PrivKeyEd25519",
"value": "wIVaBy3v4bKcrBxGsgFen9qJeqXiK4h18iWCM2LSYxMyH8PomXsANUb3KoucY9EBDj0NQi4LqrmG8DyT5D6xWQ=="
}`,
`{
"id":"0d846d89021b617026c3a3d4051ebcf4cdd09f7c",
"priv_key":{
"type":"tendermint/PrivKeyEd25519",
"value":"J5EWnwSixAZuuw2Gf5nbXXNbyliaURFgBawfwN+zU/N7ucjnxu0GLcVi107XEj2Myq95101jcPPcJE+dCncY1A=="
}
}`,
}

for _, tc := range testCases {
t.Run("", func(t *testing.T) {
cfg := DefaultBaseConfig()
tmpDir := t.TempDir()

// create invalid node key file
cfg.NodeKey = tmpDir + "/node_key.json"
err := os.WriteFile(cfg.NodeKey, []byte(tc), 0600)
require.NoError(t, err)

// when I try to load the node key
_, err = cfg.LoadNodeKeyID()

// then I get an error
assert.Error(t, err)
})
}
}
3 changes: 2 additions & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,8 @@ func loadStateFromDBOrGenesisDocProvider(stateStore sm.Store, genDoc *types.Gene
return sm.State{}, err
}

if state.IsEmpty() {
// If genesis state wasn't mined yet (last block height is 0), we assume that loaded state should be wiped
if state.IsEmpty() || state.LastBlockHeight == 0 {
// 2. If it's not there, derive it from the genesis doc
state, err = sm.MakeGenesisState(genDoc)
if err != nil {
Expand Down
61 changes: 0 additions & 61 deletions scripts/release/cliff-pre.toml

This file was deleted.

6 changes: 5 additions & 1 deletion scripts/release/cliff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# configuration file for git-cliff (0.1.0)
# configuration file for git-cliff (2.4.0)

[changelog]
# changelog header
Expand Down Expand Up @@ -59,3 +59,7 @@ ignore_tags = 'v[0-9]\.[0-9]+\.[0-9]+-[a-z]+\.[0-9]+'
topo_order = true
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"

[remote.github]
owner = "dashpay"
repo = "tenderdash"
13 changes: 9 additions & 4 deletions scripts/release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ function generateChangelog {
debug Generating CHANGELOG

CLIFF_CONFIG="${REPO_DIR}/scripts/release/cliff.toml"
CLIFF_ARGS=
if [[ "${RELEASE_TYPE}" = "prerelease" ]]; then
CLIFF_CONFIG="${REPO_DIR}/scripts/release/cliff-pre.toml"
CLIFF_ARGS="--ignore-tags='v[0-9]\.[0-9]+\.[0-9]+-[a-z]+\.[0-9]+'"
fi

echo 2>"${REPO_DIR}/CHANGELOG.md"
Expand All @@ -172,12 +173,14 @@ function generateChangelog {
-v "${REPO_DIR}/.git":/app/.git:ro \
-v "${CLIFF_CONFIG}":/cliff.toml:ro \
-v "${REPO_DIR}/CHANGELOG.md":/CHANGELOG.md \
orhunp/git-cliff:0.10.0 \
orhunp/git-cliff:2.4.0 \
--config /cliff.toml \
--output /CHANGELOG.md \
--tag "v${NEW_PACKAGE_VERSION}" \
${CLIFF_ARGS} \
--strip all \
--verbose
--verbose \
'v1.0.0-dev.1..HEAD'
}

function updateVersionGo {
Expand Down Expand Up @@ -288,7 +291,9 @@ function buildAndUploadArtifacts() {
"tenderdash-${platform_safe}" "tenderdash-${platform_safe}.sig"
done

sha256sum "${bindir}"/*.tar.gz >"${bindir}"/SHA256SUMS
pushd "${bindir}"
sha256sum *.tar.gz >SHA256SUMS
popd

# Upload to release
uploadBinaries "${bindir}"
Expand Down
15 changes: 15 additions & 0 deletions types/node_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"encoding/json"
"fmt"
"os"

"github.com/dashpay/tenderdash/crypto"
Expand Down Expand Up @@ -38,6 +39,20 @@ func (nk NodeKey) MarshalJSON() ([]byte, error) {
})
}

func (nk *NodeKey) Validate() error {
if nk.PrivKey == nil {
return fmt.Errorf("invalid or empty private key")
}
if err := nk.ID.Validate(); err != nil {
return fmt.Errorf("invalid node ID: %w", err)
}
keyID := NodeIDFromPubKey(nk.PrivKey.PubKey())
if nk.ID != keyID {
return fmt.Errorf("saved node ID %s does not match public key %s", nk.ID, keyID)
}
return nil
}

func (nk *NodeKey) UnmarshalJSON(data []byte) error {
var nkjson nodeKeyJSON
if err := json.Unmarshal(data, &nkjson); err != nil {
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 = "1.2.0-dev.3"
TMVersionDefault = "1.2.1-dev.1"
// ABCISemVer is the semantic version of the ABCI library
ABCISemVer = "1.1.0"

Expand Down

0 comments on commit 5bfd633

Please sign in to comment.