From f7e3afd8cd095b8e315fc37a40c7e0e9275456c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Cordier?= Date: Thu, 11 May 2023 11:14:05 +0200 Subject: [PATCH 1/9] Add NEXT section in CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c21aa24..bf8dcec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. +## [[NEXT]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/vNEXT) 2023 + ## [[2.0.0]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/v2.0.0) 2023-05-11 ### New Features From 8570c682d5a35f8536539068132d30bb359dbb84 Mon Sep 17 00:00:00 2001 From: Jeremy Bernard Date: Mon, 15 May 2023 13:19:25 +0200 Subject: [PATCH 2/9] Pull `poco-chain` image before tests --- build.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7ef41c7..b7e7f37 100644 --- a/build.gradle +++ b/build.gradle @@ -76,13 +76,18 @@ tasks.withType(Test).configureEach { } test { + doFirst { + exec { + commandLine 'docker', 'compose', 'pull', '-q' + } + } reports { junitXml.required = true html.required = true } } -task itest { +tasks.register('itest', Test) { group 'Verification' description 'Runs the integration tests.' } From 762f9ad2c328c825874b073774a5517d3e0cb731 Mon Sep 17 00:00:00 2001 From: Jeremy Bernard Date: Mon, 15 May 2023 15:05:34 +0200 Subject: [PATCH 3/9] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf8dcec..869a127 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. ## [[NEXT]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/vNEXT) 2023 +### Bug Fixes +- Pull `poco-chain` image before tests. (#18) + ## [[2.0.0]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/v2.0.0) 2023-05-11 ### New Features From 405d7c66325b434a173074e25a75fcb0031906e4 Mon Sep 17 00:00:00 2001 From: Maxence Cornaton Date: Wed, 17 May 2023 09:45:43 +0200 Subject: [PATCH 4/9] Add purge cached task descriptions ability --- CHANGELOG.md | 2 ++ .../poco/chain/IexecHubAbstractService.java | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 869a127..b85fb4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## [[NEXT]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/vNEXT) 2023 +### New Features +- Add purge cached task descriptions ability. (#20) ### Bug Fixes - Pull `poco-chain` image before tests. (#18) 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 d545ead..9861761 100644 --- a/src/main/java/com/iexec/commons/poco/chain/IexecHubAbstractService.java +++ b/src/main/java/com/iexec/commons/poco/chain/IexecHubAbstractService.java @@ -1336,4 +1336,29 @@ public boolean isStatusTrueOnChain(String chainTaskId, String walletAddress, return false; } } + + // region Purge + /** + * Purge description of given task. + * + * @param chainTaskId ID of the task to purge. + * @return {@literal true} if task description was cached + * and has been purged; + * {@literal false} otherwise. + */ + protected boolean purgeTask(String chainTaskId) { + if (!taskDescriptions.containsKey(chainTaskId)) { + log.info("Can't purge task description [chainTaskId:{}]", chainTaskId); + } + + return taskDescriptions.remove(chainTaskId) != null; + } + + /** + * Purge all cached task descriptions. + */ + protected void purgeAllTasksData() { + taskDescriptions.clear(); + } + // endregion } From 74b3188cd32e33a94fd01c78f4a8cb8e00d36c3b Mon Sep 17 00:00:00 2001 From: Maxence Cornaton Date: Wed, 17 May 2023 09:47:31 +0200 Subject: [PATCH 5/9] Return as soon as possible --- .../com/iexec/commons/poco/chain/IexecHubAbstractService.java | 1 + 1 file changed, 1 insertion(+) 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 9861761..f4b1653 100644 --- a/src/main/java/com/iexec/commons/poco/chain/IexecHubAbstractService.java +++ b/src/main/java/com/iexec/commons/poco/chain/IexecHubAbstractService.java @@ -1349,6 +1349,7 @@ public boolean isStatusTrueOnChain(String chainTaskId, String walletAddress, protected boolean purgeTask(String chainTaskId) { if (!taskDescriptions.containsKey(chainTaskId)) { log.info("Can't purge task description [chainTaskId:{}]", chainTaskId); + return false; } return taskDescriptions.remove(chainTaskId) != null; From e6b1ba82b9d4d55a50441e1e02bdb6183beb43cf Mon Sep 17 00:00:00 2001 From: Jeremy Bernard Date: Mon, 22 May 2023 14:49:51 +0200 Subject: [PATCH 6/9] Keep a security factor for callback gas consumption during finalize --- .../com/iexec/commons/poco/chain/Web3jAbstractService.java | 4 +++- .../iexec/commons/poco/chain/Web3jAbstractServiceTest.java | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) 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 21220a8..03c48b2 100644 --- a/src/main/java/com/iexec/commons/poco/chain/Web3jAbstractService.java +++ b/src/main/java/com/iexec/commons/poco/chain/Web3jAbstractService.java @@ -328,8 +328,10 @@ static BigInteger getGasLimitForFunction(String functionName) { case FUNC_REVEAL: gasLimit = 100000;//seen 56333 break; + case FUNC_CONTRIBUTEANDFINALIZE: case FUNC_FINALIZE: - gasLimit = 300000;//seen 175369 (242641 in reopen case) + // Multiply with a factor of 10 for callback gas consumption + gasLimit = 3000000;//seen 175369 (242641 in reopen case) break; case FUNC_REOPEN: gasLimit = 500000;//seen 43721 diff --git a/src/test/java/com/iexec/commons/poco/chain/Web3jAbstractServiceTest.java b/src/test/java/com/iexec/commons/poco/chain/Web3jAbstractServiceTest.java index a6da5d9..79ab4f6 100644 --- a/src/test/java/com/iexec/commons/poco/chain/Web3jAbstractServiceTest.java +++ b/src/test/java/com/iexec/commons/poco/chain/Web3jAbstractServiceTest.java @@ -39,9 +39,12 @@ void getGasLimitForFunction() { assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_REVEAL), BigInteger.valueOf(100000)); + assertEquals(Web3jAbstractService + .getGasLimitForFunction(FUNC_CONTRIBUTEANDFINALIZE), + BigInteger.valueOf(3000000)); assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_FINALIZE), - BigInteger.valueOf(300000)); + BigInteger.valueOf(3000000)); assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_REOPEN), BigInteger.valueOf(500000)); From c5037481a57dd5057b209db44808846696f4e6a1 Mon Sep 17 00:00:00 2001 From: Jeremy Bernard Date: Mon, 22 May 2023 16:20:25 +0200 Subject: [PATCH 7/9] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b85fb4b..f8b069e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Add purge cached task descriptions ability. (#20) ### Bug Fixes - Pull `poco-chain` image before tests. (#18) +- Keep a security factor of 10 for callback gas consumption during `finalize` and `contributeAndFinalize`. (#22) ## [[2.0.0]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/v2.0.0) 2023-05-11 From 9fd257f8f3bbb0c59edcea211e37977e61370b13 Mon Sep 17 00:00:00 2001 From: Jeremy Bernard Date: Mon, 22 May 2023 16:45:46 +0200 Subject: [PATCH 8/9] Use underscores in `Web3jAbstractService#getGasLimitForFunction` numeric values --- .../poco/chain/Web3jAbstractService.java | 18 +++++++++--------- .../poco/chain/Web3jAbstractServiceTest.java | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) 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 03c48b2..117c67d 100644 --- a/src/main/java/com/iexec/commons/poco/chain/Web3jAbstractService.java +++ b/src/main/java/com/iexec/commons/poco/chain/Web3jAbstractService.java @@ -42,7 +42,7 @@ @Slf4j public abstract class Web3jAbstractService { - static final long GAS_LIMIT_CAP = 1000000; + static final long GAS_LIMIT_CAP = 1_000_000; private final float gasPriceMultiplier; private final long gasPriceCap; private final boolean isSidechain; @@ -320,30 +320,30 @@ static BigInteger getGasLimitForFunction(String functionName) { long gasLimit; switch (functionName) { case FUNC_INITIALIZE: - gasLimit = 300000;//seen 176340 + gasLimit = 300_000;//seen 176340 break; case FUNC_CONTRIBUTE: - gasLimit = 500000;//seen 333541 + gasLimit = 500_000;//seen 333541 break; case FUNC_REVEAL: - gasLimit = 100000;//seen 56333 + gasLimit = 100_000;//seen 56333 break; case FUNC_CONTRIBUTEANDFINALIZE: case FUNC_FINALIZE: // Multiply with a factor of 10 for callback gas consumption - gasLimit = 3000000;//seen 175369 (242641 in reopen case) + gasLimit = 3_000_000;//seen 175369 (242641 in reopen case) break; case FUNC_REOPEN: - gasLimit = 500000;//seen 43721 + gasLimit = 500_000;//seen 43721 break; case FUNC_CREATEAPP: - gasLimit = 900000;//800000 might not be enough + gasLimit = 900_000;//800000 might not be enough break; case FUNC_CREATEWORKERPOOL: - gasLimit = 700000; + gasLimit = 700_000; break; case FUNC_CREATEDATASET: - gasLimit = 700000;//seen 608878 + gasLimit = 700_000;//seen 608878 break; default: gasLimit = GAS_LIMIT_CAP; diff --git a/src/test/java/com/iexec/commons/poco/chain/Web3jAbstractServiceTest.java b/src/test/java/com/iexec/commons/poco/chain/Web3jAbstractServiceTest.java index 79ab4f6..a2ec071 100644 --- a/src/test/java/com/iexec/commons/poco/chain/Web3jAbstractServiceTest.java +++ b/src/test/java/com/iexec/commons/poco/chain/Web3jAbstractServiceTest.java @@ -32,25 +32,25 @@ class Web3jAbstractServiceTest { void getGasLimitForFunction() { assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_INITIALIZE), - BigInteger.valueOf(300000)); + BigInteger.valueOf(300_000)); assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_CONTRIBUTE), - BigInteger.valueOf(500000)); + BigInteger.valueOf(500_000)); assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_REVEAL), - BigInteger.valueOf(100000)); + BigInteger.valueOf(100_000)); assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_CONTRIBUTEANDFINALIZE), - BigInteger.valueOf(3000000)); + BigInteger.valueOf(3_000_000)); assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_FINALIZE), - BigInteger.valueOf(3000000)); + BigInteger.valueOf(3_000_000)); assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_REOPEN), - BigInteger.valueOf(500000)); + BigInteger.valueOf(500_000)); assertEquals(Web3jAbstractService .getGasLimitForFunction(FUNC_CREATEDATASET), - BigInteger.valueOf(700000)); + BigInteger.valueOf(700_000)); assertEquals(Web3jAbstractService .getGasLimitForFunction("randomfunction"), BigInteger.valueOf(GAS_LIMIT_CAP)); From 23f624f93370133d2a96e008f344db8de3cbf2d3 Mon Sep 17 00:00:00 2001 From: Jeremy Bernard Date: Mon, 22 May 2023 16:54:48 +0200 Subject: [PATCH 9/9] Release version 2.0.1 --- CHANGELOG.md | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8b069e..7df60b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -## [[NEXT]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/vNEXT) 2023 +## [[2.0.1]](https://github.com/iExecBlockchainComputing/iexec-commons-poco/releases/tag/v2.0.1) 2023-05-22 ### New Features - Add purge cached task descriptions ability. (#20) diff --git a/gradle.properties b/gradle.properties index 5afd1ed..72aaa62 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=2.0.0 +version=2.0.1 nexusUser nexusPassword