Skip to content

Commit 3bcbdc9

Browse files
authored
Merge pull request #114 from iExecBlockchainComputing/release/8.3.0
Release/8.3.0
2 parents 5af1c74 + 44cf292 commit 3bcbdc9

File tree

15 files changed

+320
-156
lines changed

15 files changed

+320
-156
lines changed

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,49 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [[8.3.0]](https://github.com/iExecBlockchainComputing/iexec-result-proxy/releases/tag/v8.3.0) 2024-01-10
6+
7+
### New Features
8+
9+
- Expose version through prometheus endpoint and through VersionController. (#111 #112)
10+
11+
### Bug Fixes
12+
13+
- Remove duplicated call to blockchain in `ProxyService`. (#110)
14+
15+
### Quality
16+
17+
- Add and use a non-root user in the dockerfile. (#106)
18+
19+
### Dependency Upgrades
20+
21+
- Upgrade to `eclipse-temurin:11.0.21_9-jre-focal`. (#109)
22+
- Upgrade to Spring Boot 2.7.17. (#108)
23+
- Upgrade to Spring Dependency Management Plugin 1.1.4. (#108)
24+
- Upgrade to Spring Doc OpenAPI 1.7.0. (#111)
25+
- Upgrade to `jenkins-library` 2.7.4. (#107)
26+
- Upgrade to `iexec-commons-poco` 3.2.0. (#113)
27+
- Upgrade to `iexec-common` 8.3.1. (#113)
28+
529
## [[8.2.0]](https://github.com/iExecBlockchainComputing/iexec-result-proxy/releases/tag/v8.2.0) 2023-09-28
630

731
### New Features
32+
833
- Remove `nexus.intra.iex.ec` repository. (#94)
934
- Check result hash before uploading. (#101)
35+
1036
### Bug Fixes
37+
1138
- Fix and harmonize `Dockerfile entrypoint` in all Spring Boot applications. (#98)
1239
- Describe upload limits configuration in README.md. (#99)
40+
1341
### Quality
42+
1443
- Upgrade to Gradle 8.2.1 with up-to-date plugins. (#97)
1544
- Remove `VersionService#isSnapshot`. (#103)
45+
1646
### Dependency Upgrades
47+
1748
- Upgrade to `eclipse-temurin` 11.0.20. (#95)
1849
- Upgrade to Spring Boot 2.7.14. (#96)
1950
- Upgrade to Spring Dependency Management Plugin 1.1.3. (#96)
@@ -24,33 +55,46 @@ All notable changes to this project will be documented in this file.
2455
## [[8.1.1]](https://github.com/iExecBlockchainComputing/iexec-result-proxy/releases/tag/v8.1.1) 2023-06-23
2556

2657
### Dependency Upgrades
58+
2759
- Upgrade to `iexec-common` 8.2.1. (#92)
2860
- Upgrade to `iexec-commons-poco` 3.0.4.(#92)
2961

3062
## [[8.1.0]](https://github.com/iExecBlockchainComputing/iexec-result-proxy/releases/tag/v8.1.0) 2023-06-07
3163

3264
### New Features
65+
3366
- Enable Prometheus actuator. (#84)
67+
3468
### Bug Fixes
69+
3570
- Fix link in changelog. (#83)
3671
- `ChainConfig` instances are immutable. (#89)
72+
3773
### Dependency Upgrades
74+
3875
- Upgrade to `expiringmap` 0.5.10. (#84)
3976
- Upgrade to `iexec-common` 8.2.0. (#85 #87 #88)
4077
- Upgrade to `iexec-commons-poco` 3.0.2. (#85 #87 #88)
4178

4279
## [[8.0.0]](https://github.com/iExecBlockchainComputing/iexec-result-proxy/releases/tag/v8.0.0) 2023-03-03
4380

4481
### New Features
82+
4583
* Support Gramine framework for TEE tasks.
4684
* Add iExec banner at startup.
4785
* Show application version on banner.
86+
4887
### Bug Fixes
88+
4989
* Sign issued JWT tokens.
5090
* Fix JWT tokens flow.
91+
5192
### Quality
93+
5294
* Clean controllers.
95+
5396
### Dependency Upgrades
97+
5498
* Replace the deprecated `openjdk` Docker base image with `eclipse-temurin` and upgrade to Java 11.0.18 patch.
5599
* Upgrade to Spring Boot 2.6.14.
56100
* Upgrade to Gradle 7.6.

Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
FROM eclipse-temurin:11.0.20_8-jre-focal
1+
FROM eclipse-temurin:11.0.21_9-jre-focal
22

33
ARG jar
44

55
RUN test -n "$jar"
66

77
RUN apt-get update \
8-
&& apt-get install -y curl \
8+
&& apt-get install -y --no-install-recommends curl \
99
&& rm -rf /var/lib/apt/lists/*
1010

11+
RUN groupadd --system appuser \
12+
&& useradd -g appuser -s /sbin/nologin -c "Docker image user" appuser
13+
14+
WORKDIR /app
1115
COPY $jar iexec-result-proxy.jar
16+
RUN chown -R appuser:appuser /app
1217

13-
# For Spring-Boot project, use the entrypoint
14-
# below to reduce Tomcat startup time.
18+
USER appuser
1519
ENTRYPOINT [ "java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "iexec-result-proxy.jar" ]

Jenkinsfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
@Library('[email protected].3') _
1+
@Library('[email protected].4') _
22
buildJavaProject(
3-
buildInfo: getBuildInfo(),
4-
integrationTestsEnvVars: [],
53
shouldPublishJars: true,
6-
shouldPublishDockerImages: true,
7-
dockerfileDir: '.')
4+
shouldPublishDockerImages: true)

build.gradle

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
22
id 'java'
33
id 'io.freefair.lombok' version '8.2.2'
4-
id 'org.springframework.boot' version '2.7.14'
5-
id 'io.spring.dependency-management' version '1.1.3'
4+
id 'org.springframework.boot' version '2.7.17'
5+
id 'io.spring.dependency-management' version '1.1.4'
66
id 'jacoco'
77
id 'org.sonarqube' version '4.2.1.3168'
88
id 'maven-publish'
@@ -38,8 +38,10 @@ allprojects {
3838
}
3939
java {
4040
toolchain {
41-
languageVersion.set(JavaLanguageVersion.of(11))
41+
languageVersion.set(JavaLanguageVersion.of(17))
4242
}
43+
sourceCompatibility = "11"
44+
targetCompatibility = "11"
4345
}
4446
}
4547

@@ -59,7 +61,7 @@ dependencies {
5961
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
6062

6163
// Spring Doc
62-
implementation 'org.springdoc:springdoc-openapi-ui:1.6.3'
64+
implementation 'org.springdoc:springdoc-openapi-ui:1.7.0'
6365

6466
// ipfs
6567
implementation 'com.github.ipfs:java-ipfs-http-client:1.4.0'
@@ -90,7 +92,7 @@ springBoot {
9092
tasks.named("bootJar") {
9193
manifest {
9294
attributes("Implementation-Title": "iExec Result Proxy",
93-
"Implementation-Version": project.version)
95+
"Implementation-Version": project.version)
9496
}
9597
}
9698

@@ -109,7 +111,7 @@ jacocoTestReport {
109111
xml.required = true
110112
}
111113
}
112-
tasks.test.finalizedBy tasks.jacocoTestReport
114+
tasks.test.finalizedBy tasks.jacocoTestReport
113115
tasks.sonarqube.dependsOn tasks.jacocoTestReport
114116

115117
publishing {
@@ -130,14 +132,13 @@ publishing {
130132
}
131133
}
132134

133-
ext.jarPathForOCI = relativePath(tasks.bootJar.outputs.files.singleFile)
135+
ext.jarPathForOCI = relativePath(tasks.bootJar.outputs.files.singleFile)
134136
ext.gitShortCommit = 'git rev-parse --short=8 HEAD'.execute().text.trim()
135-
ext.ociImageName = 'local/' + ['bash', '-c', 'basename $(git config --get remote.origin.url) .git'].execute().text.trim()
137+
ext.ociImageName = 'local/' + ['bash', '-c', 'basename $(git config --get remote.origin.url) .git'].execute().text.trim()
136138

137139
tasks.register('buildImage', Exec) {
138-
group 'Build'
140+
group 'Build'
139141
description 'Builds an OCI image from a Dockerfile.'
140-
dependsOn tasks.bootJar
141-
commandLine ("sh", "-c", "docker build --build-arg jar=$jarPathForOCI -t $ociImageName:$gitShortCommit ."
142-
+ " && docker tag $ociImageName:$gitShortCommit $ociImageName:dev")
142+
dependsOn tasks.bootJar
143+
commandLine 'docker', 'build', '--build-arg', 'jar=' + jarPathForOCI, '-t', ociImageName + ':dev', '.'
143144
}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
version=8.2.0
2-
iexecCommonVersion=8.3.0
3-
iexecCommonsPocoVersion=3.1.0
1+
version=8.3.0
2+
iexecCommonVersion=8.3.1
3+
iexecCommonsPocoVersion=3.2.0
44

55
nexusUser
66
nexusPassword

iexec-result-proxy-library/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ dependencies {
1313
}
1414

1515
java {
16+
sourceCompatibility = "11"
17+
targetCompatibility = "11"
1618
withJavadocJar()
1719
withSourcesJar()
1820
}
Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
1+
/*
2+
* Copyright 2023-2023 IEXEC BLOCKCHAIN TECH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.iexec.resultproxy;
217

3-
import com.iexec.resultproxy.version.VersionService;
418
import io.swagger.v3.oas.models.OpenAPI;
519
import io.swagger.v3.oas.models.info.Info;
20+
import org.springframework.boot.info.BuildProperties;
621
import org.springframework.context.annotation.Bean;
722
import org.springframework.context.annotation.Configuration;
823

924
@Configuration
1025
public class OpenApiConfig {
1126

12-
private final VersionService versionService;
27+
public static final String TITLE = "iExec Result Proxy";
1328

14-
public OpenApiConfig(VersionService versionService) {
15-
this.versionService = versionService;
29+
private final BuildProperties buildProperties;
30+
31+
public OpenApiConfig(BuildProperties buildProperties) {
32+
this.buildProperties = buildProperties;
1633
}
1734

1835
/*
@@ -22,8 +39,8 @@ public OpenApiConfig(VersionService versionService) {
2239
public OpenAPI api() {
2340
return new OpenAPI().info(
2441
new Info()
25-
.title("iExec Result Proxy")
26-
.version(versionService.getVersion())
42+
.title(TITLE)
43+
.version(buildProperties.getVersion())
2744
);
2845
}
29-
}
46+
}

src/main/java/com/iexec/resultproxy/proxy/ProxyService.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.iexec.common.utils.FileHelper;
2222
import com.iexec.common.worker.result.ResultUtils;
2323
import com.iexec.commons.poco.chain.ChainContribution;
24-
import com.iexec.commons.poco.chain.ChainContributionStatus;
2524
import com.iexec.commons.poco.chain.ChainTask;
2625
import com.iexec.commons.poco.chain.ChainTaskStatus;
2726
import com.iexec.commons.poco.task.TaskDescription;
@@ -39,6 +38,7 @@
3938

4039
import static com.iexec.common.utils.IexecFileHelper.SLASH_IEXEC_OUT;
4140
import static com.iexec.common.utils.IexecFileHelper.readComputedFile;
41+
import static com.iexec.commons.poco.chain.ChainContributionStatus.REVEALED;
4242

4343
/**
4444
* Service class to manage all the results. If the result is public, it will be stored on IPFS. If there is a dedicated
@@ -59,17 +59,18 @@ public ProxyService(IexecHubService iexecHubService,
5959

6060

6161
boolean canUploadResult(String chainTaskId, String walletAddress, byte[] zip) {
62-
if (iexecHubService.isTeeTask(chainTaskId)){
63-
Optional<ChainTask> chainTask = iexecHubService.getChainTask(chainTaskId);//TODO Add requester field to getChainTask
64-
if (chainTask.isEmpty()){
62+
if (iexecHubService.isTeeTask(chainTaskId)) {
63+
//TODO Add requester field to getChainTask
64+
Optional<ChainTask> chainTask = iexecHubService.getChainTask(chainTaskId);
65+
if (chainTask.isEmpty()) {
6566
log.error("Trying to upload result for TEE but getChainTask failed [chainTaskId:{}, uploader:{}]",
6667
chainTaskId, walletAddress);
6768
return false;
6869
}
69-
boolean isActive = chainTask.get().getStatus().equals(ChainTaskStatus.ACTIVE);
70+
boolean isActive = chainTask.get().getStatus() == ChainTaskStatus.ACTIVE;
7071

7172
Optional<TaskDescription> taskDescription = iexecHubService.getTaskDescriptionFromChain(chainTaskId);
72-
if (taskDescription.isEmpty()){
73+
if (taskDescription.isEmpty()) {
7374
log.error("Trying to upload result for TEE but getTaskDescription failed [chainTaskId:{}, uploader:{}]",
7475
chainTaskId, walletAddress);
7576
return false;
@@ -85,15 +86,6 @@ boolean canUploadResult(String chainTaskId, String walletAddress, byte[] zip) {
8586
return false;
8687
}
8788

88-
// ContributionStatus of chainTask should be REVEALED
89-
boolean isChainContributionStatusSetToRevealed = iexecHubService.isStatusTrueOnChain(chainTaskId,
90-
walletAddress, ChainContributionStatus.REVEALED);
91-
if (!isChainContributionStatusSetToRevealed) {
92-
log.error("Trying to upload result even though ChainContributionStatus is not REVEALED [chainTaskId:{}, uploadRequester:{}]",
93-
chainTaskId, walletAddress);
94-
return false;
95-
}
96-
9789
return isResultValid(chainTaskId, walletAddress, zip);
9890
}
9991
}
@@ -102,7 +94,8 @@ boolean canUploadResult(String chainTaskId, String walletAddress, byte[] zip) {
10294
* A result for a standard task is considered as valid if:
10395
* <ul>
10496
* <li>It has an associated on-chain contribution
105-
* <li>The on-chain contribution result hash is the one we compute here again.
97+
* <li>The associated on-chain contribution status is {@code REVEALED}
98+
* <li>The on-chain contribution result hash is the one we compute here again
10699
* </ul>
107100
*
108101
* @param chainTaskId ID of the task
@@ -116,8 +109,13 @@ boolean isResultValid(String chainTaskId, String walletAddress, byte[] zip) {
116109
final String zipDestinationPath = resultFolderPath + SLASH_IEXEC_OUT;
117110
try {
118111
final Optional<ChainContribution> oChainContribution = iexecHubService.getChainContribution(chainTaskId, walletAddress);
119-
if (oChainContribution.isEmpty()) {
120-
log.error("Trying to upload result but no on-chain contribution [chainTaskId:{}, uploader:{}]",
112+
// ContributionStatus of chainTask should be REVEALED
113+
boolean isChainContributionStatusSetToRevealed = oChainContribution
114+
.map(ChainContribution::getStatus)
115+
.filter(chainStatus -> chainStatus == REVEALED)
116+
.isPresent();
117+
if (!isChainContributionStatusSetToRevealed) {
118+
log.error("Trying to upload result even though ChainContributionStatus is not REVEALED [chainTaskId:{}, uploadRequester:{}]",
121119
chainTaskId, walletAddress);
122120
return false;
123121
}
@@ -129,7 +127,7 @@ boolean isResultValid(String chainTaskId, String walletAddress, byte[] zip) {
129127
log.error("Can't write result file [chainTaskId:{}, uploader:{}]", chainTaskId, walletAddress);
130128
return false;
131129
}
132-
FileHelper.unZipFile(resultZipPath, zipDestinationPath);
130+
FileHelper.unZipFile(resultZipPath, zipDestinationPath);
133131

134132
final ComputedFile computedFile = readComputedFile(chainTaskId, zipDestinationPath);
135133
final String resultDigest = ResultUtils.computeWeb2ResultDigest(computedFile, resultFolderPath);

0 commit comments

Comments
 (0)