Skip to content

Commit 81052af

Browse files
fix: prevent prepareDatasetBulk when bulk is not implemented
1 parent 910bfa3 commit 81052af

File tree

6 files changed

+47
-4
lines changed

6 files changed

+47
-4
lines changed

src/common/execution/order-helper.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import {
1313
STORAGE_PROVIDERS,
1414
TEE_FRAMEWORKS,
1515
} from '../utils/constant.js';
16-
import { THEGRAPH_IPFS_NODE, THEGRAPH_IPFS_GATEWAY } from '../utils/config.js';
16+
import {
17+
THEGRAPH_IPFS_NODE,
18+
THEGRAPH_IPFS_GATEWAY,
19+
checkImplementedOnChain,
20+
CHAIN_SPECIFIC_FEATURES,
21+
} from '../utils/config.js';
1722
import {
1823
getStorageTokenKeyName,
1924
reservedSecretKeyName,
@@ -234,10 +239,16 @@ const ipfsUpload = async ({
234239
export const prepareDatasetBulk = async ({
235240
ipfsNode = throwIfMissing(),
236241
ipfsGateway = throwIfMissing(),
237-
datasetorders,
242+
contracts = throwIfMissing(),
243+
datasetorders = throwIfMissing(),
238244
maxDatasetPerTask = MAX_DATASET_PER_TASK,
239245
thegraphUpload = false,
240246
}) => {
247+
checkImplementedOnChain(
248+
contracts.chainId,
249+
CHAIN_SPECIFIC_FEATURES.BULK_PROCESSING,
250+
);
251+
241252
const vmMaxDatasetPerTask = await positiveStrictIntSchema()
242253
.max(MAX_DATASET_PER_TASK)
243254
.label('maxDatasetPerTask')

src/common/utils/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const CHAIN_SPECIFIC_FEATURES = {
88
VOUCHER: 'iExec Voucher',
99
COMPASS: 'iExec Compass',
1010
XRLC_BRIDGE: 'iExec xRLC Bridge',
11+
BULK_PROCESSING: 'Bulk processing',
1112
};
1213

1314
const networkConfigs = [
@@ -37,7 +38,10 @@ const networkConfigs = [
3738
},
3839
shouldRegisterNetwork: true,
3940
isExperimental: false,
40-
notImplemented: [CHAIN_SPECIFIC_FEATURES.COMPASS],
41+
notImplemented: [
42+
CHAIN_SPECIFIC_FEATURES.COMPASS,
43+
CHAIN_SPECIFIC_FEATURES.BULK_PROCESSING,
44+
],
4145
},
4246
{
4347
id: 1,
@@ -64,6 +68,7 @@ const networkConfigs = [
6468
notImplemented: [
6569
CHAIN_SPECIFIC_FEATURES.COMPASS,
6670
CHAIN_SPECIFIC_FEATURES.VOUCHER,
71+
CHAIN_SPECIFIC_FEATURES.BULK_PROCESSING,
6772
],
6873
},
6974
{
@@ -123,6 +128,7 @@ const networkConfigs = [
123128
CHAIN_SPECIFIC_FEATURES.WORKERPOOL_API_URL_REGISTRATION,
124129
CHAIN_SPECIFIC_FEATURES.VOUCHER,
125130
CHAIN_SPECIFIC_FEATURES.XRLC_BRIDGE,
131+
CHAIN_SPECIFIC_FEATURES.BULK_PROCESSING,
126132
],
127133
},
128134
];

src/lib/IExecOrderModule.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ export default class IExecOrderModule extends IExecModule {
400400
return prepareDatasetBulk({
401401
ipfsNode: await this.config.resolveIpfsNodeURL(),
402402
ipfsGateway: await this.config.resolveIpfsGatewayURL(),
403+
contracts: await this.config.resolveContractsClient(),
403404
datasetorders,
404405
maxDatasetPerTask,
405406
thegraphUpload:

test/lib/e2e/IExecOrderModule.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ const signRegex = /^(0x)([0-9a-f]{2}){65}$/;
4040

4141
describe('order', () => {
4242
describe('prepareDatasetBulk()', () => {
43-
const { iexec: iexecRequester } = getTestConfig(iexecTestChain)();
43+
const testChain = TEST_CHAINS['custom-token-chain']; // no bulk processing on bellecour;
44+
const { iexec: iexecRequester } = getTestConfig(testChain)();
4445
let datasetorders = [];
4546

4647
beforeAll(async () => {
4748
const requesterAddress = await iexecRequester.wallet.getAddress();
49+
await setBalance(testChain)(requesterAddress, ONE_ETH);
4850
const { address: appAddress } = await deployRandomApp(iexecRequester);
4951
datasetorders = await Promise.all(
5052
Array(10)

test/lib/unit/config.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,25 @@ describe('checkImplementedOnChain', () => {
166166
);
167167
});
168168
});
169+
describe(`feature ${CHAIN_SPECIFIC_FEATURES.BULK_PROCESSING}`, () => {
170+
const feature = CHAIN_SPECIFIC_FEATURES.BULK_PROCESSING;
171+
test('is not implemented on bellecour', () => {
172+
expect(() => checkImplementedOnChain(134, feature)).toThrow(
173+
`${feature} is not available on network bellecour`,
174+
);
175+
});
176+
test('is not implemented on mainnet', () => {
177+
expect(() => checkImplementedOnChain(1, feature)).toThrow(
178+
`${feature} is not available on network mainnet`,
179+
);
180+
});
181+
test('is not implemented on arbitrum-mainnet', () => {
182+
expect(() => checkImplementedOnChain(42161, feature)).toThrow(
183+
`${feature} is not available on network arbitrum-mainnet`,
184+
);
185+
});
186+
test('is implemented on arbitrum-sepolia-testnet', () => {
187+
expect(() => checkImplementedOnChain(421614, feature)).not.toThrow();
188+
});
189+
});
169190
});

test/test-utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export const TEST_CHAINS = {
6565
hubAddress: '0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca',
6666
ensRegistryAddress: '0xaf87b82B01E484f8859c980dE69eC8d09D30F22a',
6767
ensPublicResolverAddress: '0x464E9FC01C2970173B183D24B43A0FA07e6A072E',
68+
ipfsNodeURL: 'http://localhost:5001',
69+
ipfsGatewayURL: 'http://localhost:8080',
6870
pocoAdminWallet: new Wallet(
6971
'0x564a9db84969c8159f7aa3d5393c5ecd014fce6a375842a45b12af6677b12407',
7072
),

0 commit comments

Comments
 (0)