Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DA5-6 merge from 5.2 #1343

Merged
merged 14 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/JenkinsApiCompatibility
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Check corda-api compatibility with downstream consumers which implement CordApps
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaApiCompatibilityCheck(
javaVersion: '17'
Expand Down
2 changes: 1 addition & 1 deletion .ci/JenkinsfileSnykDelta
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

snykDelta(
snykOrgId: 'corda5-snyk-org-id',
Expand Down
30 changes: 30 additions & 0 deletions .ci/dev/forward-merge/JenkinsForwardMergeReleaseBranch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@Library('[email protected]') _

/*
* Forward merge any changes in current branch to the branch with following version.
*
* Please note, the branches names are intentionally separated as variables, to minimised conflicts
* during automated merges for this file.
*
* These variables should be updated when a new version is cut
*/

/**
* the branch name of origin branch, it should match the current branch
* and it acts as a fail-safe inside {@code forwardMerger} pipeline
*/
String originBranch = 'release/os/5.1'

/**
* the branch name of target branch, it should be the branch with the next version
* after the one in current branch.
*/
String targetBranch = 'release/os/5.2'

/**
* Forward merge any changes between #originBranch and #targetBranch
*/
forwardMerger(
targetBranch: targetBranch,
originBranch: originBranch,
slackChannel: '#c5-forward-merge-bot-notifications')
2 changes: 1 addition & 1 deletion .ci/dev/forward-merge/JenkinsInteropMerge
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

/*
* Forward merge any changes in current branch to the branch with following version.
Expand Down
33 changes: 33 additions & 0 deletions .ci/dev/forward-merge/JenkinsfileMergeAutomation
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! groovy
@Library('[email protected]') _

/**
* Forward merge any changes in current branch to the branch with following version.
*
* Please note, the branches names are intentionally separated as variables, to minimised conflicts
* during automated merges for this file.
*
* These variables should be updated when a new version is cut
*/

/**
* the branch name of origin branch, it should match the current branch
* and it acts as a fail-safe inside {@code forwardMerger} pipeline
*/
String originBranch = 'release/os/5.2'

/**
* the branch name of target branch, it should be the branch with the next version
* after the one in current branch.
*/
String targetBranch = 'release/os/5.3'

/**
* Forward merge any changes between {@code originBranch} and {@code targetBranch}
*/
forwardMerger(
targetBranch: targetBranch,
originBranch: originBranch,
slackChannel: '#c5-forward-merge-bot-notifications'
)

2 changes: 1 addition & 1 deletion .ci/nightly/JenkinsfileNightly
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaPipelineKubernetesAgent(
runIntegrationTests: false,
Expand Down
2 changes: 1 addition & 1 deletion .ci/nightly/JenkinsfileSnykScan
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaSnykScanPipeline (
snykTokenId: 'r3-snyk-corda5',
Expand Down
2 changes: 1 addition & 1 deletion .ci/nightly/JenkinsfileWindowsCompatibility
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

windowsCompatibility(
runIntegrationTests: false,
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @ac101m @szymonsztuka @jmacmahonr3 @julia-filipczak @vlajos
* @ac101m @szymonsztuka @jmacmahonr3 @julia-filipczak @vlajos
20 changes: 20 additions & 0 deletions .github/workflows/remove-stale-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Close stale issues and PR'
on:
schedule:
- cron: '0 0 * * 1-5'

jobs:
remove-stale-prs:
name: Remove stale PRs
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
debug-only: true
exempt-pr-labels: 'DO_NOT_CLOSE'
stale-pr-message: 'This PR is stale because it has been open 7 days with no activity. Remove the `Stale` label or add a comment - otherwise this will be closed in 7 days.'
close-pr-message: 'This PR was closed because it has been stale for 7 days with no activity.'
days-before-issue-stale: -1
days-before-issue-close: -1
days-before-pr-stale: 7
days-before-pr-close: 7
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaPipelineKubernetesAgent(
runIntegrationTests: false,
dependentJobsNames: ['/Corda5/corda-runtime-os-version-compatibility/release%2Fos%2F5.1'],
dependentJobsNames: ['/Corda5/corda-runtime-os-version-compatibility/release%2Fos%2F5.2'],
dependentJobsNonBlocking: ['/Corda5/corda-api-compatibility/'],
// always use -beta-9999999999999 for local publication as this is used for the version compatibility checks,
// This is a PR gate, so we want to check the "post merge" state before publication for real.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,30 @@
"minimum": 500
},
"sessionsPerPeer": {
"description": "The number of actively maintained sessions between two peers.",
"type": "integer",
"default": 4,
"description": "Deprecated field, numOfSessionsPerPeer should be used instead. The number of actively maintained sessions between two peers.",
"type": ["integer", "null"],
"default": null,
"minimum": 1
},
"numOfSessionsPerPeer": {
"description": "The number of actively maintained sessions between two peers.",
"type": "object",
"default": {},
"properties": {
"forMgm": {
"description": "The number of actively maintained sessions between two peers if one of them is an MGM. Communication between an MGM and a member is not considered critical and so the default value of 1 is recommended to improve performance.",
"type": "integer",
"default": 1,
"minimum": 1
},
"forMembers": {
"description": "The number of actively maintained sessions between two peers if both peers are members. The default value of 2 is recommended because the chance of both sessions failing on the same link manager is relatively low. If high-availability is critical, R3 recommends deploying multiple link manager instances instead.",
"type": "integer",
"default": 2,
"minimum": 1
}
}
},
"revocationCheck": {
"type": "object",
"default": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private RbacKeys() {
/**
* Flow start client request ID.
*/
public static final String CLIENT_REQ_REGEX = "[-._A-Za-z0-9]{1,250}";
public static final String CLIENT_REQ_REGEX = "[-._A-Za-z0-9]{1,242}";

/**
* FQN for a flow to be started.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
org.gradle.java.installations.auto-download=false

# Versioning
cordaProductVersion = 5.1.0
cordaProductVersion = 5.2.0
# NOTE: update this each time this module contains a breaking change
## NOTE: currently this is a top level revision, so all API versions will line up, but this could be moved to
## a per module property in which case module versions can change independently.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.text.MessageFormat;
import java.util.Objects;

/**
Expand Down Expand Up @@ -72,7 +71,8 @@ public static StateRef parse(@NotNull final String value, DigestService digestSe
final int lastIndexOfDelimiter = value.lastIndexOf(DELIMITER);
if (lastIndexOfDelimiter == -1) {
throw new IllegalArgumentException(
MessageFormat.format("Failed to parse a StateRef from the specified value. At least one delimiter ({0}) is expected in value: {1}.", DELIMITER, value)
"Failed to parse a StateRef from the specified value. At least one delimiter (" + DELIMITER + ") " +
"is expected in value: " + value + "."
);
}

Expand All @@ -84,12 +84,12 @@ public static StateRef parse(@NotNull final String value, DigestService digestSe
return new StateRef(transactionId, index);
} catch (NumberFormatException numberFormatException) {
throw new IllegalArgumentException(
MessageFormat.format("Failed to parse a StateRef from the specified value. The index is malformed: {0}.", value),
"Failed to parse a StateRef from the specified value. The index is malformed: " + value + ".",
numberFormatException
);
} catch (IllegalArgumentException illegalArgumentException) {
throw new IllegalArgumentException(
MessageFormat.format("Failed to parse a StateRef from the specified value. The transaction ID is malformed: {0}.", value),
"Failed to parse a StateRef from the specified value. The transaction ID is malformed: " + value + ".",
illegalArgumentException
);
}
Expand Down Expand Up @@ -126,6 +126,6 @@ public int hashCode() {
*/
@Override
public String toString() {
return MessageFormat.format("{0}{1}{2}", transactionId, DELIMITER, index);
return transactionId + DELIMITER + index;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import net.corda.v5.application.crypto.DigestService;
import net.corda.v5.crypto.SecureHash;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
Expand All @@ -26,21 +31,21 @@ void parseValidValue() {

final StateRef stateRef = new StateRef(secureHash, Integer.parseUnsignedInt(value.substring(lastIndexOfDelimiter + 1)));

Assertions.assertEquals(StateRef.parse(value, digestService).getTransactionId().toString(), stateRef.getTransactionId().toString());
assertEquals(StateRef.parse(value, digestService).getTransactionId().toString(), stateRef.getTransactionId().toString());
}

@Test
void parseMalformedWithZeroDelimiter() {
final String value = "XXX";
final String errorMessage = assertThrows(IllegalArgumentException.class, () -> StateRef.parse(value, digestService)).getMessage();
Assertions.assertEquals(String.format("Failed to parse a StateRef from the specified value. At least one delimiter (%s) is expected in value: %s.", DELIMITER, value), errorMessage);
assertEquals(String.format("Failed to parse a StateRef from the specified value. At least one delimiter (%s) is expected in value: %s.", DELIMITER, value), errorMessage);
}

@Test
void parseMalformedIndex() {
final String value = ":asdf:a";
final String errorMessage = assertThrows(IllegalArgumentException.class, () -> StateRef.parse(value, digestService)).getMessage();
Assertions.assertEquals(String.format("Failed to parse a StateRef from the specified value. The index is malformed: %s.", value), errorMessage);
assertEquals(String.format("Failed to parse a StateRef from the specified value. The index is malformed: %s.", value), errorMessage);
}

@Test
Expand All @@ -57,6 +62,31 @@ void parseMalformedTransactionId() {

final String errorMessage = assertThrows(IllegalArgumentException.class, () -> StateRef.parse(value, digestService)).getMessage();

Assertions.assertEquals(String.format("Failed to parse a StateRef from the specified value. The transaction ID is malformed: %s.", value), errorMessage);
assertEquals(String.format("Failed to parse a StateRef from the specified value. The transaction ID is malformed: %s.", value), errorMessage);
}

@ParameterizedTest(name = "Parse large state ref index and reparse into state ref {0}")
@MethodSource("stateRefIndexes")
void parseLargeValueAndReparse(int index) {
final String value = "SHA-256D:ED87C7285E1E34BF5E46302086F76317ACE9B17AEF7BD086EE09A5ACBD17CEA4:" + index;
final int lastIndexOfDelimiter = value.lastIndexOf(DELIMITER);
final String subStringBeforeDelimiter = value.substring(0, lastIndexOfDelimiter);
final SecureHash secureHash = mock(SecureHash.class);

doReturn(secureHash).when(digestService).parseSecureHash(subStringBeforeDelimiter);
doReturn(subStringBeforeDelimiter).when(secureHash).toString();

final StateRef stateRef = StateRef.parse(value, digestService);

assertEquals(stateRef, StateRef.parse(stateRef.toString(), digestService));
}

public static Stream<Arguments> stateRefIndexes() {
return Stream.of(
Arguments.of(1000),
Arguments.of(1001),
Arguments.of(99999999),
Arguments.of(Integer.MAX_VALUE)
);
}
}