diff --git a/src/main/java/com/iexec/commons/poco/chain/ChainUtils.java b/src/main/java/com/iexec/commons/poco/chain/ChainUtils.java index 0f2cbd0..c97e188 100644 --- a/src/main/java/com/iexec/commons/poco/chain/ChainUtils.java +++ b/src/main/java/com/iexec/commons/poco/chain/ChainUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 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. @@ -16,7 +16,8 @@ package com.iexec.commons.poco.chain; -import com.iexec.commons.poco.utils.BytesUtils; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.bouncycastle.util.Arrays; import org.web3j.crypto.Hash; @@ -28,14 +29,11 @@ import java.math.BigInteger; @Slf4j +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class ChainUtils { - private ChainUtils() { - throw new UnsupportedOperationException(); - } - public static String generateChainTaskId(String dealId, int taskIndex) { - byte[] dealIdBytes32 = BytesUtils.stringToBytes(dealId); + byte[] dealIdBytes32 = Numeric.hexStringToByteArray(dealId); if (dealIdBytes32.length != 32) { return null; } @@ -46,7 +44,7 @@ public static String generateChainTaskId(String dealId, int taskIndex) { } //concatenate bytes with same size only byte[] concatenate = Arrays.concatenate(dealIdBytes32, taskIndexBytes32); - return Hash.sha3(BytesUtils.bytesToString(concatenate)); + return Numeric.toHexString(Hash.sha3(concatenate)); } diff --git a/src/main/java/com/iexec/commons/poco/chain/IexecHubAbstractService.java b/src/main/java/com/iexec/commons/poco/chain/IexecHubAbstractService.java index 2c1bda6..e5a5a95 100644 --- a/src/main/java/com/iexec/commons/poco/chain/IexecHubAbstractService.java +++ b/src/main/java/com/iexec/commons/poco/chain/IexecHubAbstractService.java @@ -503,7 +503,7 @@ Optional repeatGetTaskDescriptionFromChain(final String chainTa String.format("getChainApp() [address:%s]", chainDeal.getDappPointer())) .orElse(null); - final ChainDataset chainDataset = new Retryer>() + final ChainDataset chainDataset = !chainDeal.containsDataset() ? null : new Retryer>() .repeatCall(() -> getChainDataset(chainDeal.getDataPointer()), Optional::isEmpty, retryDelay, maxRetry, diff --git a/src/main/java/com/iexec/commons/poco/chain/SignerService.java b/src/main/java/com/iexec/commons/poco/chain/SignerService.java index c9ea1c8..f7575c7 100644 --- a/src/main/java/com/iexec/commons/poco/chain/SignerService.java +++ b/src/main/java/com/iexec/commons/poco/chain/SignerService.java @@ -204,7 +204,7 @@ public String sendCall(String to, String data, DefaultBlockParameter defaultBloc if (ethCall.hasError()) { decodeAndThrowEvmRpcError(ethCall.getError(), "ethCall"); } - log.debug("ethCall [value:{}]", ethCall.getValue()); + log.trace("ethCall [value:{}]", ethCall.getValue()); return ethCall.getValue(); } diff --git a/src/main/java/com/iexec/commons/poco/chain/Web3jAbstractService.java b/src/main/java/com/iexec/commons/poco/chain/Web3jAbstractService.java index 62df0b9..f52ae19 100644 --- a/src/main/java/com/iexec/commons/poco/chain/Web3jAbstractService.java +++ b/src/main/java/com/iexec/commons/poco/chain/Web3jAbstractService.java @@ -226,7 +226,7 @@ public String sendCall(final String from, final String to, final String data, fi if (ethCall.hasError()) { decodeAndThrowEvmRpcError(ethCall.getError()); } - log.debug("ethCall [value:{}]", ethCall.getValue()); + log.trace("ethCall [value:{}]", ethCall.getValue()); return ethCall.getValue(); } diff --git a/src/main/java/com/iexec/commons/poco/utils/HashUtils.java b/src/main/java/com/iexec/commons/poco/utils/HashUtils.java index 994df1b..36b1bc5 100644 --- a/src/main/java/com/iexec/commons/poco/utils/HashUtils.java +++ b/src/main/java/com/iexec/commons/poco/utils/HashUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 IEXEC BLOCKCHAIN TECH + * Copyright 2020-2025 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. @@ -16,32 +16,31 @@ package com.iexec.commons.poco.utils; - +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.bouncycastle.util.Arrays; import org.web3j.crypto.Hash; import org.web3j.utils.Numeric; import java.nio.charset.StandardCharsets; import java.util.Objects; +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class HashUtils { - private HashUtils() { - throw new UnsupportedOperationException(); - } - public static String concatenateAndHash(String... hexaString) { // convert byte[] res = new byte[0]; for (String str : hexaString) { - res = org.bouncycastle.util.Arrays.concatenate(res, BytesUtils.stringToBytes(str)); + res = Arrays.concatenate(res, Numeric.hexStringToByteArray(str)); } // Hash the result and convert to String return Numeric.toHexString(Hash.sha3(res)); } - + /** * Generates SHA-256 digest for the given UTF-8 string. - * + * * @param utf8String * @return SHA-256 digest in hex string format, * e.g: 0x66daf4e6810d83d4859846a5df1afabf88c9fda135bc732ea977f25348d98ede @@ -54,7 +53,7 @@ public static String sha256(String utf8String) { /** * Generates SHA-256 digest for the given byte array. - * + * * @param bytes * @return SHA-256 digest in hex string format, * e.g: 0x66daf4e6810d83d4859846a5df1afabf88c9fda135bc732ea977f25348d98ede @@ -63,5 +62,5 @@ public static String sha256(byte[] bytes) { byte[] hexBytes = Hash.sha256(bytes); return Numeric.toHexString(hexBytes); } - + } diff --git a/src/test/java/com/iexec/commons/poco/chain/IexecHubAbstractServiceTest.java b/src/test/java/com/iexec/commons/poco/chain/IexecHubAbstractServiceTest.java index 6f75d63..38bd825 100644 --- a/src/test/java/com/iexec/commons/poco/chain/IexecHubAbstractServiceTest.java +++ b/src/test/java/com/iexec/commons/poco/chain/IexecHubAbstractServiceTest.java @@ -297,7 +297,7 @@ private ChainDeal getMockDeal() { .chainApp(ChainApp.builder().multiaddr("").build()) .chainCategory(ChainCategory.builder().build()) .dappPointer("0x1") - .dataPointer(BytesUtils.EMPTY_ADDRESS) + .dataPointer("0x2") .category(BigInteger.ZERO) .params(DealParams.builder().build()) .startTime(BigInteger.TEN)