Skip to content

Commit 14103ec

Browse files
authored
fix: wallet addresses need to be encoded on 32 bytes in ETH filters (#766)
1 parent 35e6285 commit 14103ec

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/com/iexec/core/chain/IexecHubService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.web3j.protocol.core.methods.request.EthFilter;
2929
import org.web3j.protocol.core.methods.response.EthLog;
3030
import org.web3j.protocol.core.methods.response.Log;
31+
import org.web3j.utils.Numeric;
3132

3233
import java.math.BigInteger;
3334
import java.util.Arrays;
@@ -178,8 +179,10 @@ public ChainReceipt getContributionBlock(final String chainTaskId,
178179
if (fromBlock > latestBlock) {
179180
return ChainReceipt.builder().build();
180181
}
182+
// wallet needs to be encoded on 32 bytes instead of 20 bytes
183+
final String filterEncodedWallet = Numeric.toHexStringWithPrefixZeroPadded(Numeric.toBigInt(workerWallet), 64);
181184
final EthFilter ethFilter = createEthFilter(
182-
fromBlock, latestBlock, LogTopic.TASK_CONTRIBUTE_EVENT, chainTaskId, workerWallet);
185+
fromBlock, latestBlock, LogTopic.TASK_CONTRIBUTE_EVENT, chainTaskId, filterEncodedWallet);
183186
return web3jService.getWeb3j().ethGetLogs(ethFilter).flowable()
184187
.map(this::createChainReceipt)
185188
.blockingFirst();
@@ -206,8 +209,10 @@ public ChainReceipt getRevealBlock(final String chainTaskId,
206209
if (fromBlock > latestBlock) {
207210
return ChainReceipt.builder().build();
208211
}
212+
// wallet needs to be encoded on 32 bytes instead of 20 bytes
213+
final String filterEncodedWallet = Numeric.toHexStringWithPrefixZeroPadded(Numeric.toBigInt(workerWallet), 64);
209214
final EthFilter ethFilter = createEthFilter(
210-
fromBlock, latestBlock, LogTopic.TASK_REVEAL_EVENT, chainTaskId, workerWallet);
215+
fromBlock, latestBlock, LogTopic.TASK_REVEAL_EVENT, chainTaskId, filterEncodedWallet);
211216
return web3jService.getWeb3j().ethGetLogs(ethFilter).flowable()
212217
.map(this::createChainReceipt)
213218
.blockingFirst();

0 commit comments

Comments
 (0)