Skip to content

Commit 579a7db

Browse files
authored
feat: enable TDX tasks support (#673)
1 parent e6614a6 commit 579a7db

24 files changed

+581
-88
lines changed

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ version=9.2.0
44
iexecCommonsPocoVersion=5.4.0
55
iexecCommonVersion=9.2.0
66
iexecCommonsContainersVersion=2.0.0
7-
iexecResultVersion=9.0.0
8-
iexecSmsVersion=9.0.0
9-
iexecCoreVersion=9.0.0
7+
iexecResultVersion=9.1.0
8+
iexecSmsVersion=9.3.0
9+
iexecCoreVersion=9.2.1
1010
nexusUser
1111
nexusPassword

src/main/java/com/iexec/worker/chain/ContributionService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ public Contribution getContribution(ComputedFile computedFile) {
169169
String enclaveChallenge = workerpoolAuthorization.getEnclaveChallenge();
170170
String enclaveSignature = computedFile.getEnclaveSignature();
171171

172-
if (iexecHubService.getTaskDescription(chainTaskId).requiresSgx()) {
172+
final TaskDescription taskDescription = iexecHubService.getTaskDescription(chainTaskId);
173+
if (taskDescription.requiresSgx() || taskDescription.requiresTdx()) {
173174
if (!enclaveAuthorizationService.isVerifiedEnclaveSignature(
174175
chainTaskId, resultHash, resultSeal, enclaveSignature, enclaveChallenge)) {
175176
log.error("Cannot get contribution with invalid enclave " +

src/main/java/com/iexec/worker/compute/ComputeManagerService.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ public boolean isAppDownloaded(String imageUri) {
160160
* @see PreComputeService#runTeePreCompute(TaskDescription)
161161
*/
162162
public PreComputeResponse runPreCompute(final TaskDescription taskDescription) {
163-
log.info("Running pre-compute [chainTaskId:{}, requiresSgx:{}]",
164-
taskDescription.getChainTaskId(), taskDescription.requiresSgx());
163+
log.info("Running pre-compute [chainTaskId:{}, requiresSgx:{}, requiresTdx:{}]",
164+
taskDescription.getChainTaskId(), taskDescription.requiresSgx(), taskDescription.requiresTdx());
165165

166-
if (taskDescription.requiresSgx()) {
166+
if (taskDescription.requiresSgx() || taskDescription.requiresTdx()) {
167167
return preComputeService.runTeePreCompute(taskDescription);
168168
}
169169
return PreComputeResponse.builder().build();
@@ -178,8 +178,8 @@ public PreComputeResponse runPreCompute(final TaskDescription taskDescription) {
178178
*/
179179
public AppComputeResponse runCompute(final TaskDescription taskDescription) {
180180
final String chainTaskId = taskDescription.getChainTaskId();
181-
log.info("Running compute [chainTaskId:{}, requiresSgx:{}]",
182-
chainTaskId, taskDescription.requiresSgx());
181+
log.info("Running compute [chainTaskId:{}, requiresSgx:{}, requiresTdx:{}]",
182+
chainTaskId, taskDescription.requiresSgx(), taskDescription.requiresTdx());
183183

184184
final AppComputeResponse appComputeResponse = appComputeService.runCompute(taskDescription);
185185

@@ -211,11 +211,11 @@ private void writeLogs(String chainTaskId, String filename, String logs) {
211211
*/
212212
public PostComputeResponse runPostCompute(final TaskDescription taskDescription) {
213213
final String chainTaskId = taskDescription.getChainTaskId();
214-
log.info("Running post-compute [chainTaskId:{}, requiresSgx:{}]",
215-
chainTaskId, taskDescription.requiresSgx());
214+
log.info("Running post-compute [chainTaskId:{}, requiresSgx:{}, requiresTdx:{}]",
215+
chainTaskId, taskDescription.requiresSgx(), taskDescription.requiresTdx());
216216

217217
final PostComputeResponse postComputeResponse;
218-
if (!taskDescription.requiresSgx()) {
218+
if (!taskDescription.requiresSgx() && !taskDescription.requiresTdx()) {
219219
postComputeResponse = postComputeService.runStandardPostCompute(taskDescription);
220220
} else {
221221
postComputeResponse = postComputeService.runTeePostCompute(taskDescription);

src/main/java/com/iexec/worker/compute/app/AppComputeService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public AppComputeResponse runCompute(final TaskDescription taskDescription) {
6363

6464
final List<String> env;
6565
final HostConfig hostConfig;
66-
if (taskDescription.requiresSgx()) {
66+
if (taskDescription.requiresSgx() || taskDescription.requiresTdx()) {
6767
final TeeService teeService = teeServicesManager.getTeeService(taskDescription.getTeeFramework());
6868
env = teeService.buildComputeDockerEnv(taskDescription);
6969
binds.addAll(teeService.getAdditionalBindings().stream().map(Bind::parse).toList());

src/main/java/com/iexec/worker/compute/post/PostComputeService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.iexec.worker.tee.TeeServicesPropertiesService;
3939
import com.iexec.worker.workflow.WorkflowError;
4040
import lombok.extern.slf4j.Slf4j;
41+
import org.apache.commons.lang3.StringUtils;
4142
import org.springframework.stereotype.Service;
4243

4344
import java.io.IOException;
@@ -181,6 +182,10 @@ public PostComputeResponse runTeePostCompute(final TaskDescription taskDescripti
181182
.withBinds(binds)
182183
.withDevices(teeService.getDevices())
183184
.withNetworkMode(workerConfigService.getDockerNetworkName());
185+
// TDX specific config to access worker DNS from post-compute
186+
if (taskDescription.requiresTdx() && !StringUtils.isBlank(workerConfigService.getDockerExtraHosts())) {
187+
hostConfig.withExtraHosts(workerConfigService.getDockerExtraHosts());
188+
}
184189
final DockerRunRequest request = DockerRunRequest.builder()
185190
.hostConfig(hostConfig)
186191
.chainTaskId(chainTaskId)

src/main/java/com/iexec/worker/compute/pre/PreComputeService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.iexec.worker.tee.TeeServicesPropertiesService;
3636
import com.iexec.worker.workflow.WorkflowError;
3737
import lombok.extern.slf4j.Slf4j;
38+
import org.apache.commons.lang3.StringUtils;
3839
import org.springframework.stereotype.Service;
3940

4041
import java.time.Duration;
@@ -147,6 +148,10 @@ private Integer prepareTeeInputData(final TaskDescription taskDescription) throw
147148
.withBinds(binds)
148149
.withDevices(teeService.getDevices())
149150
.withNetworkMode(workerConfigService.getDockerNetworkName());
151+
// TDX specific config to access worker DNS from pre-compute
152+
if (taskDescription.requiresTdx() && !StringUtils.isBlank(workerConfigService.getDockerExtraHosts())) {
153+
hostConfig.withExtraHosts(workerConfigService.getDockerExtraHosts());
154+
}
150155
final DockerRunRequest request = DockerRunRequest.builder()
151156
.hostConfig(hostConfig)
152157
.chainTaskId(chainTaskId)

src/main/java/com/iexec/worker/config/WorkerConfigurationService.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class WorkerConfigurationService {
4141
private Integer overrideAvailableCpuCount;
4242

4343
@Value("${worker.gpu-enabled}")
44+
@Getter
4445
private boolean isGpuEnabled;
4546

4647
@Value("${worker.gas-price-multiplier}")
@@ -67,6 +68,10 @@ public class WorkerConfigurationService {
6768
@Getter
6869
private String dockerNetworkName;
6970

71+
@Value("${worker.docker-extra-hosts:}")
72+
@Getter
73+
private String dockerExtraHosts;
74+
7075
@PostConstruct
7176
private void postConstruct() {
7277
if (overrideAvailableCpuCount != null && overrideAvailableCpuCount <= 0) {
@@ -75,10 +80,6 @@ private void postConstruct() {
7580
}
7681
}
7782

78-
public boolean isGpuEnabled() {
79-
return isGpuEnabled;
80-
}
81-
8283
public String getWorkerBaseDir() {
8384
return workerBaseDir + File.separator + workerName;
8485
}

src/main/java/com/iexec/worker/result/ResultService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public String uploadResultAndGetLink(final WorkerpoolAuthorization workerpoolAut
191191
}
192192

193193
// Cloud computing - tee
194-
if (task.requiresSgx()) {
194+
if (task.requiresSgx() || task.requiresTdx()) {
195195
log.info("Web2 storage, already uploaded (with tee) [chainTaskId:{}]", chainTaskId);
196196
return getWeb2ResultLink(task);
197197
}

src/main/java/com/iexec/worker/task/TaskManagerService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ ReplicateActionResponse start(final TaskDescription taskDescription) {
107107
}
108108

109109
// result encryption is not supported for standard tasks
110-
if (!taskDescription.requiresSgx() && taskDescription.getDealParams().isIexecResultEncryption()) {
110+
if (!taskDescription.requiresSgx() && !taskDescription.requiresTdx() && taskDescription.getDealParams().isIexecResultEncryption()) {
111111
return getFailureResponseAndPrintErrors(
112112
List.of(new WorkflowError(TASK_DESCRIPTION_INVALID)), context, chainTaskId);
113113
}
114114

115-
if (taskDescription.requiresSgx()) {
115+
if (taskDescription.requiresSgx() || taskDescription.requiresTdx()) {
116116
// If any TEE prerequisite is not met,
117117
// then we won't be able to run the task.
118118
// So it should be aborted right now.
@@ -195,7 +195,7 @@ ReplicateActionResponse downloadData(final TaskDescription taskDescription) {
195195
requireNonNull(taskDescription, "task description must not be null");
196196
final String chainTaskId = taskDescription.getChainTaskId();
197197
// Return early if TEE task
198-
if (taskDescription.requiresSgx()) {
198+
if (taskDescription.requiresSgx() || taskDescription.requiresTdx()) {
199199
log.info("Dataset and input files will be downloaded by the pre-compute enclave [chainTaskId:{}]", chainTaskId);
200200
return ReplicateActionResponse.success();
201201
}
@@ -256,7 +256,7 @@ ReplicateActionResponse compute(final TaskDescription taskDescription) {
256256
List.of(new WorkflowError(APP_NOT_FOUND_LOCALLY)), context, chainTaskId);
257257
}
258258

259-
if (taskDescription.requiresSgx()) {
259+
if (taskDescription.requiresSgx() || taskDescription.requiresTdx()) {
260260
final TeeService teeService = teeServicesManager.getTeeService(taskDescription.getTeeFramework());
261261
if (!teeService.prepareTeeForTask(chainTaskId)) {
262262
return getFailureResponseAndPrintErrors(

src/main/java/com/iexec/worker/tee/TeeService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public List<WorkflowError> areTeePrerequisitesMetForTask(final String chainTaskI
5656
// If it can't be loaded, then we won't be able to run the task.
5757
smsService.getSmsClient(chainTaskId);
5858
} catch (SmsClientCreationException e) {
59-
log.error("Couldn't get SmsClient [chainTaskId: {}]", chainTaskId, e);
59+
log.error("Couldn't get SmsClient [chainTaskId:{}]", chainTaskId, e);
6060
return List.of(new WorkflowError(ReplicateStatusCause.UNKNOWN_SMS));
6161
}
6262

0 commit comments

Comments
 (0)