From 0f3699987055f5ed51181b9456f9fdb625fb7134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20James=20Toussaint?= Date: Tue, 28 Jun 2022 08:54:08 +0200 Subject: [PATCH 001/138] Single TEE tag --- .../com/iexec/core/replicate/ReplicateSupplyServiceTests.java | 3 ++- src/test/java/com/iexec/core/task/TaskTestsUtils.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/iexec/core/replicate/ReplicateSupplyServiceTests.java b/src/test/java/com/iexec/core/replicate/ReplicateSupplyServiceTests.java index 17655ddd7..503643634 100644 --- a/src/test/java/com/iexec/core/replicate/ReplicateSupplyServiceTests.java +++ b/src/test/java/com/iexec/core/replicate/ReplicateSupplyServiceTests.java @@ -25,6 +25,7 @@ import com.iexec.common.replicate.ReplicateStatusModifier; import com.iexec.common.replicate.ReplicateStatusUpdate; import com.iexec.common.task.TaskAbortCause; +import com.iexec.common.tee.TeeUtils; import com.iexec.common.utils.BytesUtils; import com.iexec.common.utils.DateTimeUtils; import com.iexec.core.chain.SignatureService; @@ -66,7 +67,7 @@ class ReplicateSupplyServiceTests { private final static String DAPP_NAME = "dappName"; private final static String COMMAND_LINE = "commandLine"; private final static String NO_TEE_TAG = BytesUtils.EMPTY_HEX_STRING_32; - private final static String TEE_TAG = "0x0000000000000000000000000000000000000000000000000000000000000001"; + private final static String TEE_TAG = TeeUtils.TEE_TAG; private final static String ENCLAVE_CHALLENGE = "dummyEnclave"; private final static long maxExecutionTime = 60000; long workerLastBlock = 12; diff --git a/src/test/java/com/iexec/core/task/TaskTestsUtils.java b/src/test/java/com/iexec/core/task/TaskTestsUtils.java index c2458591c..d0a50438c 100644 --- a/src/test/java/com/iexec/core/task/TaskTestsUtils.java +++ b/src/test/java/com/iexec/core/task/TaskTestsUtils.java @@ -16,6 +16,7 @@ package com.iexec.core.task; +import com.iexec.common.tee.TeeUtils; import com.iexec.common.utils.BytesUtils; import java.time.Instant; @@ -32,7 +33,7 @@ public class TaskTestsUtils { public final static String DAPP_NAME = "dappName"; public final static String COMMAND_LINE = "commandLine"; public final static String NO_TEE_TAG = BytesUtils.EMPTY_HEX_STRING_32; - public final static String TEE_TAG = "0x0000000000000000000000000000000000000000000000000000000000000001"; + public final static String TEE_TAG = TeeUtils.TEE_TAG; public final static String RESULT_LINK = "/ipfs/the_result_string"; public static Task getStubTask(long maxExecutionTime) { From 426c236e09cc35b5b87237a748b0de7260edeca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20James=20Toussaint?= Date: Tue, 28 Jun 2022 15:05:44 +0200 Subject: [PATCH 002/138] Removed old TEE tags --- gradle.properties | 2 +- .../com/iexec/core/task/TaskRepository.java | 4 ++-- .../java/com/iexec/core/task/TaskService.java | 19 ++++++++----------- .../ReplicateSupplyServiceTests.java | 2 +- .../com/iexec/core/task/TaskModelTests.java | 3 +-- .../com/iexec/core/task/TaskServiceTests.java | 2 +- .../com/iexec/core/task/TaskTestsUtils.java | 2 +- 7 files changed, 15 insertions(+), 19 deletions(-) diff --git a/gradle.properties b/gradle.properties index 28eac2765..47777e0e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ version=7.0.1 -iexecCommonVersion=5.9.3-NEXT-SNAPSHOT +iexecCommonVersion=7.0.0-NEXT-SNAPSHOT iexecBlockchainAdapterVersion=7.0.0-NEXT-SNAPSHOT iexecResultVersion=7.0.2-NEXT-SNAPSHOT iexecSmsVersion=7.0.0-NEXT-SNAPSHOT diff --git a/src/main/java/com/iexec/core/task/TaskRepository.java b/src/main/java/com/iexec/core/task/TaskRepository.java index 5f799cd01..766014baf 100644 --- a/src/main/java/com/iexec/core/task/TaskRepository.java +++ b/src/main/java/com/iexec/core/task/TaskRepository.java @@ -56,13 +56,13 @@ interface TaskRepository extends MongoRepository { * * * @param statuses The task status should be one of this list. - * @param excludedTag The task tag should not be this tag + * @param excludedTags The task tag should not be one this tag list * - use {@literal null} if no tag should be excluded. * @param excludedChainTaskIds The chain task ID should not be one of this list. * @param sort How to prioritize tasks. * @return The first task matching with the criteria, according to the {@code sort} parameter. */ - Optional findFirstByCurrentStatusInAndTagNotAndChainTaskIdNotIn(List statuses, String excludedTag, List excludedChainTaskIds, Sort sort); + Optional findFirstByCurrentStatusInAndTagNotInAndChainTaskIdNotIn(List statuses, List excludedTags, List excludedChainTaskIds, Sort sort); @Query("{ 'currentStatus': {$nin: ?0} }") List findByCurrentStatusNotIn(List statuses); diff --git a/src/main/java/com/iexec/core/task/TaskService.java b/src/main/java/com/iexec/core/task/TaskService.java index 55a04c29e..637ae4564 100644 --- a/src/main/java/com/iexec/core/task/TaskService.java +++ b/src/main/java/com/iexec/core/task/TaskService.java @@ -26,10 +26,7 @@ import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; import static com.iexec.core.task.TaskStatus.*; @@ -149,19 +146,19 @@ public List findByCurrentStatus(List statusList) { public Optional getPrioritizedInitializedOrRunningTask( boolean shouldExcludeTeeTasks, List excludedChainTaskIds) { - final String excludedTag = shouldExcludeTeeTasks - ? TeeUtils.TEE_TAG + final List excludedTags = shouldExcludeTeeTasks + ? List.of(TeeUtils.TEE_SCONE_ONLY_TAG, TeeUtils.TEE_GRAMINE_ONLY_TAG) : null; return findPrioritizedTask( Arrays.asList(INITIALIZED, RUNNING), - excludedTag, + excludedTags, excludedChainTaskIds, Sort.by(Sort.Order.desc(Task.CURRENT_STATUS_FIELD_NAME), Sort.Order.asc(Task.CONTRIBUTION_DEADLINE_FIELD_NAME))); } /** - * Shortcut for {@link TaskRepository#findFirstByCurrentStatusInAndTagNotAndChainTaskIdNotIn}. + * Shortcut for {@link TaskRepository#findFirstByCurrentStatusInAndTagNotInAndChainTaskIdNotIn}. * Retrieves the prioritized task matching with given criteria: *