Skip to content

Commit

Permalink
Merge pull request #2710 from OriginTrail/v6/prerelease/mainnet
Browse files Browse the repository at this point in the history
OriginTrail Mainnet Release v6.0.15
  • Loading branch information
branarakic authored Sep 8, 2023
2 parents 30222bd + ca16fcd commit e4d14c2
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 94 deletions.
28 changes: 14 additions & 14 deletions installer/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
journalctl -u otnode --output cat -fn 200
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "origintrail_node",
"version": "6.0.14",
"version": "6.0.15",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
6 changes: 0 additions & 6 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 1 addition & 9 deletions src/modules/blockchain/implementation/web3-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 3 additions & 9 deletions src/service/sharding-table-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions src/service/validation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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}`,
);
}
Expand Down Expand Up @@ -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}`,
);
}
Expand Down
90 changes: 46 additions & 44 deletions test/unit/service/validation-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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;
});
});

0 comments on commit e4d14c2

Please sign in to comment.