diff --git a/installer/installer.sh b/installer/installer.sh index ba6a78771b..b9d090e96d 100755 --- a/installer/installer.sh +++ b/installer/installer.sh @@ -87,7 +87,7 @@ install_prereqs() { rm -rf setup_$NODEJS_VER.x perform_step apt update "Updating Ubuntu package repository" perform_step apt-get install nodejs -y "Installing node.js" - perform_step npm install -g npm "Installing npm" + perform_step npm install -g npm@^8 "Installing npm" perform_step install_firewall "Configuring firewall" perform_step apt remove unattended-upgrades -y "Remove unattended upgrades" } @@ -263,9 +263,9 @@ install_node() { perform_step touch $CONFIG_DIR/.origintrail_noderc "Configuring node config file" perform_step $(jq --null-input --arg tripleStore "$tripleStore" '{"logLevel": "trace", "auth": {"ipWhitelist": ["::1", "127.0.0.1"]}}' > $CONFIG_DIR/.origintrail_noderc) "Adding loglevel and auth values to node config file" - perform_step $(jq --arg tripleStore "$tripleStore" --arg tripleStoreUrl "$tripleStoreUrl" '.modules.tripleStore.implementation[$tripleStore] |= + perform_step $(jq --arg tripleStore "$tripleStore" --arg tripleStoreUrl "$tripleStoreUrl" '.modules.tripleStore.implementation[$tripleStore] |= { - "enabled": "true", + "enabled": "true", "config": { "repositories": { "privateCurrent": { @@ -293,24 +293,24 @@ install_node() { "password": "" } } - } + } } + .' $CONFIG_DIR/.origintrail_noderc > $CONFIG_DIR/origintrail_noderc_tmp) "Adding node wallets to node config file 1/2" perform_step mv $CONFIG_DIR/origintrail_noderc_tmp $CONFIG_DIR/.origintrail_noderc "Adding node wallets to node config file 2/2" - - perform_step $(jq --arg blockchain "otp" --arg evmOperationalWallet "$EVM_OPERATIONAL_WALLET" --arg evmOperationalWalletPrivateKey "$EVM_OPERATIONAL_PRIVATE_KEY" --arg evmManagementWallet "$EVM_MANAGEMENT_WALLET" --arg evmManagementWallet "$SHARES_TOKEN_NAME" --arg evmManagementWallet "$SHARES_TOKEN_SYMBOL" --arg sharesTokenName "$SHARES_TOKEN_NAME" --arg sharesTokenSymbol "$SHARES_TOKEN_SYMBOL" '.modules.blockchain.implementation[$blockchain].config |= - { - "evmOperationalWalletPublicKey": $evmOperationalWallet, - "evmOperationalWalletPrivateKey": $evmOperationalWalletPrivateKey, - "evmManagementWalletPublicKey": $evmManagementWallet, - "sharesTokenName": $sharesTokenName, + + perform_step $(jq --arg blockchain "otp" --arg evmOperationalWallet "$EVM_OPERATIONAL_WALLET" --arg evmOperationalWalletPrivateKey "$EVM_OPERATIONAL_PRIVATE_KEY" --arg evmManagementWallet "$EVM_MANAGEMENT_WALLET" --arg evmManagementWallet "$SHARES_TOKEN_NAME" --arg evmManagementWallet "$SHARES_TOKEN_SYMBOL" --arg sharesTokenName "$SHARES_TOKEN_NAME" --arg sharesTokenSymbol "$SHARES_TOKEN_SYMBOL" '.modules.blockchain.implementation[$blockchain].config |= + { + "evmOperationalWalletPublicKey": $evmOperationalWallet, + "evmOperationalWalletPrivateKey": $evmOperationalWalletPrivateKey, + "evmManagementWalletPublicKey": $evmManagementWallet, + "sharesTokenName": $sharesTokenName, "sharesTokenSymbol": $sharesTokenSymbol } + .' $CONFIG_DIR/.origintrail_noderc > $CONFIG_DIR/origintrail_noderc_tmp) "Adding node wallets to node config file 1/2" - + perform_step mv $CONFIG_DIR/origintrail_noderc_tmp $CONFIG_DIR/.origintrail_noderc "Adding node wallets to node config file 2/2" perform_step cp $OTNODE_DIR/installer/data/otnode.service /lib/systemd/system/ "Copying otnode service file" - + systemctl daemon-reload perform_step systemctl enable otnode "Enabling otnode" perform_step systemctl start otnode "Starting otnode" @@ -411,4 +411,4 @@ If the logs do not show and the screen hangs, press ctrl+c to exit the installat " read -p "Press enter to continue..." -journalctl -u otnode --output cat -fn 200 \ No newline at end of file +journalctl -u otnode --output cat -fn 200 diff --git a/package-lock.json b/package-lock.json index cf09c0f316..28d3231823 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.0.14", + "version": "6.0.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.0.14", + "version": "6.0.15", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", @@ -15569,9 +15569,9 @@ "dev": true }, "node_modules/protobufjs": { - "version": "6.11.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", - "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", + "version": "6.11.4", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.4.tgz", + "integrity": "sha512-5kQWPaJHi1WoCpjTGszzQ32PG2F4+wRY6BmAT4Vfw56Q2FZ4YZzK20xUYQH4YkfehY1e6QSICrJquM6xXZNcrw==", "hasInstallScript": true, "dependencies": { "@protobufjs/aspromise": "^1.1.2", @@ -31816,9 +31816,9 @@ "dev": true }, "protobufjs": { - "version": "6.11.3", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", - "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", + "version": "6.11.4", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.4.tgz", + "integrity": "sha512-5kQWPaJHi1WoCpjTGszzQ32PG2F4+wRY6BmAT4Vfw56Q2FZ4YZzK20xUYQH4YkfehY1e6QSICrJquM6xXZNcrw==", "requires": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", diff --git a/package.json b/package.json index c10bb71d29..2c8c7ec700 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.0.14", + "version": "6.0.15", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/constants/constants.js b/src/constants/constants.js index 6b92211067..9458748ae7 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -542,12 +542,6 @@ export const CONTRACT_EVENT_FETCH_INTERVALS = { DEVELOPMENT: 4 * 1000, }; -export const FIXED_GAS_LIMIT_METHODS = { - submitCommit: 600000, - submitUpdateCommit: 600000, - sendProof: 500000, -}; - export const BLOCK_TIME_MILLIS = { OTP: 12_000, HARDHAT: 5_000, diff --git a/src/modules/blockchain/implementation/web3-service.js b/src/modules/blockchain/implementation/web3-service.js index e003f881d8..5759b4d1bf 100644 --- a/src/modules/blockchain/implementation/web3-service.js +++ b/src/modules/blockchain/implementation/web3-service.js @@ -8,7 +8,6 @@ import { DEFAULT_BLOCKCHAIN_EVENT_SYNC_PERIOD_IN_MILLS, MAXIMUM_NUMBERS_OF_BLOCKS_TO_FETCH, TRANSACTION_QUEUE_CONCURRENCY, - FIXED_GAS_LIMIT_METHODS, TRANSACTION_POLLING_TIMEOUT_MILLIS, TRANSACTION_CONFIRMATIONS, BLOCK_TIME_MILLIS, @@ -348,14 +347,7 @@ class Web3Service { while (result === undefined) { try { /* eslint-disable no-await-in-loop */ - let gasLimit; - - if (FIXED_GAS_LIMIT_METHODS[functionName]) { - gasLimit = FIXED_GAS_LIMIT_METHODS[functionName]; - } else { - gasLimit = await contractInstance.estimateGas[functionName](...args); - } - + const gasLimit = await contractInstance.estimateGas[functionName](...args); const gas = gasLimit ?? this.convertToWei(900, 'kwei'); this.logger.info( diff --git a/src/service/sharding-table-service.js b/src/service/sharding-table-service.js index a1200c0deb..87688c0a42 100644 --- a/src/service/sharding-table-service.js +++ b/src/service/sharding-table-service.js @@ -152,6 +152,7 @@ class ShardingTableService { firstAssertionId, hashFunctionId, ) { + const kbSize = assertionSize < BYTES_IN_KILOBYTE ? BYTES_IN_KILOBYTE : assertionSize; const peerRecords = await this.findNeighbourhood( blockchainId, this.blockchainModuleManager.encodePacked( @@ -177,20 +178,13 @@ class ShardingTableService { const r0 = await this.blockchainModuleManager.getR0(blockchainId); - const minBidSuggestion = this.blockchainModuleManager - .toBigNumber(blockchainId, '1') - .mul(epochsNumber) - .mul(r0); - const bidSuggestion = this.blockchainModuleManager .toBigNumber(blockchainId, this.blockchainModuleManager.convertToWei(blockchainId, ask)) - .mul(assertionSize) + .mul(kbSize) .mul(epochsNumber) .mul(r0) .div(BYTES_IN_KILOBYTE); - return bidSuggestion.lte(minBidSuggestion) - ? minBidSuggestion.toString() - : bidSuggestion.toString(); + return bidSuggestion.toString(); } async findEligibleNodes(neighbourhood, bid, r1, r0) { diff --git a/src/service/validation-service.js b/src/service/validation-service.js index a6cd284152..0786db76d0 100644 --- a/src/service/validation-service.js +++ b/src/service/validation-service.js @@ -34,7 +34,6 @@ class ValidationService { this.validateAssertionId(assertion, assertionId); // TODO: get assertion data in one call - await this.validateAssertionSize(blockchain, assertionId, assertion); await this.validateTriplesNumber(blockchain, assertionId, assertion); await this.validateChunkSize(blockchain, assertionId, assertion); @@ -56,7 +55,8 @@ class ValidationService { } const assertionSize = assertionMetadata.getAssertionSizeInBytes(assertion); if (blockchainAssertionSize !== assertionSize) { - throw Error( + // todo after corrective component is implemented, update this logic + this.logger.warn( `Invalid assertion size, value read from blockchain: ${blockchainAssertionSize}, calculated: ${assertionSize}`, ); } @@ -90,7 +90,8 @@ class ValidationService { const calculatedAssertionId = this.validationModuleManager.calculateRoot(assertion); if (assertionId !== calculatedAssertionId) { - throw Error( + // todo after corrective component is implemented, update this logic + this.logger.warn( `Invalid assertion id. Received value: ${assertionId}, calculated: ${calculatedAssertionId}`, ); } diff --git a/test/unit/service/validation-service.test.js b/test/unit/service/validation-service.test.js index 7cb77e625e..69dafd7e39 100644 --- a/test/unit/service/validation-service.test.js +++ b/test/unit/service/validation-service.test.js @@ -49,22 +49,23 @@ describe('Validation service test', async () => { }); it('Tries to validate assertion but fails due to assertion size mismatch', async () => { - let errorThrown = false; - try { - await validationService.validateAssertion( - '0xde58cc52a5ce3a04ae7a05a13176226447ac02489252e4d37a72cbe0aea46b42', - 'hardhat', - { - '@context': 'https://schema.org', - '@id': 'https://tesla.modelX/2321', - '@type': 'Car', - name: 'Tesla Model X', - }, - ); - } catch (error) { - errorThrown = true; - } - expect(errorThrown).to.be.true; + // todo after corrective component is implemented, update this logic + // let errorThrown = false; + // try { + // await validationService.validateAssertion( + // '0xde58cc52a5ce3a04ae7a05a13176226447ac02489252e4d37a72cbe0aea46b42', + // 'hardhat', + // { + // '@context': 'https://schema.org', + // '@id': 'https://tesla.modelX/2321', + // '@type': 'Car', + // name: 'Tesla Model X', + // }, + // ); + // } catch (error) { + // errorThrown = true; + // } + // expect(errorThrown).to.be.true; }); it('Tries to validate assertion but fails due to triple number mismatch', async () => { @@ -136,34 +137,35 @@ describe('Validation service test', async () => { }); it('Tries to validate assertion but fails due to validation manager returning wrong assertion id', async () => { + // todo after corrective component is implemented, update this logic // Will lead to mismatch with passed assertion id - validationService.validationModuleManager.calculateRoot = (assertion) => ''; - - let errorThrown = false; - try { - await validationService.validateAssertion( - '0xde58cc52a5ce3a04ae7a05a13176226447ac02489252e4d37a72cbe0aea46b42', - 'hardhat', - { - '@context': 'https://schema.org', - '@id': 'https://tesla.modelX/2321', - '@type': 'Car', - name: 'Tesla Model X', - brand: { - '@type': 'Brand', - name: 'Tesla', - }, - model: 'Model X', - manufacturer: { - '@type': 'Organization', - name: 'Tesla, Inc.', - }, - fuelType: 'Electric', - }, - ); - } catch (error) { - errorThrown = true; - } - expect(errorThrown).to.be.true; + // validationService.validationModuleManager.calculateRoot = (assertion) => ''; + // + // let errorThrown = false; + // try { + // await validationService.validateAssertion( + // '0xde58cc52a5ce3a04ae7a05a13176226447ac02489252e4d37a72cbe0aea46b42', + // 'hardhat', + // { + // '@context': 'https://schema.org', + // '@id': 'https://tesla.modelX/2321', + // '@type': 'Car', + // name: 'Tesla Model X', + // brand: { + // '@type': 'Brand', + // name: 'Tesla', + // }, + // model: 'Model X', + // manufacturer: { + // '@type': 'Organization', + // name: 'Tesla, Inc.', + // }, + // fuelType: 'Electric', + // }, + // ); + // } catch (error) { + // errorThrown = true; + // } + // expect(errorThrown).to.be.true; }); });