Skip to content

Commit

Permalink
Merge pull request #91 from HorizenOfficial/dev
Browse files Browse the repository at this point in the history
version 2.4.0 to main
  • Loading branch information
paolocappelletti committed Jun 18, 2024
2 parents 4560791 + f442527 commit 51ea52f
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lazy val commonSettings = Seq(
Wart.OptionPartial),
organization := "io.horizen",
organizationName := "Zen Blockchain Foundation",
version := "2.3.0",
version := "2.4.0",
licenses := Seq("CC0" -> url("https://creativecommons.org/publicdomain/zero/1.0/legalcode")),
homepage := Some(url("https://github.com/HorizenOfficial/Sparkz")),
pomExtra :=
Expand Down
10 changes: 7 additions & 3 deletions ci/publish.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/bin/bash

set -eo pipefail

retval=0

if [[ "${TRAVIS_TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT){1}[0-9]*$ ]]; then
if [[ "${DEV_RELEASE}" == "true" ]]; then
echo "" && echo "=== Publishing development release on Sonatype Nexus repository. Timestamp is: $(date '+%a %b %d %H:%M:%S %Z %Y') ===" && echo ""
sbt -ivy ./.ivy2 -sbt-dir ./.sbt +publish
elif [[ "${TRAVIS_TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
elif [[ "${RC_RELEASE}" == "true" ]]; then
echo "" && echo "=== Publishing RC release on Maven repository. Timestamp is: $(date '+%Y-%m-%d %H:%M') ===" && echo ""
sbt -ivy ./.ivy2 -sbt-dir ./.sbt +publishSigned sonatypeBundleRelease
elif [[ "${PROD_RELEASE}" == "true" ]]; then
echo "" && echo "=== Publishing production release on Maven repository. Timestamp is: $(date '+%Y-%m-%d %H:%M') ===" && echo ""
sbt -ivy ./.ivy2 -sbt-dir ./.sbt +publishSigned sonatypeBundleRelease
else
echo "" && echo "=== Not going to publish!!! Release tag = ${TRAVIS_TAG} did not match either DEV or PROD format requirements ===" && echo ""
echo "" && echo "=== Not going to publish!!! The build did not match either DEV, RC or PROD release requirements ===" && echo ""
fi

exit "$retval"
3 changes: 3 additions & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ elif [ "${1}" = "release" ]; then
-v "${HOME}"/key.asc:/key.asc \
-e CONTAINER_PUBLISH \
-e TRAVIS_TAG \
-e PROD_RELEASE \
-e RC_RELEASE \
-e DEV_RELEASE \
-e LOCAL_USER_ID="$(id -u)" \
-e LOCAL_GRP_ID="$(id -g)"\
$(env | grep -E '^CONTAINER_' | sed -n '/^[^\t]/s/=.*//p' | sed '/^$/d' | sed 's/^/-e /g' | tr '\n' ' ') \
Expand Down
33 changes: 22 additions & 11 deletions ci/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -eo pipefail

export CONTAINER_PUBLISH="false"
package_version=$(grep -w "version :=" build.sbt | cut -d '"' -f2)
PROD_RELEASE="false"
DEV_RELEASE="false"
RC_RELEASE="false"

if [ -z "${TRAVIS_TAG}" ]; then
echo "TRAVIS_TAG: No TAG"
Expand Down Expand Up @@ -79,21 +82,29 @@ if [ -n "${TRAVIS_TAG}" ]; then
openssl enc -d -aes-256-cbc -md sha256 -pass pass:"${MAVEN_KEY_ARCHIVE_PASSWORD}" |
tar -xzf- -C "${HOME}"
export CONTAINER_PUBLISH="true"
export PROD_RELEASE="true"
else
# Checking if package version matches DEV release version
if ! [[ "${package_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT){1}[0-9]*$ ]]; then
echo "Aborting, package version is in the wrong format for development release."
if [[ "${package_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT){1}[0-9]*$ ]]; then
if [[ "${TRAVIS_TAG}" =~ "${package_version}"[0-9]*$ ]]; then
echo "" && echo "=== Development release build ===" && echo ""
export DEV_RELEASE="true"
else
echo "Aborting. Package version or tag format does not fit the requirements for development release"
exit 1
fi
elif [[ "${package_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-RC[0-9]+){1}$ ]]; then
if [[ "${TRAVIS_TAG}" == "${package_version}" ]]; then
echo "" && echo "=== RC release build ===" && echo ""
export RC_RELEASE="true"
else
echo "Aborting. Package version or tag format does not fit the requirements for RC release"
exit 1
fi
else
echo "Aborting, package version is in the wrong format for development or RC release."
exit 1
fi

# Checking Github tag format
if ! [[ "${TRAVIS_TAG}" =~ "${package_version}"[0-9]*$ ]]; then
echo "Aborting, tag format differs from the version under build.sbt file."
exit 1
fi

# Announcing DEV release
echo "" && echo "=== Development release build ===" && echo ""
echo "Fetching maven gpg signing keys."
curl -sLH "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3.raw" "${MAVEN_KEY_ARCHIVE_URL}" |
openssl enc -d -aes-256-cbc -md sha256 -pass pass:"${MAVEN_KEY_ARCHIVE_PASSWORD}" |
Expand Down
4 changes: 4 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.4.0
---------
* Increased default maxForgerConnections to 100, forger connections pool will only work for forger nodes

2.3.0
---------
* Updated dependencies
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ sparkz {
maxOutgoingConnections = 10

# Number of dedicated connections to forgers. This works in addition to the maxOutgoingConnections ones
maxForgerConnections = 20
maxForgerConnections = 100

# Network connection timeout
connectionTimeout = 1s
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/sparkz/core/api/http/ApiDirectives.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package sparkz.core.api.http
import akka.http.scaladsl.server.directives.{AuthenticationDirective, Credentials}
import akka.http.scaladsl.server.{AuthorizationFailedRejection, Directive0}
import at.favre.lib.crypto.bcrypt.BCrypt
import sparkz.core.settings.RESTApiSettings
import sparkz.core.settings.ApiSettings
import sparkz.util.SparkzEncoding
import sparkz.crypto.hash.Blake2b256

trait ApiDirectives extends CorsHandler with SparkzEncoding {
val settings: RESTApiSettings
val settings: ApiSettings
val apiKeyHeaderName: String

lazy val withAuth: Directive0 = optionalHeaderValueByName(apiKeyHeaderName).flatMap {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/sparkz/core/network/NetworkController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class NetworkController(settings: NetworkSettings,

// We allow temporary overflowing outgoing connection limits to get the peerInfo and see if peer if a forger.
// Drop connection if the peer does not fit in the limits.
val isForgerConnection = peerInfo.peerSpec.features.contains(ForgerNodePeerFeature())
val isForgerConnection = peerInfo.peerSpec.features.contains(ForgerNodePeerFeature()) && settings.isForgerNode

val connectionLimitExhausted = isConnectionLimitExhausted(peerInfo, isForgerConnection)
shouldDrop = shouldDrop || connectionLimitExhausted
Expand Down
9 changes: 8 additions & 1 deletion src/main/scala/sparkz/core/settings/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ import sparkz.util.SparkzLogging

import scala.concurrent.duration._

trait ApiSettings {
def bindAddress: InetSocketAddress;
def apiKeyHash: Option[String];
def corsAllowedOrigin: Option[String];
def timeout: FiniteDuration;
}

case class RESTApiSettings(bindAddress: InetSocketAddress,
apiKeyHash: Option[String],
corsAllowedOrigin: Option[String],
timeout: FiniteDuration)
timeout: FiniteDuration) extends ApiSettings

case class NetworkSettings(nodeName: String,
addedMaxDelay: Option[FiniteDuration],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class NetworkControllerSpec extends NetworkTests with ScalaFutures {
val tcpManagerProbe = TestProbe()

val nodeAddr = new InetSocketAddress("88.77.66.55", 12345)
val settings2 = settings.copy(network = settings.network.copy(bindAddress = nodeAddr, maxOutgoingConnections = 1, maxForgerConnections = 1))
val settings2 = settings.copy(network = settings.network.copy(bindAddress = nodeAddr, maxOutgoingConnections = 1, maxForgerConnections = 1, isForgerNode = true))
val (networkControllerRef: ActorRef, _) = createNetworkController(settings2, tcpManagerProbe)

val testPeer = new TestPeer(settings2, networkControllerRef, tcpManagerProbe)
Expand Down

0 comments on commit 51ea52f

Please sign in to comment.