Skip to content
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
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# x-release-please-start-version
version=9.1.0
# x-release-please-end
iexecCommonsPocoVersion=5.1.0
iexecCommonVersion=9.1.0
iexecCommonsPocoVersion=5.3.1
iexecCommonVersion=9.2.0
iexecCommonsContainersVersion=2.0.0
iexecResultVersion=9.0.0
iexecSmsVersion=9.0.0
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/com/iexec/worker/chain/ContributionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,13 @@ public Contribution getContribution(ComputedFile computedFile) {
String enclaveChallenge = workerpoolAuthorization.getEnclaveChallenge();
String enclaveSignature = computedFile.getEnclaveSignature();

boolean isTeeTask = iexecHubService.isTeeTask(chainTaskId);
if (isTeeTask) {
if (!enclaveAuthorizationService.isVerifiedEnclaveSignature(chainTaskId,
resultHash, resultSeal, enclaveSignature, enclaveChallenge)) {
if (iexecHubService.getTaskDescription(chainTaskId).requiresSgx()) {
if (!enclaveAuthorizationService.isVerifiedEnclaveSignature(
chainTaskId, resultHash, resultSeal, enclaveSignature, enclaveChallenge)) {
log.error("Cannot get contribution with invalid enclave " +
"signature [chainTaskId:{}, resultHash:{}, " +
"resultSeal:{}, enclaveSignature:{}, " +
"enclaveChallenge:{}]", chainTaskId, resultHash,
resultSeal, enclaveSignature, enclaveChallenge);
"resultSeal:{}, enclaveSignature:{}, enclaveChallenge:{}]",
chainTaskId, resultHash, resultSeal, enclaveSignature, enclaveChallenge);
return null;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ public boolean isAppDownloaded(String imageUri) {
* @see PreComputeService#runTeePreCompute(TaskDescription)
*/
public PreComputeResponse runPreCompute(final TaskDescription taskDescription) {
log.info("Running pre-compute [chainTaskId:{}, isTee:{}]",
taskDescription.getChainTaskId(), taskDescription.isTeeTask());
log.info("Running pre-compute [chainTaskId:{}, requiresSgx:{}]",
taskDescription.getChainTaskId(), taskDescription.requiresSgx());

if (taskDescription.isTeeTask()) {
if (taskDescription.requiresSgx()) {
return preComputeService.runTeePreCompute(taskDescription);
}
return PreComputeResponse.builder().build();
Expand All @@ -178,8 +178,8 @@ public PreComputeResponse runPreCompute(final TaskDescription taskDescription) {
*/
public AppComputeResponse runCompute(final TaskDescription taskDescription) {
final String chainTaskId = taskDescription.getChainTaskId();
log.info("Running compute [chainTaskId:{}, isTee:{}]",
chainTaskId, taskDescription.isTeeTask());
log.info("Running compute [chainTaskId:{}, requiresSgx:{}]",
chainTaskId, taskDescription.requiresSgx());

final AppComputeResponse appComputeResponse = appComputeService.runCompute(taskDescription);

Expand Down Expand Up @@ -211,11 +211,11 @@ private void writeLogs(String chainTaskId, String filename, String logs) {
*/
public PostComputeResponse runPostCompute(final TaskDescription taskDescription) {
final String chainTaskId = taskDescription.getChainTaskId();
log.info("Running post-compute [chainTaskId:{}, isTee:{}]",
chainTaskId, taskDescription.isTeeTask());
log.info("Running post-compute [chainTaskId:{}, requiresSgx:{}]",
chainTaskId, taskDescription.requiresSgx());

final PostComputeResponse postComputeResponse;
if (!taskDescription.isTeeTask()) {
if (!taskDescription.requiresSgx()) {
postComputeResponse = postComputeService.runStandardPostCompute(taskDescription);
} else {
postComputeResponse = postComputeService.runTeePostCompute(taskDescription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public AppComputeResponse runCompute(final TaskDescription taskDescription) {

final SgxDriverMode sgxDriverMode;
final List<String> env;
if (taskDescription.isTeeTask()) {
if (taskDescription.requiresSgx()) {
final TeeService teeService = teeServicesManager.getTeeService(taskDescription.getTeeFramework());
env = teeService.buildComputeDockerEnv(taskDescription);
binds.addAll(teeService.getAdditionalBindings().stream().map(Bind::parse).toList());
Expand All @@ -83,7 +83,7 @@ public AppComputeResponse runCompute(final TaskDescription taskDescription) {
.withBinds(binds)
.withDevices(sgxService.getSgxDevices());
// Enclave should be able to connect to the LAS
if (taskDescription.isTeeTask()) {
if (taskDescription.requiresSgx()) {
hostConfig.withNetworkMode(workerConfigService.getDockerNetworkName());
}
final DockerRunRequest runRequest = DockerRunRequest.builder()
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/iexec/worker/result/ResultService.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ public ResultModel getResultModelWithZip(final String chainTaskId) {

return ResultModel.builder()
.chainTaskId(chainTaskId)
.image(resultInfo.getImage())
.cmd(resultInfo.getCmd())
.zip(zipResultAsBytes)
.deterministHash(resultInfo.getDeterministHash())
.build();
Expand Down Expand Up @@ -193,7 +191,7 @@ public String uploadResultAndGetLink(final WorkerpoolAuthorization workerpoolAut
}

// Cloud computing - tee
if (task.isTeeTask()) {
if (task.requiresSgx()) {
log.info("Web2 storage, already uploaded (with tee) [chainTaskId:{}]", chainTaskId);
return getWeb2ResultLink(task);
}
Expand Down Expand Up @@ -351,7 +349,7 @@ public boolean writeComputedFile(final ComputedFile computedFile) {
return false;
}
final ChainDeal chainDeal = iexecHubService.getChainDeal(chainTask.getDealid()).orElse(null);
if (chainDeal == null || !TeeUtils.isTeeTag(chainDeal.getTag())) {
if (chainDeal == null || TeeUtils.getTeeFramework(chainDeal.getTag()) == null) {
log.error("Cannot write computed file if task is not of TEE type [chainTaskId:{}, computedFile:{}]",
chainTaskId, computedFile);
return false;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/iexec/worker/task/TaskManagerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ ReplicateActionResponse start(final TaskDescription taskDescription) {
}

// result encryption is not supported for standard tasks
if (!taskDescription.isTeeTask() && taskDescription.getDealParams().isIexecResultEncryption()) {
if (!taskDescription.requiresSgx() && taskDescription.getDealParams().isIexecResultEncryption()) {
return getFailureResponseAndPrintErrors(
List.of(new WorkflowError(TASK_DESCRIPTION_INVALID)), context, chainTaskId);
}

if (taskDescription.isTeeTask()) {
if (taskDescription.requiresSgx()) {
// If any TEE prerequisite is not met,
// then we won't be able to run the task.
// So it should be aborted right now.
Expand Down Expand Up @@ -194,7 +194,7 @@ ReplicateActionResponse downloadData(final TaskDescription taskDescription) {
requireNonNull(taskDescription, "task description must not be null");
final String chainTaskId = taskDescription.getChainTaskId();
// Return early if TEE task
if (taskDescription.isTeeTask()) {
if (taskDescription.requiresSgx()) {
log.info("Dataset and input files will be downloaded by the pre-compute enclave [chainTaskId:{}]", chainTaskId);
return ReplicateActionResponse.success();
}
Expand Down Expand Up @@ -255,7 +255,7 @@ ReplicateActionResponse compute(final TaskDescription taskDescription) {
List.of(new WorkflowError(APP_NOT_FOUND_LOCALLY)), context, chainTaskId);
}

if (taskDescription.isTeeTask()) {
if (taskDescription.requiresSgx()) {
final TeeService teeService = teeServicesManager.getTeeService(taskDescription.getTeeFramework());
if (!teeService.prepareTeeForTask(chainTaskId)) {
return getFailureResponseAndPrintErrors(
Expand Down
52 changes: 24 additions & 28 deletions src/test/java/com/iexec/worker/chain/ContributionServiceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import com.iexec.common.result.ComputedFile;
import com.iexec.commons.poco.chain.*;
import com.iexec.commons.poco.order.OrderTag;
import com.iexec.commons.poco.security.Signature;
import com.iexec.commons.poco.task.TaskDescription;
import com.iexec.commons.poco.tee.TeeUtils;
import com.iexec.commons.poco.utils.BytesUtils;
import com.iexec.commons.poco.utils.HashUtils;
import com.iexec.commons.poco.utils.SignatureUtils;
Expand Down Expand Up @@ -71,10 +73,13 @@ class ContributionServiceTests {
.contributors(List.of())
.build();

private final TaskDescription taskDescription = TaskDescription.builder()
.chainTaskId(chainTask.getChainTaskId())
.trust(BigInteger.ONE)
.build();
TaskDescription getTaskDescription(final OrderTag tag) {
return TaskDescription.builder()
.chainTaskId(chainTask.getChainTaskId())
.trust(BigInteger.ONE)
.teeFramework(TeeUtils.getTeeFramework(tag.getValue()))
.build();
}

@BeforeEach
void beforeEach() {
Expand All @@ -101,14 +106,9 @@ void shouldChainTaskNotBeInitialized() {
@Test
void getCannotContributeStatusCauseShouldReturnWorkerpoolAuthorizationNotFound() {
final String chainTaskId = chainTask.getChainTaskId();
final TaskDescription contributeAndFinalizeTaskDescription = TaskDescription.builder()
.chainTaskId(chainTaskId)
.trust(BigInteger.ONE)
.isTeeTask(true)
.build();

when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId)).thenReturn(null);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(contributeAndFinalizeTaskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.TEE_SCONE));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.of(chainTask));

assertThat(contributionService.getCannotContributeStatusCause(chainTaskId))
Expand All @@ -122,7 +122,7 @@ void getCannotContributeStatusShouldReturnChainUnreachable() {
final String chainTaskId = "chainTaskId";
when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId))
.thenReturn(getTeeWorkerpoolAuth());
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.empty());

assertThat(contributionService.getCannotContributeStatusCause(chainTaskId))
Expand All @@ -137,7 +137,7 @@ void getCannotContributeStatusShouldReturnStakeTooLow() {

when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId))
.thenReturn(getTeeWorkerpoolAuth());
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.of(chainTask));
when(iexecHubService.getChainAccount()).thenReturn(Optional.of(ChainAccount.builder().deposit(0).build()));
when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(ChainDeal.builder().workerStake(BigInteger.valueOf(5)).build()));
Expand All @@ -163,7 +163,7 @@ void getCannotContributeStatusShouldReturnTaskNotActive() {

when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId))
.thenReturn(getTeeWorkerpoolAuth());
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.of(inactiveTask));
when(iexecHubService.getChainAccount()).thenReturn(Optional.of(ChainAccount.builder().deposit(1000).build()));
when(iexecHubService.getChainDeal(CHAIN_DEAL_ID)).thenReturn(Optional.of(ChainDeal.builder().workerStake(BigInteger.valueOf(5)).build()));
Expand All @@ -188,7 +188,7 @@ void getCannotContributeStatusShouldReturnAfterDeadline() {

when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId))
.thenReturn(getTeeWorkerpoolAuth());
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.of(timedOutChainTask));
when(iexecHubService.getChainAccount())
.thenReturn(Optional.of(ChainAccount.builder().deposit(1000).build()));
Expand Down Expand Up @@ -216,7 +216,7 @@ void getCannotContributeStatusShouldReturnContributionAlreadySet() {

when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId))
.thenReturn(getTeeWorkerpoolAuth());
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.of(alreadyContributedChainTask));
when(iexecHubService.getChainAccount())
.thenReturn(Optional.of(ChainAccount.builder().deposit(1000).build()));
Expand All @@ -237,7 +237,7 @@ void getCannotContributeStatusCauseShouldReturnEmpty() {

when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId))
.thenReturn(getTeeWorkerpoolAuth());
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId))
.thenReturn(Optional.of(chainTask));
when(iexecHubService.getChainAccount())
Expand All @@ -256,14 +256,10 @@ void getCannotContributeStatusCauseShouldReturnEmpty() {
@Test
void getCannotContributeStatusShouldReturnEmptyForContributeAndFinalizeFlow() {
final String chainTaskId = chainTask.getChainTaskId();
final TaskDescription contributeAndFinalizeTaskDescription = TaskDescription.builder()
.trust(BigInteger.ONE)
.isTeeTask(true)
.build();

when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId))
.thenReturn(getTeeWorkerpoolAuth());
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(contributeAndFinalizeTaskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.TEE_SCONE));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.of(chainTask));

assertThat(contributionService.getCannotContributeStatusCause(chainTaskId)).isEmpty();
Expand All @@ -286,7 +282,7 @@ void getCannotContributeStatusShouldReturnMultipleErrors() {

when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId))
.thenReturn(getTeeWorkerpoolAuth());
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.of(problematicChainTask));
when(iexecHubService.getChainAccount())
.thenReturn(Optional.of(ChainAccount.builder().deposit(0).build())); // Also stake too low
Expand All @@ -310,7 +306,7 @@ void getCannotContributeStatusShouldReturnAuthAndChainUnreachableErrors() {
final String chainTaskId = chainTask.getChainTaskId();

when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId)).thenReturn(null);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.empty());

assertThat(contributionService.getCannotContributeStatusCause(chainTaskId))
Expand Down Expand Up @@ -342,7 +338,7 @@ void getCannotContributeAndFinalizeStatusCauseShouldReturnTrustNotOne() {
void getCannotContributeAndFinalizeStatusCauseShouldReturnChainUnreachable() {
final String chainTaskId = chainTask.getChainTaskId();

when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.empty());

assertThat(contributionService.getCannotContributeAndFinalizeStatusCause(chainTaskId))
Expand All @@ -362,7 +358,7 @@ void getCannotContributeAndFinalizeStatusCauseShouldReturnTaskAlreadyContributed

final String chainTaskId = chainTaskWithContribution.getChainTaskId();

when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.of(chainTaskWithContribution));

assertThat(contributionService.getCannotContributeAndFinalizeStatusCause(chainTaskId))
Expand All @@ -373,7 +369,7 @@ void getCannotContributeAndFinalizeStatusCauseShouldReturnTaskAlreadyContributed
void getCannotContributeAndFinalizeStatusCauseShouldReturnEmpty() {
final String chainTaskId = chainTask.getChainTaskId();

when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(taskDescription);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));
when(iexecHubService.getChainTask(chainTaskId)).thenReturn(Optional.of(chainTask));

assertThat(contributionService.getCannotContributeAndFinalizeStatusCause(chainTaskId)).isEmpty();
Expand Down Expand Up @@ -433,7 +429,7 @@ void getContribution() {

final WorkerpoolAuthorization teeWorkerpoolAuth = getTeeWorkerpoolAuth();
when(workerpoolAuthorizationService.getWorkerpoolAuthorization(chainTaskId)).thenReturn(teeWorkerpoolAuth);
when(iexecHubService.isTeeTask(chainTaskId)).thenReturn(false);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.STANDARD));

final ComputedFile computedFile = ComputedFile.builder()
.taskId(chainTaskId)
Expand Down Expand Up @@ -469,7 +465,7 @@ void getContributionWithTee() {
when(enclaveAuthorizationService.
isVerifiedEnclaveSignature(anyString(), anyString(), anyString(), anyString(), anyString()))
.thenReturn(true);
when(iexecHubService.isTeeTask(chainTaskId)).thenReturn(true);
when(iexecHubService.getTaskDescription(chainTaskId)).thenReturn(getTaskDescription(OrderTag.TEE_SCONE));

final ComputedFile computedFile = ComputedFile.builder()
.taskId(chainTaskId)
Expand Down
Loading