Skip to content

Commit

Permalink
Merge pull request #122 from iExecBlockchainComputing/release/8.6.0
Browse files Browse the repository at this point in the history
Release 8.6.0
  • Loading branch information
Natchica authored Dec 20, 2024
2 parents 81796b4 + 018f5ca commit 26fbbc6
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 89 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

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

## [[8.6.0]](https://github.com/iExecBlockchainComputing/tee-worker-post-compute/releases/tag/v8.6.0) 2024-12-20

### New Features

- Replace RestTemplate with Feign client for Result Proxy upload. (#120)

### Deprecated

- Stop building Gramine TEE image in Jenkins Pipeline. (#118)

### Dependency Upgrades

- Upgrade to `eclipse-temurin:11.0.24_8-jre-focal`. (#116)
- Upgrade to Gradle 8.10.2. (#117)
- Upgrade to `testcontainers` 1.20.4. (#119)
- Upgrade to `iexec-commons-poco` 4.2.0. (#121)
- Upgrade to `iexec-common` 8.6.0. (#121)

## [[8.5.0]](https://github.com/iExecBlockchainComputing/tee-worker-post-compute/releases/tag/v8.5.0) 2024-06-18

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:11.0.22_7-jre-focal
FROM eclipse-temurin:11.0.24_8-jre-focal

ARG jar

Expand Down
5 changes: 0 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ if (addParameters && !params.BUILD_TEE) {
return
}

buildGramine(
buildInfo: buildInfo,
dockerfileDir: 'gramine'
)

sconeBuildUnlocked(
nativeImage: "docker-regis.iex.ec/$repositoryName:$buildInfo.imageTag",
imageName: repositoryName,
Expand Down
11 changes: 4 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
id 'io.freefair.lombok' version '8.6'
id 'io.freefair.lombok' version '8.10.2'
id 'jacoco'
id 'org.sonarqube' version '5.0.0.4638'
id 'org.sonarqube' version '5.1.0.4882'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.gradleup.shadow' version '8.3.3'
}

ext {
ociImageBase = 'local/' + rootProject.name
ociImageName = ociImageBase + ':dev'
ociTeeImageName = ociImageBase + '-unlocked:dev'
// versions
testContainersVersion = '1.19.0'
testContainersVersion = '1.20.4'
mockitoVersion = '4.4.0'
systemStubsVersion = '2.0.1'
}
Expand Down Expand Up @@ -53,9 +53,6 @@ dependencies {
// Apache Commons-lang3
implementation 'org.apache.commons:commons-lang3:3.12.0'

//rest template
implementation 'org.springframework:spring-web:5.2.4.RELEASE'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.4'
}

java {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version=8.5.0
iexecCommonVersion=8.5.0
iexecCommonsPocoVersion=4.1.0
version=8.6.0
iexecCommonVersion=8.6.0
iexecCommonsPocoVersion=4.2.0

nexusUser
nexusPassword
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/iexec/worker/api/ResultProxyApiClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2024 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.iexec.worker.api;

import com.iexec.common.result.ResultModel;
import feign.Headers;
import feign.Param;
import feign.RequestLine;


public interface ResultProxyApiClient {
@RequestLine("POST /v1/results")
@Headers("Authorization: {authorization}")
String uploadToIpfs(
@Param("authorization") String authorization,
ResultModel resultModel);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
import com.dropbox.core.v2.DbxClientV2;
import com.iexec.common.result.ComputedFile;
import com.iexec.common.result.ResultModel;
import com.iexec.common.utils.FeignBuilder;
import com.iexec.worker.api.ResultProxyApiClient;
import com.iexec.worker.compute.post.PostComputeException;
import feign.FeignException;
import feign.Logger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

import java.io.File;
import java.io.IOException;
Expand All @@ -46,12 +44,12 @@ public UploaderService() {
this.dropBoxService = new DropBoxService();
}

public UploaderService(DropBoxService dropBoxService) {
public UploaderService(final DropBoxService dropBoxService) {
this.dropBoxService = dropBoxService;
}

//region Dropbox
public String uploadToDropBox(String localFilePath, String dropboxAccessToken, String remoteFilename) throws PostComputeException {
public String uploadToDropBox(final String localFilePath, final String dropboxAccessToken, final String remoteFilename) throws PostComputeException {
if (localFilePath == null || !new File(localFilePath).exists()) {
throw new PostComputeException(POST_COMPUTE_RESULT_FILE_NOT_FOUND, "Can't uploadToDropBox (localFile issue) (exiting)");
}
Expand All @@ -71,13 +69,13 @@ public String uploadToDropBox(String localFilePath, String dropboxAccessToken, S
return dropBoxService.uploadFile(client, new File(localFilePath), "/results/" + remoteFilename);
}

DbxClientV2 createDropboxClient(String dropboxAccessToken, DbxRequestConfig config) {
DbxClientV2 createDropboxClient(final String dropboxAccessToken, final DbxRequestConfig config) {
return new DbxClientV2(config, dropboxAccessToken);
}
//endregion

//region IPFS
public String uploadToIpfsWithIexecProxy(ComputedFile computedFile, String baseUrl, String token, String fileToUploadPath) throws PostComputeException {
public String uploadToIpfsWithIexecProxy(final ComputedFile computedFile, final String baseUrl, final String token, final String fileToUploadPath) throws PostComputeException {
final String taskId = computedFile.getTaskId();
byte[] fileToUpload;

Expand All @@ -89,38 +87,25 @@ public String uploadToIpfsWithIexecProxy(ComputedFile computedFile, String baseU
String.format("Can't uploadToIpfsWithIexecProxy (missing filePath to upload) [taskId:%s, fileToUploadPath:%s]", taskId, fileToUploadPath));
}

ResultModel resultModel = ResultModel.builder()
final ResultModel resultModel = ResultModel.builder()
.chainTaskId(taskId)
.deterministHash(computedFile.getResultDigest())
.enclaveSignature(computedFile.getEnclaveSignature())
.zip(fileToUpload)
.build();

HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", token);
final ResultProxyApiClient resultProxyApiClient = FeignBuilder.createBuilder(Logger.Level.HEADERS)
.target(ResultProxyApiClient.class, baseUrl);

HttpEntity<ResultModel> request = new HttpEntity<>(resultModel, headers);

HttpStatus statusCode = null;
try {
ResponseEntity<String> response = createRestTemplate().postForEntity(baseUrl, request, String.class);
statusCode = response.getStatusCode();

if (statusCode.is2xxSuccessful()) {
return response.getBody();
}
} catch (RestClientException e) {
return resultProxyApiClient.uploadToIpfs(token, resultModel);
} catch (FeignException e) {
log.error("Can't uploadToIpfsWithIexecProxy (result proxy issue)[taskId:{}]", taskId, e);
throw new PostComputeException(
POST_COMPUTE_IPFS_UPLOAD_FAILED,
String.format("Can't uploadToIpfsWithIexecProxy (result proxy issue)[taskId:%s, status:%s]", taskId, e.status())
);
}

throw new PostComputeException(
POST_COMPUTE_IPFS_UPLOAD_FAILED,
String.format("Can't uploadToIpfsWithIexecProxy (result proxy issue)[taskId:%s, status:%s]", taskId, statusCode)
);
}

RestTemplate createRestTemplate() {
return new RestTemplate();
}
//endregion

Expand Down
Loading

0 comments on commit 26fbbc6

Please sign in to comment.