From 819bd8b6a69e45047695bfe931b79ea6202d50fa Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 24 Oct 2023 14:51:43 +0200 Subject: [PATCH 01/72] Add gnosis-service --- config/config.json | 30 +++++++++++++++++++ src/constants/constants.js | 1 + .../implementation/gnosis/gnosis-service.js | 30 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 src/modules/blockchain/implementation/gnosis/gnosis-service.js diff --git a/config/config.json b/config/config.json index 7b490510c4..1fa6187fdc 100644 --- a/config/config.json +++ b/config/config.json @@ -296,6 +296,16 @@ "rpcEndpoints": ["http://localhost:8545"], "initialStakeAmount": 50000, "initialAskAmount": 0.2 + }, + "gnosis": { + "enabled": false, + "package": "./blockchain/implementation/gnosis/gnosis-service.js", + "config": { + "networkId": "chiado", + "hubContractAddress": "", + "gasPriceOracleLink": "", + "rpcEndpoints": ["https://rpc.chiadochain.net"] + } } } } @@ -432,6 +442,16 @@ "https://lofar-testnet.origintrail.network" ] } + }, + "gnosis": { + "enabled": false, + "package": "./blockchain/implementation/gnosis/gnosis-service.js", + "config": { + "networkId": "chiado", + "hubContractAddress": "", + "gasPriceOracleLink": "", + "rpcEndpoints": ["https://rpc.chiadochain.net"] + } } } }, @@ -588,6 +608,16 @@ "https://astrosat.origintrail.network/" ] } + }, + "gnosis": { + "enabled": false, + "package": "./blockchain/implementation/gnosis/gnosis-service.js", + "config": { + "networkId": "gnosis", + "hubContractAddress": "", + "gasPriceOracleLink": "https://api.gnosisscan.io/api?module=proxy&action=eth_gasPrice", + "rpcEndpoints": ["https://rpc.gnosischain.com/"] + } } } }, diff --git a/src/constants/constants.js b/src/constants/constants.js index 3fff5854e4..f1dd6e9202 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -564,6 +564,7 @@ export const CONTRACT_EVENT_FETCH_INTERVALS = { export const BLOCK_TIME_MILLIS = { OTP: 12_000, HARDHAT: 5_000, + GNOSIS: 5_000, DEFAULT: 12_000, }; diff --git a/src/modules/blockchain/implementation/gnosis/gnosis-service.js b/src/modules/blockchain/implementation/gnosis/gnosis-service.js new file mode 100644 index 0000000000..fa715fc7f2 --- /dev/null +++ b/src/modules/blockchain/implementation/gnosis/gnosis-service.js @@ -0,0 +1,30 @@ +import axios from 'axios'; +import Web3Service from '../web3-service.js'; +import { BLOCK_TIME_MILLIS } from '../../../../constants/constants.js'; + +class GnosisService extends Web3Service { + constructor(ctx) { + super(ctx); + + this.baseTokenTicker = 'GNO'; + this.tracTicker = 'TRAC'; + } + + getBlockTimeMillis() { + return BLOCK_TIME_MILLIS.GNOSIS; + } + + async getGasPrice() { + try { + this.logger.debug('Gas price:'); + const response = await axios.get(this.config.gasPriceOracleLink); + this.logger.debug(response); + const gasPriceRounded = Math.round(response.result * 1e9); + return gasPriceRounded; + } catch (error) { + return undefined; + } + } +} + +export default GnosisService; From 2b20ba66acedb7774121c55a66781d7803c87a71 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Fri, 27 Oct 2023 11:02:12 +0200 Subject: [PATCH 02/72] Added multiple blockchains starting in bdd tests --- config/config.json | 24 +++++++++++++++++++++++ package.json | 2 +- test/bdd/steps/blockchain.mjs | 26 +++++++++++++++++++++++++ test/bdd/steps/hooks.mjs | 1 + test/bdd/steps/lib/local-blockchain.mjs | 6 +++--- test/bdd/steps/lib/state.mjs | 2 ++ 6 files changed, 57 insertions(+), 4 deletions(-) diff --git a/config/config.json b/config/config.json index 7b490510c4..e2122c4d8f 100644 --- a/config/config.json +++ b/config/config.json @@ -297,6 +297,30 @@ "initialStakeAmount": 50000, "initialAskAmount": 0.2 } + }, + "hardhat-test1": { + "enabled": true, + "package": "./blockchain/implementation/hardhat/hardhat-service.js", + "config": { + "blockchainTitle": "hardhat-test-1", + "networkId": "hardhat::testnet1", + "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "rpcEndpoints": ["http://localhost:8545"], + "initialStakeAmount": 50000, + "initialAskAmount": 0.2 + } + }, + "hardhat-test2": { + "enabled": true, + "package": "./blockchain/implementation/hardhat/hardhat-service.js", + "config": { + "blockchainTitle": "hardhat-test-2", + "networkId": "hardhat::testnet2", + "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "rpcEndpoints": ["http://localhost:8545"], + "initialStakeAmount": 50000, + "initialAskAmount": 0.2 + } } } }, diff --git a/package.json b/package.json index 307fadd425..d4f40344a9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "prepare": "husky install", "lint-staged": "lint-staged", "create-account-mapping-signature": "node tools/ot-parachain-account-mapping/create-account-mapping-signature.js ", - "start:local_blockchain": "npm explore dkg-evm-module -- npm run dev", + "start:local_blockchain": "npm explore dkg-evm-module -- npm run dev -- --port", "kill:local_blockchain": "npx kill-port 8545", "test:bdd": "cucumber-js --fail-fast --format progress --format-options '{\"colorsEnabled\": true}' test/bdd/ --import test/bdd/steps/ --exit", "test:unit": "nyc --all mocha --exit $(find test/unit -name '*.js')", diff --git a/test/bdd/steps/blockchain.mjs b/test/bdd/steps/blockchain.mjs index 16cac4c171..9f84fe00d4 100644 --- a/test/bdd/steps/blockchain.mjs +++ b/test/bdd/steps/blockchain.mjs @@ -18,3 +18,29 @@ Given(/^the blockchain is set up$/, { timeout: 240_000 }, function blockchainSet }) .catch((error) => done(error)); }); + +Given(/^the blockchain is set up on port (\d+) and on port (\d+)$/, { timeout: 240_000 }, function blockchainSetup(port1, port2, done) { + this.logger.log(`Starting local blockchain on port: ${port1} and port: ${port2}`); + + const blockchainConsole1 = new console.Console( + fs.createWriteStream(`${this.state.scenarionLogDir}/blockchain${port1}.log`), + ); + const blockchainConsole2 = new console.Console( + fs.createWriteStream(`${this.state.scenarionLogDir}/blockchain${port2}.log`), + ); + const promises = []; + + const localBlockchain1 = new LocalBlockchain(); + this.state.localBlockchains.push(localBlockchain1); + + const localBlockchain2 = new LocalBlockchain(); + this.state.localBlockchains.push(localBlockchain2); + + promises.push(localBlockchain1.initialize(port1, blockchainConsole1)); + promises.push(localBlockchain2.initialize(port2, blockchainConsole2)); + + Promise.all(promises).then(()=>{ + done(); + }).catch((error) => done(error)); + +}); diff --git a/test/bdd/steps/hooks.mjs b/test/bdd/steps/hooks.mjs index c1d31646b4..895c6ab24a 100644 --- a/test/bdd/steps/hooks.mjs +++ b/test/bdd/steps/hooks.mjs @@ -16,6 +16,7 @@ Before(function beforeMethod(testCase, done) { // Initialize variables this.state = {}; this.state.localBlockchain = null; + this.state.localBlockchains = []; this.state.nodes = {}; this.state.bootstraps = []; let logDir = process.env.CUCUMBER_ARTIFACTS_DIR || '.'; diff --git a/test/bdd/steps/lib/local-blockchain.mjs b/test/bdd/steps/lib/local-blockchain.mjs index 777238c95d..581c776c6d 100644 --- a/test/bdd/steps/lib/local-blockchain.mjs +++ b/test/bdd/steps/lib/local-blockchain.mjs @@ -50,13 +50,13 @@ const testParametersStorageParams = { let startBlockchainProcess; class LocalBlockchain { - async initialize(_console = console) { - startBlockchainProcess = exec('npm run start:local_blockchain'); + async initialize(port, _console = console) { + startBlockchainProcess = exec(`npm run start:local_blockchain -- ${port}`); startBlockchainProcess.stdout.on('data', (data) => { _console.log(data); }); - this.provider = new ethers.providers.JsonRpcProvider('http://localhost:8545'); + this.provider = new ethers.providers.JsonRpcProvider(`http://localhost:${port}`); const [privateKeysFile, publicKeysFile] = await Promise.all([ readFile('test/bdd/steps/api/datasets/privateKeys.json'), diff --git a/test/bdd/steps/lib/state.mjs b/test/bdd/steps/lib/state.mjs index 727635eeb3..0730d927c0 100644 --- a/test/bdd/steps/lib/state.mjs +++ b/test/bdd/steps/lib/state.mjs @@ -7,6 +7,8 @@ const state = { // this is local blockchain object look at test/bdd/steps/lib/local-blockchain.js localBlockchain: {}, + // this is local blockchain object look at test/bdd/steps/lib/local-blockchain.js + localBlockchains: [], // array of nodes nodes: { 0: { From 28bcfb7b19aa3250f881ef1cd8883e1031434812 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Fri, 27 Oct 2023 11:37:41 +0200 Subject: [PATCH 03/72] Added multiple blockchains support in all tests --- test/bdd/features/get-errors.feature | 14 +++++--- test/bdd/features/get.feature | 29 ++++++++++------ test/bdd/features/publish-errors.feature | 2 +- test/bdd/features/publish.feature | 10 +++--- test/bdd/features/update-errors.feature | 2 +- test/bdd/features/update.feature | 11 +++--- test/bdd/steps/blockchain.mjs | 44 ++++++++---------------- test/bdd/steps/common.mjs | 27 ++++++++++----- test/bdd/steps/lib/state.mjs | 5 ++- 9 files changed, 79 insertions(+), 65 deletions(-) diff --git a/test/bdd/features/get-errors.feature b/test/bdd/features/get-errors.feature index 1ea6d7c22f..9f0286e9b9 100644 --- a/test/bdd/features/get-errors.feature +++ b/test/bdd/features/get-errors.feature @@ -1,6 +1,6 @@ Feature: Get errors test Background: Setup local blockchain, bootstraps and nodes - Given the blockchain is set up + Given the blockchains are set up And 1 bootstrap is running @get-errors @@ -24,8 +24,10 @@ Feature: Get errors test @get-errors Scenario: Getting non-existent state Given I setup 4 nodes - And I set R0 to be 1 - And I set R1 to be 2 + And I set R0 to be 1 on blockchain test1 + And I set R1 to be 2 on blockchain test1 + And I set R0 to be 1 on blockchain test2 + And I set R1 to be 2 on blockchain test2 And I wait for 5 seconds When I call Publish on the node 1 with validAssertion @@ -36,8 +38,10 @@ Feature: Get errors test @get-errors Scenario: Getting invalid state hash Given I setup 4 nodes - And I set R0 to be 1 - And I set R1 to be 2 + And I set R0 to be 1 on blockchain test1 + And I set R1 to be 2 on blockchain test1 + And I set R0 to be 1 on blockchain test2 + And I set R1 to be 2 on blockchain test2 And I wait for 5 seconds When I call Publish on the node 1 with validAssertion diff --git a/test/bdd/features/get.feature b/test/bdd/features/get.feature index 88c3af8c01..203c898f98 100644 --- a/test/bdd/features/get.feature +++ b/test/bdd/features/get.feature @@ -1,13 +1,16 @@ Feature: Get asset states test Background: Setup local blockchain, bootstraps and nodes - Given the blockchain is set up + Given the blockchains are set up And 1 bootstrap is running @release Scenario: Get first state of the updated knowledge asset - Given I set R0 to be 1 - And I set R1 to be 2 - And I set finalizationCommitsNumber to be 2 + Given I set R0 to be 1 on blockchain test1 + And I set R1 to be 2 on blockchain test1 + And I set finalizationCommitsNumber to be 2 on blockchain test1 + And I set R0 to be 1 on blockchain test2 + And I set R1 to be 2 on blockchain test2 + And I set finalizationCommitsNumber to be 2 on blockchain test2 And I setup 4 nodes And I wait for 5 seconds @@ -25,9 +28,12 @@ Feature: Get asset states test @release Scenario: Get latest state of the updated knowledge asset - Given I set R0 to be 1 - And I set R1 to be 2 - And I set finalizationCommitsNumber to be 2 + Given I set R0 to be 1 on blockchain test1 + And I set R1 to be 2 on blockchain test1 + And I set finalizationCommitsNumber to be 2 on blockchain test1 + And I set R0 to be 1 on blockchain test2 + And I set R1 to be 2 on blockchain test2 + And I set finalizationCommitsNumber to be 2 on blockchain test2 And I setup 4 nodes And I wait for 5 seconds @@ -45,9 +51,12 @@ Feature: Get asset states test @release Scenario: Get all states of the knowledge asset that is updated 2 times - Given I set R0 to be 1 - And I set R1 to be 2 - And I set finalizationCommitsNumber to be 2 + Given I set R0 to be 1 on blockchain test1 + And I set R1 to be 2 on blockchain test1 + And I set finalizationCommitsNumber to be 2 on blockchain test1 + And I set R0 to be 1 on blockchain test2 + And I set R1 to be 2 on blockchain test2 + And I set finalizationCommitsNumber to be 2 on blockchain test2 And I setup 4 nodes And I wait for 5 seconds diff --git a/test/bdd/features/publish-errors.feature b/test/bdd/features/publish-errors.feature index 503f7040a3..e1e7566192 100644 --- a/test/bdd/features/publish-errors.feature +++ b/test/bdd/features/publish-errors.feature @@ -1,6 +1,6 @@ Feature: Publish errors test Background: Setup local blockchain, bootstraps and nodes - Given the blockchain is set up + Given the blockchains are set up And 1 bootstrap is running @publish-errors diff --git a/test/bdd/features/publish.feature b/test/bdd/features/publish.feature index 3cdc2c54f4..3e75dbef13 100644 --- a/test/bdd/features/publish.feature +++ b/test/bdd/features/publish.feature @@ -1,12 +1,14 @@ Feature: Release related tests Background: Setup local blockchain, bootstraps and nodes - Given the blockchain is set up + Given the blockchains are set up And 1 bootstrap is running @release - Scenario: Publishing a valid assertion - Given I set R0 to be 1 - And I set R1 to be 2 + Scenario: Publishing a valid assertion on both blockchains + Given I set R0 to be 1 on blockchain test1 + And I set R1 to be 2 on blockchain test1 + And I set R0 to be 1 on blockchain test2 + And I set R1 to be 2 on blockchain test2 And I setup 4 nodes And I wait for 5 seconds diff --git a/test/bdd/features/update-errors.feature b/test/bdd/features/update-errors.feature index c5e6c5659c..0fa082bc22 100644 --- a/test/bdd/features/update-errors.feature +++ b/test/bdd/features/update-errors.feature @@ -1,6 +1,6 @@ Feature: Update errors test Background: Setup local blockchain, bootstraps and nodes - Given the blockchain is set up + Given the blockchains are set up And 1 bootstrap is running @update-errors diff --git a/test/bdd/features/update.feature b/test/bdd/features/update.feature index fb1d42a81e..5289b04a50 100644 --- a/test/bdd/features/update.feature +++ b/test/bdd/features/update.feature @@ -1,13 +1,16 @@ Feature: Update asset test Background: Setup local blockchain, bootstraps and nodes - Given the blockchain is set up + Given the blockchains are set up And 1 bootstrap is running @release Scenario: Update an existing knowledge asset - Given I set R0 to be 1 - And I set R1 to be 2 - And I set finalizationCommitsNumber to be 2 + Given I set R0 to be 1 on blockchain test1 + And I set R1 to be 2 on blockchain test1 + And I set finalizationCommitsNumber to be 2 on blockchain test1 + And I set R0 to be 1 on blockchain test2 + And I set R1 to be 2 on blockchain test2 + And I set finalizationCommitsNumber to be 2 on blockchain test2 And I setup 4 nodes And I wait for 5 seconds diff --git a/test/bdd/steps/blockchain.mjs b/test/bdd/steps/blockchain.mjs index 9f84fe00d4..85fc7c9bb9 100644 --- a/test/bdd/steps/blockchain.mjs +++ b/test/bdd/steps/blockchain.mjs @@ -3,41 +3,25 @@ import { expect } from 'chai'; import fs from 'fs'; import LocalBlockchain from './lib/local-blockchain.mjs'; -Given(/^the blockchain is set up$/, { timeout: 240_000 }, function blockchainSetup(done) { - this.logger.log('Starting blockchain'); - expect(this.state.localBlockchain, "localBlockchain shouldn't be defined").to.be.equal(null); - const blockchainConsole = new console.Console( - fs.createWriteStream(`${this.state.scenarionLogDir}/blockchain.log`), - ); +Given(/^the blockchains are set up$/, { timeout: 240_000 }, function blockchainSetup(done) { - this.state.localBlockchain = new LocalBlockchain(); - this.state.localBlockchain - .initialize(blockchainConsole) - .then(() => { - done(); - }) - .catch((error) => done(error)); -}); - -Given(/^the blockchain is set up on port (\d+) and on port (\d+)$/, { timeout: 240_000 }, function blockchainSetup(port1, port2, done) { - this.logger.log(`Starting local blockchain on port: ${port1} and port: ${port2}`); + const blockchains = [ + {name: 'test1', port: 8545}, + {name: 'test2', port: 9545} + ] - const blockchainConsole1 = new console.Console( - fs.createWriteStream(`${this.state.scenarionLogDir}/blockchain${port1}.log`), - ); - const blockchainConsole2 = new console.Console( - fs.createWriteStream(`${this.state.scenarionLogDir}/blockchain${port2}.log`), - ); const promises = []; - const localBlockchain1 = new LocalBlockchain(); - this.state.localBlockchains.push(localBlockchain1); - - const localBlockchain2 = new LocalBlockchain(); - this.state.localBlockchains.push(localBlockchain2); + blockchains.forEach((blockchain)=>{ + this.logger.log(`Starting local blockchain ${blockchain.name} on port: ${blockchain.port}`); + const blockchainConsole = new console.Console( + fs.createWriteStream(`${this.state.scenarionLogDir}/blockchain-${blockchain.name}.log`), + ); + const localBlockchain = new LocalBlockchain(); + this.state.localBlockchains[blockchain.name] = localBlockchain; - promises.push(localBlockchain1.initialize(port1, blockchainConsole1)); - promises.push(localBlockchain2.initialize(port2, blockchainConsole2)); + promises.push(localBlockchain.initialize(blockchain.port, blockchainConsole)); + }) Promise.all(promises).then(()=>{ done(); diff --git a/test/bdd/steps/common.mjs b/test/bdd/steps/common.mjs index 5a09f88575..cca0609efb 100644 --- a/test/bdd/steps/common.mjs +++ b/test/bdd/steps/common.mjs @@ -245,17 +245,26 @@ Given(/^I wait for (\d+) seconds$/, { timeout: 100000 }, async function waitFor( await sleep(seconds * 1000); }); -Given(/^I set R1 to be (\d+)$/, { timeout: 100000 }, async function waitFor(r1) { - this.logger.log(`I set R1 to be ${r1}`); - await this.state.localBlockchain.setR1(r1); +Given(/^I set R1 to be (\d+) on blockchain ([^"]*)$/, { timeout: 100000 }, async function waitFor(r1, blockchain) { + if (!this.state.localBlockchains[blockchain]) { + throw Error(`Unknown blockchain ${blockchain}`); + } + this.logger.log(`I set R1 to be ${r1} on blockchain ${blockchain}`); + await this.state.localBlockchains[blockchain].setR1(r1); }); -Given(/^I set R0 to be (\d+)$/, { timeout: 100000 }, async function waitFor(r0) { - this.logger.log(`I set R0 to be ${r0}`); - await this.state.localBlockchain.setR0(r0); +Given(/^I set R0 to be (\d+) on blockchain ([^"]*)$/, { timeout: 100000 }, async function waitFor(r0, blockchain) { + if (!this.state.localBlockchains[blockchain]) { + throw Error(`Unknown blockchain ${blockchain}`); + } + this.logger.log(`I set R0 to be ${r0} on blockchain ${blockchain}`); + await this.state.localBlockchains[blockchain].setR0(r0); }); -Given(/^I set finalizationCommitsNumber to be (\d+)$/, { timeout: 100000 }, async function waitFor(finalizationCommitsNumber) { - this.logger.log(`I set finalizationCommitsNumber to be ${finalizationCommitsNumber}`); - await this.state.localBlockchain.setFinalizationCommitsNumber(finalizationCommitsNumber); +Given(/^I set finalizationCommitsNumber to be (\d+) on blockchain ([^"]*)$/, { timeout: 100000 }, async function waitFor(finalizationCommitsNumber, blockchain) { + if (!this.state.localBlockchains[blockchain]) { + throw Error(`Unknown blockchain ${blockchain}`); + } + this.logger.log(`I set finalizationCommitsNumber to be ${finalizationCommitsNumber} on blockchain ${blockchain}`); + await this.state.localBlockchains[blockchain].setFinalizationCommitsNumber(finalizationCommitsNumber); }); diff --git a/test/bdd/steps/lib/state.mjs b/test/bdd/steps/lib/state.mjs index 0730d927c0..a4a98ad675 100644 --- a/test/bdd/steps/lib/state.mjs +++ b/test/bdd/steps/lib/state.mjs @@ -8,7 +8,10 @@ const state = { // this is local blockchain object look at test/bdd/steps/lib/local-blockchain.js localBlockchain: {}, // this is local blockchain object look at test/bdd/steps/lib/local-blockchain.js - localBlockchains: [], + localBlockchains: { + test1: {}, + test2: {} + }, // array of nodes nodes: { 0: { From 9ff9747d3407947f4bdd922c8643ff6e5df57178 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 27 Oct 2023 16:37:52 +0200 Subject: [PATCH 04/72] Add second hardhat in local setup --- config/config.json | 13 +++++++++++++ .../.origintrail_noderc_template.json | 13 +++++++++---- .../local-network-setup/generate-config-files.js | 15 ++++++++++++++- tools/local-network-setup/run-local-blockchain.js | 3 ++- .../setup-macos-environment.sh | 12 +++++++++++- 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/config/config.json b/config/config.json index e2122c4d8f..daf4c38af0 100644 --- a/config/config.json +++ b/config/config.json @@ -125,6 +125,19 @@ "initialAskAmount": 0.2 } }, + "hardhat2": { + "enabled": true, + "package": "./blockchain/implementation/hardhat/hardhat-service.js", + "config": { + "blockchainTitle": "hardhat2", + "networkId": "ganache::testnet", + "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "rpcEndpoints": ["http://localhost:9545"], + "evmManagementPublicKey": "0x1B420da5f7Be66567526E32bc68ab29F1A63765A", + "initialStakeAmount": 50000, + "initialAskAmount": 0.2 + } + }, "otp": { "enabled": false, "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", diff --git a/tools/local-network-setup/.origintrail_noderc_template.json b/tools/local-network-setup/.origintrail_noderc_template.json index e1cbacf528..95566e84bf 100644 --- a/tools/local-network-setup/.origintrail_noderc_template.json +++ b/tools/local-network-setup/.origintrail_noderc_template.json @@ -145,6 +145,14 @@ "evmOperationalWalletPrivateKey": "0x02b39cac1532bef9dba3e36ec32d3de1e9a88f1dda597d3ac6e2130aed9adc4e" } }, + "hardhat2": { + "package": "./blockchain/implementation/hardhat/hardhat-service.js", + "config": { + "evmOperationalWalletPublicKey": "0xd6879C0A03aDD8cFc43825A42a3F3CF44DB7D2b9", + "rpcEndpoints": [], + "evmOperationalWalletPrivateKey": "0x02b39cac1532bef9dba3e36ec32d3de1e9a88f1dda597d3ac6e2130aed9adc4e" + } + }, "otp": { "config": { "evmOperationalWalletPublicKey": "...", @@ -171,9 +179,6 @@ } }, "auth": { - "ipWhitelist": [ - "::1", - "127.0.0.1" - ] + "ipWhitelist": ["::1", "127.0.0.1"] } } diff --git a/tools/local-network-setup/generate-config-files.js b/tools/local-network-setup/generate-config-files.js index 74ccc1cf1d..f98e8fdaea 100644 --- a/tools/local-network-setup/generate-config-files.js +++ b/tools/local-network-setup/generate-config-files.js @@ -102,7 +102,20 @@ function generateBlockchainConfig(templateBlockchainConfig, nodeIndex) { blockchainConfig.implementation[blockchain].config = { ...blockchainConfig.implementation[blockchain].config, hubContractAddress, - rpcEndpoints: [process.env.RPC_ENDPOINT], + rpcEndpoints: [process.env.RPC_ENDPOINT1], + evmOperationalWalletPublicKey: publicKeys[nodeIndex], + evmOperationalWalletPrivateKey: privateKeys[nodeIndex], + evmManagementWalletPublicKey: publicKeys[publicKeys.length - 1 - nodeIndex], + evmManagementWalletPrivateKey: privateKeys[privateKeys.length - 1 - nodeIndex], + sharesTokenName: `LocalNode${nodeIndex}`, + sharesTokenSymbol: `LN${nodeIndex}`, + }; + + // TODO: Don't use string + blockchainConfig.implementation['hardhat2'].config = { + ...blockchainConfig.implementation['hardhat2'].config, + hubContractAddress, + rpcEndpoints: [process.env.RPC_ENDPOINT2], evmOperationalWalletPublicKey: publicKeys[nodeIndex], evmOperationalWalletPrivateKey: privateKeys[nodeIndex], evmManagementWalletPublicKey: publicKeys[publicKeys.length - 1 - nodeIndex], diff --git a/tools/local-network-setup/run-local-blockchain.js b/tools/local-network-setup/run-local-blockchain.js index 40b9333f26..40477fee84 100644 --- a/tools/local-network-setup/run-local-blockchain.js +++ b/tools/local-network-setup/run-local-blockchain.js @@ -1,5 +1,6 @@ import LocalBlockchain from '../../test/bdd/steps/lib/local-blockchain.mjs'; +const port = parseInt(process.argv[2], 10); const localBlockchain = new LocalBlockchain(); -await localBlockchain.initialize(console); +await localBlockchain.initialize(port, console); diff --git a/tools/local-network-setup/setup-macos-environment.sh b/tools/local-network-setup/setup-macos-environment.sh index edf36af4a3..5211b09142 100755 --- a/tools/local-network-setup/setup-macos-environment.sh +++ b/tools/local-network-setup/setup-macos-environment.sh @@ -51,7 +51,17 @@ then osascript -e "tell app \"Terminal\" do script \"cd $pathToOtNode - node tools/local-network-setup/run-local-blockchain.js\" + node tools/local-network-setup/run-local-blockchain.js 8545\" + end tell" + echo Waiting for hardhat to start and contracts deployment + + echo ================================ + echo ====== Starting hardhat 2 ====== + echo ================================ + + osascript -e "tell app \"Terminal\" + do script \"cd $pathToOtNode + node tools/local-network-setup/run-local-blockchain.js 9545\" end tell" echo Waiting for hardhat to start and contracts deployment fi From 692b2bf14e99dbee644bbc481807d28f6e0bba24 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Mon, 30 Oct 2023 12:42:38 +0100 Subject: [PATCH 05/72] Added multichain user configuration migration, added operational db migration for ual extension --- ot-node.js | 23 +++++++++ src/migration/ual-extension-migration.js | 50 +++++++++++++++++++ .../20233010122500-update-blockchain-id.js | 14 ++++++ 3 files changed, 87 insertions(+) create mode 100644 src/migration/ual-extension-migration.js create mode 100644 src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js diff --git a/ot-node.js b/ot-node.js index 716669d52d..2ebfcdaa8b 100644 --- a/ot-node.js +++ b/ot-node.js @@ -19,6 +19,7 @@ import MarkOldBlockchainEventsAsProcessedMigration from './src/migration/mark-ol import TripleStoreMetadataMigration from './src/migration/triple-store-metadata-migration.js'; import RemoveOldEpochCommandsMigration from './src/migration/remove-old-epoch-commands-migration.js'; import PendingStorageMigration from './src/migration/pending-storage-migration.js'; +import UalExtensionMigration from './src/migration/ual-extension-migration.js'; const require = createRequire(import.meta.url); const pjson = require('./package.json'); @@ -38,6 +39,7 @@ class OTNode { await this.removeUpdateFile(); await this.executeTripleStoreUserConfigurationMigration(); await this.executeTelemetryModuleUserConfigurationMigration(); + await this.executeUalExtensionMigration(); this.logger.info(' ██████╗ ████████╗███╗ ██╗ ██████╗ ██████╗ ███████╗'); this.logger.info('██╔═══██╗╚══██╔══╝████╗ ██║██╔═══██╗██╔══██╗██╔════╝'); this.logger.info('██║ ██║ ██║ ██╔██╗ ██║██║ ██║██║ ██║█████╗'); @@ -341,6 +343,27 @@ class OTNode { } } + async executeUalExtensionMigration() { + if ( + process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT || + process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST + ) + return; + const repositoryModuleManager = this.container.resolve('repositoryModuleManager'); + + const migration = new UalExtensionMigration( + 'ualExtensionMigration', + this.logger, + this.config, + repositoryModuleManager, + ); + if (!(await migration.migrationAlreadyExecuted())) { + await migration.migrate(); + this.logger.info('Node will now restart!'); + this.stop(1); + } + } + async executeTripleStoreUserConfigurationMigration() { if ( process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT || diff --git a/src/migration/ual-extension-migration.js b/src/migration/ual-extension-migration.js new file mode 100644 index 0000000000..a3ca8de584 --- /dev/null +++ b/src/migration/ual-extension-migration.js @@ -0,0 +1,50 @@ +import appRootPath from 'app-root-path'; +import path from 'path'; +import BaseMigration from './base-migration.js'; + +class UalExtensionMigration extends BaseMigration { + constructor(migrationName, logger, config, repositoryModuleManager) { + super(migrationName, logger, config); + this.repositoryModuleManager = repositoryModuleManager; + } + + async executeMigration() { + const configurationFolderPath = path.join(appRootPath.path, '..'); + const configurationFilePath = path.join( + configurationFolderPath, + this.config.configFilename, + ); + + const userConfiguration = await this.fileService.readFile(configurationFilePath, true); + + const promises = []; + + // user configuration migration + if (userConfiguration.modules.blockchain.implementation) { + for (const implementationName in userConfiguration.modules.blockchain.implementation) { + const implementation = + userConfiguration.modules.block.implementation[implementationName]; + + if (implementation.chainId || implementation.blockchainId) { + // todo update chainId and blockchain Id or remove them totally + implementation.chainId = ''; + promises.add( + this.fileService.writeContentsToFile( + configurationFolderPath, + this.config.configFilename, + JSON.stringify(userConfiguration, null, 4), + ), + ); + } + } + } + + this.logger.trace('Ual extension user migration completed'); + + // triple store migration + + await Promise.all(promises); + } +} + +export default UalExtensionMigration; diff --git a/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js new file mode 100644 index 0000000000..da0d42f0b9 --- /dev/null +++ b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js @@ -0,0 +1,14 @@ +/* import { NODE_ENVIRONMENTS } from '../../../../../constants/constants.js'; + +// todo add real chain id +const chainIds = { + [NODE_ENVIRONMENTS.TESTNET]: 1234, + [NODE_ENVIRONMENTS.MAINNET]: 4321, + [NODE_ENVIRONMENTS.DEVELOPMENT]: 5678, +}; +const chainId = chainIds[process.env.NODE_ENV]; + +export async function up({ context: { queryInterface } }) {} + +export async function down({ context: { queryInterface } }) {} +*/ From fdcd958738d2c6a0f0ebfe4b4f7ed42068f26e8a Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Mon, 30 Oct 2023 21:37:26 +0100 Subject: [PATCH 06/72] Update nodes setup --- config/config.json | 2 +- test/bdd/steps/common.mjs | 125 +++++++++++++++++++++++---------- test/utilities/steps-utils.mjs | 67 +++++++++++------- 3 files changed, 127 insertions(+), 67 deletions(-) diff --git a/config/config.json b/config/config.json index e2122c4d8f..d7ad181302 100644 --- a/config/config.json +++ b/config/config.json @@ -317,7 +317,7 @@ "blockchainTitle": "hardhat-test-2", "networkId": "hardhat::testnet2", "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", - "rpcEndpoints": ["http://localhost:8545"], + "rpcEndpoints": ["http://localhost:9545"], "initialStakeAmount": 50000, "initialAskAmount": 0.2 } diff --git a/test/bdd/steps/common.mjs b/test/bdd/steps/common.mjs index cca0609efb..5d901b1ab8 100644 --- a/test/bdd/steps/common.mjs +++ b/test/bdd/steps/common.mjs @@ -5,7 +5,7 @@ import { setTimeout as sleep } from 'timers/promises'; import DkgClientHelper from '../../utilities/dkg-client-helper.mjs'; import StepsUtils from '../../utilities/steps-utils.mjs'; -import FileService from "../../../src/service/file-service.js"; +import FileService from '../../../src/service/file-service.js'; const stepsUtils = new StepsUtils(); @@ -14,21 +14,30 @@ Given( { timeout: 30000 }, function nodeSetup(nodeCount, done) { this.logger.log(`I setup ${nodeCount} node${nodeCount !== 1 ? 's' : ''}`); - const wallets = this.state.localBlockchain.getWallets(); + const wallets = {}; + Object.keys(this.state.localBlockchains).forEach((localBlockchain) => { + wallets[localBlockchain] = this.state.localBlockchains[localBlockchain].getWallets(); + }); const currentNumberOfNodes = Object.keys(this.state.nodes).length; let nodesStarted = 0; for (let i = 0; i < nodeCount; i += 1) { const nodeIndex = currentNumberOfNodes + i; - const wallet = wallets[nodeIndex + 1]; - const managementWallet = wallets[nodeIndex + 1 + Math.floor(wallets.length / 2)]; + const nodeWallets = Object.keys(wallets).map((localBlockchain) => { + return wallets[localBlockchain][nodeIndex + 1]; + }); + const nodeManagementWallets = Object.keys(wallets).map((localBlockchain) => { + return wallets[localBlockchain][ + nodeIndex + 1 + Math.floor(wallets[localBlockchain].length / 2) + ]; + }); const rpcPort = 8901 + nodeIndex; const networkPort = 9001 + nodeIndex; const nodeName = `origintrail-test-${nodeIndex}`; const sharesTokenName = `origintrail-test-${nodeIndex}`; const sharesTokenSymbol = `OT-T-${nodeIndex}`; const nodeConfiguration = stepsUtils.createNodeConfiguration( - wallet, - managementWallet, + nodeWallets, + nodeManagementWallets, nodeIndex, nodeName, rpcPort, @@ -55,9 +64,14 @@ Given( endpoint: 'http://localhost', port: rpcPort, blockchain: { - name: 'hardhat', - publicKey: wallet.address, - privateKey: wallet.privateKey, + name: 'hardhat-test1', + publicKey: nodeWallets[0].address, + privateKey: nodeManagementWallets[0].privateKey, + }, + blockchain: { + name: 'hardhat-test2', + publicKey: nodeWallets[1].address, + privateKey: nodeManagementWallets[1].privateKey, }, maxNumberOfRetries: 5, frequency: 2, @@ -68,7 +82,10 @@ Given( forkedNode, configuration: nodeConfiguration, nodeRpcUrl: `http://localhost:${rpcPort}`, - fileService: new FileService({config: nodeConfiguration, logger: this.logger}), + fileService: new FileService({ + config: nodeConfiguration, + logger: this.logger, + }), }; } nodesStarted += 1; @@ -88,18 +105,26 @@ Given( expect(nodeCount).to.be.equal(1); // Currently not supported more. this.logger.log('Initializing bootstrap node'); const nodeIndex = Object.keys(this.state.nodes).length; - const wallets = this.state.localBlockchain.getWallets(); - const wallet = wallets[nodeIndex]; - const managementWallet = - this.state.localBlockchain.getWallets()[nodeIndex + Math.floor(wallets.length / 2)]; + const wallets = {}; + Object.keys(this.state.localBlockchains).forEach((localBlockchain) => { + wallets[localBlockchain] = this.state.localBlockchains[localBlockchain].getWallets(); + }); + const nodeWallets = Object.keys(wallets).map((localBlockchain) => { + return wallets[localBlockchain][nodeIndex]; + }); + const nodeManagementWallets = Object.keys(wallets).map((localBlockchain) => { + return wallets[localBlockchain][ + nodeIndex + Math.floor(wallets[localBlockchain].length / 2) + ]; + }); const rpcPort = 8900; const networkPort = 9000; const nodeName = 'origintrail-test-bootstrap'; const sharesTokenName = `${nodeName}-${nodeIndex}`; const sharesTokenSymbol = `OT-B-${nodeIndex}`; const nodeConfiguration = stepsUtils.createNodeConfiguration( - wallet, - managementWallet, + nodeWallets, + nodeManagementWallets, nodeIndex, nodeName, rpcPort, @@ -132,7 +157,10 @@ Given( forkedNode, configuration: nodeConfiguration, nodeRpcUrl: `http://localhost:${rpcPort}`, - fileService: new FileService({config: nodeConfiguration, logger: this.logger}), + fileService: new FileService({ + config: nodeConfiguration, + logger: this.logger, + }), }); } done(); @@ -210,7 +238,10 @@ Given( forkedNode, configuration: nodeConfiguration, nodeRpcUrl: `http://localhost:${rpcPort}`, - fileService: new FileService({config: nodeConfiguration, logger: this.logger}), + fileService: new FileService({ + config: nodeConfiguration, + logger: this.logger, + }), }; } done(); @@ -245,26 +276,42 @@ Given(/^I wait for (\d+) seconds$/, { timeout: 100000 }, async function waitFor( await sleep(seconds * 1000); }); -Given(/^I set R1 to be (\d+) on blockchain ([^"]*)$/, { timeout: 100000 }, async function waitFor(r1, blockchain) { - if (!this.state.localBlockchains[blockchain]) { - throw Error(`Unknown blockchain ${blockchain}`); - } - this.logger.log(`I set R1 to be ${r1} on blockchain ${blockchain}`); - await this.state.localBlockchains[blockchain].setR1(r1); -}); +Given( + /^I set R1 to be (\d+) on blockchain ([^"]*)$/, + { timeout: 100000 }, + async function waitFor(r1, blockchain) { + if (!this.state.localBlockchains[blockchain]) { + throw Error(`Unknown blockchain ${blockchain}`); + } + this.logger.log(`I set R1 to be ${r1} on blockchain ${blockchain}`); + await this.state.localBlockchains[blockchain].setR1(r1); + }, +); -Given(/^I set R0 to be (\d+) on blockchain ([^"]*)$/, { timeout: 100000 }, async function waitFor(r0, blockchain) { - if (!this.state.localBlockchains[blockchain]) { - throw Error(`Unknown blockchain ${blockchain}`); - } - this.logger.log(`I set R0 to be ${r0} on blockchain ${blockchain}`); - await this.state.localBlockchains[blockchain].setR0(r0); -}); +Given( + /^I set R0 to be (\d+) on blockchain ([^"]*)$/, + { timeout: 100000 }, + async function waitFor(r0, blockchain) { + if (!this.state.localBlockchains[blockchain]) { + throw Error(`Unknown blockchain ${blockchain}`); + } + this.logger.log(`I set R0 to be ${r0} on blockchain ${blockchain}`); + await this.state.localBlockchains[blockchain].setR0(r0); + }, +); -Given(/^I set finalizationCommitsNumber to be (\d+) on blockchain ([^"]*)$/, { timeout: 100000 }, async function waitFor(finalizationCommitsNumber, blockchain) { - if (!this.state.localBlockchains[blockchain]) { - throw Error(`Unknown blockchain ${blockchain}`); - } - this.logger.log(`I set finalizationCommitsNumber to be ${finalizationCommitsNumber} on blockchain ${blockchain}`); - await this.state.localBlockchains[blockchain].setFinalizationCommitsNumber(finalizationCommitsNumber); -}); +Given( + /^I set finalizationCommitsNumber to be (\d+) on blockchain ([^"]*)$/, + { timeout: 100000 }, + async function waitFor(finalizationCommitsNumber, blockchain) { + if (!this.state.localBlockchains[blockchain]) { + throw Error(`Unknown blockchain ${blockchain}`); + } + this.logger.log( + `I set finalizationCommitsNumber to be ${finalizationCommitsNumber} on blockchain ${blockchain}`, + ); + await this.state.localBlockchains[blockchain].setFinalizationCommitsNumber( + finalizationCommitsNumber, + ); + }, +); diff --git a/test/utilities/steps-utils.mjs b/test/utilities/steps-utils.mjs index e17a5eb646..f05b9e3d04 100644 --- a/test/utilities/steps-utils.mjs +++ b/test/utilities/steps-utils.mjs @@ -9,8 +9,8 @@ class StepsUtils { } createNodeConfiguration( - wallet, - managementWallet, + nodeWallets, + nodeManagementWallets, nodeIndex, nodeName, rpcPort, @@ -24,11 +24,24 @@ class StepsUtils { blockchain: { implementation: { hardhat: { + enabled: false, + }, + 'hardhat-test1': { config: { - evmOperationalWalletPublicKey: wallet.address, - evmOperationalWalletPrivateKey: wallet.privateKey, - evmManagementWalletPublicKey: managementWallet.address, - evmManagementWalletPrivateKey: managementWallet.privateKey, + evmOperationalWalletPublicKey: nodeWallets[0].address, + evmOperationalWalletPrivateKey: nodeWallets[0].privateKey, + evmManagementWalletPublicKey: nodeManagementWallets[0].address, + evmManagementWalletPrivateKey: nodeManagementWallets[0].privateKey, + sharesTokenName, + sharesTokenSymbol, + }, + }, + 'hardhat-test2': { + config: { + evmOperationalWalletPublicKey: nodeWallets[1].address, + evmOperationalWalletPrivateKey: nodeWallets[1].privateKey, + evmManagementWalletPublicKey: nodeManagementWallets[1].address, + evmManagementWalletPrivateKey: nodeManagementWallets[1].privateKey, sharesTokenName, sharesTokenSymbol, }, @@ -63,30 +76,30 @@ class StepsUtils { 'ot-blazegraph': { config: { repositories: { - "privateCurrent": { - "url": "http://localhost:9999", - "name": "private-current", - "username": "admin", - "password": "" + privateCurrent: { + url: 'http://localhost:9999', + name: 'private-current', + username: 'admin', + password: '', + }, + privateHistory: { + url: 'http://localhost:9999', + name: 'private-history', + username: 'admin', + password: '', }, - "privateHistory": { - "url": "http://localhost:9999", - "name": "private-history", - "username": "admin", - "password": "" + publicCurrent: { + url: 'http://localhost:9999', + name: 'public-current', + username: 'admin', + password: '', }, - "publicCurrent": { - "url": "http://localhost:9999", - "name": "public-current", - "username": "admin", - "password": "" + publicHistory: { + url: 'http://localhost:9999', + name: 'public-history', + username: 'admin', + password: '', }, - "publicHistory": { - "url": "http://localhost:9999", - "name": "public-history", - "username": "admin", - "password": "" - } }, }, }, From d3f35545a23511831d46825c53e67757c8711a66 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 31 Oct 2023 10:43:56 +0100 Subject: [PATCH 07/72] Add kill all local blockchains --- package.json | 2 +- test/bdd/steps/hooks.mjs | 42 +++++++++++++++---------- test/bdd/steps/lib/local-blockchain.mjs | 8 +++-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index d4f40344a9..fd9d14195d 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "lint-staged": "lint-staged", "create-account-mapping-signature": "node tools/ot-parachain-account-mapping/create-account-mapping-signature.js ", "start:local_blockchain": "npm explore dkg-evm-module -- npm run dev -- --port", - "kill:local_blockchain": "npx kill-port 8545", + "kill:local_blockchain": "npx kill-port --port", "test:bdd": "cucumber-js --fail-fast --format progress --format-options '{\"colorsEnabled\": true}' test/bdd/ --import test/bdd/steps/ --exit", "test:unit": "nyc --all mocha --exit $(find test/unit -name '*.js')", "test:modules": "nyc --all mocha --exit $(find test/modules -name '*.js')", diff --git a/test/bdd/steps/hooks.mjs b/test/bdd/steps/hooks.mjs index 895c6ab24a..b62f088bdd 100644 --- a/test/bdd/steps/hooks.mjs +++ b/test/bdd/steps/hooks.mjs @@ -2,9 +2,9 @@ import 'dotenv/config'; import { Before, BeforeAll, After, AfterAll } from '@cucumber/cucumber'; import slugify from 'slugify'; import fs from 'fs'; -import mysql from "mysql2"; +import mysql from 'mysql2'; import { NODE_ENVIRONMENTS } from '../../../src/constants/constants.js'; -import TripleStoreModuleManager from "../../../src/modules/triple-store/triple-store-module-manager.js"; +import TripleStoreModuleManager from '../../../src/modules/triple-store/triple-store-module-manager.js'; process.env.NODE_ENV = NODE_ENVIRONMENTS.TEST; @@ -33,22 +33,26 @@ After(function afterMethod(testCase, done) { const promises = []; for (const key in this.state.nodes) { this.state.nodes[key].forkedNode.kill(); - tripleStoreConfiguration.push({modules: {tripleStore: this.state.nodes[key].configuration.modules.tripleStore}}); + tripleStoreConfiguration.push({ + modules: { tripleStore: this.state.nodes[key].configuration.modules.tripleStore }, + }); databaseNames.push(this.state.nodes[key].configuration.operationalDatabase.databaseName); const dataFolderPath = this.state.nodes[key].fileService.getDataFolderPath(); promises.push(this.state.nodes[key].fileService.removeFolder(dataFolderPath)); } this.state.bootstraps.forEach((node) => { node.forkedNode.kill(); - tripleStoreConfiguration.push({modules: {tripleStore: node.configuration.modules.tripleStore}}); + tripleStoreConfiguration.push({ + modules: { tripleStore: node.configuration.modules.tripleStore }, + }); databaseNames.push(node.configuration.operationalDatabase.databaseName); const dataFolderPath = node.fileService.getDataFolderPath(); promises.push(node.fileService.removeFolder(dataFolderPath)); }); - if (this.state.localBlockchain) { - this.logger.info('Stopping local blockchain!'); - promises.push(this.state.localBlockchain.stop()); - this.state.localBlockchain = null; + for (const localBlockchain in this.state.localBlockchains) { + this.logger.info(`Stopping local blockchain ${localBlockchain}!`); + promises.push(this.state.localBlockchains[localBlockchain].stop()); + this.state.localBlockchains[localBlockchain] = null; } this.logger.log('After test hook, cleaning repositories'); @@ -64,18 +68,24 @@ After(function afterMethod(testCase, done) { promises.push(con); tripleStoreConfiguration.forEach((config) => { promises.push(async () => { - const tripleStoreModuleManager = new TripleStoreModuleManager({config, logger: this.logger}); + const tripleStoreModuleManager = new TripleStoreModuleManager({ + config, + logger: this.logger, + }); await tripleStoreModuleManager.initialize(); for (const implementationName of tripleStoreModuleManager.getImplementationNames()) { - const {tripleStoreConfig} = tripleStoreModuleManager.getImplementation(implementationName); + const { tripleStoreConfig } = + tripleStoreModuleManager.getImplementation(implementationName); Object.keys(tripleStoreConfig.repositories).map(async (repository) => { - this.logger.log('Removing triple store configuration:', JSON.stringify(tripleStoreConfig, null, 4)); - await tripleStoreModuleManager.deleteRepository(implementationName, repository); - } - ) + this.logger.log( + 'Removing triple store configuration:', + JSON.stringify(tripleStoreConfig, null, 4), + ); + await tripleStoreModuleManager.deleteRepository(implementationName, repository); + }); } - }) - }) + }); + }); Promise.all(promises) .then(() => { con.end(); diff --git a/test/bdd/steps/lib/local-blockchain.mjs b/test/bdd/steps/lib/local-blockchain.mjs index 581c776c6d..0dfbc80a50 100644 --- a/test/bdd/steps/lib/local-blockchain.mjs +++ b/test/bdd/steps/lib/local-blockchain.mjs @@ -51,6 +51,7 @@ let startBlockchainProcess; class LocalBlockchain { async initialize(port, _console = console) { + this.port = port; startBlockchainProcess = exec(`npm run start:local_blockchain -- ${port}`); startBlockchainProcess.stdout.on('data', (data) => { _console.log(data); @@ -94,7 +95,7 @@ class LocalBlockchain { } async stop() { - const commandLog = await execSync('npm run kill:local_blockchain'); + const commandLog = await execSync(`npm run kill:local_blockchain -- ${this.port}`); console.log(`Killing hardhat process: ${commandLog.toString()}`); startBlockchainProcess.kill(); } @@ -138,7 +139,10 @@ class LocalBlockchain { async setFinalizationCommitsNumber(commitsNumber) { console.log(`Setting finalizationCommitsNumber in parameters storage to: ${commitsNumber}`); - const encodedData = this.ParametersStorageInterface.encodeFunctionData('setFinalizationCommitsNumber', [commitsNumber]); + const encodedData = this.ParametersStorageInterface.encodeFunctionData( + 'setFinalizationCommitsNumber', + [commitsNumber], + ); const parametersStorageAddress = await this.hubContract.getContractAddress( 'ParametersStorage', ); From 74677858d795b77ed8ed4c3c984fc74abcdd5d15 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Wed, 1 Nov 2023 11:25:36 +0100 Subject: [PATCH 08/72] Added triple store, user and operational db migration --- ot-node.js | 36 +++++++++--- src/migration/ual-extension-migration.js | 50 ----------------- .../ual-extension-triple-store-migration.js | 56 +++++++++++++++++++ ...-extension-user-configuration-migration.js | 35 ++++++++++++ .../20233010122500-update-blockchain-id.js | 31 ++++++++-- src/service/triple-store-service.js | 17 +++++- 6 files changed, 163 insertions(+), 62 deletions(-) delete mode 100644 src/migration/ual-extension-migration.js create mode 100644 src/migration/ual-extension-triple-store-migration.js create mode 100644 src/migration/ual-extension-user-configuration-migration.js diff --git a/ot-node.js b/ot-node.js index 2ebfcdaa8b..15468dfc65 100644 --- a/ot-node.js +++ b/ot-node.js @@ -19,7 +19,8 @@ import MarkOldBlockchainEventsAsProcessedMigration from './src/migration/mark-ol import TripleStoreMetadataMigration from './src/migration/triple-store-metadata-migration.js'; import RemoveOldEpochCommandsMigration from './src/migration/remove-old-epoch-commands-migration.js'; import PendingStorageMigration from './src/migration/pending-storage-migration.js'; -import UalExtensionMigration from './src/migration/ual-extension-migration.js'; +import UalExtensionTripleStoreMigration from './src/migration/ual-extension-triple-store-migration.js'; +import UalExtensionUserConfigurationMigration from './src/migration/ual-extension-user-configuration-migration.js'; const require = createRequire(import.meta.url); const pjson = require('./package.json'); @@ -39,7 +40,7 @@ class OTNode { await this.removeUpdateFile(); await this.executeTripleStoreUserConfigurationMigration(); await this.executeTelemetryModuleUserConfigurationMigration(); - await this.executeUalExtensionMigration(); + await this.executeUalExtensionUserConfigurationMigration(); this.logger.info(' ██████╗ ████████╗███╗ ██╗ ██████╗ ██████╗ ███████╗'); this.logger.info('██╔═══██╗╚══██╔══╝████╗ ██║██╔═══██╗██╔══██╗██╔════╝'); this.logger.info('██║ ██║ ██║ ██╔██╗ ██║██║ ██║██║ ██║█████╗'); @@ -56,6 +57,7 @@ class OTNode { this.initializeEventEmitter(); await this.initializeModules(); + await this.executeUalExtensionTripleStoreMigration(); await this.executePullShardingTableMigration(); await this.executePrivateAssetsMetadataMigration(); await this.executeRemoveAgreementStartEndTimeMigration(); @@ -343,19 +345,39 @@ class OTNode { } } - async executeUalExtensionMigration() { + async executeUalExtensionUserConfigurationMigration() { if ( process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT || process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST ) return; - const repositoryModuleManager = this.container.resolve('repositoryModuleManager'); - const migration = new UalExtensionMigration( - 'ualExtensionMigration', + const migration = new UalExtensionUserConfigurationMigration( + 'ualExtensionUserConfigurationMigration', this.logger, this.config, - repositoryModuleManager, + ); + if (!(await migration.migrationAlreadyExecuted())) { + await migration.migrate(); + this.logger.info('Node will now restart!'); + this.stop(1); + } + } + + async executeUalExtensionTripleStoreMigration() { + if ( + process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT || + process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST + ) + return; + + const tripleStoreService = this.container.resolve('tripleStoreService'); + + const migration = new UalExtensionTripleStoreMigration( + 'ualExtensionTripleStoreMigration', + this.logger, + this.config, + tripleStoreService, ); if (!(await migration.migrationAlreadyExecuted())) { await migration.migrate(); diff --git a/src/migration/ual-extension-migration.js b/src/migration/ual-extension-migration.js deleted file mode 100644 index a3ca8de584..0000000000 --- a/src/migration/ual-extension-migration.js +++ /dev/null @@ -1,50 +0,0 @@ -import appRootPath from 'app-root-path'; -import path from 'path'; -import BaseMigration from './base-migration.js'; - -class UalExtensionMigration extends BaseMigration { - constructor(migrationName, logger, config, repositoryModuleManager) { - super(migrationName, logger, config); - this.repositoryModuleManager = repositoryModuleManager; - } - - async executeMigration() { - const configurationFolderPath = path.join(appRootPath.path, '..'); - const configurationFilePath = path.join( - configurationFolderPath, - this.config.configFilename, - ); - - const userConfiguration = await this.fileService.readFile(configurationFilePath, true); - - const promises = []; - - // user configuration migration - if (userConfiguration.modules.blockchain.implementation) { - for (const implementationName in userConfiguration.modules.blockchain.implementation) { - const implementation = - userConfiguration.modules.block.implementation[implementationName]; - - if (implementation.chainId || implementation.blockchainId) { - // todo update chainId and blockchain Id or remove them totally - implementation.chainId = ''; - promises.add( - this.fileService.writeContentsToFile( - configurationFolderPath, - this.config.configFilename, - JSON.stringify(userConfiguration, null, 4), - ), - ); - } - } - } - - this.logger.trace('Ual extension user migration completed'); - - // triple store migration - - await Promise.all(promises); - } -} - -export default UalExtensionMigration; diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js new file mode 100644 index 0000000000..8230f936fc --- /dev/null +++ b/src/migration/ual-extension-triple-store-migration.js @@ -0,0 +1,56 @@ +import BaseMigration from './base-migration.js'; +import { TRIPLE_STORE_REPOSITORIES } from '../constants/constants.js'; + +class UalExtensionTripleStoreMigration extends BaseMigration { + constructor(migrationName, logger, config, tripleStoreService) { + super(migrationName, logger, config); + this.tripleStoreService = tripleStoreService; + } + + async executeMigration() { + const oldBlockchainId = 'did:dkg:hardhat'; + const newBlockchainId = 'did:dkg:hardhat:12345'; + + const updateSubjectQuery = ` + WITH + DELETE { + ?s ?p ?o + } + INSERT { + ?newSubject ?p ?o + } + WHERE { + ?s ?p ?o . + FILTER (STRSTARTS(STR(?s), "${oldBlockchainId}")) + BIND (IRI(REPLACE(STR(?s), "${oldBlockchainId}", "${newBlockchainId}")) AS ?newSubject) + } + `; + + await this.tripleStoreService.queryVoidAllRepositories( + TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT, + updateSubjectQuery, + ); + + const updateObjectQuery = ` + WITH + DELETE { + ?s ?p ?o + } + INSERT { + ?s ?p ?newObject + } + WHERE { + ?s ?p ?o . + FILTER(STRENDS(STR(?p), "blockchain")) + BIND ("${newBlockchainId}" AS ?newObject) + } + `; + + await this.tripleStoreService.queryVoidAllRepositories( + TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT, + updateObjectQuery, + ); + } +} + +export default UalExtensionTripleStoreMigration; diff --git a/src/migration/ual-extension-user-configuration-migration.js b/src/migration/ual-extension-user-configuration-migration.js new file mode 100644 index 0000000000..f3a00e2844 --- /dev/null +++ b/src/migration/ual-extension-user-configuration-migration.js @@ -0,0 +1,35 @@ +import appRootPath from 'app-root-path'; +import path from 'path'; +import BaseMigration from './base-migration.js'; + +class UalExtensionUserConfigurationMigration extends BaseMigration { + constructor(migrationName, logger, config, repositoryModuleManager) { + super(migrationName, logger, config); + this.repositoryModuleManager = repositoryModuleManager; + } + + async executeMigration() { + const configurationFolderPath = path.join(appRootPath.path, '..'); + const configurationFilePath = path.join( + configurationFolderPath, + this.config.configFilename, + ); + + const userConfiguration = await this.fileService.readFile(configurationFilePath, true); + + // user configuration migration + if (userConfiguration.modules.blockchain.implementation.otp) { + // todo add chain id in implementation name + userConfiguration.modules.blockchain.implementation['otp:'] = + userConfiguration.modules.blockchain.implementation.otp; + delete userConfiguration.modules.blockchain.implementation.otp; + await this.fileService.writeContentsToFile( + configurationFolderPath, + this.config.configFilename, + JSON.stringify(userConfiguration, null, 4), + ); + } + } +} + +export default UalExtensionUserConfigurationMigration; diff --git a/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js index da0d42f0b9..de6caeb652 100644 --- a/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js +++ b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js @@ -1,4 +1,4 @@ -/* import { NODE_ENVIRONMENTS } from '../../../../../constants/constants.js'; +import { NODE_ENVIRONMENTS } from '../../../../../constants/constants.js'; // todo add real chain id const chainIds = { @@ -8,7 +8,30 @@ const chainIds = { }; const chainId = chainIds[process.env.NODE_ENV]; -export async function up({ context: { queryInterface } }) {} +export async function up({ context: { queryInterface } }) { + await queryInterface.sequelize.query(` + update service_agreement set blockchain_id='otp:${chainId}' + `); -export async function down({ context: { queryInterface } }) {} -*/ + await queryInterface.sequelize.query(` + update blockchain_event set blockchain_id='otp:${chainId}' + `); + + await queryInterface.sequelize.query(` + update blockchain set blockchain_id='otp:${chainId}' + `); +} + +export async function down({ context: { queryInterface } }) { + await queryInterface.sequelize.query(` + update service_agreement set blockchain_id='otp' + `); + + await queryInterface.sequelize.query(` + update blockchain_event set blockchain_id='otp' + `); + + await queryInterface.sequelize.query(` + update blockchain set blockchain_id='otp' + `); +} diff --git a/src/service/triple-store-service.js b/src/service/triple-store-service.js index 7697dd5858..e55bcf51a9 100644 --- a/src/service/triple-store-service.js +++ b/src/service/triple-store-service.js @@ -1,6 +1,6 @@ import { formatAssertion } from 'assertion-tools'; -import { SCHEMA_CONTEXT } from '../constants/constants.js'; +import { SCHEMA_CONTEXT, TRIPLE_STORE_REPOSITORIES } from '../constants/constants.js'; class TripleStoreService { constructor(ctx) { @@ -228,6 +228,21 @@ class TripleStoreService { query, ); } + + async queryVoidAllRepositories(query) { + const queryPromises = []; + for (const repository in TRIPLE_STORE_REPOSITORIES) { + queryPromises.push( + this.tripleStoreModuleManager.queryVoid( + this.repositoryImplementations[repository], + repository, + query, + ), + ); + } + + return Promise.all(queryPromises); + } } export default TripleStoreService; From 74fa5e4b368c5c3267f7c469f816996441cf98cb Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Wed, 1 Nov 2023 11:53:38 +0100 Subject: [PATCH 09/72] Updated chain ids for all networks --- config/config.json | 6 +++--- .../ual-extension-triple-store-migration.js | 13 +++++++++--- ...-extension-user-configuration-migration.js | 20 ++++++++++++++----- .../20233010122500-update-blockchain-id.js | 7 +++---- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/config/config.json b/config/config.json index 7b490510c4..eec6045cbc 100644 --- a/config/config.json +++ b/config/config.json @@ -421,7 +421,7 @@ "blockchain": { "enabled": true, "implementation": { - "otp": { + "otp:20430": { "enabled": true, "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", "config": { @@ -575,9 +575,9 @@ }, "blockchain": { "enabled": true, - "defaultImplementation": "otp", + "defaultImplementation": "otp:2043", "implementation": { - "otp": { + "otp:2043": { "enabled": true, "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", "config": { diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 8230f936fc..682ec98793 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -1,5 +1,12 @@ import BaseMigration from './base-migration.js'; -import { TRIPLE_STORE_REPOSITORIES } from '../constants/constants.js'; +import { NODE_ENVIRONMENTS, TRIPLE_STORE_REPOSITORIES } from '../constants/constants.js'; + +const chainIds = { + [NODE_ENVIRONMENTS.TESTNET]: 20430, + [NODE_ENVIRONMENTS.MAINNET]: 2043, + [NODE_ENVIRONMENTS.DEVELOPMENT]: 2160, +}; +const chainId = chainIds[process.env.NODE_ENV]; class UalExtensionTripleStoreMigration extends BaseMigration { constructor(migrationName, logger, config, tripleStoreService) { @@ -8,8 +15,8 @@ class UalExtensionTripleStoreMigration extends BaseMigration { } async executeMigration() { - const oldBlockchainId = 'did:dkg:hardhat'; - const newBlockchainId = 'did:dkg:hardhat:12345'; + const oldBlockchainId = 'did:dkg:otp'; + const newBlockchainId = `${oldBlockchainId}:${chainId}`; const updateSubjectQuery = ` WITH diff --git a/src/migration/ual-extension-user-configuration-migration.js b/src/migration/ual-extension-user-configuration-migration.js index f3a00e2844..63bc5a84bf 100644 --- a/src/migration/ual-extension-user-configuration-migration.js +++ b/src/migration/ual-extension-user-configuration-migration.js @@ -1,6 +1,14 @@ import appRootPath from 'app-root-path'; import path from 'path'; import BaseMigration from './base-migration.js'; +import { NODE_ENVIRONMENTS } from '../constants/constants.js'; + +const chainIds = { + [NODE_ENVIRONMENTS.TESTNET]: 20430, + [NODE_ENVIRONMENTS.MAINNET]: 2043, + [NODE_ENVIRONMENTS.DEVELOPMENT]: 2160, +}; +const chainId = chainIds[process.env.NODE_ENV]; class UalExtensionUserConfigurationMigration extends BaseMigration { constructor(migrationName, logger, config, repositoryModuleManager) { @@ -17,12 +25,14 @@ class UalExtensionUserConfigurationMigration extends BaseMigration { const userConfiguration = await this.fileService.readFile(configurationFilePath, true); - // user configuration migration if (userConfiguration.modules.blockchain.implementation.otp) { - // todo add chain id in implementation name - userConfiguration.modules.blockchain.implementation['otp:'] = - userConfiguration.modules.blockchain.implementation.otp; - delete userConfiguration.modules.blockchain.implementation.otp; + const oldBlockchainId = 'otp'; + const newBlockchainId = `${oldBlockchainId}:${chainId}`; + userConfiguration.modules.blockchain.implementation.defaultImplementation = + newBlockchainId; + userConfiguration.modules.blockchain.implementation[newBlockchainId] = + userConfiguration.modules.blockchain.implementation[oldBlockchainId]; + delete userConfiguration.modules.blockchain.implementation[oldBlockchainId]; await this.fileService.writeContentsToFile( configurationFolderPath, this.config.configFilename, diff --git a/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js index de6caeb652..878fde5b19 100644 --- a/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js +++ b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js @@ -1,10 +1,9 @@ import { NODE_ENVIRONMENTS } from '../../../../../constants/constants.js'; -// todo add real chain id const chainIds = { - [NODE_ENVIRONMENTS.TESTNET]: 1234, - [NODE_ENVIRONMENTS.MAINNET]: 4321, - [NODE_ENVIRONMENTS.DEVELOPMENT]: 5678, + [NODE_ENVIRONMENTS.TESTNET]: 20430, + [NODE_ENVIRONMENTS.MAINNET]: 2043, + [NODE_ENVIRONMENTS.DEVELOPMENT]: 2160, }; const chainId = chainIds[process.env.NODE_ENV]; From 4d1c4de88e0cd2b6766a6f9801e73996f89ff114 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Wed, 1 Nov 2023 11:56:13 +0100 Subject: [PATCH 10/72] Added chain ids in constants --- src/constants/constants.js | 7 +++++++ src/migration/ual-extension-triple-store-migration.js | 11 +++-------- .../ual-extension-user-configuration-migration.js | 9 ++------- .../migrations/20233010122500-update-blockchain-id.js | 9 ++------- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/constants/constants.js b/src/constants/constants.js index 3fff5854e4..6c029e24cf 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -556,6 +556,13 @@ export const NODE_ENVIRONMENTS = { MAINNET: 'mainnet', }; +export const CHAIN_IDS = { + DEVELOPMENT: 2160, + TEST: 'test', + TESTNET: 20430, + MAINNET: 2043, +}; + export const CONTRACT_EVENT_FETCH_INTERVALS = { MAINNET: 10 * 1000, DEVELOPMENT: 4 * 1000, diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 682ec98793..69d96428aa 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -1,12 +1,7 @@ import BaseMigration from './base-migration.js'; -import { NODE_ENVIRONMENTS, TRIPLE_STORE_REPOSITORIES } from '../constants/constants.js'; - -const chainIds = { - [NODE_ENVIRONMENTS.TESTNET]: 20430, - [NODE_ENVIRONMENTS.MAINNET]: 2043, - [NODE_ENVIRONMENTS.DEVELOPMENT]: 2160, -}; -const chainId = chainIds[process.env.NODE_ENV]; +import { CHAIN_IDS, TRIPLE_STORE_REPOSITORIES } from '../constants/constants.js'; + +const chainId = CHAIN_IDS[process.env.NODE_ENV]; class UalExtensionTripleStoreMigration extends BaseMigration { constructor(migrationName, logger, config, tripleStoreService) { diff --git a/src/migration/ual-extension-user-configuration-migration.js b/src/migration/ual-extension-user-configuration-migration.js index 63bc5a84bf..8d8353c7cf 100644 --- a/src/migration/ual-extension-user-configuration-migration.js +++ b/src/migration/ual-extension-user-configuration-migration.js @@ -1,14 +1,9 @@ import appRootPath from 'app-root-path'; import path from 'path'; import BaseMigration from './base-migration.js'; -import { NODE_ENVIRONMENTS } from '../constants/constants.js'; +import { CHAIN_IDS } from '../constants/constants.js'; -const chainIds = { - [NODE_ENVIRONMENTS.TESTNET]: 20430, - [NODE_ENVIRONMENTS.MAINNET]: 2043, - [NODE_ENVIRONMENTS.DEVELOPMENT]: 2160, -}; -const chainId = chainIds[process.env.NODE_ENV]; +const chainId = CHAIN_IDS[process.env.NODE_ENV]; class UalExtensionUserConfigurationMigration extends BaseMigration { constructor(migrationName, logger, config, repositoryModuleManager) { diff --git a/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js index 878fde5b19..3df8683e0a 100644 --- a/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js +++ b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js @@ -1,11 +1,6 @@ -import { NODE_ENVIRONMENTS } from '../../../../../constants/constants.js'; +import { CHAIN_IDS } from '../../../../../constants/constants.js'; -const chainIds = { - [NODE_ENVIRONMENTS.TESTNET]: 20430, - [NODE_ENVIRONMENTS.MAINNET]: 2043, - [NODE_ENVIRONMENTS.DEVELOPMENT]: 2160, -}; -const chainId = chainIds[process.env.NODE_ENV]; +const chainId = CHAIN_IDS[process.env.NODE_ENV]; export async function up({ context: { queryInterface } }) { await queryInterface.sequelize.query(` From ebd0d3ae10b72e17d2c645409f5de37b1d583d7f Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Wed, 1 Nov 2023 12:52:43 +0100 Subject: [PATCH 11/72] Updated migrations and configuration with chain ids --- config/config.json | 204 +++++++++++++----- src/constants/constants.js | 6 +- .../ual-extension-triple-store-migration.js | 8 +- 3 files changed, 162 insertions(+), 56 deletions(-) diff --git a/config/config.json b/config/config.json index eec6045cbc..82b6a9d24d 100644 --- a/config/config.json +++ b/config/config.json @@ -112,58 +112,16 @@ "blockchain": { "enabled": true, "implementation": { - "hardhat": { + "hardhat:31337": { "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { - "blockchainTitle": "hardhat", - "networkId": "ganache::testnet", "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", "rpcEndpoints": ["http://localhost:8545"], "evmManagementPublicKey": "0x1B420da5f7Be66567526E32bc68ab29F1A63765A", "initialStakeAmount": 50000, "initialAskAmount": 0.2 } - }, - "otp": { - "enabled": false, - "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", - "config": { - "networkId": "otp::testnet", - "hubContractAddress": "0x707233a55bD035C6Bc732196CA4dbffa63CbA169", - "rpcEndpoints": ["https://lofar-tm-rpc.origin-trail.network"], - "initialStakeAmount": 50000, - "initialAskAmount": 2 - } - }, - "polygon": { - "enabled": false, - "package": "./blockchain/implementation/polygon/polygon-service.js", - "config": { - "networkId": "polygon::testnet", - "hubContractAddress": "0xdaa16AC171CfE8Df6F79C06E7EEAb2249E2C9Ec8", - "gasPriceOracleLink": "https://gasstation-mumbai.matic.today/v2", - "rpcEndpoints": [ - "https://matic-mumbai.chainstacklabs.com", - "https://rpc-mumbai.matic.today", - "https://matic-testnet-archive-rpc.bwarelabs.com" - ], - "evmManagementPublicKey": "0x1B420da5f7Be66567526E32bc68ab29F1A63765A", - "initialStakeAmount": 50000, - "initialAskAmount": 2 - } - }, - "rinkeby": { - "enabled": false, - "package": "./blockchain/implementation/polygon/eth-service.js", - "config": { - "networkId": "eth::rinkeby", - "hubContractAddress": "", - "gasPriceOracleLink": "", - "rpcEndpoints": [], - "initialStakeAmount": 50000, - "initialAskAmount": 2 - } } } }, @@ -286,12 +244,10 @@ "blockchain": { "enabled": true, "implementation": { - "hardhat": { + "hardhat:31337": { "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { - "blockchainTitle": "ganache", - "networkId": "ganache::testnet", "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", "rpcEndpoints": ["http://localhost:8545"], "initialStakeAmount": 50000, @@ -425,7 +381,6 @@ "enabled": true, "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", "config": { - "networkId": "parachain::testnet", "hubContractAddress": "0xBbfF7Ea6b2Addc1f38A0798329e12C08f03750A6", "rpcEndpoints": [ "https://lofar-testnet.origin-trail.network", @@ -491,6 +446,160 @@ "publicOperations": [] } }, + "devnet": { + "modules": { + "autoUpdater": { + "enabled": true, + "implementation": { + "ot-auto-updater": { + "enabled": true, + "package": "./auto-updater/implementation/ot-auto-updater.js", + "config": { + "branch": "v6/release/testnet" + } + } + } + }, + "network": { + "enabled": true, + "implementation": { + "libp2p-service": { + "enabled": true, + "package": "./network/implementation/libp2p-service.js", + "config": { + "dht": { + "kBucketSize": 20 + }, + "connectionManager": { + "autoDial": true, + "autoDialInterval": 10e3, + "dialTimeout": 2e3 + }, + "peerRouting": { + "refreshManager": { + "enabled": true, + "interval": 6e5, + "bootDelay": 2e3 + } + }, + "port": 9000, + "bootstrap": [ + "/ip4/64.225.99.151/tcp/9000/p2p/QmawsTRqaLPyLQ5PfStpFcpQW4bvNQ59zV1by2G5aJHuVn", + "/ip4/18.157.122.121/tcp/9000/p2p/QmfDebvsKNwCggBBmEWB43cAZtTa2umMsnRvBnMV4sY5th" + ] + } + } + } + }, + "httpClient": { + "enabled": true, + "implementation": { + "express-http-client": { + "enabled": true, + "package": "./http-client/implementation/express-http-client.js", + "config": { + "useSsl": false, + "port": 8900, + "sslKeyPath": "/root/certs/privkey.pem", + "sslCertificatePath": "/root/certs/fullchain.pem", + "rateLimiter": { + "timeWindowSeconds": 60, + "maxRequests": 10 + } + } + } + } + }, + "repository": { + "enabled": true, + "implementation": { + "sequelize-repository": { + "enabled": true, + "package": "./repository/implementation/sequelize/sequelize-repository.js", + "config": { + "database": "operationaldb", + "user": "root", + "password": "password", + "port": "3306", + "host": "localhost", + "dialect": "mysql", + "logging": false + } + } + } + }, + "blockchain": { + "enabled": true, + "implementation": { + "otp:2160": { + "enabled": true, + "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", + "config": { + "hubContractAddress": "0x833048F6e6BEa78E0AAdedeCd2Dc2231dda443FB", + "rpcEndpoints": [ + "https://lofar-tm-rpc.origin-trail.network", + "https://lofar.origintrail.network" + ] + } + } + } + }, + "validation": { + "enabled": true, + "implementation": { + "merkle-validation": { + "enabled": true, + "package": "./validation/implementation/merkle-validation.js", + "config": {} + } + } + }, + "tripleStore": { + "enabled": true, + "implementation": { + "ot-blazegraph": { + "enabled": false, + "package": "./triple-store/implementation/ot-blazegraph/ot-blazegraph.js", + "config": {} + }, + "ot-fuseki": { + "enabled": false, + "package": "./triple-store/implementation/ot-fuseki/ot-fuseki.js", + "config": {} + }, + "ot-graphdb": { + "enabled": false, + "package": "./triple-store/implementation/ot-graphdb/ot-graphdb.js", + "config": {} + } + } + }, + "telemetry": { + "enabled": true, + "implementation": { + "ot-telemetry": { + "enabled": true, + "package": "./telemetry/implementation/ot-telemetry.js", + "config": { + "sendTelemetryData": true, + "signalingServerUrl": "https://devnet-signaling.origin-trail.network/signal" + } + } + } + } + }, + "maximumAssertionSizeInKb": 2500, + "commandExecutorVerboseLoggingEnabled": false, + "appDataPath": "data", + "logLevel": "trace", + "auth": { + "ipBasedAuthEnabled": true, + "tokenBasedAuthEnabled": false, + "loggingEnabled": true, + "ipWhitelist": ["::1", "127.0.0.1"], + "publicOperations": [] + } + }, "mainnet": { "modules": { "autoUpdater": { @@ -581,7 +690,6 @@ "enabled": true, "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", "config": { - "networkId": "otp::mainnet", "hubContractAddress": "0x5fA7916c48Fe6D5F1738d12Ad234b78c90B4cAdA", "rpcEndpoints": [ "https://astrosat-parachain-rpc.origin-trail.network", diff --git a/src/constants/constants.js b/src/constants/constants.js index 6c029e24cf..254109bd8b 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -552,13 +552,15 @@ export const CONTRACT_EVENTS = { export const NODE_ENVIRONMENTS = { DEVELOPMENT: 'development', TEST: 'test', + DEVNET: 'devnet', TESTNET: 'testnet', MAINNET: 'mainnet', }; export const CHAIN_IDS = { - DEVELOPMENT: 2160, - TEST: 'test', + DEVELOPMENT: 31337, + TEST: 31337, + DEVNET: 2160, TESTNET: 20430, MAINNET: 2043, }; diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 69d96428aa..fb4b71d19a 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -12,7 +12,6 @@ class UalExtensionTripleStoreMigration extends BaseMigration { async executeMigration() { const oldBlockchainId = 'did:dkg:otp'; const newBlockchainId = `${oldBlockchainId}:${chainId}`; - const updateSubjectQuery = ` WITH DELETE { @@ -23,7 +22,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { } WHERE { ?s ?p ?o . - FILTER (STRSTARTS(STR(?s), "${oldBlockchainId}")) + FILTER (STRSTARTS(STR(?s), "${oldBlockchainId}/")) BIND (IRI(REPLACE(STR(?s), "${oldBlockchainId}", "${newBlockchainId}")) AS ?newSubject) } `; @@ -48,10 +47,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { } `; - await this.tripleStoreService.queryVoidAllRepositories( - TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT, - updateObjectQuery, - ); + await this.tripleStoreService.queryVoidAllRepositories(updateObjectQuery); } } From 15643fefe168d8b8bbd6d545e6b2b17879b08e2c Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Wed, 1 Nov 2023 13:34:52 +0100 Subject: [PATCH 12/72] Add multychain test for release --- config/config.json | 24 ---- test/bdd/features/get.feature | 78 +++++++++--- test/bdd/features/publish.feature | 6 +- test/bdd/features/update.feature | 14 ++- test/bdd/steps/api/datasets/requests.json | 142 +++++++++++----------- test/bdd/steps/api/get.mjs | 50 ++++---- test/bdd/steps/api/publish.mjs | 15 ++- test/bdd/steps/api/update.mjs | 15 ++- test/bdd/steps/common.mjs | 26 ++-- test/utilities/dkg-client-helper.mjs | 18 ++- test/utilities/steps-utils.mjs | 45 +++---- 11 files changed, 251 insertions(+), 182 deletions(-) diff --git a/config/config.json b/config/config.json index d7ad181302..7b490510c4 100644 --- a/config/config.json +++ b/config/config.json @@ -297,30 +297,6 @@ "initialStakeAmount": 50000, "initialAskAmount": 0.2 } - }, - "hardhat-test1": { - "enabled": true, - "package": "./blockchain/implementation/hardhat/hardhat-service.js", - "config": { - "blockchainTitle": "hardhat-test-1", - "networkId": "hardhat::testnet1", - "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", - "rpcEndpoints": ["http://localhost:8545"], - "initialStakeAmount": 50000, - "initialAskAmount": 0.2 - } - }, - "hardhat-test2": { - "enabled": true, - "package": "./blockchain/implementation/hardhat/hardhat-service.js", - "config": { - "blockchainTitle": "hardhat-test-2", - "networkId": "hardhat::testnet2", - "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", - "rpcEndpoints": ["http://localhost:9545"], - "initialStakeAmount": 50000, - "initialAskAmount": 0.2 - } } } }, diff --git a/test/bdd/features/get.feature b/test/bdd/features/get.feature index 203c898f98..8a51797c57 100644 --- a/test/bdd/features/get.feature +++ b/test/bdd/features/get.feature @@ -4,7 +4,7 @@ Feature: Get asset states test And 1 bootstrap is running @release - Scenario: Get first state of the updated knowledge asset + Scenario: Get first state of the updated knowledge asset on both blockchains Given I set R0 to be 1 on blockchain test1 And I set R1 to be 2 on blockchain test1 And I set finalizationCommitsNumber to be 2 on blockchain test1 @@ -14,20 +14,32 @@ Feature: Get asset states test And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test1 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED + + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test2 + And I wait for latest Publish to finalize + Then Latest Publish operation finished with status: COMPLETED + + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test1 + And I wait for latest Update to finalize + Then Latest Update operation finished with status: COMPLETED - When I call Update on the node 4 for the latest published UAL with validUpdate_1 + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test2 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - When I call Get directly on the node 4 with validGetFirstStateRequestBody + When I call Get directly on the node 4 with validGetFirstStateRequestBody on blockchain test1 + And I wait for latest resolve to finalize + Then Latest Get operation finished with status: COMPLETED + + When I call Get directly on the node 4 with validGetFirstStateRequestBody on blockchain test2 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED @release - Scenario: Get latest state of the updated knowledge asset + Scenario: Get latest state of the updated knowledge asset on both blockchains Given I set R0 to be 1 on blockchain test1 And I set R1 to be 2 on blockchain test1 And I set finalizationCommitsNumber to be 2 on blockchain test1 @@ -37,20 +49,32 @@ Feature: Get asset states test And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test1 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - When I call Update on the node 4 for the latest published UAL with validUpdate_1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test2 + And I wait for latest Publish to finalize + Then Latest Publish operation finished with status: COMPLETED + + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test1 + And I wait for latest Update to finalize + Then Latest Update operation finished with status: COMPLETED + + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test2 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED + + When I call Get directly on the node 4 with validGetUpdatedStateRequestBody on blockchain test1 + And I wait for latest resolve to finalize + Then Latest Get operation finished with status: COMPLETED - When I call Get directly on the node 4 with validGetUpdatedStateRequestBody + When I call Get directly on the node 4 with validGetUpdatedStateRequestBody on blockchain test2 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED @release - Scenario: Get all states of the knowledge asset that is updated 2 times + Scenario: Get all states of the knowledge asset that is updated 2 times on both blockchains Given I set R0 to be 1 on blockchain test1 And I set R1 to be 2 on blockchain test1 And I set finalizationCommitsNumber to be 2 on blockchain test1 @@ -60,28 +84,52 @@ Feature: Get asset states test And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test1 + And I wait for latest Publish to finalize + Then Latest Publish operation finished with status: COMPLETED + + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test2 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - When I call Update on the node 4 for the latest published UAL with validUpdate_1 + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test1 + And I wait for latest Update to finalize + Then Latest Update operation finished with status: COMPLETED + + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test2 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED And I wait for 30 seconds - When I call Update on the node 4 for the latest published UAL with validUpdate_2 + When I call Update on the node 4 for the latest published UAL with validUpdate_2 on blockchain test1 + And I wait for latest Update to finalize + Then Latest Update operation finished with status: COMPLETED + + When I call Update on the node 4 for the latest published UAL with validUpdate_2 on blockchain test2 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - When I call Get directly on the node 4 with getFirstStateRequestBody + When I call Get directly on the node 4 with getFirstStateRequestBody on blockchain test1 + And I wait for latest resolve to finalize + Then Latest Get operation finished with status: COMPLETED + + When I call Get directly on the node 4 with getFirstStateRequestBody on blockchain test2 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED - When I call Get directly on the node 4 with getSecondStateRequestBody + When I call Get directly on the node 4 with getSecondStateRequestBody on blockchain test1 + And I wait for latest resolve to finalize + Then Latest Get operation finished with status: COMPLETED + + When I call Get directly on the node 4 with getSecondStateRequestBody on blockchain test2 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED - When I call Get directly on the node 4 with getThirdStateRequestBody + When I call Get directly on the node 4 with getThirdStateRequestBody on blockchain test1 + And I wait for latest resolve to finalize + Then Latest Get operation finished with status: COMPLETED + + When I call Get directly on the node 4 with getThirdStateRequestBody on blockchain test2 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED diff --git a/test/bdd/features/publish.feature b/test/bdd/features/publish.feature index 3e75dbef13..21d49731b7 100644 --- a/test/bdd/features/publish.feature +++ b/test/bdd/features/publish.feature @@ -12,6 +12,10 @@ Feature: Release related tests And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validAssertion + When I call Publish on the node 4 with validAssertion on blockchain test1 + And I wait for latest Publish to finalize + Then Latest Publish operation finished with status: COMPLETED + + When I call Publish on the node 4 with validAssertion on blockchain test2 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED diff --git a/test/bdd/features/update.feature b/test/bdd/features/update.feature index 5289b04a50..fc8356b238 100644 --- a/test/bdd/features/update.feature +++ b/test/bdd/features/update.feature @@ -4,7 +4,7 @@ Feature: Update asset test And 1 bootstrap is running @release - Scenario: Update an existing knowledge asset + Scenario: Update an existing knowledge asset on both blockchains Given I set R0 to be 1 on blockchain test1 And I set R1 to be 2 on blockchain test1 And I set finalizationCommitsNumber to be 2 on blockchain test1 @@ -14,10 +14,18 @@ Feature: Update asset test And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test1 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - When I call Update on the node 4 for the latest published UAL with validUpdate_1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test2 + And I wait for latest Publish to finalize + Then Latest Publish operation finished with status: COMPLETED + + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test1 + And I wait for latest Update to finalize + Then Latest Update operation finished with status: COMPLETED + + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test2 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED diff --git a/test/bdd/steps/api/datasets/requests.json b/test/bdd/steps/api/datasets/requests.json index be7258046b..be4fbce7cd 100644 --- a/test/bdd/steps/api/datasets/requests.json +++ b/test/bdd/steps/api/datasets/requests.json @@ -1,73 +1,73 @@ { - "validPublishRequestBody": { - "assertionId": "0xc311cca6412f8453067ac7a04831af411b2963734d107541763c1ef7c8e56f65", - "assertion": [ - "_:c14n0 \"Born: April 30, 1916, Petoskey, Michigan, United States\" .", - "_:c14n0 \"Claude Elwood Shannon was an American mathematician, electrical engineer, and cryptographer known as the father of information theory. \" .", - "_:c14n0 \"Died: February 24, 2001, Medford, Massachusetts, United States\" .", - "_:c14n0 \"Claude Shànnon\" .", - "_:c14n0 ." - ], - "blockchain": "hardhat", - "contract": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07", - "tokenId": 0 - }, - "validGetFirstStateRequestBody": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", - "state": "0xe3a6733d7b999ca6f0d141afe3e38ac59223a4dfde7a5458932d2094ed4193cf" - }, - "validGetUpdatedStateRequestBody": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0" - }, - "getFirstStateRequestBody": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", - "state": "0xe3a6733d7b999ca6f0d141afe3e38ac59223a4dfde7a5458932d2094ed4193cf" - }, - "getSecondStateRequestBody": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", - "state": "0x591503a1c8ba4667dd7afd203025c1bf594d817d8eec71274fe960d69fb8584f" - }, - "getThirdStateRequestBody": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", - "state": "0x759c285786b95622dad67a6be857a4eec3d9ba0caec991ed4297629ae6abbc0d" - }, - "blockchainNotDefinedRequestBody": { - "publishType": "asset", - "assertionId": "0xc311cca6412f8453067ac7a04831af411b2963734d107541763c1ef7c8e56f65", - "assertion": [ - "_:c14n0 \"Born: April 30, 1916, Petoskey, Michigan, United States\" .", - "_:c14n0 \"Claude Elwood Shannon was an American mathematician, electrical engineer, and cryptographer known as the father of information theory. \" .", - "_:c14n0 \"Died: February 24, 2001, Medford, Massachusetts, United States\" .", - "_:c14n0 \"Claude Shànnon\" .", - "_:c14n0 ." - ], - "blockchain": null, - "contract": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07", - "tokenId": 0 - }, - "nonExistentUAL": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/1" - }, - "invalidUAL": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F/52b28595d31B441D079B2Ca07/1" - }, - "nonExistentState": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", - "state": -1 - }, - "invalidStateHash": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", - "state": "0x591503a1c8ba4667dd7afd203025c1bf594d817d8eec71274fe960d69fb8584e" - }, - "validUpdateRequestBody": { - "assertionId": "0x591503a1c8ba4667dd7afd203025c1bf594d817d8eec71274fe960d69fb8584f", - "assertion": [ - " .", - " \"TL\" .", - " ." - ], - "blockchain": "hardhat", - "contract": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07", - "tokenId": 0 - } + "validPublishRequestBody": { + "assertionId": "0xc311cca6412f8453067ac7a04831af411b2963734d107541763c1ef7c8e56f65", + "assertion": [ + "_:c14n0 \"Born: April 30, 1916, Petoskey, Michigan, United States\" .", + "_:c14n0 \"Claude Elwood Shannon was an American mathematician, electrical engineer, and cryptographer known as the father of information theory. \" .", + "_:c14n0 \"Died: February 24, 2001, Medford, Massachusetts, United States\" .", + "_:c14n0 \"Claude Shànnon\" .", + "_:c14n0 ." + ], + "blockchain": "test2", + "contract": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07", + "tokenId": 0 + }, + "validGetFirstStateRequestBody": { + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "state": "0xe3a6733d7b999ca6f0d141afe3e38ac59223a4dfde7a5458932d2094ed4193cf" + }, + "validGetUpdatedStateRequestBody": { + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0" + }, + "getFirstStateRequestBody": { + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "state": "0xe3a6733d7b999ca6f0d141afe3e38ac59223a4dfde7a5458932d2094ed4193cf" + }, + "getSecondStateRequestBody": { + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "state": "0x591503a1c8ba4667dd7afd203025c1bf594d817d8eec71274fe960d69fb8584f" + }, + "getThirdStateRequestBody": { + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "state": "0x759c285786b95622dad67a6be857a4eec3d9ba0caec991ed4297629ae6abbc0d" + }, + "blockchainNotDefinedRequestBody": { + "publishType": "asset", + "assertionId": "0xc311cca6412f8453067ac7a04831af411b2963734d107541763c1ef7c8e56f65", + "assertion": [ + "_:c14n0 \"Born: April 30, 1916, Petoskey, Michigan, United States\" .", + "_:c14n0 \"Claude Elwood Shannon was an American mathematician, electrical engineer, and cryptographer known as the father of information theory. \" .", + "_:c14n0 \"Died: February 24, 2001, Medford, Massachusetts, United States\" .", + "_:c14n0 \"Claude Shànnon\" .", + "_:c14n0 ." + ], + "blockchain": null, + "contract": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07", + "tokenId": 0 + }, + "nonExistentUAL": { + "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/1" + }, + "invalidUAL": { + "id": "did:dkg:hardhat/0xB0D4afd8879eD9F/52b28595d31B441D079B2Ca07/1" + }, + "nonExistentState": { + "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "state": -1 + }, + "invalidStateHash": { + "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "state": "0x591503a1c8ba4667dd7afd203025c1bf594d817d8eec71274fe960d69fb8584e" + }, + "validUpdateRequestBody": { + "assertionId": "0x591503a1c8ba4667dd7afd203025c1bf594d817d8eec71274fe960d69fb8584f", + "assertion": [ + " .", + " \"TL\" .", + " ." + ], + "blockchain": "test2", + "contract": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07", + "tokenId": 0 + } } diff --git a/test/bdd/steps/api/get.mjs b/test/bdd/steps/api/get.mjs index 47ea8df7a1..7f3a0ed794 100644 --- a/test/bdd/steps/api/get.mjs +++ b/test/bdd/steps/api/get.mjs @@ -28,18 +28,31 @@ When( ); When( - /^I call Get directly on the node (\d+) with ([^"]*)/, + /^I call Get directly on the node (\d+) with ([^"]*) on blockchain ([^"]*)/, { timeout: 30000 }, - async function getFromNode(node, requestName) { - this.logger.log(`I call get directly on the node ${node}`); + async function getFromNode(node, requestName, blockchain) { + this.logger.log(`I call get directly on the node ${node} on blockchain ${blockchain}`); + + expect( + !!this.state.localBlockchains[blockchain], + `Blockchain with name ${blockchain} not found`, + ).to.be.equal(true); + expect( !!requests[requestName], `Request body with name: ${requestName} not found!`, ).to.be.equal(true); - const requestBody = requests[requestName]; + + const requestBody = JSON.parse(JSON.stringify(requests[requestName])); + this.logger.log(`Start: ${JSON.stringify(requestBody, null, 4)}`); + requestBody.id = requestBody.id.replace('blockchain', blockchain); + this.logger.log(`Replace: ${JSON.stringify(requestBody, null, 4)}`); try { - const result = await httpApiHelper.get(this.state.nodes[node - 1].nodeRpcUrl, requestBody); + const result = await httpApiHelper.get( + this.state.nodes[node - 1].nodeRpcUrl, + requestBody, + ); const { operationId } = result.data; this.state.latestGetData = { nodeId: node - 1, @@ -51,24 +64,15 @@ When( }, ); -Then( - /^It should fail with status code (\d+)/, - function checkLatestError(expectedStatusCode) { - const expectedStatusCodeInt = parseInt(expectedStatusCode, 10); - assert( - this.state.latestError, - 'No error occurred' - ); - assert( - this.state.latestError.statusCode, - 'No status code in error' - ); - assert( - this.state.latestError.statusCode === expectedStatusCodeInt, - `Expected request to fail with status code ${expectedStatusCodeInt}, but it failed with another code.` - ); - }, -); +Then(/^It should fail with status code (\d+)/, function checkLatestError(expectedStatusCode) { + const expectedStatusCodeInt = parseInt(expectedStatusCode, 10); + assert(this.state.latestError, 'No error occurred'); + assert(this.state.latestError.statusCode, 'No status code in error'); + assert( + this.state.latestError.statusCode === expectedStatusCodeInt, + `Expected request to fail with status code ${expectedStatusCodeInt}, but it failed with another code.`, + ); +}); When('I wait for latest Get to finalize', { timeout: 80000 }, async function getFinalize() { this.logger.log('I wait for latest get to finalize'); diff --git a/test/bdd/steps/api/publish.mjs b/test/bdd/steps/api/publish.mjs index 1b18aea9b7..18b6bf3bb3 100644 --- a/test/bdd/steps/api/publish.mjs +++ b/test/bdd/steps/api/publish.mjs @@ -10,18 +10,25 @@ const requests = JSON.parse(await readFile('test/bdd/steps/api/datasets/requests const httpApiHelper = new HttpApiHelper(); When( - /^I call Publish on the node (\d+) with ([^"]*)/, + /^I call Publish on the node (\d+) with ([^"]*) on blockchain ([^"]*)/, { timeout: 120000 }, - async function publish(node, assertionName) { - this.logger.log(`I call publish route on the node ${node}`); + async function publish(node, assertionName, blockchain) { + this.logger.log(`I call publish route on the node ${node} on blockchain ${blockchain}`); + + expect( + !!this.state.localBlockchains[blockchain], + `Blockchain with name ${blockchain} not found`, + ).to.be.equal(true); + expect( !!assertions[assertionName], `Assertion with name: ${assertionName} not found!`, ).to.be.equal(true); const assertion = assertions[assertionName]; + const options = this.state.nodes[node - 1].clientBlockchainOptions[blockchain]; const result = await this.state.nodes[node - 1].client - .publish(assertion) + .publish(assertion, options) .catch((error) => { assert.fail(`Error while trying to publish assertion. ${error}`); }); diff --git a/test/bdd/steps/api/update.mjs b/test/bdd/steps/api/update.mjs index ebf4c46513..4740083d75 100644 --- a/test/bdd/steps/api/update.mjs +++ b/test/bdd/steps/api/update.mjs @@ -10,10 +10,16 @@ const requests = JSON.parse(await readFile('test/bdd/steps/api/datasets/requests const httpApiHelper = new HttpApiHelper(); When( - /^I call Update on the node (\d+) for the latest published UAL with ([^"]*)/, + /^I call Update on the node (\d+) for the latest published UAL with ([^"]*) on blockchain ([^"]*)/, { timeout: 120000 }, - async function update(node, assertionName) { - this.logger.log(`I call update route on the node ${node}`); + async function update(node, assertionName, blockchain) { + this.logger.log(`I call update route on the node ${node} on blockchain ${blockchain}`); + + expect( + !!this.state.localBlockchains[blockchain], + `Blockchain with name ${blockchain} not found`, + ).to.be.equal(true); + expect( !!assertions[assertionName], `Assertion with name: ${assertionName} not found!`, @@ -21,8 +27,9 @@ When( const assertion = assertions[assertionName]; const { UAL } = this.state.latestPublishData; + const options = this.state.nodes[node - 1].clientBlockchainOptions[blockchain]; const result = await this.state.nodes[node - 1].client - .update(UAL, assertion) + .update(UAL, assertion, options) .catch((error) => { assert.fail(`Error while trying to update assertion. ${error}`); }); diff --git a/test/bdd/steps/common.mjs b/test/bdd/steps/common.mjs index 5d901b1ab8..aa1a74757f 100644 --- a/test/bdd/steps/common.mjs +++ b/test/bdd/steps/common.mjs @@ -36,6 +36,7 @@ Given( const sharesTokenName = `origintrail-test-${nodeIndex}`; const sharesTokenSymbol = `OT-T-${nodeIndex}`; const nodeConfiguration = stepsUtils.createNodeConfiguration( + this.state.localBlockchains, nodeWallets, nodeManagementWallets, nodeIndex, @@ -63,20 +64,23 @@ Given( const client = new DkgClientHelper({ endpoint: 'http://localhost', port: rpcPort, - blockchain: { - name: 'hardhat-test1', - publicKey: nodeWallets[0].address, - privateKey: nodeManagementWallets[0].privateKey, - }, - blockchain: { - name: 'hardhat-test2', - publicKey: nodeWallets[1].address, - privateKey: nodeManagementWallets[1].privateKey, - }, maxNumberOfRetries: 5, frequency: 2, contentType: 'all', }); + let clientBlockchainOptions = {}; + Object.keys(this.state.localBlockchains).forEach((localBlockchain, index) => { + clientBlockchainOptions[localBlockchain] = { + blockchain: { + name: localBlockchain, + publicKey: nodeWallets[index].address, + privateKey: nodeWallets[index].privateKey, + rpc: `http://localhost:${this.state.localBlockchains[localBlockchain].port}`, + hubContract: '0x5FbDB2315678afecb367f032d93F642f64180aa3', + }, + }; + }); + this.state.nodes[nodeIndex] = { client, forkedNode, @@ -86,6 +90,7 @@ Given( config: nodeConfiguration, logger: this.logger, }), + clientBlockchainOptions, }; } nodesStarted += 1; @@ -123,6 +128,7 @@ Given( const sharesTokenName = `${nodeName}-${nodeIndex}`; const sharesTokenSymbol = `OT-B-${nodeIndex}`; const nodeConfiguration = stepsUtils.createNodeConfiguration( + this.state.localBlockchains, nodeWallets, nodeManagementWallets, nodeIndex, diff --git a/test/utilities/dkg-client-helper.mjs b/test/utilities/dkg-client-helper.mjs index bc18895fcd..6b41114a0a 100644 --- a/test/utilities/dkg-client-helper.mjs +++ b/test/utilities/dkg-client-helper.mjs @@ -10,30 +10,36 @@ class DkgClientHelper { return this.client.node.info(); } - async publish(data) { - const options = { + async publish(data, userOptions = {}) { + const defaultOptions = { visibility: 'public', epochsNum: 5, hashFunctionId: CONTENT_ASSET_HASH_FUNCTION_ID, }; + const options = { ...defaultOptions, ...userOptions }; + return this.client.asset.create(data, options); } - async update(ual, assertion) { - const options = { + async update(ual, assertion, userOptions = {}) { + const defaultOptions = { hashFunctionId: CONTENT_ASSET_HASH_FUNCTION_ID, }; + const options = { ...defaultOptions, ...userOptions }; + return this.client.asset.update(ual, assertion, options); } - async get(ual, state) { - const options = { + async get(ual, state, userOptions = {}) { + const defaultOptions = { state, validate: true, }; + const options = { ...defaultOptions, ...userOptions }; + return this.client.asset.get(ual, options); } diff --git a/test/utilities/steps-utils.mjs b/test/utilities/steps-utils.mjs index f05b9e3d04..2cfd456ed7 100644 --- a/test/utilities/steps-utils.mjs +++ b/test/utilities/steps-utils.mjs @@ -9,6 +9,7 @@ class StepsUtils { } createNodeConfiguration( + localBlockchains, nodeWallets, nodeManagementWallets, nodeIndex, @@ -19,33 +20,13 @@ class StepsUtils { sharesTokenSymbol, bootstrap = false, ) { - return { + let config = { modules: { blockchain: { implementation: { hardhat: { enabled: false, }, - 'hardhat-test1': { - config: { - evmOperationalWalletPublicKey: nodeWallets[0].address, - evmOperationalWalletPrivateKey: nodeWallets[0].privateKey, - evmManagementWalletPublicKey: nodeManagementWallets[0].address, - evmManagementWalletPrivateKey: nodeManagementWallets[0].privateKey, - sharesTokenName, - sharesTokenSymbol, - }, - }, - 'hardhat-test2': { - config: { - evmOperationalWalletPublicKey: nodeWallets[1].address, - evmOperationalWalletPrivateKey: nodeWallets[1].privateKey, - evmManagementWalletPublicKey: nodeManagementWallets[1].address, - evmManagementWalletPrivateKey: nodeManagementWallets[1].privateKey, - sharesTokenName, - sharesTokenSymbol, - }, - }, }, }, network: { @@ -138,6 +119,28 @@ class StepsUtils { name: nodeName, }, }; + + Object.keys(localBlockchains).forEach((localBlockchain, index) => { + config.modules.blockchain.implementation[localBlockchain] = { + enabled: true, + package: './blockchain/implementation/hardhat/hardhat-service.js', + config: { + blockchainTitle: localBlockchain, + networkId: `hardhat::${localBlockchain}`, + hubContractAddress: '0x5FbDB2315678afecb367f032d93F642f64180aa3', + rpcEndpoints: [`http://localhost:${localBlockchains[localBlockchain].port}`], + initialStakeAmount: 50000, + initialAskAmount: 0.2, + evmOperationalWalletPublicKey: nodeWallets[index].address, + evmOperationalWalletPrivateKey: nodeWallets[index].privateKey, + evmManagementWalletPublicKey: nodeManagementWallets[index].address, + evmManagementWalletPrivateKey: nodeManagementWallets[index].privateKey, + sharesTokenName, + sharesTokenSymbol, + }, + }; + }); + return config; } } export default StepsUtils; From 82611d530e9cb61f14dd252c2767a8bf7abdd773 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 9 Nov 2023 10:30:23 +0100 Subject: [PATCH 13/72] Multichain local setup --- .../local-network-setup/.origintrail_noderc_template.json | 7 ++----- tools/local-network-setup/setup-macos-environment.sh | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/local-network-setup/.origintrail_noderc_template.json b/tools/local-network-setup/.origintrail_noderc_template.json index e1cbacf528..0b5fcb9818 100644 --- a/tools/local-network-setup/.origintrail_noderc_template.json +++ b/tools/local-network-setup/.origintrail_noderc_template.json @@ -137,7 +137,7 @@ "blockchain": { "defaultImplementation": "hardhat", "implementation": { - "hardhat": { + "hardhat:31337": { "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { "evmOperationalWalletPublicKey": "0xd6879C0A03aDD8cFc43825A42a3F3CF44DB7D2b9", @@ -171,9 +171,6 @@ } }, "auth": { - "ipWhitelist": [ - "::1", - "127.0.0.1" - ] + "ipWhitelist": ["::1", "127.0.0.1"] } } diff --git a/tools/local-network-setup/setup-macos-environment.sh b/tools/local-network-setup/setup-macos-environment.sh index edf36af4a3..4030e6a445 100755 --- a/tools/local-network-setup/setup-macos-environment.sh +++ b/tools/local-network-setup/setup-macos-environment.sh @@ -1,9 +1,9 @@ #!/bin/sh pathToOtNode=$(pwd) numberOfNodes=4 -network="hardhat" +network="hardhat:31337" tripleStore="ot-blazegraph" -availableNetworks=("hardhat") +availableNetworks=("hardhat:31337") export $(xargs < $pathToOtNode/.env) export ACCESS_KEY=$RPC_ENDPOINT # Check for script arguments @@ -43,7 +43,7 @@ while [ $# -gt 0 ]; do esac shift done -if [[ $network == hardhat ]] +if [[ $network == hardhat:31337 ]] then echo ================================ echo ====== Starting hardhat ====== From 248c6e0f5c147249bcedd0f11efb5da0dc3d8d66 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 9 Nov 2023 13:45:12 +0100 Subject: [PATCH 14/72] Add blockchainIdMiddleware --- src/controllers/http-api/http-api-router.js | 4 ++- .../http-client/http-client-module-manager.js | 7 +++-- .../implementation/express-http-client.js | 4 ++- .../middleware/blockchain-id-midleware.js | 30 +++++++++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 src/modules/http-client/implementation/middleware/blockchain-id-midleware.js diff --git a/src/controllers/http-api/http-api-router.js b/src/controllers/http-api/http-api-router.js index cadf110dfd..5e5edd016c 100644 --- a/src/controllers/http-api/http-api-router.js +++ b/src/controllers/http-api/http-api-router.js @@ -4,6 +4,7 @@ import { HTTP_API_ROUTES } from '../../constants/constants.js'; class HttpApiRouter { constructor(ctx) { this.httpClientModuleManager = ctx.httpClientModuleManager; + this.blockchainModuleManager = ctx.blockchainModuleManager; this.apiRoutes = HTTP_API_ROUTES; this.apiVersions = Object.keys(this.apiRoutes); @@ -36,7 +37,8 @@ class HttpApiRouter { } initializeBeforeMiddlewares() { - this.httpClientModuleManager.initializeBeforeMiddlewares(); + const blockchainImpelemntations = this.blockchainModuleManager.getImplementationNames(); + this.httpClientModuleManager.initializeBeforeMiddlewares(blockchainImpelemntations); } async initializeVersionedListeners() { diff --git a/src/modules/http-client/http-client-module-manager.js b/src/modules/http-client/http-client-module-manager.js index aef322cf6d..adbbb364d2 100644 --- a/src/modules/http-client/http-client-module-manager.js +++ b/src/modules/http-client/http-client-module-manager.js @@ -52,9 +52,12 @@ class HttpClientModuleManager extends BaseModuleManager { } } - initializeBeforeMiddlewares() { + initializeBeforeMiddlewares(blockchainImpelemntations) { if (this.initialized) { - return this.getImplementation().module.initializeBeforeMiddlewares(this.authService); + return this.getImplementation().module.initializeBeforeMiddlewares( + this.authService, + blockchainImpelemntations, + ); } } diff --git a/src/modules/http-client/implementation/express-http-client.js b/src/modules/http-client/implementation/express-http-client.js index cd37b698c2..9f141fc1ca 100644 --- a/src/modules/http-client/implementation/express-http-client.js +++ b/src/modules/http-client/implementation/express-http-client.js @@ -7,6 +7,7 @@ import requestValidationMiddleware from './middleware/request-validation-middlew import rateLimiterMiddleware from './middleware/rate-limiter-middleware.js'; import authenticationMiddleware from './middleware/authentication-middleware.js'; import authorizationMiddleware from './middleware/authorization-middleware.js'; +import blockchainIdMiddleware from './middleware/blockchain-id-midleware.js'; import { BYTES_IN_MEGABYTE, MAX_FILE_SIZE } from '../../../constants/constants.js'; class ExpressHttpClient { @@ -66,11 +67,12 @@ class ExpressHttpClient { return middlewares; } - initializeBeforeMiddlewares(authService) { + initializeBeforeMiddlewares(authService, blockchainImpelemntations) { this._initializeCorsMiddleware(); this.app.use(authenticationMiddleware(authService)); this.app.use(authorizationMiddleware(authService)); this._initializeBaseMiddlewares(); + this.app.use(blockchainIdMiddleware(blockchainImpelemntations)); } initializeAfterMiddlewares() { diff --git a/src/modules/http-client/implementation/middleware/blockchain-id-midleware.js b/src/modules/http-client/implementation/middleware/blockchain-id-midleware.js new file mode 100644 index 0000000000..42d6759ef9 --- /dev/null +++ b/src/modules/http-client/implementation/middleware/blockchain-id-midleware.js @@ -0,0 +1,30 @@ +function addBlockchainId(blockchain, blockchainImplementations) { + let updatedBlockchain = blockchain; + + if (blockchain?.split(':').length === 1) { + for (const implementation of blockchainImplementations) { + if (implementation.split(':')[0] === blockchain) { + updatedBlockchain = implementation; + break; + } + } + } + + return updatedBlockchain; +} + +export default function blockchainIdMiddleware(blockchainImplementations) { + return (req, res, next) => { + if (req.method === 'GET') + req.query.blockchain = addBlockchainId(req.query.blockchain, blockchainImplementations); + else if (Array.isArray(req.body)) { + for (const element of req.body) { + element.blockchain = addBlockchainId(element.blockchain, blockchainImplementations); + } + } else { + req.body.blockchain = addBlockchainId(req.body.blockchain, blockchainImplementations); + } + + next(); + }; +} From 26208bbd110225e6f93ae968c0996fce724975f0 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 9 Nov 2023 14:24:17 +0100 Subject: [PATCH 15/72] Add resolveUAL handles blockchain without id --- src/service/ual-service.js | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/service/ual-service.js b/src/service/ual-service.js index bd89578f35..ce77e77dcf 100644 --- a/src/service/ual-service.js +++ b/src/service/ual-service.js @@ -31,15 +31,40 @@ class UALService { if (!this.isContract(contract)) { throw new Error(`Invalid contract format: ${contract}`); } - return { blockchain: parts[0], contract, tokenId: Number(parts[2]) }; + let blockchainUAL = parts[0]; + if (blockchainUAL.split(':').length === 1) { + for (const implementation of this.blockchainModuleManager.getImplementationNames()) { + if (implementation.split(':')[0] === blockchainUAL) { + blockchainUAL = implementation; + break; + } + } + } + return { blockchain: blockchainUAL, contract, tokenId: Number(parts[2]) }; } if (parts.length === 2) { const parts2 = parts[0].split(':'); - const contract = parts2[1]; - if (!this.isContract(contract)) { - throw new Error(`Invalid contract format: ${contract}`); + if (parts2.length === 3) { + const contract = parts2[2]; + if (!this.isContract(contract)) { + throw new Error(`Invalid contract format: ${contract}`); + } + return { blockchain: parts2[0] + parts2[1], contract, tokenId: Number(parts[1]) }; + } + if (parts2.length === 2) { + let blockchainWithId; + for (const implementation of this.blockchainModuleManager.getImplementationNames()) { + if (implementation.split(':')[0] === blockchainWithId) { + blockchainWithId = implementation; + break; + } + } + const contract = parts2[1]; + if (!this.isContract(contract)) { + throw new Error(`Invalid contract format: ${contract}`); + } + return { blockchain: blockchainWithId, contract, tokenId: Number(parts[1]) }; } - return { blockchain: parts2[0], contract, tokenId: Number(parts[1]) }; } throw new Error(`UAL doesn't have correct format: ${ual}`); From e8415b04158fadce3eabe1347c128fd9b495970d Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 9 Nov 2023 16:18:47 +0100 Subject: [PATCH 16/72] Add backwards compatibility for old UAL for RPC requests --- src/controllers/rpc/rpc-router.js | 10 ++++++++-- .../network/implementation/libp2p-service.js | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/controllers/rpc/rpc-router.js b/src/controllers/rpc/rpc-router.js index 7773e29de2..a40108010a 100644 --- a/src/controllers/rpc/rpc-router.js +++ b/src/controllers/rpc/rpc-router.js @@ -1,6 +1,8 @@ class RpcRouter { constructor(ctx) { this.networkModuleManager = ctx.networkModuleManager; + this.blockchainModuleManager = ctx.blockchainModuleManager; + this.protocolService = ctx.protocolService; this.logger = ctx.logger; @@ -21,9 +23,13 @@ class RpcRouter { const operation = this.protocolService.toOperation(protocol); const handleRequest = `${version}HandleRequest`; const controller = `${operation}RpcController`; + const blockchainImplementations = this.blockchainModuleManager.getImplementationNames(); - this.networkModuleManager.handleMessage(protocol, (message, remotePeerId) => - this[controller][handleRequest](message, remotePeerId, protocol), + this.networkModuleManager.handleMessage( + protocol, + blockchainImplementations, + (message, remotePeerId) => + this[controller][handleRequest](message, remotePeerId, protocol), ); } } diff --git a/src/modules/network/implementation/libp2p-service.js b/src/modules/network/implementation/libp2p-service.js index da50372d0a..fab7479b89 100644 --- a/src/modules/network/implementation/libp2p-service.js +++ b/src/modules/network/implementation/libp2p-service.js @@ -194,7 +194,7 @@ class Libp2pService { return this.node.peerId; } - handleMessage(protocol, handler) { + handleMessage(protocol, blockchainImplementations, handler) { this.logger.info(`Enabling network protocol: ${protocol}`); this.node.handle(protocol, async (handlerProps) => { @@ -245,11 +245,25 @@ class Libp2pService { this.logger.debug( `Receiving message from ${peerIdString} to ${this.config.id}: protocol: ${protocol}, messageType: ${message.header.messageType};`, ); - await handler(message, peerIdString); + const modifiedMessage = this.modifyMessage(message, blockchainImplementations); + await handler(modifiedMessage, peerIdString); } }); } + modifyMessage(message, blockchainImplementations) { + const modifiedMessage = message; + if (modifiedMessage.data.blockchain?.split(':').length === 1) { + for (const implementation of blockchainImplementations) { + if (implementation.split(':')[0] === modifiedMessage.data.blockchain) { + modifiedMessage.data.blockchain = implementation; + break; + } + } + } + return modifiedMessage; + } + updateSessionStream(operationId, keywordUuid, peerIdString, stream) { this.logger.trace( `Storing new session stream for remotePeerId: ${peerIdString} with operation id: ${operationId}`, From a6bcb6ea2c2a44569728d748799736d7bd906871 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 9 Nov 2023 16:21:21 +0100 Subject: [PATCH 17/72] Remove unneeded code --- src/modules/blockchain/blockchain-module-manager.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/blockchain/blockchain-module-manager.js b/src/modules/blockchain/blockchain-module-manager.js index 55ea81e810..2d4b714e91 100644 --- a/src/modules/blockchain/blockchain-module-manager.js +++ b/src/modules/blockchain/blockchain-module-manager.js @@ -383,10 +383,10 @@ class BlockchainModuleManager extends BaseModuleManager { callImplementationFunction(blockchain, functionName, args = []) { if (blockchain) { - const split = blockchain.split(':'); - const [name] = split; - if (this.getImplementation(name)) { - return this.getImplementation(name).module[functionName](...args); + // const split = blockchain.split(':'); + // const [name] = split; + if (this.getImplementation(blockchain)) { + return this.getImplementation(blockchain).module[functionName](...args); } } else { return this.getImplementation().module[functionName](...args); From 2b113634b68efcfd3bd7a6c45732d9522483045b Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 9 Nov 2023 16:25:14 +0100 Subject: [PATCH 18/72] Add ual-service isUAL support blockchain with id --- src/service/ual-service.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/service/ual-service.js b/src/service/ual-service.js index ce77e77dcf..afa894239f 100644 --- a/src/service/ual-service.js +++ b/src/service/ual-service.js @@ -15,12 +15,21 @@ class UALService { const parts = ual.replace('did:', '').replace('dkg:', '').split('/'); if (parts.length === 3) { // eslint-disable-next-line no-restricted-globals - return this.isContract(parts[1]) && !isNaN(Number(parts[2])); + return this.isContract(parts[1]) && !Number.isNaN(Number(parts[2])); } if (parts.length === 2) { const parts2 = parts[0].split(':'); // eslint-disable-next-line no-restricted-globals - return parts2.length === 2 && this.isContract(parts2[1]) && !isNaN(Number(parts[1])); + if (parts2.length === 3) { + return ( + parts2.length === 2 && + this.isContract(parts2[2]) && + !Number.isNaN(Number(parts[1])) + ); + } + return ( + parts2.length === 2 && this.isContract(parts2[1]) && !Number.isNaN(Number(parts[1])) + ); } } From 3be7fa7d9a206d29cbdf703decbeb285c3fd89e7 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 9 Nov 2023 16:43:47 +0100 Subject: [PATCH 19/72] Add bdd test support new blockchain naming --- test/utilities/steps-utils.mjs | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/utilities/steps-utils.mjs b/test/utilities/steps-utils.mjs index e17a5eb646..29e2b13d21 100644 --- a/test/utilities/steps-utils.mjs +++ b/test/utilities/steps-utils.mjs @@ -23,7 +23,7 @@ class StepsUtils { modules: { blockchain: { implementation: { - hardhat: { + 'hardhat:31337': { config: { evmOperationalWalletPublicKey: wallet.address, evmOperationalWalletPrivateKey: wallet.privateKey, @@ -63,30 +63,30 @@ class StepsUtils { 'ot-blazegraph': { config: { repositories: { - "privateCurrent": { - "url": "http://localhost:9999", - "name": "private-current", - "username": "admin", - "password": "" + privateCurrent: { + url: 'http://localhost:9999', + name: 'private-current', + username: 'admin', + password: '', }, - "privateHistory": { - "url": "http://localhost:9999", - "name": "private-history", - "username": "admin", - "password": "" + privateHistory: { + url: 'http://localhost:9999', + name: 'private-history', + username: 'admin', + password: '', }, - "publicCurrent": { - "url": "http://localhost:9999", - "name": "public-current", - "username": "admin", - "password": "" + publicCurrent: { + url: 'http://localhost:9999', + name: 'public-current', + username: 'admin', + password: '', + }, + publicHistory: { + url: 'http://localhost:9999', + name: 'public-history', + username: 'admin', + password: '', }, - "publicHistory": { - "url": "http://localhost:9999", - "name": "public-history", - "username": "admin", - "password": "" - } }, }, }, From 419728f451753da94db72353e3b10b2a3dc5aba8 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 17 Nov 2023 15:16:35 +0100 Subject: [PATCH 20/72] Add chainId to blockchain name --- config/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.json b/config/config.json index 1fa6187fdc..f526953609 100644 --- a/config/config.json +++ b/config/config.json @@ -443,7 +443,7 @@ ] } }, - "gnosis": { + "chiado:10200": { "enabled": false, "package": "./blockchain/implementation/gnosis/gnosis-service.js", "config": { @@ -609,7 +609,7 @@ ] } }, - "gnosis": { + "gnosis:100": { "enabled": false, "package": "./blockchain/implementation/gnosis/gnosis-service.js", "config": { From 192f47615869ddbf0ca58951c06dce7aad12b377 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 17 Nov 2023 15:26:39 +0100 Subject: [PATCH 21/72] Remove gnosis blockchain from test config --- config/config.json | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/config/config.json b/config/config.json index f526953609..00eee2c757 100644 --- a/config/config.json +++ b/config/config.json @@ -296,16 +296,6 @@ "rpcEndpoints": ["http://localhost:8545"], "initialStakeAmount": 50000, "initialAskAmount": 0.2 - }, - "gnosis": { - "enabled": false, - "package": "./blockchain/implementation/gnosis/gnosis-service.js", - "config": { - "networkId": "chiado", - "hubContractAddress": "", - "gasPriceOracleLink": "", - "rpcEndpoints": ["https://rpc.chiadochain.net"] - } } } } From 164131a2c40284bc251dd3af23fce4658dfd5926 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 21 Nov 2023 10:29:34 +0100 Subject: [PATCH 22/72] Fix local setup --- config/config.json | 4 ++-- tools/local-network-setup/.origintrail_noderc_template.json | 6 +++--- tools/local-network-setup/generate-config-files.js | 4 ++-- tools/local-network-setup/setup-macos-environment.sh | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config/config.json b/config/config.json index f61d78ada3..16eabb0053 100644 --- a/config/config.json +++ b/config/config.json @@ -112,7 +112,7 @@ "blockchain": { "enabled": true, "implementation": { - "hardhat:31337": { + "hardhat1:31337": { "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { @@ -123,7 +123,7 @@ "initialAskAmount": 0.2 } }, - "hardhat2": { + "hardhat2:31337": { "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { diff --git a/tools/local-network-setup/.origintrail_noderc_template.json b/tools/local-network-setup/.origintrail_noderc_template.json index eb2238559a..1c812e51c2 100644 --- a/tools/local-network-setup/.origintrail_noderc_template.json +++ b/tools/local-network-setup/.origintrail_noderc_template.json @@ -135,9 +135,9 @@ } }, "blockchain": { - "defaultImplementation": "hardhat", + "defaultImplementation": "hardhat1:31337", "implementation": { - "hardhat:31337": { + "hardhat1:31337": { "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { "evmOperationalWalletPublicKey": "0xd6879C0A03aDD8cFc43825A42a3F3CF44DB7D2b9", @@ -145,7 +145,7 @@ "evmOperationalWalletPrivateKey": "0x02b39cac1532bef9dba3e36ec32d3de1e9a88f1dda597d3ac6e2130aed9adc4e" } }, - "hardhat2": { + "hardhat2:31337": { "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { "evmOperationalWalletPublicKey": "0xd6879C0A03aDD8cFc43825A42a3F3CF44DB7D2b9", diff --git a/tools/local-network-setup/generate-config-files.js b/tools/local-network-setup/generate-config-files.js index f98e8fdaea..9ab3458d5e 100644 --- a/tools/local-network-setup/generate-config-files.js +++ b/tools/local-network-setup/generate-config-files.js @@ -112,8 +112,8 @@ function generateBlockchainConfig(templateBlockchainConfig, nodeIndex) { }; // TODO: Don't use string - blockchainConfig.implementation['hardhat2'].config = { - ...blockchainConfig.implementation['hardhat2'].config, + blockchainConfig.implementation['hardhat2:31337'].config = { + ...blockchainConfig.implementation['hardhat2:31337'].config, hubContractAddress, rpcEndpoints: [process.env.RPC_ENDPOINT2], evmOperationalWalletPublicKey: publicKeys[nodeIndex], diff --git a/tools/local-network-setup/setup-macos-environment.sh b/tools/local-network-setup/setup-macos-environment.sh index 60a05f2304..22964700f5 100755 --- a/tools/local-network-setup/setup-macos-environment.sh +++ b/tools/local-network-setup/setup-macos-environment.sh @@ -1,9 +1,9 @@ #!/bin/sh pathToOtNode=$(pwd) numberOfNodes=4 -network="hardhat:31337" +network="hardhat1:31337" tripleStore="ot-blazegraph" -availableNetworks=("hardhat:31337") +availableNetworks=("hardhat1:31337") export $(xargs < $pathToOtNode/.env) export ACCESS_KEY=$RPC_ENDPOINT # Check for script arguments @@ -43,7 +43,7 @@ while [ $# -gt 0 ]; do esac shift done -if [[ $network == hardhat:31337 ]] +if [[ $network == hardhat1:31337 ]] then echo ================================ echo ====== Starting hardhat ====== From 139c427851291e40727ce17133f5277006a5550d Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 21 Nov 2023 12:52:43 +0100 Subject: [PATCH 23/72] Fix UAL triple store migration --- src/constants/constants.js | 10 +++++----- src/migration/ual-extension-triple-store-migration.js | 7 ++----- src/service/triple-store-service.js | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/constants/constants.js b/src/constants/constants.js index e4d07c16fe..a10124aa7b 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -572,11 +572,11 @@ export const NODE_ENVIRONMENTS = { }; export const CHAIN_IDS = { - DEVELOPMENT: 31337, - TEST: 31337, - DEVNET: 2160, - TESTNET: 20430, - MAINNET: 2043, + development: 31337, + test: 31337, + devnet: 2160, + testnet: 20430, + mainnet: 2043, }; export const CONTRACT_EVENT_FETCH_INTERVALS = { diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index fb4b71d19a..3fe44cb67e 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -1,5 +1,5 @@ import BaseMigration from './base-migration.js'; -import { CHAIN_IDS, TRIPLE_STORE_REPOSITORIES } from '../constants/constants.js'; +import { CHAIN_IDS } from '../constants/constants.js'; const chainId = CHAIN_IDS[process.env.NODE_ENV]; @@ -27,10 +27,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { } `; - await this.tripleStoreService.queryVoidAllRepositories( - TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT, - updateSubjectQuery, - ); + await this.tripleStoreService.queryVoidAllRepositories(updateSubjectQuery); const updateObjectQuery = ` WITH diff --git a/src/service/triple-store-service.js b/src/service/triple-store-service.js index 6e5986d21c..92a2799dc3 100644 --- a/src/service/triple-store-service.js +++ b/src/service/triple-store-service.js @@ -381,7 +381,7 @@ class TripleStoreService { queryPromises.push( this.tripleStoreModuleManager.queryVoid( this.repositoryImplementations[repository], - repository, + TRIPLE_STORE_REPOSITORIES[repository], query, ), ); From a3d6c103e65542d7b73128d31fb9d835453d67e3 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Tue, 21 Nov 2023 12:56:58 +0100 Subject: [PATCH 24/72] Updated the code to fetch old blockchain id from configuration --- .../ual-extension-triple-store-migration.js | 31 +++++++++++++- ...-extension-user-configuration-migration.js | 40 +++++++++++++------ 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 3fe44cb67e..5eacad6a92 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -1,3 +1,5 @@ +import path from 'path'; +import appRootPath from 'app-root-path'; import BaseMigration from './base-migration.js'; import { CHAIN_IDS } from '../constants/constants.js'; @@ -10,8 +12,16 @@ class UalExtensionTripleStoreMigration extends BaseMigration { } async executeMigration() { - const oldBlockchainId = 'did:dkg:otp'; - const newBlockchainId = `${oldBlockchainId}:${chainId}`; + const configurationFolderPath = path.join(appRootPath.path, '..'); + const configurationFilePath = path.join( + configurationFolderPath, + this.config.configFilename, + ); + + const userConfiguration = await this.fileService.readFile(configurationFilePath, true); + + const oldBlockchainId = this.getOldBlockchainId(userConfiguration); + const newBlockchainId = `did:dkg:${oldBlockchainId}:${chainId}`; const updateSubjectQuery = ` WITH DELETE { @@ -46,6 +56,23 @@ class UalExtensionTripleStoreMigration extends BaseMigration { await this.tripleStoreService.queryVoidAllRepositories(updateObjectQuery); } + + getOldBlockchainId(userConfiguration) { + let oldBlockchainId; + if (userConfiguration.modules.blockchain.implementation) { + for (const implementationName in userConfiguration.modules.blockchain.implementation) { + if ( + userConfiguration.modules.blockchain.implementation[implementationName].enabled + ) { + oldBlockchainId = implementationName; + } + } + } + if (!oldBlockchainId) { + throw Error('Unable to find old blockchain id in user configuration'); + } + return oldBlockchainId.split(':')[0]; + } } export default UalExtensionTripleStoreMigration; diff --git a/src/migration/ual-extension-user-configuration-migration.js b/src/migration/ual-extension-user-configuration-migration.js index 8d8353c7cf..98a553fa25 100644 --- a/src/migration/ual-extension-user-configuration-migration.js +++ b/src/migration/ual-extension-user-configuration-migration.js @@ -20,20 +20,34 @@ class UalExtensionUserConfigurationMigration extends BaseMigration { const userConfiguration = await this.fileService.readFile(configurationFilePath, true); - if (userConfiguration.modules.blockchain.implementation.otp) { - const oldBlockchainId = 'otp'; - const newBlockchainId = `${oldBlockchainId}:${chainId}`; - userConfiguration.modules.blockchain.implementation.defaultImplementation = - newBlockchainId; - userConfiguration.modules.blockchain.implementation[newBlockchainId] = - userConfiguration.modules.blockchain.implementation[oldBlockchainId]; - delete userConfiguration.modules.blockchain.implementation[oldBlockchainId]; - await this.fileService.writeContentsToFile( - configurationFolderPath, - this.config.configFilename, - JSON.stringify(userConfiguration, null, 4), - ); + const oldBlockchainId = this.getOldBlockchainId(userConfiguration); + const newBlockchainId = `${oldBlockchainId}:${chainId}`; + userConfiguration.modules.blockchain.implementation.defaultImplementation = newBlockchainId; + userConfiguration.modules.blockchain.implementation[newBlockchainId] = + userConfiguration.modules.blockchain.implementation[oldBlockchainId]; + delete userConfiguration.modules.blockchain.implementation[oldBlockchainId]; + await this.fileService.writeContentsToFile( + configurationFolderPath, + this.config.configFilename, + JSON.stringify(userConfiguration, null, 4), + ); + } + + getOldBlockchainId(userConfiguration) { + let oldBlockchainId; + if (userConfiguration.modules.blockchain.implementation) { + for (const implementationName in userConfiguration.modules.blockchain.implementation) { + if ( + userConfiguration.modules.blockchain.implementation[implementationName].enabled + ) { + oldBlockchainId = implementationName; + } + } + } + if (!oldBlockchainId) { + throw Error('Unable to find old blockchain id in user configuration'); } + return oldBlockchainId; } } From 818de4bead0f61f10572ec35e7d18155b3fca119 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 21 Nov 2023 13:45:25 +0100 Subject: [PATCH 25/72] Fix migration now updates UAL --- src/migration/ual-extension-triple-store-migration.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 5eacad6a92..bb29ae5dd4 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -21,7 +21,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { const userConfiguration = await this.fileService.readFile(configurationFilePath, true); const oldBlockchainId = this.getOldBlockchainId(userConfiguration); - const newBlockchainId = `did:dkg:${oldBlockchainId}:${chainId}`; + const newBlockchainId = `${oldBlockchainId}:${chainId}`; const updateSubjectQuery = ` WITH DELETE { @@ -32,7 +32,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { } WHERE { ?s ?p ?o . - FILTER (STRSTARTS(STR(?s), "${oldBlockchainId}/")) + FILTER (STRSTARTS(STR(?s), "did:dkg:${oldBlockchainId}/")) BIND (IRI(REPLACE(STR(?s), "${oldBlockchainId}", "${newBlockchainId}")) AS ?newSubject) } `; From 5a736b8e1069d2a387f62149793200378a51c231 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Wed, 22 Nov 2023 10:52:13 +0100 Subject: [PATCH 26/72] Change hardhat1 to hardhat --- config/config.json | 2 +- tools/local-network-setup/.origintrail_noderc_template.json | 3 ++- tools/local-network-setup/setup-macos-environment.sh | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config/config.json b/config/config.json index 16eabb0053..f0b5903b21 100644 --- a/config/config.json +++ b/config/config.json @@ -112,7 +112,7 @@ "blockchain": { "enabled": true, "implementation": { - "hardhat1:31337": { + "hardhat:31337": { "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { diff --git a/tools/local-network-setup/.origintrail_noderc_template.json b/tools/local-network-setup/.origintrail_noderc_template.json index 1c812e51c2..25646969d0 100644 --- a/tools/local-network-setup/.origintrail_noderc_template.json +++ b/tools/local-network-setup/.origintrail_noderc_template.json @@ -137,7 +137,8 @@ "blockchain": { "defaultImplementation": "hardhat1:31337", "implementation": { - "hardhat1:31337": { + "hardhat:31337": { + "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { "evmOperationalWalletPublicKey": "0xd6879C0A03aDD8cFc43825A42a3F3CF44DB7D2b9", diff --git a/tools/local-network-setup/setup-macos-environment.sh b/tools/local-network-setup/setup-macos-environment.sh index 22964700f5..60a05f2304 100755 --- a/tools/local-network-setup/setup-macos-environment.sh +++ b/tools/local-network-setup/setup-macos-environment.sh @@ -1,9 +1,9 @@ #!/bin/sh pathToOtNode=$(pwd) numberOfNodes=4 -network="hardhat1:31337" +network="hardhat:31337" tripleStore="ot-blazegraph" -availableNetworks=("hardhat1:31337") +availableNetworks=("hardhat:31337") export $(xargs < $pathToOtNode/.env) export ACCESS_KEY=$RPC_ENDPOINT # Check for script arguments @@ -43,7 +43,7 @@ while [ $# -gt 0 ]; do esac shift done -if [[ $network == hardhat1:31337 ]] +if [[ $network == hardhat:31337 ]] then echo ================================ echo ====== Starting hardhat ====== From 241d89c73651651c030441cb973cc82b442f0288 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Wed, 22 Nov 2023 10:55:26 +0100 Subject: [PATCH 27/72] Remove node restart after Ual Extension TripleStore Migration --- src/migration/migration-executor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/migration/migration-executor.js b/src/migration/migration-executor.js index c68164abff..510b5c970d 100644 --- a/src/migration/migration-executor.js +++ b/src/migration/migration-executor.js @@ -327,8 +327,8 @@ class MigrationExecutor { ); if (!(await migration.migrationAlreadyExecuted())) { await migration.migrate(); - logger.info('Node will now restart!'); - this.exitNode(1); + // logger.info('Node will now restart!'); + // this.exitNode(1); } } From b5ba8222b6f50142c0d2e0ff12c7669879a03fca Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Wed, 22 Nov 2023 12:00:24 +0100 Subject: [PATCH 28/72] Updated set ask and set stake scripts for multichain. Updated user configuration for new blockchain id format, added support for old installer --- scripts/set-ask.js | 31 ++++++++++++++++--- scripts/set-stake.js | 25 +++++++++++++-- ...-extension-user-configuration-migration.js | 12 +++++++ 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/scripts/set-ask.js b/scripts/set-ask.js index 71bba163d8..1799175500 100644 --- a/scripts/set-ask.js +++ b/scripts/set-ask.js @@ -1,5 +1,6 @@ /* eslint-disable no-console */ import { ethers } from 'ethers'; +import axios from 'axios'; import { createRequire } from 'module'; import { NODE_ENVIRONMENTS, @@ -13,14 +14,28 @@ const Profile = require('dkg-evm-module/abi/Profile.json'); const IdentityStorage = require('dkg-evm-module/abi/IdentityStorage.json'); const Hub = require('dkg-evm-module/abi/Hub.json'); const argv = require('minimist')(process.argv.slice(1), { - string: ['ask', 'privateKey', 'hubContractAddress'], + string: ['ask', 'privateKey', 'hubContractAddress', 'gasPriceOracleLink'], }); const devEnvironment = process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT || process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST; -async function setAsk(rpcEndpoint, ask, walletPrivateKey, hubContractAddress) { +async function getGasPrice(gasPriceOracleLink) { + if (!gasPriceOracleLink) { + return devEnvironment ? undefined : 8; + } + try { + const response = await axios.get(gasPriceOracleLink); + const gasPriceRounded = Math.round(response.result * 1e9); + this.logger.debug(`Gas price: ${gasPriceRounded}`); + return gasPriceRounded; + } catch (error) { + return undefined; + } +} + +async function setAsk(rpcEndpoint, ask, walletPrivateKey, hubContractAddress, gasPriceOracleLink) { const provider = new ethers.providers.JsonRpcProvider(rpcEndpoint); const wallet = new ethers.Wallet(walletPrivateKey, provider); @@ -36,8 +51,10 @@ async function setAsk(rpcEndpoint, ask, walletPrivateKey, hubContractAddress) { const askWei = ethers.utils.parseEther(ask); + const gasPrice = await getGasPrice(gasPriceOracleLink); + const tx = await profile.setAsk(identityId, askWei, { - gasPrice: devEnvironment ? undefined : 8, + gasPrice, gasLimit: 500_000, }); await provider.waitForTransaction( @@ -50,7 +67,13 @@ async function setAsk(rpcEndpoint, ask, walletPrivateKey, hubContractAddress) { const expectedArguments = ['rpcEndpoint', 'ask', 'privateKey', 'hubContractAddress']; if (validateArguments(argv, expectedArguments)) { - setAsk(argv.rpcEndpoint, argv.ask, argv.privateKey, argv.hubContractAddress) + setAsk( + argv.rpcEndpoint, + argv.ask, + argv.privateKey, + argv.hubContractAddress, + argv.gasPriceOracleLink, + ) .then(() => { console.log('Set ask completed'); process.exit(0); diff --git a/scripts/set-stake.js b/scripts/set-stake.js index 953b6f1e60..a9ca5d0443 100644 --- a/scripts/set-stake.js +++ b/scripts/set-stake.js @@ -1,6 +1,7 @@ /* eslint-disable no-console */ import { ethers } from 'ethers'; import { createRequire } from 'module'; +import axios from 'axios'; import { NODE_ENVIRONMENTS, TRANSACTION_POLLING_TIMEOUT_MILLIS, @@ -19,6 +20,7 @@ const argv = require('minimist')(process.argv.slice(1), { 'operationalWalletPrivateKey', 'managementWalletPrivateKey', 'hubContractAddress', + 'gasPriceOracleLink', ], }); @@ -26,12 +28,27 @@ const devEnvironment = process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT || process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST; +async function getGasPrice(gasPriceOracleLink) { + if (!gasPriceOracleLink) { + return devEnvironment ? undefined : 8; + } + try { + const response = await axios.get(gasPriceOracleLink); + const gasPriceRounded = Math.round(response.result * 1e9); + this.logger.debug(`Gas price: ${gasPriceRounded}`); + return gasPriceRounded; + } catch (error) { + return undefined; + } +} + async function setStake( rpcEndpoint, stake, operationalWalletPrivateKey, managementWalletPrivateKey, hubContractAddress, + gasPriceOracleLink, ) { const provider = new ethers.providers.JsonRpcProvider(rpcEndpoint); const operationalWallet = new ethers.Wallet(operationalWalletPrivateKey, provider); @@ -52,10 +69,13 @@ async function setStake( const stakeWei = ethers.utils.parseEther(stake); + const gasPrice = await getGasPrice(gasPriceOracleLink); + let tx = await tokenContract.increaseAllowance(stakingContractAddress, stakeWei, { - gasPrice: devEnvironment ? undefined : 8, + gasPrice, gasLimit: 500_000, }); + await provider.waitForTransaction( tx.hash, TRANSACTION_CONFIRMATIONS, @@ -63,7 +83,7 @@ async function setStake( ); // TODO: Add ABI instead of hard-coded function definition tx = await stakingContract['addStake(uint72,uint96)'](identityId, stakeWei, { - gasPrice: devEnvironment ? undefined : 1_000, + gasPrice: gasPrice * 100, gasLimit: 500_000, }); await provider.waitForTransaction( @@ -88,6 +108,7 @@ if (validateArguments(argv, expectedArguments)) { argv.operationalWalletPrivateKey, argv.managementWalletPrivateKey, argv.hubContractAddress, + argv.gasPriceOracleLink, ) .then(() => { console.log('Set stake completed'); diff --git a/src/migration/ual-extension-user-configuration-migration.js b/src/migration/ual-extension-user-configuration-migration.js index 98a553fa25..d0c9c14eed 100644 --- a/src/migration/ual-extension-user-configuration-migration.js +++ b/src/migration/ual-extension-user-configuration-migration.js @@ -21,6 +21,14 @@ class UalExtensionUserConfigurationMigration extends BaseMigration { const userConfiguration = await this.fileService.readFile(configurationFilePath, true); const oldBlockchainId = this.getOldBlockchainId(userConfiguration); + + if (!this.blockchainIdInNewFormat(oldBlockchainId)) { + this.logger.info( + 'Blockchain id in user configuration already updated to be in new format, migration will be skipped', + ); + return null; + } + const newBlockchainId = `${oldBlockchainId}:${chainId}`; userConfiguration.modules.blockchain.implementation.defaultImplementation = newBlockchainId; userConfiguration.modules.blockchain.implementation[newBlockchainId] = @@ -33,6 +41,10 @@ class UalExtensionUserConfigurationMigration extends BaseMigration { ); } + blockchainIdInNewFormat(blockchainId) { + return blockchainId.contains(':'); + } + getOldBlockchainId(userConfiguration) { let oldBlockchainId; if (userConfiguration.modules.blockchain.implementation) { From 144325294326316cd240d22e419a715c76d174a3 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Wed, 22 Nov 2023 12:16:17 +0100 Subject: [PATCH 29/72] Use config instead of user config in ual extension tripleStore migration --- .../ual-extension-triple-store-migration.js | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index bb29ae5dd4..6f5110bc40 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -1,5 +1,3 @@ -import path from 'path'; -import appRootPath from 'app-root-path'; import BaseMigration from './base-migration.js'; import { CHAIN_IDS } from '../constants/constants.js'; @@ -12,15 +10,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { } async executeMigration() { - const configurationFolderPath = path.join(appRootPath.path, '..'); - const configurationFilePath = path.join( - configurationFolderPath, - this.config.configFilename, - ); - - const userConfiguration = await this.fileService.readFile(configurationFilePath, true); - - const oldBlockchainId = this.getOldBlockchainId(userConfiguration); + const oldBlockchainId = this.getOldBlockchainId(); const newBlockchainId = `${oldBlockchainId}:${chainId}`; const updateSubjectQuery = ` WITH @@ -57,19 +47,17 @@ class UalExtensionTripleStoreMigration extends BaseMigration { await this.tripleStoreService.queryVoidAllRepositories(updateObjectQuery); } - getOldBlockchainId(userConfiguration) { + getOldBlockchainId() { let oldBlockchainId; - if (userConfiguration.modules.blockchain.implementation) { - for (const implementationName in userConfiguration.modules.blockchain.implementation) { - if ( - userConfiguration.modules.blockchain.implementation[implementationName].enabled - ) { + if (this.config.modules.blockchain.implementation) { + for (const implementationName in this.config.modules.blockchain.implementation) { + if (this.config.modules.blockchain.implementation[implementationName].enabled) { oldBlockchainId = implementationName; } } } if (!oldBlockchainId) { - throw Error('Unable to find old blockchain id in user configuration'); + throw Error('Unable to find old blockchain id in configuration'); } return oldBlockchainId.split(':')[0]; } From 509307c903595677c4178e6df61c5cd0dc230638 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Wed, 22 Nov 2023 12:35:51 +0100 Subject: [PATCH 30/72] Remove chanin id from blockchain when sending network command --- src/commands/protocols/common/protocol-init-command.js | 6 ++++-- .../protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js | 5 ++++- .../get/sender/v1.0.0/v1-0-0-get-request-command.js | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/commands/protocols/common/protocol-init-command.js b/src/commands/protocols/common/protocol-init-command.js index 8f139828d2..618ba0c343 100644 --- a/src/commands/protocols/common/protocol-init-command.js +++ b/src/commands/protocols/common/protocol-init-command.js @@ -3,8 +3,10 @@ import { NETWORK_MESSAGE_TYPES } from '../../../constants/constants.js'; class ProtocolInitCommand extends ProtocolMessageCommand { async prepareMessage(command) { - const { assertionId, blockchain, contract, tokenId, keyword, hashFunctionId } = - command.data; + const { assertionId, contract, tokenId, keyword, hashFunctionId } = command.data; + + // Bacwards compatibility, send blockchain without chainId + const blockchain = command.data.blockchain.split(':')[0]; return { assertionId, blockchain, contract, tokenId, keyword, hashFunctionId }; } diff --git a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js index ce55bf1ace..f1609c3e45 100644 --- a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js +++ b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js @@ -10,7 +10,10 @@ class GetInitCommand extends ProtocolInitCommand { } async prepareMessage(command) { - const { blockchain, contract, tokenId, keyword, assertionId, state } = command.data; + const { contract, tokenId, keyword, assertionId, state } = command.data; + + // Bacwards compatibility, send blockchain without chainId + const blockchain = command.data.blockchain.split(':')[0]; return { blockchain, diff --git a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js index 7c6d6e1cfc..634a1daec0 100644 --- a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js +++ b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js @@ -31,7 +31,10 @@ class GetRequestCommand extends ProtocolRequestCommand { } async prepareMessage(command) { - const { blockchain, contract, tokenId, assertionId, state, hashFunctionId } = command.data; + const { contract, tokenId, assertionId, state, hashFunctionId } = command.data; + + // Bacwards compatibility, send blockchain without chainId + const blockchain = command.data.blockchain.split(':')[0]; return { blockchain, From cc0f395029632842e68f14dc43c5d4fc229ed73b Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Wed, 22 Nov 2023 12:45:46 +0100 Subject: [PATCH 31/72] Fix typo --- src/commands/protocols/common/protocol-init-command.js | 2 +- .../protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js | 2 +- .../protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/protocols/common/protocol-init-command.js b/src/commands/protocols/common/protocol-init-command.js index 618ba0c343..6ed5941312 100644 --- a/src/commands/protocols/common/protocol-init-command.js +++ b/src/commands/protocols/common/protocol-init-command.js @@ -5,7 +5,7 @@ class ProtocolInitCommand extends ProtocolMessageCommand { async prepareMessage(command) { const { assertionId, contract, tokenId, keyword, hashFunctionId } = command.data; - // Bacwards compatibility, send blockchain without chainId + // Backwards compatibility, send blockchain without chainId const blockchain = command.data.blockchain.split(':')[0]; return { assertionId, blockchain, contract, tokenId, keyword, hashFunctionId }; diff --git a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js index f1609c3e45..950aec21ea 100644 --- a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js +++ b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js @@ -12,7 +12,7 @@ class GetInitCommand extends ProtocolInitCommand { async prepareMessage(command) { const { contract, tokenId, keyword, assertionId, state } = command.data; - // Bacwards compatibility, send blockchain without chainId + // Backwards compatibility, send blockchain without chainId const blockchain = command.data.blockchain.split(':')[0]; return { diff --git a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js index 634a1daec0..f6a2e34711 100644 --- a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js +++ b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js @@ -33,7 +33,7 @@ class GetRequestCommand extends ProtocolRequestCommand { async prepareMessage(command) { const { contract, tokenId, assertionId, state, hashFunctionId } = command.data; - // Bacwards compatibility, send blockchain without chainId + // Backwards compatibility, send blockchain without chainId const blockchain = command.data.blockchain.split(':')[0]; return { From 7189907bd470fc5cdfd166ccf393f186dc1a352e Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Wed, 22 Nov 2023 14:49:51 +0100 Subject: [PATCH 32/72] Fix not sending NaN but undefined --- scripts/set-stake.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/set-stake.js b/scripts/set-stake.js index a9ca5d0443..b307c6b74f 100644 --- a/scripts/set-stake.js +++ b/scripts/set-stake.js @@ -83,7 +83,7 @@ async function setStake( ); // TODO: Add ABI instead of hard-coded function definition tx = await stakingContract['addStake(uint72,uint96)'](identityId, stakeWei, { - gasPrice: gasPrice * 100, + gasPrice: gasPrice ? gasPrice * 100 : undefined, gasLimit: 500_000, }); await provider.waitForTransaction( From 359e83328a0f66ac3629e8afc85ca2d4c09b0fa5 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Wed, 22 Nov 2023 22:49:47 +0100 Subject: [PATCH 33/72] Start blockchains with different version of contracts --- package.json | 2 ++ test/bdd/steps/lib/local-blockchain.mjs | 4 ++-- tools/local-network-setup/run-local-blockchain.js | 3 ++- tools/local-network-setup/setup-macos-environment.sh | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b18bc591af..1823d79039 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "lint-staged": "lint-staged", "create-account-mapping-signature": "node tools/ot-parachain-account-mapping/create-account-mapping-signature.js ", "start:local_blockchain": "npm explore dkg-evm-module -- npm run dev -- --port", + "start:local_blockchainv1": "npm explore dkg-evm-module -- npm run dev:v1 -- --port", + "start:local_blockchainv2": "npm explore dkg-evm-module -- npm run dev:v2 -- --port", "kill:local_blockchain": "npx kill-port --port", "test:bdd": "cucumber-js --fail-fast --format progress --format-options '{\"colorsEnabled\": true}' test/bdd/ --import test/bdd/steps/ --exit", "test:unit": "nyc --all mocha --exit $(find test/unit -name '*.js')", diff --git a/test/bdd/steps/lib/local-blockchain.mjs b/test/bdd/steps/lib/local-blockchain.mjs index 0dfbc80a50..2b7969c04c 100644 --- a/test/bdd/steps/lib/local-blockchain.mjs +++ b/test/bdd/steps/lib/local-blockchain.mjs @@ -50,9 +50,9 @@ const testParametersStorageParams = { let startBlockchainProcess; class LocalBlockchain { - async initialize(port, _console = console) { + async initialize(port, version, _console = console) { this.port = port; - startBlockchainProcess = exec(`npm run start:local_blockchain -- ${port}`); + startBlockchainProcess = exec(`npm run start:local_blockchain${version} -- ${port}`); startBlockchainProcess.stdout.on('data', (data) => { _console.log(data); }); diff --git a/tools/local-network-setup/run-local-blockchain.js b/tools/local-network-setup/run-local-blockchain.js index 40477fee84..b7311aa644 100644 --- a/tools/local-network-setup/run-local-blockchain.js +++ b/tools/local-network-setup/run-local-blockchain.js @@ -1,6 +1,7 @@ import LocalBlockchain from '../../test/bdd/steps/lib/local-blockchain.mjs'; const port = parseInt(process.argv[2], 10); +const version = process.argv[3]; const localBlockchain = new LocalBlockchain(); -await localBlockchain.initialize(port, console); +await localBlockchain.initialize(port, version, console); diff --git a/tools/local-network-setup/setup-macos-environment.sh b/tools/local-network-setup/setup-macos-environment.sh index 60a05f2304..55c54329a2 100755 --- a/tools/local-network-setup/setup-macos-environment.sh +++ b/tools/local-network-setup/setup-macos-environment.sh @@ -51,7 +51,7 @@ then osascript -e "tell app \"Terminal\" do script \"cd $pathToOtNode - node tools/local-network-setup/run-local-blockchain.js 8545\" + node tools/local-network-setup/run-local-blockchain.js 8545 v1\" end tell" echo Waiting for hardhat to start and contracts deployment @@ -61,7 +61,7 @@ then osascript -e "tell app \"Terminal\" do script \"cd $pathToOtNode - node tools/local-network-setup/run-local-blockchain.js 9545\" + node tools/local-network-setup/run-local-blockchain.js 9545 v2\" end tell" echo Waiting for hardhat to start and contracts deployment fi From fbbdc2d927e59d03c00d96993d5b18df452c5e0c Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 23 Nov 2023 09:37:14 +0100 Subject: [PATCH 34/72] Move argument order in localBlockchain.initialize --- test/bdd/steps/lib/local-blockchain.mjs | 2 +- tools/local-network-setup/run-local-blockchain.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/bdd/steps/lib/local-blockchain.mjs b/test/bdd/steps/lib/local-blockchain.mjs index 2b7969c04c..19410f9504 100644 --- a/test/bdd/steps/lib/local-blockchain.mjs +++ b/test/bdd/steps/lib/local-blockchain.mjs @@ -50,7 +50,7 @@ const testParametersStorageParams = { let startBlockchainProcess; class LocalBlockchain { - async initialize(port, version, _console = console) { + async initialize(port, _console = console, version = '') { this.port = port; startBlockchainProcess = exec(`npm run start:local_blockchain${version} -- ${port}`); startBlockchainProcess.stdout.on('data', (data) => { diff --git a/tools/local-network-setup/run-local-blockchain.js b/tools/local-network-setup/run-local-blockchain.js index b7311aa644..33e679aca5 100644 --- a/tools/local-network-setup/run-local-blockchain.js +++ b/tools/local-network-setup/run-local-blockchain.js @@ -1,7 +1,7 @@ import LocalBlockchain from '../../test/bdd/steps/lib/local-blockchain.mjs'; const port = parseInt(process.argv[2], 10); -const version = process.argv[3]; +const version = process.argv.length > 3 ? process.argv[3] : ''; const localBlockchain = new LocalBlockchain(); -await localBlockchain.initialize(port, version, console); +await localBlockchain.initialize(port, console, version); From d2eec5143d0b297fe99a74b869414d332855e3a5 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 23 Nov 2023 17:06:20 +0100 Subject: [PATCH 35/72] Add filtering unprocessed blockchain events by blockchainId --- .../blockchain-event-repository.js | 3 ++- .../repository/repository-module-manager.js | 7 +++++-- .../blockchain-event-listener-service.js | 20 ++++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/modules/repository/implementation/sequelize/repositories/blockchain-event-repository.js b/src/modules/repository/implementation/sequelize/repositories/blockchain-event-repository.js index 151f221ddc..c03087cadb 100644 --- a/src/modules/repository/implementation/sequelize/repositories/blockchain-event-repository.js +++ b/src/modules/repository/implementation/sequelize/repositories/blockchain-event-repository.js @@ -23,9 +23,10 @@ class BlockchainEventRepository { return inserted.map((event) => event.dataValues); } - async getAllUnprocessedBlockchainEvents(eventNames) { + async getAllUnprocessedBlockchainEvents(eventNames, blockchainId) { return this.model.findAll({ where: { + blockchainId, processed: false, event: { [Sequelize.Op.in]: eventNames }, }, diff --git a/src/modules/repository/repository-module-manager.js b/src/modules/repository/repository-module-manager.js index 5cf4a83153..66ac6171c0 100644 --- a/src/modules/repository/repository-module-manager.js +++ b/src/modules/repository/repository-module-manager.js @@ -250,8 +250,11 @@ class RepositoryModuleManager extends BaseModuleManager { return this.getRepository('blockchain_event').insertBlockchainEvents(events); } - async getAllUnprocessedBlockchainEvents(eventNames) { - return this.getRepository('blockchain_event').getAllUnprocessedBlockchainEvents(eventNames); + async getAllUnprocessedBlockchainEvents(eventNames, blockchainId) { + return this.getRepository('blockchain_event').getAllUnprocessedBlockchainEvents( + eventNames, + blockchainId, + ); } async markBlockchainEventsAsProcessed(events) { diff --git a/src/service/blockchain-event-listener-service.js b/src/service/blockchain-event-listener-service.js index 29d63ff71a..ea8f9611e4 100644 --- a/src/service/blockchain-event-listener-service.js +++ b/src/service/blockchain-event-listener-service.js @@ -93,7 +93,10 @@ class BlockchainEventListenerService { } const contractEvents = await Promise.all(syncContractEventsPromises); - await this.handleBlockchainEvents(contractEvents.flatMap((events) => events)); + await this.handleBlockchainEvents( + contractEvents.flatMap((events) => events), + blockchainId, + ); } listenOnBlockchainEvents(blockchainId) { @@ -162,18 +165,25 @@ class BlockchainEventListenerService { return events; } - async handleBlockchainEvents(events) { + async handleBlockchainEvents(events, blockchainId) { const eventsForProcessing = events.filter((event) => eventNames.includes(event.event)); if (eventsForProcessing?.length) { - this.logger.trace(`${eventsForProcessing.length} blockchain events caught.`); + this.logger.trace( + `${eventsForProcessing.length} blockchain events caught on blockchain ${blockchainId}.`, + ); await this.repositoryModuleManager.insertBlockchainEvents(eventsForProcessing); } const unprocessedEvents = - await this.repositoryModuleManager.getAllUnprocessedBlockchainEvents(eventNames); + await this.repositoryModuleManager.getAllUnprocessedBlockchainEvents( + eventNames, + blockchainId, + ); if (unprocessedEvents?.length) { - this.logger.trace(`Processing ${unprocessedEvents.length} blockchain events.`); + this.logger.trace( + `Processing ${unprocessedEvents.length} blockchain events on blockchain ${blockchainId}.`, + ); let groupedEvents = {}; let currentBlock = 0; for (const event of unprocessedEvents) { From 30300facb829aeef62eea19816395c2dad9a4aed Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 24 Nov 2023 16:16:24 +0100 Subject: [PATCH 36/72] Changes from review --- config/config.json | 9 +-------- package.json | 4 ++-- .../protocols/common/protocol-init-command.js | 2 +- .../get/sender/v1.0.0/v1-0-0-get-init-command.js | 2 +- .../get/sender/v1.0.0/v1-0-0-get-request-command.js | 2 +- src/controllers/http-api/http-api-router.js | 4 ++-- .../implementation/gnosis/gnosis-service.js | 9 +++------ .../http-client/implementation/express-http-client.js | 4 ++-- src/service/ual-service.js | 11 ++++++----- test/utilities/steps-utils.mjs | 2 -- .../.origintrail_noderc_template.json | 2 -- tools/local-network-setup/setup-macos-environment.sh | 4 ++-- 12 files changed, 21 insertions(+), 34 deletions(-) diff --git a/config/config.json b/config/config.json index f0b5903b21..15227d717e 100644 --- a/config/config.json +++ b/config/config.json @@ -127,8 +127,6 @@ "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { - "blockchainTitle": "hardhat2", - "networkId": "ganache::testnet", "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", "rpcEndpoints": ["http://localhost:9545"], "evmManagementPublicKey": "0x1B420da5f7Be66567526E32bc68ab29F1A63765A", @@ -140,7 +138,6 @@ "enabled": false, "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", "config": { - "networkId": "otp::testnet", "hubContractAddress": "0x707233a55bD035C6Bc732196CA4dbffa63CbA169", "rpcEndpoints": [ "https://lofar-tm-rpc.origin-trail.network", @@ -154,7 +151,6 @@ "enabled": false, "package": "./blockchain/implementation/polygon/polygon-service.js", "config": { - "networkId": "polygon::testnet", "hubContractAddress": "0xdaa16AC171CfE8Df6F79C06E7EEAb2249E2C9Ec8", "gasPriceOracleLink": "https://gasstation-mumbai.matic.today/v2", "rpcEndpoints": [ @@ -171,7 +167,6 @@ "enabled": false, "package": "./blockchain/implementation/polygon/eth-service.js", "config": { - "networkId": "eth::rinkeby", "hubContractAddress": "", "gasPriceOracleLink": "", "rpcEndpoints": [], @@ -444,11 +439,10 @@ ] } }, - "chiado:10200": { + "gnosis:10200": { "enabled": false, "package": "./blockchain/implementation/gnosis/gnosis-service.js", "config": { - "networkId": "chiado", "hubContractAddress": "", "gasPriceOracleLink": "", "rpcEndpoints": ["https://rpc.chiadochain.net"] @@ -768,7 +762,6 @@ "enabled": false, "package": "./blockchain/implementation/gnosis/gnosis-service.js", "config": { - "networkId": "gnosis", "hubContractAddress": "", "gasPriceOracleLink": "https://api.gnosisscan.io/api?module=proxy&action=eth_gasPrice", "rpcEndpoints": ["https://rpc.gnosischain.com/"] diff --git a/package.json b/package.json index 1823d79039..dbb595af9a 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ "lint-staged": "lint-staged", "create-account-mapping-signature": "node tools/ot-parachain-account-mapping/create-account-mapping-signature.js ", "start:local_blockchain": "npm explore dkg-evm-module -- npm run dev -- --port", - "start:local_blockchainv1": "npm explore dkg-evm-module -- npm run dev:v1 -- --port", - "start:local_blockchainv2": "npm explore dkg-evm-module -- npm run dev:v2 -- --port", + "start:local_blockchain:v1": "npm explore dkg-evm-module -- npm run dev:v1 -- --port", + "start:local_blockchain:v2": "npm explore dkg-evm-module -- npm run dev:v2 -- --port", "kill:local_blockchain": "npx kill-port --port", "test:bdd": "cucumber-js --fail-fast --format progress --format-options '{\"colorsEnabled\": true}' test/bdd/ --import test/bdd/steps/ --exit", "test:unit": "nyc --all mocha --exit $(find test/unit -name '*.js')", diff --git a/src/commands/protocols/common/protocol-init-command.js b/src/commands/protocols/common/protocol-init-command.js index 6ed5941312..6a76e0318b 100644 --- a/src/commands/protocols/common/protocol-init-command.js +++ b/src/commands/protocols/common/protocol-init-command.js @@ -5,7 +5,7 @@ class ProtocolInitCommand extends ProtocolMessageCommand { async prepareMessage(command) { const { assertionId, contract, tokenId, keyword, hashFunctionId } = command.data; - // Backwards compatibility, send blockchain without chainId + // TODO: Backwards compatibility, send blockchain without chainId const blockchain = command.data.blockchain.split(':')[0]; return { assertionId, blockchain, contract, tokenId, keyword, hashFunctionId }; diff --git a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js index 950aec21ea..2c366cd952 100644 --- a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js +++ b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-init-command.js @@ -12,7 +12,7 @@ class GetInitCommand extends ProtocolInitCommand { async prepareMessage(command) { const { contract, tokenId, keyword, assertionId, state } = command.data; - // Backwards compatibility, send blockchain without chainId + // TODO: Backwards compatibility, send blockchain without chainId const blockchain = command.data.blockchain.split(':')[0]; return { diff --git a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js index f6a2e34711..6780a99871 100644 --- a/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js +++ b/src/commands/protocols/get/sender/v1.0.0/v1-0-0-get-request-command.js @@ -33,7 +33,7 @@ class GetRequestCommand extends ProtocolRequestCommand { async prepareMessage(command) { const { contract, tokenId, assertionId, state, hashFunctionId } = command.data; - // Backwards compatibility, send blockchain without chainId + // TODO: Backwards compatibility, send blockchain without chainId const blockchain = command.data.blockchain.split(':')[0]; return { diff --git a/src/controllers/http-api/http-api-router.js b/src/controllers/http-api/http-api-router.js index 5e5edd016c..f141912e79 100644 --- a/src/controllers/http-api/http-api-router.js +++ b/src/controllers/http-api/http-api-router.js @@ -37,8 +37,8 @@ class HttpApiRouter { } initializeBeforeMiddlewares() { - const blockchainImpelemntations = this.blockchainModuleManager.getImplementationNames(); - this.httpClientModuleManager.initializeBeforeMiddlewares(blockchainImpelemntations); + const blockchainImplementations = this.blockchainModuleManager.getImplementationNames(); + this.httpClientModuleManager.initializeBeforeMiddlewares(blockchainImplementations); } async initializeVersionedListeners() { diff --git a/src/modules/blockchain/implementation/gnosis/gnosis-service.js b/src/modules/blockchain/implementation/gnosis/gnosis-service.js index fa715fc7f2..582d9ea475 100644 --- a/src/modules/blockchain/implementation/gnosis/gnosis-service.js +++ b/src/modules/blockchain/implementation/gnosis/gnosis-service.js @@ -1,4 +1,3 @@ -import axios from 'axios'; import Web3Service from '../web3-service.js'; import { BLOCK_TIME_MILLIS } from '../../../../constants/constants.js'; @@ -15,12 +14,10 @@ class GnosisService extends Web3Service { } async getGasPrice() { + if (this.config.gasPriceOracleLink) return super.getGasPrice(); + try { - this.logger.debug('Gas price:'); - const response = await axios.get(this.config.gasPriceOracleLink); - this.logger.debug(response); - const gasPriceRounded = Math.round(response.result * 1e9); - return gasPriceRounded; + return this.provider.getGasPrice(); } catch (error) { return undefined; } diff --git a/src/modules/http-client/implementation/express-http-client.js b/src/modules/http-client/implementation/express-http-client.js index 9f141fc1ca..c6a75edc9a 100644 --- a/src/modules/http-client/implementation/express-http-client.js +++ b/src/modules/http-client/implementation/express-http-client.js @@ -67,12 +67,12 @@ class ExpressHttpClient { return middlewares; } - initializeBeforeMiddlewares(authService, blockchainImpelemntations) { + initializeBeforeMiddlewares(authService, blockchainImplementations) { this._initializeCorsMiddleware(); this.app.use(authenticationMiddleware(authService)); this.app.use(authorizationMiddleware(authService)); this._initializeBaseMiddlewares(); - this.app.use(blockchainIdMiddleware(blockchainImpelemntations)); + this.app.use(blockchainIdMiddleware(blockchainImplementations)); } initializeAfterMiddlewares() { diff --git a/src/service/ual-service.js b/src/service/ual-service.js index 3a562038b1..b6e4cd10db 100644 --- a/src/service/ual-service.js +++ b/src/service/ual-service.js @@ -12,6 +12,7 @@ class UALService { // did:dkg:otp:2043/0x123231/5 isUAL(ual) { + if (!ual.startsWith('did:dkg:')) return false; const parts = ual.replace('did:', '').replace('dkg:', '').split('/'); if (parts.length === 3) { // eslint-disable-next-line no-restricted-globals @@ -40,16 +41,16 @@ class UALService { if (!this.isContract(contract)) { throw new Error(`Invalid contract format: ${contract}`); } - let blockchainUAL = parts[0]; - if (blockchainUAL.split(':').length === 1) { + let blockchainName = parts[0]; + if (blockchainName.split(':').length === 1) { for (const implementation of this.blockchainModuleManager.getImplementationNames()) { - if (implementation.split(':')[0] === blockchainUAL) { - blockchainUAL = implementation; + if (implementation.split(':')[0] === blockchainName) { + blockchainName = implementation; break; } } } - return { blockchain: blockchainUAL, contract, tokenId: Number(parts[2]) }; + return { blockchain: blockchainName, contract, tokenId: Number(parts[2]) }; } if (parts.length === 2) { const parts2 = parts[0].split(':'); diff --git a/test/utilities/steps-utils.mjs b/test/utilities/steps-utils.mjs index e43840bf52..41d824aef6 100644 --- a/test/utilities/steps-utils.mjs +++ b/test/utilities/steps-utils.mjs @@ -132,8 +132,6 @@ class StepsUtils { enabled: true, package: './blockchain/implementation/hardhat/hardhat-service.js', config: { - blockchainTitle: localBlockchain, - networkId: `hardhat::${localBlockchain}`, hubContractAddress: '0x5FbDB2315678afecb367f032d93F642f64180aa3', rpcEndpoints: [`http://localhost:${localBlockchains[localBlockchain].port}`], initialStakeAmount: 50000, diff --git a/tools/local-network-setup/.origintrail_noderc_template.json b/tools/local-network-setup/.origintrail_noderc_template.json index 25646969d0..133980ed57 100644 --- a/tools/local-network-setup/.origintrail_noderc_template.json +++ b/tools/local-network-setup/.origintrail_noderc_template.json @@ -135,7 +135,6 @@ } }, "blockchain": { - "defaultImplementation": "hardhat1:31337", "implementation": { "hardhat:31337": { "enabled": true, @@ -170,7 +169,6 @@ "rinkeby": { "package": "./blockchain/implementation/polygon/eth-service.js", "config": { - "networkId": "eth::rinkeby", "hubContractAddress": "", "gasPriceOracleLink": "", "rpcEndpoints": [] diff --git a/tools/local-network-setup/setup-macos-environment.sh b/tools/local-network-setup/setup-macos-environment.sh index 55c54329a2..a729781be4 100755 --- a/tools/local-network-setup/setup-macos-environment.sh +++ b/tools/local-network-setup/setup-macos-environment.sh @@ -51,7 +51,7 @@ then osascript -e "tell app \"Terminal\" do script \"cd $pathToOtNode - node tools/local-network-setup/run-local-blockchain.js 8545 v1\" + node tools/local-network-setup/run-local-blockchain.js 8545 :v1\" end tell" echo Waiting for hardhat to start and contracts deployment @@ -61,7 +61,7 @@ then osascript -e "tell app \"Terminal\" do script \"cd $pathToOtNode - node tools/local-network-setup/run-local-blockchain.js 9545 v2\" + node tools/local-network-setup/run-local-blockchain.js 9545 :v2\" end tell" echo Waiting for hardhat to start and contracts deployment fi From 9548c5a597e40fe00f620b80ff43483de07c58b6 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 24 Nov 2023 16:57:12 +0100 Subject: [PATCH 37/72] Move RPC message modification to be used from router --- src/controllers/rpc/rpc-router.js | 23 ++++++++++++++----- .../network/implementation/libp2p-service.js | 18 ++------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/controllers/rpc/rpc-router.js b/src/controllers/rpc/rpc-router.js index a40108010a..72e409800b 100644 --- a/src/controllers/rpc/rpc-router.js +++ b/src/controllers/rpc/rpc-router.js @@ -25,14 +25,25 @@ class RpcRouter { const controller = `${operation}RpcController`; const blockchainImplementations = this.blockchainModuleManager.getImplementationNames(); - this.networkModuleManager.handleMessage( - protocol, - blockchainImplementations, - (message, remotePeerId) => - this[controller][handleRequest](message, remotePeerId, protocol), - ); + this.networkModuleManager.handleMessage(protocol, (message, remotePeerId) => { + const modifyedMessage = this.modifyMessage(message, blockchainImplementations); + this[controller][handleRequest](modifyedMessage, remotePeerId, protocol); + }); } } + + modifyMessage(message, blockchainImplementations) { + const modifiedMessage = message; + if (modifiedMessage.data.blockchain?.split(':').length === 1) { + for (const implementation of blockchainImplementations) { + if (implementation.split(':')[0] === modifiedMessage.data.blockchain) { + modifiedMessage.data.blockchain = implementation; + break; + } + } + } + return modifiedMessage; + } } export default RpcRouter; diff --git a/src/modules/network/implementation/libp2p-service.js b/src/modules/network/implementation/libp2p-service.js index fab7479b89..da50372d0a 100644 --- a/src/modules/network/implementation/libp2p-service.js +++ b/src/modules/network/implementation/libp2p-service.js @@ -194,7 +194,7 @@ class Libp2pService { return this.node.peerId; } - handleMessage(protocol, blockchainImplementations, handler) { + handleMessage(protocol, handler) { this.logger.info(`Enabling network protocol: ${protocol}`); this.node.handle(protocol, async (handlerProps) => { @@ -245,25 +245,11 @@ class Libp2pService { this.logger.debug( `Receiving message from ${peerIdString} to ${this.config.id}: protocol: ${protocol}, messageType: ${message.header.messageType};`, ); - const modifiedMessage = this.modifyMessage(message, blockchainImplementations); - await handler(modifiedMessage, peerIdString); + await handler(message, peerIdString); } }); } - modifyMessage(message, blockchainImplementations) { - const modifiedMessage = message; - if (modifiedMessage.data.blockchain?.split(':').length === 1) { - for (const implementation of blockchainImplementations) { - if (implementation.split(':')[0] === modifiedMessage.data.blockchain) { - modifiedMessage.data.blockchain = implementation; - break; - } - } - } - return modifiedMessage; - } - updateSessionStream(operationId, keywordUuid, peerIdString, stream) { this.logger.trace( `Storing new session stream for remotePeerId: ${peerIdString} with operation id: ${operationId}`, From 6c6681d1e27c7424752b9cc2769a9f358121e401 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 24 Nov 2023 17:00:56 +0100 Subject: [PATCH 38/72] Remove code for splitting blockchain name in callImplementationFunction --- src/modules/blockchain/blockchain-module-manager.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/modules/blockchain/blockchain-module-manager.js b/src/modules/blockchain/blockchain-module-manager.js index 0af7f08a72..d7b8b98c19 100644 --- a/src/modules/blockchain/blockchain-module-manager.js +++ b/src/modules/blockchain/blockchain-module-manager.js @@ -393,8 +393,6 @@ class BlockchainModuleManager extends BaseModuleManager { callImplementationFunction(blockchain, functionName, args = []) { if (blockchain) { - // const split = blockchain.split(':'); - // const [name] = split; if (this.getImplementation(blockchain)) { return this.getImplementation(blockchain).module[functionName](...args); } From 8759fa1f6216f332afa9c5eefde7de69a16d0c91 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Mon, 27 Nov 2023 10:13:34 +0100 Subject: [PATCH 39/72] Package-lock.json update --- package-lock.json | 87 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3f4be22abd..00bfae4443 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.0.16", + "version": "6.0.20", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.0.16", + "version": "6.0.20", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", @@ -22,10 +22,10 @@ "async": "^3.2.4", "async-mutex": "^0.3.2", "awilix": "^7.0.3", - "axios": "^0.27.2", + "axios": "^1.6.0", "cors": "^2.8.5", "deep-extend": "^0.6.0", - "dkg-evm-module": "git+https://git@github.com:OriginTrail/dkg-evm-module.git#feature/multichain-integration", + "dkg-evm-module": "^4.0.7", "dotenv": "^16.0.1", "ethers": "^5.7.2", "express": "^4.18.1", @@ -6175,12 +6175,13 @@ } }, "node_modules/axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", "dependencies": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" } }, "node_modules/axios/node_modules/form-data": { @@ -8195,6 +8196,16 @@ "integrity": "sha512-/xJX0/VTPcbc5xQE2VUP91y1xN8q/rDfhEzLm+vLc3hYvb5+qHCnpJRuFcrKn63zumK/sCwYYzhG8HP78JYSTA==", "dev": true }, + "node_modules/dkg.js/node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, "node_modules/dkg.js/node_modules/ethers": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.2.2.tgz", @@ -8222,6 +8233,20 @@ "node": ">=14.0.0" } }, + "node_modules/dkg.js/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/dkg.js/node_modules/tslib": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", @@ -15646,6 +15671,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", @@ -24548,12 +24578,13 @@ "peer": true }, "axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", "requires": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" }, "dependencies": { "form-data": { @@ -25681,7 +25712,7 @@ }, "dkg-evm-module": { "version": "git+https://git@github.com/OriginTrail/dkg-evm-module.git#6e70f03ea3907d89f1a24d7dbc78d2699814ec36", - "from": "dkg-evm-module@git+https://git@github.com:OriginTrail/dkg-evm-module.git#feature/multichain-integration", + "from": "dkg-evm-module@^4.0.7", "requires": { "@openzeppelin/contracts": "^4.9.3", "@polkadot/api": "^10.1.4", @@ -26101,6 +26132,16 @@ "integrity": "sha512-/xJX0/VTPcbc5xQE2VUP91y1xN8q/rDfhEzLm+vLc3hYvb5+qHCnpJRuFcrKn63zumK/sCwYYzhG8HP78JYSTA==", "dev": true }, + "axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dev": true, + "requires": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, "ethers": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.2.2.tgz", @@ -26115,6 +26156,17 @@ "ws": "8.5.0" } }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, "tslib": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", @@ -31907,6 +31959,11 @@ } } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", From 659397c992a813cf24970e0bdac616c09cebbeea Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Mon, 27 Nov 2023 10:29:15 +0100 Subject: [PATCH 40/72] Remove restart after ual migration --- src/migration/migration-executor.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/migration/migration-executor.js b/src/migration/migration-executor.js index 510b5c970d..3f8cfc44f0 100644 --- a/src/migration/migration-executor.js +++ b/src/migration/migration-executor.js @@ -327,8 +327,6 @@ class MigrationExecutor { ); if (!(await migration.migrationAlreadyExecuted())) { await migration.migrate(); - // logger.info('Node will now restart!'); - // this.exitNode(1); } } From 9462a3b3e79b0fcebe5814dd849c52da37b83858 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Mon, 27 Nov 2023 10:48:52 +0100 Subject: [PATCH 41/72] Revert to using oracle for gas price --- .../blockchain/implementation/gnosis/gnosis-service.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/blockchain/implementation/gnosis/gnosis-service.js b/src/modules/blockchain/implementation/gnosis/gnosis-service.js index 582d9ea475..29a6d25105 100644 --- a/src/modules/blockchain/implementation/gnosis/gnosis-service.js +++ b/src/modules/blockchain/implementation/gnosis/gnosis-service.js @@ -1,3 +1,4 @@ +import axios from 'axios'; import Web3Service from '../web3-service.js'; import { BLOCK_TIME_MILLIS } from '../../../../constants/constants.js'; @@ -14,10 +15,11 @@ class GnosisService extends Web3Service { } async getGasPrice() { - if (this.config.gasPriceOracleLink) return super.getGasPrice(); - try { - return this.provider.getGasPrice(); + const response = await axios.get(this.config.gasPriceOracleLink); + const gasPriceRounded = Math.round(response.result * 1e9); + this.logger.debug(`Gas price on Gnosis: ${gasPriceRounded}`); + return gasPriceRounded; } catch (error) { return undefined; } From fcc4cf9eab6705d79780a8b2457577ad520a0b5c Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Mon, 27 Nov 2023 14:53:37 +0100 Subject: [PATCH 42/72] Add devnet gnosis config and gnosis getGas handles mainnet and testnet differently --- config/config.json | 13 ++++++++++++- .../implementation/gnosis/gnosis-service.js | 11 ++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config/config.json b/config/config.json index 15227d717e..ea6841d597 100644 --- a/config/config.json +++ b/config/config.json @@ -442,9 +442,10 @@ "gnosis:10200": { "enabled": false, "package": "./blockchain/implementation/gnosis/gnosis-service.js", + "config": { "hubContractAddress": "", - "gasPriceOracleLink": "", + "gasPriceOracleLink": "https://blockscout.chiadochain.net/api/v1/gas-price-oracle", "rpcEndpoints": ["https://rpc.chiadochain.net"] } } @@ -601,6 +602,16 @@ "https://lofar.origintrail.network" ] } + }, + "gnosis:10200": { + "enabled": false, + "package": "./blockchain/implementation/gnosis/gnosis-service.js", + + "config": { + "hubContractAddress": "", + "gasPriceOracleLink": "https://blockscout.chiadochain.net/api/v1/gas-price-oracle", + "rpcEndpoints": ["https://rpc.chiadochain.net"] + } } } }, diff --git a/src/modules/blockchain/implementation/gnosis/gnosis-service.js b/src/modules/blockchain/implementation/gnosis/gnosis-service.js index 29a6d25105..4c74dbb03b 100644 --- a/src/modules/blockchain/implementation/gnosis/gnosis-service.js +++ b/src/modules/blockchain/implementation/gnosis/gnosis-service.js @@ -17,9 +17,14 @@ class GnosisService extends Web3Service { async getGasPrice() { try { const response = await axios.get(this.config.gasPriceOracleLink); - const gasPriceRounded = Math.round(response.result * 1e9); - this.logger.debug(`Gas price on Gnosis: ${gasPriceRounded}`); - return gasPriceRounded; + let gasPrice; + if (this.config.name.split(':')[1] === '100') { + gasPrice = Number(response.result, 10); + } else if (this.config.name.split(':')[1] === '10200') { + gasPrice = Math.round(response.average * 1e9); + } + this.logger.debug(`Gas price on Gnosis: ${gasPrice}`); + return gasPrice; } catch (error) { return undefined; } From 11709cd2dd23bf7b5d7fe046cea20e0b29e61d4b Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Tue, 28 Nov 2023 12:07:50 +0100 Subject: [PATCH 43/72] Updated local network setup script, updated bdd tests --- config/config.json | 54 +--- src/service/validation-service.js | 5 +- test/bdd/features/get-errors.feature | 28 +-- test/bdd/features/get.feature | 104 ++++---- test/bdd/features/publish-errors.feature | 2 +- test/bdd/features/publish.feature | 12 +- test/bdd/features/update.feature | 22 +- test/bdd/steps/blockchain.mjs | 4 +- test/bdd/steps/common.mjs | 236 +++++++++--------- test/utilities/steps-utils.mjs | 50 ++-- .../.origintrail_noderc_template.json | 23 +- tools/local-network-setup/README.md | 3 +- .../generate-config-files.js | 8 +- .../setup-macos-environment.sh | 2 +- 14 files changed, 258 insertions(+), 295 deletions(-) diff --git a/config/config.json b/config/config.json index ea6841d597..00fcae1be4 100644 --- a/config/config.json +++ b/config/config.json @@ -112,7 +112,7 @@ "blockchain": { "enabled": true, "implementation": { - "hardhat:31337": { + "hardhat1:31337": { "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { @@ -133,46 +133,6 @@ "initialStakeAmount": 50000, "initialAskAmount": 0.2 } - }, - "otp": { - "enabled": false, - "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", - "config": { - "hubContractAddress": "0x707233a55bD035C6Bc732196CA4dbffa63CbA169", - "rpcEndpoints": [ - "https://lofar-tm-rpc.origin-trail.network", - "https://lofar.origintrail.network/" - ], - "initialStakeAmount": 50000, - "initialAskAmount": 2 - } - }, - "polygon": { - "enabled": false, - "package": "./blockchain/implementation/polygon/polygon-service.js", - "config": { - "hubContractAddress": "0xdaa16AC171CfE8Df6F79C06E7EEAb2249E2C9Ec8", - "gasPriceOracleLink": "https://gasstation-mumbai.matic.today/v2", - "rpcEndpoints": [ - "https://matic-mumbai.chainstacklabs.com", - "https://rpc-mumbai.matic.today", - "https://matic-testnet-archive-rpc.bwarelabs.com" - ], - "evmManagementPublicKey": "0x1B420da5f7Be66567526E32bc68ab29F1A63765A", - "initialStakeAmount": 50000, - "initialAskAmount": 2 - } - }, - "rinkeby": { - "enabled": false, - "package": "./blockchain/implementation/polygon/eth-service.js", - "config": { - "hubContractAddress": "", - "gasPriceOracleLink": "", - "rpcEndpoints": [], - "initialStakeAmount": 50000, - "initialAskAmount": 2 - } } } }, @@ -295,7 +255,7 @@ "blockchain": { "enabled": true, "implementation": { - "hardhat:31337": { + "hardhat1:31337": { "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { @@ -304,6 +264,16 @@ "initialStakeAmount": 50000, "initialAskAmount": 0.2 } + }, + "hardhat2:31337": { + "enabled": true, + "package": "./blockchain/implementation/hardhat/hardhat-service.js", + "config": { + "hubContractAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", + "rpcEndpoints": ["http://localhost:9545"], + "initialStakeAmount": 50000, + "initialAskAmount": 0.2 + } } } }, diff --git a/src/service/validation-service.js b/src/service/validation-service.js index 0786db76d0..3218387d88 100644 --- a/src/service/validation-service.js +++ b/src/service/validation-service.js @@ -16,11 +16,14 @@ class ValidationService { let isValid = true; try { - await this.blockchainModuleManager.getKnowledgeAssetOwner( + const result = await this.blockchainModuleManager.getKnowledgeAssetOwner( blockchain, contract, tokenId, ); + if (!result) { + isValid = false; + } } catch (err) { isValid = false; } diff --git a/test/bdd/features/get-errors.feature b/test/bdd/features/get-errors.feature index 9f0286e9b9..ba16564fab 100644 --- a/test/bdd/features/get-errors.feature +++ b/test/bdd/features/get-errors.feature @@ -8,7 +8,7 @@ Feature: Get errors test Given I setup 4 nodes And I wait for 5 seconds - When I call Get directly on the node 1 with nonExistentUAL + When I call Get directly on the node 1 with nonExistentUAL on blockchain hardhat1:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: GetRouteError @@ -17,35 +17,35 @@ Feature: Get errors test Given I setup 4 nodes And I wait for 5 seconds - When I call Get directly on the node 1 with invalidUAL + When I call Get directly on the node 1 with invalidUAL on blockchain hardhat1:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: GetRouteError @get-errors Scenario: Getting non-existent state Given I setup 4 nodes - And I set R0 to be 1 on blockchain test1 - And I set R1 to be 2 on blockchain test1 - And I set R0 to be 1 on blockchain test2 - And I set R1 to be 2 on blockchain test2 + And I set R0 to be 1 on blockchain hardhat1:31337 + And I set R1 to be 2 on blockchain hardhat1:31337 + And I set R0 to be 1 on blockchain hardhat2:31337 + And I set R1 to be 2 on blockchain hardhat2:31337 And I wait for 5 seconds - When I call Publish on the node 1 with validAssertion + When I call Publish on the node 1 with validAssertion on blockchain hardhat1:31337 And I wait for latest Publish to finalize - And I call Get directly on the node 1 with nonExistentState + And I call Get directly on the node 1 with nonExistentState on blockchain hardhat1:31337 Then It should fail with status code 400 @get-errors Scenario: Getting invalid state hash Given I setup 4 nodes - And I set R0 to be 1 on blockchain test1 - And I set R1 to be 2 on blockchain test1 - And I set R0 to be 1 on blockchain test2 - And I set R1 to be 2 on blockchain test2 + And I set R0 to be 1 on blockchain hardhat1:31337 + And I set R1 to be 2 on blockchain hardhat1:31337 + And I set R0 to be 1 on blockchain hardhat2:31337 + And I set R1 to be 2 on blockchain hardhat2:31337 And I wait for 5 seconds - When I call Publish on the node 1 with validAssertion + When I call Publish on the node 1 with validAssertion on blockchain hardhat1:31337 And I wait for latest Publish to finalize - And I call Get directly on the node 1 with invalidStateHash + And I call Get directly on the node 1 with invalidStateHash on blockchain hardhat1:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: GetAssertionIdError diff --git a/test/bdd/features/get.feature b/test/bdd/features/get.feature index 8a51797c57..f27035795b 100644 --- a/test/bdd/features/get.feature +++ b/test/bdd/features/get.feature @@ -5,131 +5,131 @@ Feature: Get asset states test @release Scenario: Get first state of the updated knowledge asset on both blockchains - Given I set R0 to be 1 on blockchain test1 - And I set R1 to be 2 on blockchain test1 - And I set finalizationCommitsNumber to be 2 on blockchain test1 - And I set R0 to be 1 on blockchain test2 - And I set R1 to be 2 on blockchain test2 - And I set finalizationCommitsNumber to be 2 on blockchain test2 + Given I set R0 to be 1 on blockchain hardhat1:31337 + And I set R1 to be 2 on blockchain hardhat1:31337 + And I set finalizationCommitsNumber to be 2 on blockchain hardhat1:31337 + And I set R0 to be 1 on blockchain hardhat2:31337 + And I set R1 to be 2 on blockchain hardhat2:31337 + And I set finalizationCommitsNumber to be 2 on blockchain hardhat2:31337 And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain hardhat1:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test2 + + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain hardhat2:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - - When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test1 + + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain hardhat1:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test2 + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain hardhat2:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - When I call Get directly on the node 4 with validGetFirstStateRequestBody on blockchain test1 + When I call Get directly on the node 4 with validGetFirstStateRequestBody on blockchain hardhat1:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED - - When I call Get directly on the node 4 with validGetFirstStateRequestBody on blockchain test2 + + When I call Get directly on the node 4 with validGetFirstStateRequestBody on blockchain hardhat2:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED @release Scenario: Get latest state of the updated knowledge asset on both blockchains - Given I set R0 to be 1 on blockchain test1 - And I set R1 to be 2 on blockchain test1 - And I set finalizationCommitsNumber to be 2 on blockchain test1 - And I set R0 to be 1 on blockchain test2 - And I set R1 to be 2 on blockchain test2 - And I set finalizationCommitsNumber to be 2 on blockchain test2 + Given I set R0 to be 1 on blockchain hardhat1:31337 + And I set R1 to be 2 on blockchain hardhat1:31337 + And I set finalizationCommitsNumber to be 2 on blockchain hardhat1:31337 + And I set R0 to be 1 on blockchain hardhat2:31337 + And I set R1 to be 2 on blockchain hardhat2:31337 + And I set finalizationCommitsNumber to be 2 on blockchain hardhat2:31337 And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain hardhat1:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test2 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain hardhat2:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - - When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test1 + + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain hardhat1:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test2 + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain hardhat2:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - - When I call Get directly on the node 4 with validGetUpdatedStateRequestBody on blockchain test1 + + When I call Get directly on the node 4 with validGetUpdatedStateRequestBody on blockchain hardhat1:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED - When I call Get directly on the node 4 with validGetUpdatedStateRequestBody on blockchain test2 + When I call Get directly on the node 4 with validGetUpdatedStateRequestBody on blockchain hardhat2:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED @release Scenario: Get all states of the knowledge asset that is updated 2 times on both blockchains - Given I set R0 to be 1 on blockchain test1 - And I set R1 to be 2 on blockchain test1 - And I set finalizationCommitsNumber to be 2 on blockchain test1 - And I set R0 to be 1 on blockchain test2 - And I set R1 to be 2 on blockchain test2 - And I set finalizationCommitsNumber to be 2 on blockchain test2 + Given I set R0 to be 1 on blockchain hardhat1:31337 + And I set R1 to be 2 on blockchain hardhat1:31337 + And I set finalizationCommitsNumber to be 2 on blockchain hardhat1:31337 + And I set R0 to be 1 on blockchain hardhat2:31337 + And I set R1 to be 2 on blockchain hardhat2:31337 + And I set finalizationCommitsNumber to be 2 on blockchain hardhat2:31337 And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain hardhat1:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test2 + + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain hardhat2:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test1 + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain hardhat1:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test2 + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain hardhat2:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED And I wait for 30 seconds - When I call Update on the node 4 for the latest published UAL with validUpdate_2 on blockchain test1 + When I call Update on the node 4 for the latest published UAL with validUpdate_2 on blockchain hardhat1:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - - When I call Update on the node 4 for the latest published UAL with validUpdate_2 on blockchain test2 + + When I call Update on the node 4 for the latest published UAL with validUpdate_2 on blockchain hardhat2:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - When I call Get directly on the node 4 with getFirstStateRequestBody on blockchain test1 + When I call Get directly on the node 4 with getFirstStateRequestBody on blockchain hardhat1:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED - - When I call Get directly on the node 4 with getFirstStateRequestBody on blockchain test2 + + When I call Get directly on the node 4 with getFirstStateRequestBody on blockchain hardhat2:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED - When I call Get directly on the node 4 with getSecondStateRequestBody on blockchain test1 + When I call Get directly on the node 4 with getSecondStateRequestBody on blockchain hardhat1:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED - - When I call Get directly on the node 4 with getSecondStateRequestBody on blockchain test2 + + When I call Get directly on the node 4 with getSecondStateRequestBody on blockchain hardhat2:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED - When I call Get directly on the node 4 with getThirdStateRequestBody on blockchain test1 + When I call Get directly on the node 4 with getThirdStateRequestBody on blockchain hardhat1:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED - - When I call Get directly on the node 4 with getThirdStateRequestBody on blockchain test2 + + When I call Get directly on the node 4 with getThirdStateRequestBody on blockchain hardhat2:31337 And I wait for latest resolve to finalize Then Latest Get operation finished with status: COMPLETED diff --git a/test/bdd/features/publish-errors.feature b/test/bdd/features/publish-errors.feature index e1e7566192..a717855f6a 100644 --- a/test/bdd/features/publish-errors.feature +++ b/test/bdd/features/publish-errors.feature @@ -8,7 +8,7 @@ Feature: Publish errors test Given I setup 2 nodes And I wait for 5 seconds - When I call Publish on the node 1 with validAssertion + When I call Publish on the node 1 with validAssertion on blockchain hardhat1:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: PublishStartError diff --git a/test/bdd/features/publish.feature b/test/bdd/features/publish.feature index 21d49731b7..6317726472 100644 --- a/test/bdd/features/publish.feature +++ b/test/bdd/features/publish.feature @@ -5,17 +5,17 @@ Feature: Release related tests @release Scenario: Publishing a valid assertion on both blockchains - Given I set R0 to be 1 on blockchain test1 - And I set R1 to be 2 on blockchain test1 - And I set R0 to be 1 on blockchain test2 - And I set R1 to be 2 on blockchain test2 + Given I set R0 to be 1 on blockchain hardhat1:31337 + And I set R1 to be 2 on blockchain hardhat1:31337 + And I set R0 to be 1 on blockchain hardhat2:31337 + And I set R1 to be 2 on blockchain hardhat2:31337 And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validAssertion on blockchain test1 + When I call Publish on the node 4 with validAssertion on blockchain hardhat1:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - When I call Publish on the node 4 with validAssertion on blockchain test2 + When I call Publish on the node 4 with validAssertion on blockchain hardhat2:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED diff --git a/test/bdd/features/update.feature b/test/bdd/features/update.feature index fc8356b238..e0ce54dc91 100644 --- a/test/bdd/features/update.feature +++ b/test/bdd/features/update.feature @@ -5,27 +5,27 @@ Feature: Update asset test @release Scenario: Update an existing knowledge asset on both blockchains - Given I set R0 to be 1 on blockchain test1 - And I set R1 to be 2 on blockchain test1 - And I set finalizationCommitsNumber to be 2 on blockchain test1 - And I set R0 to be 1 on blockchain test2 - And I set R1 to be 2 on blockchain test2 - And I set finalizationCommitsNumber to be 2 on blockchain test2 + Given I set R0 to be 1 on blockchain hardhat1:31337 + And I set R1 to be 2 on blockchain hardhat1:31337 + And I set finalizationCommitsNumber to be 2 on blockchain hardhat1:31337 + And I set R0 to be 1 on blockchain hardhat2:31337 + And I set R1 to be 2 on blockchain hardhat2:31337 + And I set finalizationCommitsNumber to be 2 on blockchain hardhat2:31337 And I setup 4 nodes And I wait for 5 seconds - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test1 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain hardhat1:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain test2 + When I call Publish on the node 4 with validPublish_1ForValidUpdate_1 on blockchain hardhat2:31337 And I wait for latest Publish to finalize Then Latest Publish operation finished with status: COMPLETED - When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test1 + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain hardhat1:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED - - When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain test2 + + When I call Update on the node 4 for the latest published UAL with validUpdate_1 on blockchain hardhat2:31337 And I wait for latest Update to finalize Then Latest Update operation finished with status: COMPLETED diff --git a/test/bdd/steps/blockchain.mjs b/test/bdd/steps/blockchain.mjs index 85fc7c9bb9..01fbccae97 100644 --- a/test/bdd/steps/blockchain.mjs +++ b/test/bdd/steps/blockchain.mjs @@ -6,8 +6,8 @@ import LocalBlockchain from './lib/local-blockchain.mjs'; Given(/^the blockchains are set up$/, { timeout: 240_000 }, function blockchainSetup(done) { const blockchains = [ - {name: 'test1', port: 8545}, - {name: 'test2', port: 9545} + {name: 'hardhat1:31337', port: 8545}, + {name: 'hardhat2:31337', port: 9545} ] const promises = []; diff --git a/test/bdd/steps/common.mjs b/test/bdd/steps/common.mjs index aa1a74757f..7d8886d8eb 100644 --- a/test/bdd/steps/common.mjs +++ b/test/bdd/steps/common.mjs @@ -14,21 +14,21 @@ Given( { timeout: 30000 }, function nodeSetup(nodeCount, done) { this.logger.log(`I setup ${nodeCount} node${nodeCount !== 1 ? 's' : ''}`); - const wallets = {}; - Object.keys(this.state.localBlockchains).forEach((localBlockchain) => { - wallets[localBlockchain] = this.state.localBlockchains[localBlockchain].getWallets(); - }); + const currentNumberOfNodes = Object.keys(this.state.nodes).length; let nodesStarted = 0; for (let i = 0; i < nodeCount; i += 1) { const nodeIndex = currentNumberOfNodes + i; - const nodeWallets = Object.keys(wallets).map((localBlockchain) => { - return wallets[localBlockchain][nodeIndex + 1]; - }); - const nodeManagementWallets = Object.keys(wallets).map((localBlockchain) => { - return wallets[localBlockchain][ - nodeIndex + 1 + Math.floor(wallets[localBlockchain].length / 2) - ]; + const blockchains = []; + Object.keys(this.state.localBlockchains).forEach((blockchainId) => { + const blockchain = this.state.localBlockchains[blockchainId]; + const wallets = blockchain.getWallets(); + blockchains.push({ + blockchainId, + operationalWallet: wallets[nodeIndex], + managementWallet: wallets[nodeIndex + Math.floor(wallets.length / 2)], + port: blockchain.port + }) }); const rpcPort = 8901 + nodeIndex; const networkPort = 9001 + nodeIndex; @@ -36,9 +36,7 @@ Given( const sharesTokenName = `origintrail-test-${nodeIndex}`; const sharesTokenSymbol = `OT-T-${nodeIndex}`; const nodeConfiguration = stepsUtils.createNodeConfiguration( - this.state.localBlockchains, - nodeWallets, - nodeManagementWallets, + blockchains, nodeIndex, nodeName, rpcPort, @@ -69,13 +67,15 @@ Given( contentType: 'all', }); let clientBlockchainOptions = {}; - Object.keys(this.state.localBlockchains).forEach((localBlockchain, index) => { - clientBlockchainOptions[localBlockchain] = { + Object.keys(this.state.localBlockchains).forEach((blockchainId, index) => { + const blockchain = this.state.localBlockchains[blockchainId]; + const wallets = blockchain.getWallets(); + clientBlockchainOptions[blockchainId] = { blockchain: { - name: localBlockchain, - publicKey: nodeWallets[index].address, - privateKey: nodeWallets[index].privateKey, - rpc: `http://localhost:${this.state.localBlockchains[localBlockchain].port}`, + name: blockchainId, + publicKey: wallets[index].address, + privateKey: wallets[index].privateKey, + rpc: `http://localhost:${blockchain.port}`, hubContract: '0x5FbDB2315678afecb367f032d93F642f64180aa3', }, }; @@ -110,17 +110,17 @@ Given( expect(nodeCount).to.be.equal(1); // Currently not supported more. this.logger.log('Initializing bootstrap node'); const nodeIndex = Object.keys(this.state.nodes).length; - const wallets = {}; - Object.keys(this.state.localBlockchains).forEach((localBlockchain) => { - wallets[localBlockchain] = this.state.localBlockchains[localBlockchain].getWallets(); - }); - const nodeWallets = Object.keys(wallets).map((localBlockchain) => { - return wallets[localBlockchain][nodeIndex]; - }); - const nodeManagementWallets = Object.keys(wallets).map((localBlockchain) => { - return wallets[localBlockchain][ - nodeIndex + Math.floor(wallets[localBlockchain].length / 2) - ]; + + const blockchains = []; + Object.keys(this.state.localBlockchains).forEach((blockchainId) => { + const blockchain = this.state.localBlockchains[blockchainId]; + const wallets = blockchain.getWallets(); + blockchains.push({ + blockchainId, + operationalWallet: wallets[0], + managementWallet: wallets[Math.floor(wallets.length / 2)], + port: this.state.localBlockchains[blockchainId].port + }) }); const rpcPort = 8900; const networkPort = 9000; @@ -128,9 +128,7 @@ Given( const sharesTokenName = `${nodeName}-${nodeIndex}`; const sharesTokenSymbol = `OT-B-${nodeIndex}`; const nodeConfiguration = stepsUtils.createNodeConfiguration( - this.state.localBlockchains, - nodeWallets, - nodeManagementWallets, + blockchains, nodeIndex, nodeName, rpcPort, @@ -173,87 +171,95 @@ Given( }); }, ); -// regex allows strings separated by dots -Given( - /^I setup node (\d+) with ([a-z][\w-]*(?:\.[\w-]+)*) set to ([^"]*)$/, - { timeout: 120000 }, - function setupPublishNode(nodeNum, propertyName, propertyValue, done) { - const nodeIndex = Object.keys(this.state.nodes).length; - const wallets = this.state.localBlockchain.getWallets(); - const wallet = wallets[nodeIndex + 1]; - const managementWallet = - this.state.localBlockchain.getWallets()[nodeIndex + 1 + Math.floor(wallets.length / 2)]; - const rpcPort = 8901 + nodeIndex; - const networkPort = 9001 + nodeIndex; - const nodeName = `origintrail-test-${nodeIndex}`; - const sharesTokenName = `origintrail-test-${nodeIndex}`; - const sharesTokenSymbol = `OT-T-${nodeIndex}`; - const nodeConfiguration = stepsUtils.createNodeConfiguration( - wallet, - managementWallet, - nodeIndex, - nodeName, - rpcPort, - networkPort, - sharesTokenName, - sharesTokenSymbol, - ); - const propertyNameSplit = propertyName.split('.'); - this.logger.log(`I setup node ${nodeNum} with ${propertyName} set to ${propertyValue}`); - expect( - Object.prototype.hasOwnProperty.call(nodeConfiguration, propertyNameSplit[0]), - `Property ${propertyName} doesn't exist`, - ).to.be.equal(true); - let propName = nodeConfiguration; - for (let i = 0; i < propertyNameSplit.length - 1; i += 1) { - propName = propName[propertyNameSplit[i]]; - } - if (propName[propertyNameSplit.slice(-1)] !== undefined) { - propName[propertyNameSplit.slice(-1)] = propertyValue === '\\0' ? '\0' : propertyValue; - } else { - assert.fail(`Property ${propertyName} doesn't exist`); - } - const forkedNode = stepsUtils.forkNode(nodeConfiguration); - - const logFileStream = fs.createWriteStream(`${this.state.scenarionLogDir}/${nodeName}.log`); - forkedNode.stdout.setEncoding('utf8'); - forkedNode.stdout.on('data', (data) => { - // Here is where the output goes - logFileStream.write(data); - }); - - // eslint-disable-next-line no-loop-func - forkedNode.on('message', (response) => { - if (response.error) { - assert.fail(`Error while initializing node${nodeIndex} : ${response.error}`); - } else { - const client = new DkgClientHelper({ - endpoint: 'http://localhost', - port: rpcPort, - blockchain: { - name: 'hardhat', - publicKey: wallet.address, - privateKey: wallet.privateKey, - }, - maxNumberOfRetries: 5, - frequency: 2, - contentType: 'all', - }); - this.state.nodes[nodeIndex] = { - client, - forkedNode, - configuration: nodeConfiguration, - nodeRpcUrl: `http://localhost:${rpcPort}`, - fileService: new FileService({ - config: nodeConfiguration, - logger: this.logger, - }), - }; - } - done(); - }); - }, -); +// +// Given( +// /^I setup node (\d+) with ([a-z][\w-]*(?:\.[\w-]+)*) set to ([^"]*)$/, +// { timeout: 120000 }, +// function setupPublishNode(nodeNum, propertyName, propertyValue, done) { +// const nodeIndex = Object.keys(this.state.nodes).length; +// +// const blockchains = []; +// +// Object.keys(this.state.localBlockchains).forEach((blockchainId) => { +// const blockchain = this.state.localBlockchains[blockchainId]; +// const wallets = blockchain.getWallets(); +// blockchains.push({ +// blockchainId, +// operationalWallet: wallets[nodeIndex], +// managementWallet: wallets[nodeIndex + Math.floor(wallets[blockchainId].length / 2)], +// port: blockchain.port +// }) +// }); +// const rpcPort = 8901 + nodeIndex; +// const networkPort = 9001 + nodeIndex; +// const nodeName = `origintrail-test-${nodeIndex}`; +// const sharesTokenName = `origintrail-test-${nodeIndex}`; +// const sharesTokenSymbol = `OT-T-${nodeIndex}`; +// const nodeConfiguration = stepsUtils.createNodeConfiguration( +// blockchains, +// nodeIndex, +// nodeName, +// rpcPort, +// networkPort, +// sharesTokenName, +// sharesTokenSymbol, +// ); +// const propertyNameSplit = propertyName.split('.'); +// this.logger.log(`I setup node ${nodeNum} with ${propertyName} set to ${propertyValue}`); +// expect( +// Object.prototype.hasOwnProperty.call(nodeConfiguration, propertyNameSplit[0]), +// `Property ${propertyName} doesn't exist`, +// ).to.be.equal(true); +// let propName = nodeConfiguration; +// for (let i = 0; i < propertyNameSplit.length - 1; i += 1) { +// propName = propName[propertyNameSplit[i]]; +// } +// if (propName[propertyNameSplit.slice(-1)] !== undefined) { +// propName[propertyNameSplit.slice(-1)] = propertyValue === '\\0' ? '\0' : propertyValue; +// } else { +// assert.fail(`Property ${propertyName} doesn't exist`); +// } +// const forkedNode = stepsUtils.forkNode(nodeConfiguration); +// +// const logFileStream = fs.createWriteStream(`${this.state.scenarionLogDir}/${nodeName}.log`); +// forkedNode.stdout.setEncoding('utf8'); +// forkedNode.stdout.on('data', (data) => { +// // Here is where the output goes +// logFileStream.write(data); +// }); +// +// // eslint-disable-next-line no-loop-func +// forkedNode.on('message', (response) => { +// if (response.error) { +// assert.fail(`Error while initializing node${nodeIndex} : ${response.error}`); +// } else { +// const client = new DkgClientHelper({ +// endpoint: 'http://localhost', +// port: rpcPort, +// blockchain: { +// name: 'hardhat', +// publicKey: wallet.address, +// privateKey: wallet.privateKey, +// }, +// maxNumberOfRetries: 5, +// frequency: 2, +// contentType: 'all', +// }); +// this.state.nodes[nodeIndex] = { +// client, +// forkedNode, +// configuration: nodeConfiguration, +// nodeRpcUrl: `http://localhost:${rpcPort}`, +// fileService: new FileService({ +// config: nodeConfiguration, +// logger: this.logger, +// }), +// }; +// } +// done(); +// }); +// }, +// ); Then( /Latest (Get|Publish|Update) operation finished with status: ([COMPLETED|FAILED|PublishValidateAssertionError|PublishStartError|GetAssertionIdError|GetNetworkError|GetLocalError|PublishRouteError]+)$/, diff --git a/test/utilities/steps-utils.mjs b/test/utilities/steps-utils.mjs index 41d824aef6..36cfa244ce 100644 --- a/test/utilities/steps-utils.mjs +++ b/test/utilities/steps-utils.mjs @@ -8,10 +8,25 @@ class StepsUtils { return forkedNode; } + /** + * + * @param blockchains [{ + * blockchainId: 'blockchainId', + * port: '', + * operationalWallet: 'operationalWallet', + * managementWallet: 'managementWallet' + * }] + * @param nodeIndex + * @param nodeName + * @param rpcPort + * @param networkPort + * @param sharesTokenName + * @param sharesTokenSymbol + * @param bootstrap + * @returns {{operationalDatabase: {databaseName: (string|string)}, graphDatabase: {name}, auth: {ipBasedAuthEnabled: boolean}, appDataPath: (string|string), rpcPort, modules: {httpClient: {implementation: {"express-http-client": {config: {port}}}}, repository: {implementation: {"sequelize-repository": {config: {database: (string|string)}}}}, tripleStore: {implementation: {"ot-blazegraph": {config: {repositories: {publicHistory: {password: string, name: string, url: string, username: string}, publicCurrent: {password: string, name: string, url: string, username: string}, privateHistory: {password: string, name: string, url: string, username: string}, privateCurrent: {password: string, name: string, url: string, username: string}}}}}}, validation: {implementation: {"merkle-validation": {package: string, enabled: boolean}}, enabled: boolean}, network: {implementation: {"libp2p-service": {config: {privateKey: (string|undefined), port}}}}}}} + */ createNodeConfiguration( - localBlockchains, - nodeWallet, - nodeManagementWallet, + blockchains, nodeIndex, nodeName, rpcPort, @@ -23,18 +38,7 @@ class StepsUtils { let config = { modules: { blockchain: { - implementation: { - 'hardhat:31337': { - config: { - evmOperationalWalletPublicKey: wallet.address, - evmOperationalWalletPrivateKey: wallet.privateKey, - evmManagementWalletPublicKey: managementWallet.address, - evmManagementWalletPrivateKey: managementWallet.privateKey, - sharesTokenName, - sharesTokenSymbol, - }, - }, - }, + implementation: {} }, network: { implementation: { @@ -127,24 +131,24 @@ class StepsUtils { }, }; - Object.keys(localBlockchains).forEach((localBlockchain, index) => { - config.modules.blockchain.implementation[localBlockchain] = { + for (const blockchain of blockchains) { + config.modules.blockchain.implementation[blockchain.blockchainId] = { enabled: true, package: './blockchain/implementation/hardhat/hardhat-service.js', config: { hubContractAddress: '0x5FbDB2315678afecb367f032d93F642f64180aa3', - rpcEndpoints: [`http://localhost:${localBlockchains[localBlockchain].port}`], + rpcEndpoints: [`http://localhost:${blockchain.port}`], initialStakeAmount: 50000, initialAskAmount: 0.2, - evmOperationalWalletPublicKey: nodeWallets[index].address, - evmOperationalWalletPrivateKey: nodeWallets[index].privateKey, - evmManagementWalletPublicKey: nodeManagementWallets[index].address, - evmManagementWalletPrivateKey: nodeManagementWallets[index].privateKey, + evmOperationalWalletPublicKey: blockchain.operationalWallet.address, + evmOperationalWalletPrivateKey: blockchain.operationalWallet.privateKey, + evmManagementWalletPublicKey: blockchain.managementWallet.address, + evmManagementWalletPrivateKey: blockchain.managementWallet.privateKey, sharesTokenName, sharesTokenSymbol, }, }; - }); + } return config; } } diff --git a/tools/local-network-setup/.origintrail_noderc_template.json b/tools/local-network-setup/.origintrail_noderc_template.json index 133980ed57..f63e39a681 100644 --- a/tools/local-network-setup/.origintrail_noderc_template.json +++ b/tools/local-network-setup/.origintrail_noderc_template.json @@ -136,7 +136,7 @@ }, "blockchain": { "implementation": { - "hardhat:31337": { + "hardhat1:31337": { "enabled": true, "package": "./blockchain/implementation/hardhat/hardhat-service.js", "config": { @@ -152,27 +152,6 @@ "rpcEndpoints": [], "evmOperationalWalletPrivateKey": "0x02b39cac1532bef9dba3e36ec32d3de1e9a88f1dda597d3ac6e2130aed9adc4e" } - }, - "otp": { - "config": { - "evmOperationalWalletPublicKey": "...", - "evmOperationalWalletPrivateKey": "...", - "rpcEndpoints": [], - "evmManagementWalletPublicKey": "..." - } - }, - "polygon": { - "config": { - "rpcEndpoints": [] - } - }, - "rinkeby": { - "package": "./blockchain/implementation/polygon/eth-service.js", - "config": { - "hubContractAddress": "", - "gasPriceOracleLink": "", - "rpcEndpoints": [] - } } } } diff --git a/tools/local-network-setup/README.md b/tools/local-network-setup/README.md index 44ae3089f7..26cbf046e9 100644 --- a/tools/local-network-setup/README.md +++ b/tools/local-network-setup/README.md @@ -36,7 +36,8 @@ nano .env and paste the following content inside (save and close): ```bash NODE_ENV=development -RPC_ENDPOINT=http://localhost:8545 +RPC_ENDPOINT_BC1=http://localhost:8545 +RPC_ENDPOINT_BC2=http://localhost:9545 PRIVATE_KEY=02b39cac1532bef9dba3e36ec32d3de1e9a88f1dda597d3ac6e2130aed9adc4e ``` **Note:** The private key above is used ONLY for convenience and SHOULD be changed to a secure key when used in production. If you are connecting to rinkeby testnet network you need to provide valid RPC_ENDPOINT diff --git a/tools/local-network-setup/generate-config-files.js b/tools/local-network-setup/generate-config-files.js index 9ab3458d5e..cff6c9c5c8 100644 --- a/tools/local-network-setup/generate-config-files.js +++ b/tools/local-network-setup/generate-config-files.js @@ -99,10 +99,10 @@ function generateTripleStoreConfig(templateTripleStoreConfig, nodeIndex) { function generateBlockchainConfig(templateBlockchainConfig, nodeIndex) { const blockchainConfig = JSON.parse(JSON.stringify(templateBlockchainConfig)); - blockchainConfig.implementation[blockchain].config = { - ...blockchainConfig.implementation[blockchain].config, + blockchainConfig.implementation['hardhat1:31337'].config = { + ...blockchainConfig.implementation['hardhat1:31337'].config, hubContractAddress, - rpcEndpoints: [process.env.RPC_ENDPOINT1], + rpcEndpoints: [process.env.RPC_ENDPOINT_BC1], evmOperationalWalletPublicKey: publicKeys[nodeIndex], evmOperationalWalletPrivateKey: privateKeys[nodeIndex], evmManagementWalletPublicKey: publicKeys[publicKeys.length - 1 - nodeIndex], @@ -115,7 +115,7 @@ function generateBlockchainConfig(templateBlockchainConfig, nodeIndex) { blockchainConfig.implementation['hardhat2:31337'].config = { ...blockchainConfig.implementation['hardhat2:31337'].config, hubContractAddress, - rpcEndpoints: [process.env.RPC_ENDPOINT2], + rpcEndpoints: [process.env.RPC_ENDPOINT_BC2], evmOperationalWalletPublicKey: publicKeys[nodeIndex], evmOperationalWalletPrivateKey: privateKeys[nodeIndex], evmManagementWalletPublicKey: publicKeys[publicKeys.length - 1 - nodeIndex], diff --git a/tools/local-network-setup/setup-macos-environment.sh b/tools/local-network-setup/setup-macos-environment.sh index a729781be4..0b5151b107 100755 --- a/tools/local-network-setup/setup-macos-environment.sh +++ b/tools/local-network-setup/setup-macos-environment.sh @@ -71,7 +71,7 @@ echo ====== Generating configs ====== echo ================================ node $pathToOtNode/tools/local-network-setup/generate-config-files.js $numberOfNodes $network $tripleStore $hubContractAddress - +sleep 5 echo ================================ echo ======== Starting nodes ======== echo ================================ From 02476a61a8feaeb2073d6c0b42d068ae028bf015 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Tue, 28 Nov 2023 12:10:34 +0100 Subject: [PATCH 44/72] Updated test requests --- test/bdd/steps/api/datasets/requests.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/bdd/steps/api/datasets/requests.json b/test/bdd/steps/api/datasets/requests.json index be4fbce7cd..58a7c88980 100644 --- a/test/bdd/steps/api/datasets/requests.json +++ b/test/bdd/steps/api/datasets/requests.json @@ -8,27 +8,27 @@ "_:c14n0 \"Claude Shànnon\" .", "_:c14n0 ." ], - "blockchain": "test2", + "blockchain": "hardhat1:31337", "contract": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07", "tokenId": 0 }, "validGetFirstStateRequestBody": { - "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": "0xe3a6733d7b999ca6f0d141afe3e38ac59223a4dfde7a5458932d2094ed4193cf" }, "validGetUpdatedStateRequestBody": { - "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0" + "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0" }, "getFirstStateRequestBody": { - "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": "0xe3a6733d7b999ca6f0d141afe3e38ac59223a4dfde7a5458932d2094ed4193cf" }, "getSecondStateRequestBody": { - "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": "0x591503a1c8ba4667dd7afd203025c1bf594d817d8eec71274fe960d69fb8584f" }, "getThirdStateRequestBody": { - "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": "0x759c285786b95622dad67a6be857a4eec3d9ba0caec991ed4297629ae6abbc0d" }, "blockchainNotDefinedRequestBody": { @@ -46,17 +46,17 @@ "tokenId": 0 }, "nonExistentUAL": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/1" + "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/1" }, "invalidUAL": { "id": "did:dkg:hardhat/0xB0D4afd8879eD9F/52b28595d31B441D079B2Ca07/1" }, "nonExistentState": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": -1 }, "invalidStateHash": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": "0x591503a1c8ba4667dd7afd203025c1bf594d817d8eec71274fe960d69fb8584e" }, "validUpdateRequestBody": { @@ -66,7 +66,7 @@ " \"TL\" .", " ." ], - "blockchain": "test2", + "blockchain": "hardhat1:31337", "contract": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07", "tokenId": 0 } From bfae25faf8c2f8102d8c7c2b4b2436a94a0ae567 Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Tue, 28 Nov 2023 12:23:34 +0100 Subject: [PATCH 45/72] Requests updated, removed unnecessary logs --- test/bdd/steps/api/datasets/requests.json | 12 ++++++------ test/bdd/steps/api/get.mjs | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/bdd/steps/api/datasets/requests.json b/test/bdd/steps/api/datasets/requests.json index 58a7c88980..ac5eefe732 100644 --- a/test/bdd/steps/api/datasets/requests.json +++ b/test/bdd/steps/api/datasets/requests.json @@ -13,22 +13,22 @@ "tokenId": 0 }, "validGetFirstStateRequestBody": { - "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": "0xe3a6733d7b999ca6f0d141afe3e38ac59223a4dfde7a5458932d2094ed4193cf" }, "validGetUpdatedStateRequestBody": { - "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0" + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0" }, "getFirstStateRequestBody": { - "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": "0xe3a6733d7b999ca6f0d141afe3e38ac59223a4dfde7a5458932d2094ed4193cf" }, "getSecondStateRequestBody": { - "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": "0x591503a1c8ba4667dd7afd203025c1bf594d817d8eec71274fe960d69fb8584f" }, "getThirdStateRequestBody": { - "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", + "id": "did:dkg:blockchain/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", "state": "0x759c285786b95622dad67a6be857a4eec3d9ba0caec991ed4297629ae6abbc0d" }, "blockchainNotDefinedRequestBody": { @@ -49,7 +49,7 @@ "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/1" }, "invalidUAL": { - "id": "did:dkg:hardhat/0xB0D4afd8879eD9F/52b28595d31B441D079B2Ca07/1" + "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F/52b28595d31B441D079B2Ca07/1" }, "nonExistentState": { "id": "did:dkg:hardhat1:31337/0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07/0", diff --git a/test/bdd/steps/api/get.mjs b/test/bdd/steps/api/get.mjs index 7f3a0ed794..7b49dfd543 100644 --- a/test/bdd/steps/api/get.mjs +++ b/test/bdd/steps/api/get.mjs @@ -44,9 +44,7 @@ When( ).to.be.equal(true); const requestBody = JSON.parse(JSON.stringify(requests[requestName])); - this.logger.log(`Start: ${JSON.stringify(requestBody, null, 4)}`); requestBody.id = requestBody.id.replace('blockchain', blockchain); - this.logger.log(`Replace: ${JSON.stringify(requestBody, null, 4)}`); try { const result = await httpApiHelper.get( From dd4e5fc67f5f08ec286f002c79530210f138078f Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Tue, 28 Nov 2023 12:40:40 +0100 Subject: [PATCH 46/72] Blockchain log artifacts updated --- test/bdd/steps/blockchain.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bdd/steps/blockchain.mjs b/test/bdd/steps/blockchain.mjs index 01fbccae97..5ed3b4c2c8 100644 --- a/test/bdd/steps/blockchain.mjs +++ b/test/bdd/steps/blockchain.mjs @@ -12,10 +12,10 @@ Given(/^the blockchains are set up$/, { timeout: 240_000 }, function blockchainS const promises = []; - blockchains.forEach((blockchain)=>{ + blockchains.forEach((blockchain, index)=>{ this.logger.log(`Starting local blockchain ${blockchain.name} on port: ${blockchain.port}`); const blockchainConsole = new console.Console( - fs.createWriteStream(`${this.state.scenarionLogDir}/blockchain-${blockchain.name}.log`), + fs.createWriteStream(`${this.state.scenarionLogDir}/blockchain-${blockchain.name.replace(':', '-')}.log`), ); const localBlockchain = new LocalBlockchain(); this.state.localBlockchains[blockchain.name] = localBlockchain; From 8158b0a0675c9ba8cec740ebd1ad0a919317bbc1 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 28 Nov 2023 14:39:07 +0100 Subject: [PATCH 47/72] Handle gasPrice from oracle differently on mainnet and testnet --- scripts/set-ask.js | 17 ++++++++++++++--- scripts/set-stake.js | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/scripts/set-ask.js b/scripts/set-ask.js index 1799175500..2ce056f599 100644 --- a/scripts/set-ask.js +++ b/scripts/set-ask.js @@ -26,10 +26,21 @@ async function getGasPrice(gasPriceOracleLink) { return devEnvironment ? undefined : 8; } try { + let gasPrice; const response = await axios.get(gasPriceOracleLink); - const gasPriceRounded = Math.round(response.result * 1e9); - this.logger.debug(`Gas price: ${gasPriceRounded}`); - return gasPriceRounded; + if ( + gasPriceOracleLink === 'https://api.gnosisscan.io/api?module=proxy&action=eth_gasPrice' + ) { + gasPrice = Number(response.result, 10); + } else if ( + gasPriceOracleLink === 'https://blockscout.chiadochain.net/api/v1/gas-price-oracle' + ) { + gasPrice = Math.round(response.average * 1e9); + } else { + gasPrice = Math.round(response.result * 1e9); + } + this.logger.debug(`Gas price: ${gasPrice}`); + return gasPrice; } catch (error) { return undefined; } diff --git a/scripts/set-stake.js b/scripts/set-stake.js index b307c6b74f..64938814e1 100644 --- a/scripts/set-stake.js +++ b/scripts/set-stake.js @@ -33,10 +33,21 @@ async function getGasPrice(gasPriceOracleLink) { return devEnvironment ? undefined : 8; } try { + let gasPrice; const response = await axios.get(gasPriceOracleLink); - const gasPriceRounded = Math.round(response.result * 1e9); - this.logger.debug(`Gas price: ${gasPriceRounded}`); - return gasPriceRounded; + if ( + gasPriceOracleLink === 'https://api.gnosisscan.io/api?module=proxy&action=eth_gasPrice' + ) { + gasPrice = Number(response.result, 10); + } else if ( + gasPriceOracleLink === 'https://blockscout.chiadochain.net/api/v1/gas-price-oracle' + ) { + gasPrice = Math.round(response.average * 1e9); + } else { + gasPrice = Math.round(response.result * 1e9); + } + this.logger.debug(`Gas price: ${gasPrice}`); + return gasPrice; } catch (error) { return undefined; } From b634baba1f2c833f2b5277f97a6ace59a95d6cda Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 28 Nov 2023 15:42:05 +0100 Subject: [PATCH 48/72] Add gnosis hub contract adress --- config/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.json b/config/config.json index 00fcae1be4..3444737b9a 100644 --- a/config/config.json +++ b/config/config.json @@ -414,7 +414,7 @@ "package": "./blockchain/implementation/gnosis/gnosis-service.js", "config": { - "hubContractAddress": "", + "hubContractAddress": "0xC06210312C9217A0EdF67453618F5eB96668679A", "gasPriceOracleLink": "https://blockscout.chiadochain.net/api/v1/gas-price-oracle", "rpcEndpoints": ["https://rpc.chiadochain.net"] } @@ -578,7 +578,7 @@ "package": "./blockchain/implementation/gnosis/gnosis-service.js", "config": { - "hubContractAddress": "", + "hubContractAddress": "0xD2bA102A0b11944d00180eE8136208ccF87bC39A", "gasPriceOracleLink": "https://blockscout.chiadochain.net/api/v1/gas-price-oracle", "rpcEndpoints": ["https://rpc.chiadochain.net"] } From 96df80ddddaa612d26458efc93e7c03e11e834c7 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 28 Nov 2023 16:10:14 +0100 Subject: [PATCH 49/72] Update src/controllers/rpc/rpc-router.js Co-authored-by: Uladzislau Hubar <71610423+u-hubar@users.noreply.github.com> --- src/controllers/rpc/rpc-router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/rpc/rpc-router.js b/src/controllers/rpc/rpc-router.js index 72e409800b..d88be188f6 100644 --- a/src/controllers/rpc/rpc-router.js +++ b/src/controllers/rpc/rpc-router.js @@ -26,7 +26,7 @@ class RpcRouter { const blockchainImplementations = this.blockchainModuleManager.getImplementationNames(); this.networkModuleManager.handleMessage(protocol, (message, remotePeerId) => { - const modifyedMessage = this.modifyMessage(message, blockchainImplementations); + const modifiedMessage = this.modifyMessage(message, blockchainImplementations); this[controller][handleRequest](modifyedMessage, remotePeerId, protocol); }); } From 7e1af01fc4e93765c42325883fab083962892915 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 28 Nov 2023 16:10:25 +0100 Subject: [PATCH 50/72] Update src/controllers/rpc/rpc-router.js Co-authored-by: Uladzislau Hubar <71610423+u-hubar@users.noreply.github.com> --- src/controllers/rpc/rpc-router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/rpc/rpc-router.js b/src/controllers/rpc/rpc-router.js index d88be188f6..18bfd4e9a1 100644 --- a/src/controllers/rpc/rpc-router.js +++ b/src/controllers/rpc/rpc-router.js @@ -27,7 +27,7 @@ class RpcRouter { this.networkModuleManager.handleMessage(protocol, (message, remotePeerId) => { const modifiedMessage = this.modifyMessage(message, blockchainImplementations); - this[controller][handleRequest](modifyedMessage, remotePeerId, protocol); + this[controller][handleRequest](modifiedMessage, remotePeerId, protocol); }); } } From f0dfbddb323c9c3dea3e08354f1bc390968940f4 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Tue, 28 Nov 2023 16:15:46 +0100 Subject: [PATCH 51/72] Moved CHAIN_IDS map from constants to the migration files, added 'shard' table update to the operational db migration --- src/constants/constants.js | 8 -------- .../ual-extension-triple-store-migration.js | 8 +++++++- ...al-extension-user-configuration-migration.js | 8 +++++++- .../20233010122500-update-blockchain-id.js | 17 +++++++++++++++-- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/constants/constants.js b/src/constants/constants.js index a10124aa7b..06ae5f58c9 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -571,14 +571,6 @@ export const NODE_ENVIRONMENTS = { MAINNET: 'mainnet', }; -export const CHAIN_IDS = { - development: 31337, - test: 31337, - devnet: 2160, - testnet: 20430, - mainnet: 2043, -}; - export const CONTRACT_EVENT_FETCH_INTERVALS = { MAINNET: 10 * 1000, DEVELOPMENT: 4 * 1000, diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 6f5110bc40..8aa611a543 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -1,6 +1,12 @@ import BaseMigration from './base-migration.js'; -import { CHAIN_IDS } from '../constants/constants.js'; +const CHAIN_IDS = { + development: 31337, + test: 31337, + devnet: 2160, + testnet: 20430, + mainnet: 2043, +}; const chainId = CHAIN_IDS[process.env.NODE_ENV]; class UalExtensionTripleStoreMigration extends BaseMigration { diff --git a/src/migration/ual-extension-user-configuration-migration.js b/src/migration/ual-extension-user-configuration-migration.js index d0c9c14eed..76807dfa2b 100644 --- a/src/migration/ual-extension-user-configuration-migration.js +++ b/src/migration/ual-extension-user-configuration-migration.js @@ -1,8 +1,14 @@ import appRootPath from 'app-root-path'; import path from 'path'; import BaseMigration from './base-migration.js'; -import { CHAIN_IDS } from '../constants/constants.js'; +const CHAIN_IDS = { + development: 31337, + test: 31337, + devnet: 2160, + testnet: 20430, + mainnet: 2043, +}; const chainId = CHAIN_IDS[process.env.NODE_ENV]; class UalExtensionUserConfigurationMigration extends BaseMigration { diff --git a/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js index 3df8683e0a..4074736ed8 100644 --- a/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js +++ b/src/modules/repository/implementation/sequelize/migrations/20233010122500-update-blockchain-id.js @@ -1,8 +1,17 @@ -import { CHAIN_IDS } from '../../../../../constants/constants.js'; - +const CHAIN_IDS = { + development: 31337, + test: 31337, + devnet: 2160, + testnet: 20430, + mainnet: 2043, +}; const chainId = CHAIN_IDS[process.env.NODE_ENV]; export async function up({ context: { queryInterface } }) { + await queryInterface.sequelize.query(` + update shard set blockchain_id='otp:${chainId}' + `); + await queryInterface.sequelize.query(` update service_agreement set blockchain_id='otp:${chainId}' `); @@ -17,6 +26,10 @@ export async function up({ context: { queryInterface } }) { } export async function down({ context: { queryInterface } }) { + await queryInterface.sequelize.query(` + update shard set blockchain_id='otp' + `); + await queryInterface.sequelize.query(` update service_agreement set blockchain_id='otp' `); From c865045d4e6822977ab608ac778faab61559ec4e Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 28 Nov 2023 16:34:16 +0100 Subject: [PATCH 52/72] Fix local setup uses right name for first blockchain --- tools/local-network-setup/setup-macos-environment.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/local-network-setup/setup-macos-environment.sh b/tools/local-network-setup/setup-macos-environment.sh index 0b5151b107..94e3d9b0f3 100755 --- a/tools/local-network-setup/setup-macos-environment.sh +++ b/tools/local-network-setup/setup-macos-environment.sh @@ -1,9 +1,9 @@ #!/bin/sh pathToOtNode=$(pwd) numberOfNodes=4 -network="hardhat:31337" +network="hardhat1:31337" tripleStore="ot-blazegraph" -availableNetworks=("hardhat:31337") +availableNetworks=("hardhat1:31337") export $(xargs < $pathToOtNode/.env) export ACCESS_KEY=$RPC_ENDPOINT # Check for script arguments @@ -43,10 +43,10 @@ while [ $# -gt 0 ]; do esac shift done -if [[ $network == hardhat:31337 ]] +if [[ $network == hardhat1:31337 ]] then echo ================================ - echo ====== Starting hardhat ====== + echo ====== Starting hardhat1 ====== echo ================================ osascript -e "tell app \"Terminal\" From e8af51d4ae964ac73f6a10cfe537058b5e818652 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Tue, 28 Nov 2023 17:07:49 +0100 Subject: [PATCH 53/72] Check if KA owner zero address --- src/constants/constants.js | 6 ++++-- src/service/validation-service.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/constants/constants.js b/src/constants/constants.js index 06ae5f58c9..ea9f47e221 100644 --- a/src/constants/constants.js +++ b/src/constants/constants.js @@ -1,4 +1,4 @@ -import { BigNumber } from 'ethers'; +import { BigNumber, ethers } from 'ethers'; export const WS_RPC_PROVIDER_PRIORITY = 2; @@ -18,7 +18,9 @@ export const UINT256_UINT32_DIVISOR_BN = UINT256_MAX_BN.div(UINT32_MAX_BN); export const ZERO_PREFIX = '0x'; -export const ZERO_BYTES32 = `0x${'0'.repeat(64)}`; +export const ZERO_BYTES32 = ethers.constants.HashZero; + +export const ZERO_ADDRESS = ethers.constants.AddressZero; export const SCHEMA_CONTEXT = 'http://schema.org/'; diff --git a/src/service/validation-service.js b/src/service/validation-service.js index 3218387d88..60b0e374ba 100644 --- a/src/service/validation-service.js +++ b/src/service/validation-service.js @@ -1,5 +1,5 @@ import { assertionMetadata } from 'assertion-tools'; -import { BYTES_IN_KILOBYTE } from '../constants/constants.js'; +import { BYTES_IN_KILOBYTE, ZERO_ADDRESS } from '../constants/constants.js'; class ValidationService { constructor(ctx) { @@ -21,7 +21,7 @@ class ValidationService { contract, tokenId, ); - if (!result) { + if (result === ZERO_ADDRESS) { isValid = false; } } catch (err) { From d883aef9143e68225b15f68165dd0bc97d95f903 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Tue, 28 Nov 2023 17:17:59 +0100 Subject: [PATCH 54/72] Bumped version to 6.1.0, updated dkg-evm-module to 4.1.0 --- package-lock.json | 602 ++++++++++++++++++++++++---------------------- package.json | 4 +- 2 files changed, 318 insertions(+), 288 deletions(-) diff --git a/package-lock.json b/package-lock.json index 00bfae4443..96ed40c12e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.0.20", + "version": "6.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.0.20", + "version": "6.1.0", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", @@ -25,7 +25,7 @@ "axios": "^1.6.0", "cors": "^2.8.5", "deep-extend": "^0.6.0", - "dkg-evm-module": "^4.0.7", + "dkg-evm-module": "^4.1.0", "dotenv": "^16.0.1", "ethers": "^5.7.2", "express": "^4.18.1", @@ -535,6 +535,29 @@ "buffer": "^6.0.3" } }, + "node_modules/@chainsafe/as-sha256": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@chainsafe/as-sha256/-/as-sha256-0.3.1.tgz", + "integrity": "sha512-hldFFYuf49ed7DAakWVXSJODuq3pzJEguD8tQ7h+sGkM18vja+OFoJI9krnGmgzyuZC2ETX0NOIcCTy31v2Mtg==" + }, + "node_modules/@chainsafe/persistent-merkle-tree": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@chainsafe/persistent-merkle-tree/-/persistent-merkle-tree-0.4.2.tgz", + "integrity": "sha512-lLO3ihKPngXLTus/L7WHKaw9PnNJWizlOF1H9NNzHP6Xvh82vzg9F2bzkXhYIFshMZ2gTCEz8tq6STe7r5NDfQ==", + "dependencies": { + "@chainsafe/as-sha256": "^0.3.1" + } + }, + "node_modules/@chainsafe/ssz": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/@chainsafe/ssz/-/ssz-0.9.4.tgz", + "integrity": "sha512-77Qtg2N1ayqs4Bg/wvnWfg5Bta7iy7IRh8XqXh7oNMeP2HBbBwx8m6yTpA8p0EHItWPEBkgZd5S5/LSlp3GXuQ==", + "dependencies": { + "@chainsafe/as-sha256": "^0.3.1", + "@chainsafe/persistent-merkle-tree": "^0.4.2", + "case": "^1.6.3" + } + }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -3994,32 +4017,34 @@ } }, "node_modules/@nomicfoundation/ethereumjs-block": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-block/-/ethereumjs-block-4.2.2.tgz", - "integrity": "sha512-atjpt4gc6ZGZUPHBAQaUJsm1l/VCo7FmyQ780tMGO8QStjLdhz09dXynmhwVTy5YbRr0FOh/uX3QaEM0yIB2Zg==", - "dependencies": { - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-trie": "5.0.5", - "@nomicfoundation/ethereumjs-tx": "4.1.2", - "@nomicfoundation/ethereumjs-util": "8.0.6", - "ethereum-cryptography": "0.1.3" + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-block/-/ethereumjs-block-5.0.2.tgz", + "integrity": "sha512-hSe6CuHI4SsSiWWjHDIzWhSiAVpzMUcDRpWYzN0T9l8/Rz7xNn3elwVOJ/tAyS0LqL6vitUD78Uk7lQDXZun7Q==", + "dependencies": { + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-trie": "6.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", + "ethereum-cryptography": "0.1.3", + "ethers": "^5.7.1" }, "engines": { "node": ">=14" } }, "node_modules/@nomicfoundation/ethereumjs-blockchain": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-blockchain/-/ethereumjs-blockchain-6.2.2.tgz", - "integrity": "sha512-6AIB2MoTEPZJLl6IRKcbd8mUmaBAQ/NMe3O7OsAOIiDjMNPPH5KaUQiLfbVlegT4wKIg/GOsFH7XlH2KDVoJNg==", - "dependencies": { - "@nomicfoundation/ethereumjs-block": "4.2.2", - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-ethash": "2.0.5", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-trie": "5.0.5", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-blockchain/-/ethereumjs-blockchain-7.0.2.tgz", + "integrity": "sha512-8UUsSXJs+MFfIIAKdh3cG16iNmWzWC/91P40sazNvrqhhdR/RtGDlFk2iFTGbBAZPs2+klZVzhRX8m2wvuvz3w==", + "dependencies": { + "@nomicfoundation/ethereumjs-block": "5.0.2", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-ethash": "3.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-trie": "6.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "abstract-level": "^1.0.3", "debug": "^4.3.3", "ethereum-cryptography": "0.1.3", @@ -4040,22 +4065,22 @@ } }, "node_modules/@nomicfoundation/ethereumjs-common": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-common/-/ethereumjs-common-3.1.2.tgz", - "integrity": "sha512-JAEBpIua62dyObHM9KI2b4wHZcRQYYge9gxiygTWa3lNCr2zo+K0TbypDpgiNij5MCGNWP1eboNfNfx1a3vkvA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-common/-/ethereumjs-common-4.0.2.tgz", + "integrity": "sha512-I2WGP3HMGsOoycSdOTSqIaES0ughQTueOsddJ36aYVpI3SN8YSusgRFLwzDJwRFVIYDKx/iJz0sQ5kBHVgdDwg==", "dependencies": { - "@nomicfoundation/ethereumjs-util": "8.0.6", + "@nomicfoundation/ethereumjs-util": "9.0.2", "crc-32": "^1.2.0" } }, "node_modules/@nomicfoundation/ethereumjs-ethash": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-ethash/-/ethereumjs-ethash-2.0.5.tgz", - "integrity": "sha512-xlLdcICGgAYyYmnI3r1t0R5fKGBJNDQSOQxXNjVO99JmxJIdXR5MgPo5CSJO1RpyzKOgzi3uIFn8agv564dZEQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-ethash/-/ethereumjs-ethash-3.0.2.tgz", + "integrity": "sha512-8PfoOQCcIcO9Pylq0Buijuq/O73tmMVURK0OqdjhwqcGHYC2PwhbajDh7GZ55ekB0Px197ajK3PQhpKoiI/UPg==", "dependencies": { - "@nomicfoundation/ethereumjs-block": "4.2.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "@nomicfoundation/ethereumjs-block": "5.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "abstract-level": "^1.0.3", "bigint-crypto-utils": "^3.0.23", "ethereum-cryptography": "0.1.3" @@ -4065,14 +4090,14 @@ } }, "node_modules/@nomicfoundation/ethereumjs-evm": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-evm/-/ethereumjs-evm-1.3.2.tgz", - "integrity": "sha512-I00d4MwXuobyoqdPe/12dxUQxTYzX8OckSaWsMcWAfQhgVDvBx6ffPyP/w1aL0NW7MjyerySPcSVfDJAMHjilw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-evm/-/ethereumjs-evm-2.0.2.tgz", + "integrity": "sha512-rBLcUaUfANJxyOx9HIdMX6uXGin6lANCulIm/pjMgRqfiCRMZie3WKYxTSd8ZE/d+qT+zTedBF4+VHTdTSePmQ==", "dependencies": { - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-util": "8.0.6", - "@types/async-eventemitter": "^0.2.1", - "async-eventemitter": "^0.2.4", + "@ethersproject/providers": "^5.7.1", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "debug": "^4.3.3", "ethereum-cryptography": "0.1.3", "mcl-wasm": "^0.7.1", @@ -4083,9 +4108,9 @@ } }, "node_modules/@nomicfoundation/ethereumjs-rlp": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-rlp/-/ethereumjs-rlp-4.0.3.tgz", - "integrity": "sha512-DZMzB/lqPK78T6MluyXqtlRmOMcsZbTTbbEyAjo0ncaff2mqu/k8a79PBcyvpgAhWD/R59Fjq/x3ro5Lof0AtA==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-rlp/-/ethereumjs-rlp-5.0.2.tgz", + "integrity": "sha512-QwmemBc+MMsHJ1P1QvPl8R8p2aPvvVcKBbvHnQOKBpBztEo0omN0eaob6FeZS/e3y9NSe+mfu3nNFBHszqkjTA==", "bin": { "rlp": "bin/rlp" }, @@ -4094,26 +4119,26 @@ } }, "node_modules/@nomicfoundation/ethereumjs-statemanager": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-statemanager/-/ethereumjs-statemanager-1.0.5.tgz", - "integrity": "sha512-CAhzpzTR5toh/qOJIZUUOnWekUXuRqkkzaGAQrVcF457VhtCmr+ddZjjK50KNZ524c1XP8cISguEVNqJ6ij1sA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-statemanager/-/ethereumjs-statemanager-2.0.2.tgz", + "integrity": "sha512-dlKy5dIXLuDubx8Z74sipciZnJTRSV/uHG48RSijhgm1V7eXYFC567xgKtsKiVZB1ViTP9iFL4B6Je0xD6X2OA==", "dependencies": { - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-trie": "5.0.5", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", "debug": "^4.3.3", "ethereum-cryptography": "0.1.3", - "functional-red-black-tree": "^1.0.1" + "ethers": "^5.7.1", + "js-sdsl": "^4.1.4" } }, "node_modules/@nomicfoundation/ethereumjs-trie": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-trie/-/ethereumjs-trie-5.0.5.tgz", - "integrity": "sha512-+8sNZrXkzvA1NH5F4kz5RSYl1I6iaRz7mAZRsyxOm0IVY4UaP43Ofvfp/TwOalFunurQrYB5pRO40+8FBcxFMA==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-trie/-/ethereumjs-trie-6.0.2.tgz", + "integrity": "sha512-yw8vg9hBeLYk4YNg5MrSJ5H55TLOv2FSWUTROtDtTMMmDGROsAu+0tBjiNGTnKRi400M6cEzoFfa89Fc5k8NTQ==", "dependencies": { - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", + "@types/readable-stream": "^2.3.13", "ethereum-cryptography": "0.1.3", "readable-stream": "^3.6.0" }, @@ -4135,13 +4160,15 @@ } }, "node_modules/@nomicfoundation/ethereumjs-tx": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-tx/-/ethereumjs-tx-4.1.2.tgz", - "integrity": "sha512-emJBJZpmTdUa09cqxQqHaysbBI9Od353ZazeH7WgPb35miMgNY6mb7/3vBA98N5lUW/rgkiItjX0KZfIzihSoQ==", - "dependencies": { - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-tx/-/ethereumjs-tx-5.0.2.tgz", + "integrity": "sha512-T+l4/MmTp7VhJeNloMkM+lPU3YMUaXdcXgTGCf8+ZFvV9NYZTRLFekRwlG6/JMmVfIfbrW+dRRJ9A6H5Q/Z64g==", + "dependencies": { + "@chainsafe/ssz": "^0.9.2", + "@ethersproject/providers": "^5.7.2", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "ethereum-cryptography": "0.1.3" }, "engines": { @@ -4149,36 +4176,51 @@ } }, "node_modules/@nomicfoundation/ethereumjs-util": { - "version": "8.0.6", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-util/-/ethereumjs-util-8.0.6.tgz", - "integrity": "sha512-jOQfF44laa7xRfbfLXojdlcpkvxeHrE2Xu7tSeITsWFgoII163MzjOwFEzSNozHYieFysyoEMhCdP+NY5ikstw==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-util/-/ethereumjs-util-9.0.2.tgz", + "integrity": "sha512-4Wu9D3LykbSBWZo8nJCnzVIYGvGCuyiYLIJa9XXNVt1q1jUzHdB+sJvx95VGCpPkCT+IbLecW6yfzy3E1bQrwQ==", "dependencies": { - "@nomicfoundation/ethereumjs-rlp": "4.0.3", + "@chainsafe/ssz": "^0.10.0", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", "ethereum-cryptography": "0.1.3" }, "engines": { "node": ">=14" } }, + "node_modules/@nomicfoundation/ethereumjs-util/node_modules/@chainsafe/persistent-merkle-tree": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@chainsafe/persistent-merkle-tree/-/persistent-merkle-tree-0.5.0.tgz", + "integrity": "sha512-l0V1b5clxA3iwQLXP40zYjyZYospQLZXzBVIhhr9kDg/1qHZfzzHw0jj4VPBijfYCArZDlPkRi1wZaV2POKeuw==", + "dependencies": { + "@chainsafe/as-sha256": "^0.3.1" + } + }, + "node_modules/@nomicfoundation/ethereumjs-util/node_modules/@chainsafe/ssz": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/@chainsafe/ssz/-/ssz-0.10.2.tgz", + "integrity": "sha512-/NL3Lh8K+0q7A3LsiFq09YXS9fPE+ead2rr7vM2QK8PLzrNsw3uqrif9bpRX5UxgeRjM+vYi+boCM3+GM4ovXg==", + "dependencies": { + "@chainsafe/as-sha256": "^0.3.1", + "@chainsafe/persistent-merkle-tree": "^0.5.0" + } + }, "node_modules/@nomicfoundation/ethereumjs-vm": { - "version": "6.4.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-vm/-/ethereumjs-vm-6.4.2.tgz", - "integrity": "sha512-PRTyxZMP6kx+OdAzBhuH1LD2Yw+hrSpaytftvaK//thDy2OI07S0nrTdbrdk7b8ZVPAc9H9oTwFBl3/wJ3w15g==", - "dependencies": { - "@nomicfoundation/ethereumjs-block": "4.2.2", - "@nomicfoundation/ethereumjs-blockchain": "6.2.2", - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-evm": "1.3.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-statemanager": "1.0.5", - "@nomicfoundation/ethereumjs-trie": "5.0.5", - "@nomicfoundation/ethereumjs-tx": "4.1.2", - "@nomicfoundation/ethereumjs-util": "8.0.6", - "@types/async-eventemitter": "^0.2.1", - "async-eventemitter": "^0.2.4", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-vm/-/ethereumjs-vm-7.0.2.tgz", + "integrity": "sha512-Bj3KZT64j54Tcwr7Qm/0jkeZXJMfdcAtRBedou+Hx0dPOSIgqaIr0vvLwP65TpHbak2DmAq+KJbW2KNtIoFwvA==", + "dependencies": { + "@nomicfoundation/ethereumjs-block": "5.0.2", + "@nomicfoundation/ethereumjs-blockchain": "7.0.2", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-evm": "2.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-statemanager": "2.0.2", + "@nomicfoundation/ethereumjs-trie": "6.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "debug": "^4.3.3", "ethereum-cryptography": "0.1.3", - "functional-red-black-tree": "^1.0.1", "mcl-wasm": "^0.7.1", "rustbn.js": "~0.2.0" }, @@ -5379,11 +5421,6 @@ "resolved": "https://registry.npmjs.org/@types/argparse/-/argparse-1.0.38.tgz", "integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==" }, - "node_modules/@types/async-eventemitter": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@types/async-eventemitter/-/async-eventemitter-0.2.1.tgz", - "integrity": "sha512-M2P4Ng26QbAeITiH7w1d7OxtldgfAe0wobpyJzVK/XOb0cUGKU2R4pfAhqcJBXAe2ife5ZOhSv4wk7p+ffURtg==" - }, "node_modules/@types/bn.js": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", @@ -6069,22 +6106,6 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" }, - "node_modules/async-eventemitter": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/async-eventemitter/-/async-eventemitter-0.2.4.tgz", - "integrity": "sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw==", - "dependencies": { - "async": "^2.4.0" - } - }, - "node_modules/async-eventemitter/node_modules/async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "dependencies": { - "lodash": "^4.17.14" - } - }, "node_modules/async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", @@ -6276,22 +6297,11 @@ } }, "node_modules/bigint-crypto-utils": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/bigint-crypto-utils/-/bigint-crypto-utils-3.1.8.tgz", - "integrity": "sha512-+VMV9Laq8pXLBKKKK49nOoq9bfR3j7NNQAtbA617a4nw9bVLo8rsqkKMBgM2AJWlNX9fEIyYaYX+d0laqYV4tw==", - "dependencies": { - "bigint-mod-arith": "^3.1.0" - }, - "engines": { - "node": ">=10.4.0" - } - }, - "node_modules/bigint-mod-arith": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.2.tgz", - "integrity": "sha512-nx8J8bBeiRR+NlsROFH9jHswW5HO8mgfOSqW0AmjicMMvaONDa8AO+5ViKDUUNytBPWiwfvZP4/Bj4Y3lUfvgQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/bigint-crypto-utils/-/bigint-crypto-utils-3.3.0.tgz", + "integrity": "sha512-jOTSb+drvEDxEq6OuUybOAv/xxoh3cuYRUIPyu8sSHQNKM303UQ2R1DAo45o1AkcIXw6fzbaFI1+xGGdaXs2lg==", "engines": { - "node": ">=10.4.0" + "node": ">=14.0.0" } }, "node_modules/bignumber.js": { @@ -6736,6 +6746,14 @@ "upper-case-first": "^2.0.2" } }, + "node_modules/case": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/case/-/case-1.6.3.tgz", + "integrity": "sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ==", + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -6942,15 +6960,15 @@ "dev": true }, "node_modules/classic-level": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/classic-level/-/classic-level-1.2.0.tgz", - "integrity": "sha512-qw5B31ANxSluWz9xBzklRWTUAJ1SXIdaVKTVS7HcTGKOAmExx65Wo5BUICW+YGORe2FOUaDghoI9ZDxj82QcFg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/classic-level/-/classic-level-1.3.0.tgz", + "integrity": "sha512-iwFAJQYtqRTRM0F6L8h4JCt00ZSGdOyqh7yVrhhjrOpFhmBjNlRUey64MCiyo6UmQHMJ+No3c81nujPv+n9yrg==", "hasInstallScript": true, "dependencies": { "abstract-level": "^1.0.2", "catering": "^2.1.0", "module-error": "^1.0.1", - "napi-macros": "~2.0.0", + "napi-macros": "^2.2.2", "node-gyp-build": "^4.3.0" }, "engines": { @@ -7647,8 +7665,8 @@ }, "node_modules/dkg-evm-module": { "version": "4.1.0", - "resolved": "git+https://git@github.com/OriginTrail/dkg-evm-module.git#6e70f03ea3907d89f1a24d7dbc78d2699814ec36", - "license": "Apache-2.0", + "resolved": "https://registry.npmjs.org/dkg-evm-module/-/dkg-evm-module-4.1.0.tgz", + "integrity": "sha512-80l9dIjUchBk5SOx6+hdo/I1+r1hUpxHmz3fwQuLISvof4aLSVZ2oqvkEdMPtkvBOjgT3F7uKnHSu6SanBa40A==", "dependencies": { "@openzeppelin/contracts": "^4.9.3", "@polkadot/api": "^10.1.4", @@ -7657,7 +7675,7 @@ "@polkadot/util-crypto": "^11.1.1", "@prb/math": "^2.5.0", "dotenv": "^16.0.3", - "hardhat": "^2.13.0", + "hardhat": "^2.19.1", "hardhat-deploy": "^0.11.25", "hardhat-deploy-ethers": "^0.3.0-beta.13", "ts-node": "^10.9.1", @@ -10601,27 +10619,26 @@ } }, "node_modules/hardhat": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/hardhat/-/hardhat-2.13.0.tgz", - "integrity": "sha512-ZlzBOLML1QGlm6JWyVAG8lVTEAoOaVm1in/RU2zoGAnYEoD1Rp4T+ZMvrLNhHaaeS9hfjJ1gJUBfiDr4cx+htQ==", + "version": "2.19.1", + "resolved": "https://registry.npmjs.org/hardhat/-/hardhat-2.19.1.tgz", + "integrity": "sha512-bsWa63g1GB78ZyMN08WLhFElLPA+J+pShuKD1BFO2+88g3l+BL3R07vj9deIi9dMbssxgE714Gof1dBEDGqnCw==", "dependencies": { "@ethersproject/abi": "^5.1.2", "@metamask/eth-sig-util": "^4.0.0", - "@nomicfoundation/ethereumjs-block": "^4.0.0", - "@nomicfoundation/ethereumjs-blockchain": "^6.0.0", - "@nomicfoundation/ethereumjs-common": "^3.0.0", - "@nomicfoundation/ethereumjs-evm": "^1.0.0", - "@nomicfoundation/ethereumjs-rlp": "^4.0.0", - "@nomicfoundation/ethereumjs-statemanager": "^1.0.0", - "@nomicfoundation/ethereumjs-trie": "^5.0.0", - "@nomicfoundation/ethereumjs-tx": "^4.0.0", - "@nomicfoundation/ethereumjs-util": "^8.0.0", - "@nomicfoundation/ethereumjs-vm": "^6.0.0", + "@nomicfoundation/ethereumjs-block": "5.0.2", + "@nomicfoundation/ethereumjs-blockchain": "7.0.2", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-evm": "2.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-statemanager": "2.0.2", + "@nomicfoundation/ethereumjs-trie": "6.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", + "@nomicfoundation/ethereumjs-vm": "7.0.2", "@nomicfoundation/solidity-analyzer": "^0.1.0", "@sentry/node": "^5.18.1", "@types/bn.js": "^5.1.0", "@types/lru-cache": "^5.1.0", - "abort-controller": "^3.0.0", "adm-zip": "^0.4.16", "aggregate-error": "^3.0.0", "ansi-escapes": "^4.3.0", @@ -10644,7 +10661,6 @@ "mnemonist": "^0.38.0", "mocha": "^10.0.0", "p-map": "^4.0.0", - "qs": "^6.7.0", "raw-body": "^2.4.1", "resolve": "1.17.0", "semver": "^6.3.0", @@ -10659,9 +10675,6 @@ "bin": { "hardhat": "internal/cli/bootstrap.js" }, - "engines": { - "node": ">=14.0.0" - }, "peerDependencies": { "ts-node": "*", "typescript": "*" @@ -14306,9 +14319,9 @@ } }, "node_modules/napi-macros": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", - "integrity": "sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg==" + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.2.2.tgz", + "integrity": "sha512-hmEVtAGYzVQpCKdbQea4skABsdXW4RUh5t5mJ2zzqowJS2OyXZTU1KhDVFhx+NlWZ4ap9mqR9TcDO3LTTttd+g==" }, "node_modules/native-abort-controller": { "version": "1.0.4", @@ -19802,6 +19815,29 @@ "buffer": "^6.0.3" } }, + "@chainsafe/as-sha256": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@chainsafe/as-sha256/-/as-sha256-0.3.1.tgz", + "integrity": "sha512-hldFFYuf49ed7DAakWVXSJODuq3pzJEguD8tQ7h+sGkM18vja+OFoJI9krnGmgzyuZC2ETX0NOIcCTy31v2Mtg==" + }, + "@chainsafe/persistent-merkle-tree": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@chainsafe/persistent-merkle-tree/-/persistent-merkle-tree-0.4.2.tgz", + "integrity": "sha512-lLO3ihKPngXLTus/L7WHKaw9PnNJWizlOF1H9NNzHP6Xvh82vzg9F2bzkXhYIFshMZ2gTCEz8tq6STe7r5NDfQ==", + "requires": { + "@chainsafe/as-sha256": "^0.3.1" + } + }, + "@chainsafe/ssz": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/@chainsafe/ssz/-/ssz-0.9.4.tgz", + "integrity": "sha512-77Qtg2N1ayqs4Bg/wvnWfg5Bta7iy7IRh8XqXh7oNMeP2HBbBwx8m6yTpA8p0EHItWPEBkgZd5S5/LSlp3GXuQ==", + "requires": { + "@chainsafe/as-sha256": "^0.3.1", + "@chainsafe/persistent-merkle-tree": "^0.4.2", + "case": "^1.6.3" + } + }, "@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -22788,29 +22824,31 @@ } }, "@nomicfoundation/ethereumjs-block": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-block/-/ethereumjs-block-4.2.2.tgz", - "integrity": "sha512-atjpt4gc6ZGZUPHBAQaUJsm1l/VCo7FmyQ780tMGO8QStjLdhz09dXynmhwVTy5YbRr0FOh/uX3QaEM0yIB2Zg==", - "requires": { - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-trie": "5.0.5", - "@nomicfoundation/ethereumjs-tx": "4.1.2", - "@nomicfoundation/ethereumjs-util": "8.0.6", - "ethereum-cryptography": "0.1.3" + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-block/-/ethereumjs-block-5.0.2.tgz", + "integrity": "sha512-hSe6CuHI4SsSiWWjHDIzWhSiAVpzMUcDRpWYzN0T9l8/Rz7xNn3elwVOJ/tAyS0LqL6vitUD78Uk7lQDXZun7Q==", + "requires": { + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-trie": "6.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", + "ethereum-cryptography": "0.1.3", + "ethers": "^5.7.1" } }, "@nomicfoundation/ethereumjs-blockchain": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-blockchain/-/ethereumjs-blockchain-6.2.2.tgz", - "integrity": "sha512-6AIB2MoTEPZJLl6IRKcbd8mUmaBAQ/NMe3O7OsAOIiDjMNPPH5KaUQiLfbVlegT4wKIg/GOsFH7XlH2KDVoJNg==", - "requires": { - "@nomicfoundation/ethereumjs-block": "4.2.2", - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-ethash": "2.0.5", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-trie": "5.0.5", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-blockchain/-/ethereumjs-blockchain-7.0.2.tgz", + "integrity": "sha512-8UUsSXJs+MFfIIAKdh3cG16iNmWzWC/91P40sazNvrqhhdR/RtGDlFk2iFTGbBAZPs2+klZVzhRX8m2wvuvz3w==", + "requires": { + "@nomicfoundation/ethereumjs-block": "5.0.2", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-ethash": "3.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-trie": "6.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "abstract-level": "^1.0.3", "debug": "^4.3.3", "ethereum-cryptography": "0.1.3", @@ -22830,36 +22868,36 @@ } }, "@nomicfoundation/ethereumjs-common": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-common/-/ethereumjs-common-3.1.2.tgz", - "integrity": "sha512-JAEBpIua62dyObHM9KI2b4wHZcRQYYge9gxiygTWa3lNCr2zo+K0TbypDpgiNij5MCGNWP1eboNfNfx1a3vkvA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-common/-/ethereumjs-common-4.0.2.tgz", + "integrity": "sha512-I2WGP3HMGsOoycSdOTSqIaES0ughQTueOsddJ36aYVpI3SN8YSusgRFLwzDJwRFVIYDKx/iJz0sQ5kBHVgdDwg==", "requires": { - "@nomicfoundation/ethereumjs-util": "8.0.6", + "@nomicfoundation/ethereumjs-util": "9.0.2", "crc-32": "^1.2.0" } }, "@nomicfoundation/ethereumjs-ethash": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-ethash/-/ethereumjs-ethash-2.0.5.tgz", - "integrity": "sha512-xlLdcICGgAYyYmnI3r1t0R5fKGBJNDQSOQxXNjVO99JmxJIdXR5MgPo5CSJO1RpyzKOgzi3uIFn8agv564dZEQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-ethash/-/ethereumjs-ethash-3.0.2.tgz", + "integrity": "sha512-8PfoOQCcIcO9Pylq0Buijuq/O73tmMVURK0OqdjhwqcGHYC2PwhbajDh7GZ55ekB0Px197ajK3PQhpKoiI/UPg==", "requires": { - "@nomicfoundation/ethereumjs-block": "4.2.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "@nomicfoundation/ethereumjs-block": "5.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "abstract-level": "^1.0.3", "bigint-crypto-utils": "^3.0.23", "ethereum-cryptography": "0.1.3" } }, "@nomicfoundation/ethereumjs-evm": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-evm/-/ethereumjs-evm-1.3.2.tgz", - "integrity": "sha512-I00d4MwXuobyoqdPe/12dxUQxTYzX8OckSaWsMcWAfQhgVDvBx6ffPyP/w1aL0NW7MjyerySPcSVfDJAMHjilw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-evm/-/ethereumjs-evm-2.0.2.tgz", + "integrity": "sha512-rBLcUaUfANJxyOx9HIdMX6uXGin6lANCulIm/pjMgRqfiCRMZie3WKYxTSd8ZE/d+qT+zTedBF4+VHTdTSePmQ==", "requires": { - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-util": "8.0.6", - "@types/async-eventemitter": "^0.2.1", - "async-eventemitter": "^0.2.4", + "@ethersproject/providers": "^5.7.1", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "debug": "^4.3.3", "ethereum-cryptography": "0.1.3", "mcl-wasm": "^0.7.1", @@ -22867,31 +22905,31 @@ } }, "@nomicfoundation/ethereumjs-rlp": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-rlp/-/ethereumjs-rlp-4.0.3.tgz", - "integrity": "sha512-DZMzB/lqPK78T6MluyXqtlRmOMcsZbTTbbEyAjo0ncaff2mqu/k8a79PBcyvpgAhWD/R59Fjq/x3ro5Lof0AtA==" + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-rlp/-/ethereumjs-rlp-5.0.2.tgz", + "integrity": "sha512-QwmemBc+MMsHJ1P1QvPl8R8p2aPvvVcKBbvHnQOKBpBztEo0omN0eaob6FeZS/e3y9NSe+mfu3nNFBHszqkjTA==" }, "@nomicfoundation/ethereumjs-statemanager": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-statemanager/-/ethereumjs-statemanager-1.0.5.tgz", - "integrity": "sha512-CAhzpzTR5toh/qOJIZUUOnWekUXuRqkkzaGAQrVcF457VhtCmr+ddZjjK50KNZ524c1XP8cISguEVNqJ6ij1sA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-statemanager/-/ethereumjs-statemanager-2.0.2.tgz", + "integrity": "sha512-dlKy5dIXLuDubx8Z74sipciZnJTRSV/uHG48RSijhgm1V7eXYFC567xgKtsKiVZB1ViTP9iFL4B6Je0xD6X2OA==", "requires": { - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-trie": "5.0.5", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", "debug": "^4.3.3", "ethereum-cryptography": "0.1.3", - "functional-red-black-tree": "^1.0.1" + "ethers": "^5.7.1", + "js-sdsl": "^4.1.4" } }, "@nomicfoundation/ethereumjs-trie": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-trie/-/ethereumjs-trie-5.0.5.tgz", - "integrity": "sha512-+8sNZrXkzvA1NH5F4kz5RSYl1I6iaRz7mAZRsyxOm0IVY4UaP43Ofvfp/TwOalFunurQrYB5pRO40+8FBcxFMA==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-trie/-/ethereumjs-trie-6.0.2.tgz", + "integrity": "sha512-yw8vg9hBeLYk4YNg5MrSJ5H55TLOv2FSWUTROtDtTMMmDGROsAu+0tBjiNGTnKRi400M6cEzoFfa89Fc5k8NTQ==", "requires": { - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", + "@types/readable-stream": "^2.3.13", "ethereum-cryptography": "0.1.3", "readable-stream": "^3.6.0" }, @@ -22909,44 +22947,63 @@ } }, "@nomicfoundation/ethereumjs-tx": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-tx/-/ethereumjs-tx-4.1.2.tgz", - "integrity": "sha512-emJBJZpmTdUa09cqxQqHaysbBI9Od353ZazeH7WgPb35miMgNY6mb7/3vBA98N5lUW/rgkiItjX0KZfIzihSoQ==", - "requires": { - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-util": "8.0.6", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-tx/-/ethereumjs-tx-5.0.2.tgz", + "integrity": "sha512-T+l4/MmTp7VhJeNloMkM+lPU3YMUaXdcXgTGCf8+ZFvV9NYZTRLFekRwlG6/JMmVfIfbrW+dRRJ9A6H5Q/Z64g==", + "requires": { + "@chainsafe/ssz": "^0.9.2", + "@ethersproject/providers": "^5.7.2", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "ethereum-cryptography": "0.1.3" } }, "@nomicfoundation/ethereumjs-util": { - "version": "8.0.6", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-util/-/ethereumjs-util-8.0.6.tgz", - "integrity": "sha512-jOQfF44laa7xRfbfLXojdlcpkvxeHrE2Xu7tSeITsWFgoII163MzjOwFEzSNozHYieFysyoEMhCdP+NY5ikstw==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-util/-/ethereumjs-util-9.0.2.tgz", + "integrity": "sha512-4Wu9D3LykbSBWZo8nJCnzVIYGvGCuyiYLIJa9XXNVt1q1jUzHdB+sJvx95VGCpPkCT+IbLecW6yfzy3E1bQrwQ==", "requires": { - "@nomicfoundation/ethereumjs-rlp": "4.0.3", + "@chainsafe/ssz": "^0.10.0", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", "ethereum-cryptography": "0.1.3" + }, + "dependencies": { + "@chainsafe/persistent-merkle-tree": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@chainsafe/persistent-merkle-tree/-/persistent-merkle-tree-0.5.0.tgz", + "integrity": "sha512-l0V1b5clxA3iwQLXP40zYjyZYospQLZXzBVIhhr9kDg/1qHZfzzHw0jj4VPBijfYCArZDlPkRi1wZaV2POKeuw==", + "requires": { + "@chainsafe/as-sha256": "^0.3.1" + } + }, + "@chainsafe/ssz": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/@chainsafe/ssz/-/ssz-0.10.2.tgz", + "integrity": "sha512-/NL3Lh8K+0q7A3LsiFq09YXS9fPE+ead2rr7vM2QK8PLzrNsw3uqrif9bpRX5UxgeRjM+vYi+boCM3+GM4ovXg==", + "requires": { + "@chainsafe/as-sha256": "^0.3.1", + "@chainsafe/persistent-merkle-tree": "^0.5.0" + } + } } }, "@nomicfoundation/ethereumjs-vm": { - "version": "6.4.2", - "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-vm/-/ethereumjs-vm-6.4.2.tgz", - "integrity": "sha512-PRTyxZMP6kx+OdAzBhuH1LD2Yw+hrSpaytftvaK//thDy2OI07S0nrTdbrdk7b8ZVPAc9H9oTwFBl3/wJ3w15g==", - "requires": { - "@nomicfoundation/ethereumjs-block": "4.2.2", - "@nomicfoundation/ethereumjs-blockchain": "6.2.2", - "@nomicfoundation/ethereumjs-common": "3.1.2", - "@nomicfoundation/ethereumjs-evm": "1.3.2", - "@nomicfoundation/ethereumjs-rlp": "4.0.3", - "@nomicfoundation/ethereumjs-statemanager": "1.0.5", - "@nomicfoundation/ethereumjs-trie": "5.0.5", - "@nomicfoundation/ethereumjs-tx": "4.1.2", - "@nomicfoundation/ethereumjs-util": "8.0.6", - "@types/async-eventemitter": "^0.2.1", - "async-eventemitter": "^0.2.4", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@nomicfoundation/ethereumjs-vm/-/ethereumjs-vm-7.0.2.tgz", + "integrity": "sha512-Bj3KZT64j54Tcwr7Qm/0jkeZXJMfdcAtRBedou+Hx0dPOSIgqaIr0vvLwP65TpHbak2DmAq+KJbW2KNtIoFwvA==", + "requires": { + "@nomicfoundation/ethereumjs-block": "5.0.2", + "@nomicfoundation/ethereumjs-blockchain": "7.0.2", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-evm": "2.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-statemanager": "2.0.2", + "@nomicfoundation/ethereumjs-trie": "6.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", "debug": "^4.3.3", "ethereum-cryptography": "0.1.3", - "functional-red-black-tree": "^1.0.1", "mcl-wasm": "^0.7.1", "rustbn.js": "~0.2.0" } @@ -23890,11 +23947,6 @@ "resolved": "https://registry.npmjs.org/@types/argparse/-/argparse-1.0.38.tgz", "integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==" }, - "@types/async-eventemitter": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@types/async-eventemitter/-/async-eventemitter-0.2.1.tgz", - "integrity": "sha512-M2P4Ng26QbAeITiH7w1d7OxtldgfAe0wobpyJzVK/XOb0cUGKU2R4pfAhqcJBXAe2ife5ZOhSv4wk7p+ffURtg==" - }, "@types/bn.js": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", @@ -24488,24 +24540,6 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" }, - "async-eventemitter": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/async-eventemitter/-/async-eventemitter-0.2.4.tgz", - "integrity": "sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw==", - "requires": { - "async": "^2.4.0" - }, - "dependencies": { - "async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "requires": { - "lodash": "^4.17.14" - } - } - } - }, "async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", @@ -24660,17 +24694,9 @@ "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==" }, "bigint-crypto-utils": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/bigint-crypto-utils/-/bigint-crypto-utils-3.1.8.tgz", - "integrity": "sha512-+VMV9Laq8pXLBKKKK49nOoq9bfR3j7NNQAtbA617a4nw9bVLo8rsqkKMBgM2AJWlNX9fEIyYaYX+d0laqYV4tw==", - "requires": { - "bigint-mod-arith": "^3.1.0" - } - }, - "bigint-mod-arith": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.2.tgz", - "integrity": "sha512-nx8J8bBeiRR+NlsROFH9jHswW5HO8mgfOSqW0AmjicMMvaONDa8AO+5ViKDUUNytBPWiwfvZP4/Bj4Y3lUfvgQ==" + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/bigint-crypto-utils/-/bigint-crypto-utils-3.3.0.tgz", + "integrity": "sha512-jOTSb+drvEDxEq6OuUybOAv/xxoh3cuYRUIPyu8sSHQNKM303UQ2R1DAo45o1AkcIXw6fzbaFI1+xGGdaXs2lg==" }, "bignumber.js": { "version": "9.1.1", @@ -25018,6 +25044,11 @@ "upper-case-first": "^2.0.2" } }, + "case": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/case/-/case-1.6.3.tgz", + "integrity": "sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ==" + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -25175,14 +25206,14 @@ "dev": true }, "classic-level": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/classic-level/-/classic-level-1.2.0.tgz", - "integrity": "sha512-qw5B31ANxSluWz9xBzklRWTUAJ1SXIdaVKTVS7HcTGKOAmExx65Wo5BUICW+YGORe2FOUaDghoI9ZDxj82QcFg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/classic-level/-/classic-level-1.3.0.tgz", + "integrity": "sha512-iwFAJQYtqRTRM0F6L8h4JCt00ZSGdOyqh7yVrhhjrOpFhmBjNlRUey64MCiyo6UmQHMJ+No3c81nujPv+n9yrg==", "requires": { "abstract-level": "^1.0.2", "catering": "^2.1.0", "module-error": "^1.0.1", - "napi-macros": "~2.0.0", + "napi-macros": "^2.2.2", "node-gyp-build": "^4.3.0" } }, @@ -25711,8 +25742,9 @@ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" }, "dkg-evm-module": { - "version": "git+https://git@github.com/OriginTrail/dkg-evm-module.git#6e70f03ea3907d89f1a24d7dbc78d2699814ec36", - "from": "dkg-evm-module@^4.0.7", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/dkg-evm-module/-/dkg-evm-module-4.1.0.tgz", + "integrity": "sha512-80l9dIjUchBk5SOx6+hdo/I1+r1hUpxHmz3fwQuLISvof4aLSVZ2oqvkEdMPtkvBOjgT3F7uKnHSu6SanBa40A==", "requires": { "@openzeppelin/contracts": "^4.9.3", "@polkadot/api": "^10.1.4", @@ -25721,7 +25753,7 @@ "@polkadot/util-crypto": "^11.1.1", "@prb/math": "^2.5.0", "dotenv": "^16.0.3", - "hardhat": "^2.13.0", + "hardhat": "^2.19.1", "hardhat-deploy": "^0.11.25", "hardhat-deploy-ethers": "^0.3.0-beta.13", "ts-node": "^10.9.1", @@ -28055,27 +28087,26 @@ } }, "hardhat": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/hardhat/-/hardhat-2.13.0.tgz", - "integrity": "sha512-ZlzBOLML1QGlm6JWyVAG8lVTEAoOaVm1in/RU2zoGAnYEoD1Rp4T+ZMvrLNhHaaeS9hfjJ1gJUBfiDr4cx+htQ==", + "version": "2.19.1", + "resolved": "https://registry.npmjs.org/hardhat/-/hardhat-2.19.1.tgz", + "integrity": "sha512-bsWa63g1GB78ZyMN08WLhFElLPA+J+pShuKD1BFO2+88g3l+BL3R07vj9deIi9dMbssxgE714Gof1dBEDGqnCw==", "requires": { "@ethersproject/abi": "^5.1.2", "@metamask/eth-sig-util": "^4.0.0", - "@nomicfoundation/ethereumjs-block": "^4.0.0", - "@nomicfoundation/ethereumjs-blockchain": "^6.0.0", - "@nomicfoundation/ethereumjs-common": "^3.0.0", - "@nomicfoundation/ethereumjs-evm": "^1.0.0", - "@nomicfoundation/ethereumjs-rlp": "^4.0.0", - "@nomicfoundation/ethereumjs-statemanager": "^1.0.0", - "@nomicfoundation/ethereumjs-trie": "^5.0.0", - "@nomicfoundation/ethereumjs-tx": "^4.0.0", - "@nomicfoundation/ethereumjs-util": "^8.0.0", - "@nomicfoundation/ethereumjs-vm": "^6.0.0", + "@nomicfoundation/ethereumjs-block": "5.0.2", + "@nomicfoundation/ethereumjs-blockchain": "7.0.2", + "@nomicfoundation/ethereumjs-common": "4.0.2", + "@nomicfoundation/ethereumjs-evm": "2.0.2", + "@nomicfoundation/ethereumjs-rlp": "5.0.2", + "@nomicfoundation/ethereumjs-statemanager": "2.0.2", + "@nomicfoundation/ethereumjs-trie": "6.0.2", + "@nomicfoundation/ethereumjs-tx": "5.0.2", + "@nomicfoundation/ethereumjs-util": "9.0.2", + "@nomicfoundation/ethereumjs-vm": "7.0.2", "@nomicfoundation/solidity-analyzer": "^0.1.0", "@sentry/node": "^5.18.1", "@types/bn.js": "^5.1.0", "@types/lru-cache": "^5.1.0", - "abort-controller": "^3.0.0", "adm-zip": "^0.4.16", "aggregate-error": "^3.0.0", "ansi-escapes": "^4.3.0", @@ -28098,7 +28129,6 @@ "mnemonist": "^0.38.0", "mocha": "^10.0.0", "p-map": "^4.0.0", - "qs": "^6.7.0", "raw-body": "^2.4.1", "resolve": "1.17.0", "semver": "^6.3.0", @@ -30927,9 +30957,9 @@ "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" }, "napi-macros": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", - "integrity": "sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg==" + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.2.2.tgz", + "integrity": "sha512-hmEVtAGYzVQpCKdbQea4skABsdXW4RUh5t5mJ2zzqowJS2OyXZTU1KhDVFhx+NlWZ4ap9mqR9TcDO3LTTttd+g==" }, "native-abort-controller": { "version": "1.0.4", diff --git a/package.json b/package.json index dbb595af9a..04b8a57868 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.0.20", + "version": "6.1.0", "description": "OTNode V6", "main": "index.js", "type": "module", @@ -77,7 +77,7 @@ "axios": "^1.6.0", "cors": "^2.8.5", "deep-extend": "^0.6.0", - "dkg-evm-module": "^4.0.7", + "dkg-evm-module": "^4.1.0", "dotenv": "^16.0.1", "ethers": "^5.7.2", "express": "^4.18.1", From d92e677e7034d9e87bef2ed32b78e8bafa9906a5 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Tue, 28 Nov 2023 17:19:47 +0100 Subject: [PATCH 55/72] Fixed KA owner check in ValidationService --- src/service/validation-service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/validation-service.js b/src/service/validation-service.js index 60b0e374ba..a841a4265d 100644 --- a/src/service/validation-service.js +++ b/src/service/validation-service.js @@ -21,7 +21,7 @@ class ValidationService { contract, tokenId, ); - if (result === ZERO_ADDRESS) { + if (!result || result === ZERO_ADDRESS) { isValid = false; } } catch (err) { From b2cfdd8aa3cc0e728aced7b78bf350a505c1c3d4 Mon Sep 17 00:00:00 2001 From: djordjekovac Date: Wed, 29 Nov 2023 12:53:38 +0100 Subject: [PATCH 56/72] OriginTrail Devnet Prerelease v6.1.0.hotfix1 (#2811) * Fixed bug with user migration * Fixed bug with user configuration migration * Make triple store ual extension migration non blocking * Make ual extension triple store migration blocking for event handling * Skipping epoch check command if migration is not executed * Added logs in epoch check command * Updating the code to support new devnet environement --- config/config.json | 6 +++--- ot-node.js | 15 ++++++++------- package-lock.json | 4 ++-- package.json | 2 +- .../protocols/common/epoch-check-command.js | 13 +++++++++++++ src/migration/migration-executor.js | 18 +++++++++++++++++- src/migration/network-private-key-migration.js | 6 +++++- ...l-extension-user-configuration-migration.js | 11 +++++------ .../network/implementation/libp2p-service.js | 2 +- src/service/file-service.js | 6 +++++- 10 files changed, 60 insertions(+), 23 deletions(-) diff --git a/config/config.json b/config/config.json index 3444737b9a..a7e8345980 100644 --- a/config/config.json +++ b/config/config.json @@ -399,7 +399,7 @@ "enabled": true, "implementation": { "otp:20430": { - "enabled": true, + "enabled": false, "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", "config": { "hubContractAddress": "0xBbfF7Ea6b2Addc1f38A0798329e12C08f03750A6", @@ -563,7 +563,7 @@ "enabled": true, "implementation": { "otp:2160": { - "enabled": true, + "enabled": false, "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", "config": { "hubContractAddress": "0x833048F6e6BEa78E0AAdedeCd2Dc2231dda443FB", @@ -728,7 +728,7 @@ "defaultImplementation": "otp:2043", "implementation": { "otp:2043": { - "enabled": true, + "enabled": false, "package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js", "config": { "hubContractAddress": "0x5fA7916c48Fe6D5F1738d12Ad234b78c90B4cAdA", diff --git a/ot-node.js b/ot-node.js index c545c9ef03..43f8434230 100644 --- a/ot-node.js +++ b/ot-node.js @@ -57,12 +57,6 @@ class OTNode { await this.initializeModules(); - await MigrationExecutor.executeUalExtensionTripleStoreMigration( - this.container, - this.logger, - this.config, - ); - await MigrationExecutor.executePullShardingTableMigration( this.container, this.logger, @@ -104,7 +98,14 @@ class OTNode { await this.initializeCommandExecutor(); await this.initializeShardingTableService(); - await this.initializeBlockchainEventListenerService(); + + MigrationExecutor.executeUalExtensionTripleStoreMigration( + this.container, + this.logger, + this.config, + ).then(async () => { + await this.initializeBlockchainEventListenerService(); + }); await this.initializeRouters(); await this.startNetworkModule(); diff --git a/package-lock.json b/package-lock.json index 96ed40c12e..00070a5fe9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix.1", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index 04b8a57868..18ec743a52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix.1", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/commands/protocols/common/epoch-check-command.js b/src/commands/protocols/common/epoch-check-command.js index 330a700f09..a1024ded62 100644 --- a/src/commands/protocols/common/epoch-check-command.js +++ b/src/commands/protocols/common/epoch-check-command.js @@ -7,6 +7,7 @@ import { OPERATION_ID_STATUS, ERROR_TYPE, } from '../../../constants/constants.js'; +import MigrationExecutor from '../../../migration/migration-executor.js'; class EpochCheckCommand extends Command { constructor(ctx) { @@ -17,11 +18,23 @@ class EpochCheckCommand extends Command { this.shardingTableService = ctx.shardingTableService; this.blockchainModuleManager = ctx.blockchainModuleManager; this.serviceAgreementService = ctx.serviceAgreementService; + this.fileService = ctx.fileService; this.errorType = ERROR_TYPE.COMMIT_PROOF.EPOCH_CHECK_ERROR; } async execute(command) { + const migrationExecuted = await MigrationExecutor.migrationAlreadyExecuted( + 'ualExtensionTripleStoreMigration', + this.fileService, + ); + if (!migrationExecuted) { + this.logger.info( + 'Epoch check command will be postponed until ual extension triple store migration is completed', + ); + return Command.repeat(); + } + this.logger.info('Starting epoch check command'); const operationId = this.operationIdService.generateId(); this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.EPOCH_CHECK_START, diff --git a/src/migration/migration-executor.js b/src/migration/migration-executor.js index 3f8cfc44f0..7d5399dce5 100644 --- a/src/migration/migration-executor.js +++ b/src/migration/migration-executor.js @@ -1,3 +1,4 @@ +import path from 'path'; import { NODE_ENVIRONMENTS } from '../constants/constants.js'; import PullBlockchainShardingTableMigration from './pull-sharding-table-migration.js'; import PrivateAssetsMetadataMigration from './private-assets-metadata-migration.js'; @@ -326,13 +327,28 @@ class MigrationExecutor { tripleStoreService, ); if (!(await migration.migrationAlreadyExecuted())) { - await migration.migrate(); + try { + await migration.migrate(); + } catch (error) { + logger.error( + `Unable to execute ual extension triple store migration. Error: ${error.message}`, + ); + this.exitNode(1); + } } } static exitNode(code = 0) { process.exit(code); } + + static async migrationAlreadyExecuted(migrationName, fileService) { + const migrationFilePath = path.join(fileService.getMigrationFolderPath(), migrationName); + if (await fileService.pathExists(migrationFilePath)) { + return true; + } + return false; + } } export default MigrationExecutor; diff --git a/src/migration/network-private-key-migration.js b/src/migration/network-private-key-migration.js index c95fbe1f95..70a18b1e8e 100644 --- a/src/migration/network-private-key-migration.js +++ b/src/migration/network-private-key-migration.js @@ -10,7 +10,11 @@ class NetworkPrivateKeyMigration extends BaseMigration { if (networkPrivateKey) { let directoryPath; - if (process.env.NODE_ENV === 'testnet' || process.env.NODE_ENV === 'mainnet') { + if ( + process.env.NODE_ENV === 'testnet' || + process.env.NODE_ENV === 'mainnet' || + process.env.NODE_ENV === 'devnet' + ) { directoryPath = join( appRootPath.path, '..', diff --git a/src/migration/ual-extension-user-configuration-migration.js b/src/migration/ual-extension-user-configuration-migration.js index 76807dfa2b..5d0c74f570 100644 --- a/src/migration/ual-extension-user-configuration-migration.js +++ b/src/migration/ual-extension-user-configuration-migration.js @@ -28,7 +28,7 @@ class UalExtensionUserConfigurationMigration extends BaseMigration { const oldBlockchainId = this.getOldBlockchainId(userConfiguration); - if (!this.blockchainIdInNewFormat(oldBlockchainId)) { + if (this.blockchainIdInNewFormat(oldBlockchainId)) { this.logger.info( 'Blockchain id in user configuration already updated to be in new format, migration will be skipped', ); @@ -36,9 +36,10 @@ class UalExtensionUserConfigurationMigration extends BaseMigration { } const newBlockchainId = `${oldBlockchainId}:${chainId}`; - userConfiguration.modules.blockchain.implementation.defaultImplementation = newBlockchainId; + userConfiguration.modules.blockchain.defaultImplementation = newBlockchainId; userConfiguration.modules.blockchain.implementation[newBlockchainId] = userConfiguration.modules.blockchain.implementation[oldBlockchainId]; + userConfiguration.modules.blockchain.implementation[newBlockchainId].enabled = true; delete userConfiguration.modules.blockchain.implementation[oldBlockchainId]; await this.fileService.writeContentsToFile( configurationFolderPath, @@ -48,16 +49,14 @@ class UalExtensionUserConfigurationMigration extends BaseMigration { } blockchainIdInNewFormat(blockchainId) { - return blockchainId.contains(':'); + return blockchainId.includes(':'); } getOldBlockchainId(userConfiguration) { let oldBlockchainId; if (userConfiguration.modules.blockchain.implementation) { for (const implementationName in userConfiguration.modules.blockchain.implementation) { - if ( - userConfiguration.modules.blockchain.implementation[implementationName].enabled - ) { + if (implementationName.includes('otp')) { oldBlockchainId = implementationName; } } diff --git a/src/modules/network/implementation/libp2p-service.js b/src/modules/network/implementation/libp2p-service.js index da50372d0a..385d9be40e 100644 --- a/src/modules/network/implementation/libp2p-service.js +++ b/src/modules/network/implementation/libp2p-service.js @@ -123,7 +123,7 @@ class Libp2pService { getKeyPath() { let directoryPath; - if (process.env.NODE_ENV === 'testnet' || process.env.NODE_ENV === 'mainnet') { + if (!devEnvironment) { directoryPath = join( appRootPath.path, '..', diff --git a/src/service/file-service.js b/src/service/file-service.js index 7d92ce8a84..bc5b60098a 100644 --- a/src/service/file-service.js +++ b/src/service/file-service.js @@ -104,7 +104,11 @@ class FileService { } getDataFolderPath() { - if (process.env.NODE_ENV === 'testnet' || process.env.NODE_ENV === 'mainnet') { + if ( + process.env.NODE_ENV === 'testnet' || + process.env.NODE_ENV === 'mainnet' || + process.env.NODE_ENV === 'devnet' + ) { return path.join(appRootPath.path, '..', this.config.appDataPath); } return path.join(appRootPath.path, this.config.appDataPath); From 6c9e5024258c50cc11df938c65fe444303034dd3 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 30 Nov 2023 11:59:55 +0100 Subject: [PATCH 57/72] Execute triple store migration in chunks --- .../ual-extension-triple-store-migration.js | 92 ++++++++++++++----- 1 file changed, 69 insertions(+), 23 deletions(-) diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 8aa611a543..0e6aee587a 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -1,4 +1,5 @@ import BaseMigration from './base-migration.js'; +import { TRIPLE_STORE_REPOSITORIES } from '../constants/constants.js'; const CHAIN_IDS = { development: 31337, @@ -18,39 +19,84 @@ class UalExtensionTripleStoreMigration extends BaseMigration { async executeMigration() { const oldBlockchainId = this.getOldBlockchainId(); const newBlockchainId = `${oldBlockchainId}:${chainId}`; - const updateSubjectQuery = ` - WITH - DELETE { - ?s ?p ?o - } - INSERT { - ?newSubject ?p ?o - } - WHERE { - ?s ?p ?o . - FILTER (STRSTARTS(STR(?s), "did:dkg:${oldBlockchainId}/")) - BIND (IRI(REPLACE(STR(?s), "${oldBlockchainId}", "${newBlockchainId}")) AS ?newSubject) - } - `; - await this.tripleStoreService.queryVoidAllRepositories(updateSubjectQuery); + const chunkSize = 5000; - const updateObjectQuery = ` + const totalSubjectsQuery = ` + SELECT (COUNT(*) AS ?totalObjects) + WHERE { + GRAPH { + ?s ?p ?o . + FILTER (STRSTARTS(STR(?s), "did:dkg:${oldBlockchainId}/")) + } + }`; + const updateSubjectQuery = ` WITH DELETE { ?s ?p ?o } INSERT { - ?s ?p ?newObject + ?newSubject ?p ?o } WHERE { - ?s ?p ?o . - FILTER(STRENDS(STR(?p), "blockchain")) - BIND ("${newBlockchainId}" AS ?newObject) - } - `; + { + SELECT ?s ?p ?o (IRI(REPLACE(STR(?s), "${oldBlockchainId}", "${newBlockchainId}")) AS ?newSubject) + WHERE { + ?s ?p ?o . + FILTER (STRSTARTS(STR(?s), "did:dkg:${oldBlockchainId}/")) + } + LIMIT ${chunkSize} + } + } + `; + const updateObjectQuery = ` + WITH + DELETE { + ?s ?p ?o + } + INSERT { + ?s ?p "${newBlockchainId}" . + } + WHERE { + SELECT ?s ?p ?o + WHERE { + ?s ?p ?o . + FILTER(STRENDS(STR(?p), "blockchain")) + } + LIMIT ${chunkSize} + } + `; + for (const repository in TRIPLE_STORE_REPOSITORIES) { + // eslint-disable-next-line no-await-in-loop + const totalSubjectsResult = await this.tripleStoreService.select( + TRIPLE_STORE_REPOSITORIES[repository], + totalSubjectsQuery, + ); + const totalSubjects = parseInt( + totalSubjectsResult[0].totalObjects.match( + /"(\d+)"\^\^http:\/\/www.w3.org\/2001\/XMLSchema#integer/, + )[1], + 10, + ); + let offset = 0; + if (totalSubjects !== 0) { + do { + // eslint-disable-next-line no-await-in-loop + await this.tripleStoreService.queryVoid( + TRIPLE_STORE_REPOSITORIES[repository], + updateSubjectQuery, + ); + + // eslint-disable-next-line no-await-in-loop + await this.tripleStoreService.queryVoid( + TRIPLE_STORE_REPOSITORIES[repository], + updateObjectQuery, + ); - await this.tripleStoreService.queryVoidAllRepositories(updateObjectQuery); + offset += chunkSize; + } while (offset < totalSubjects); + } + } } getOldBlockchainId() { From 28137ac6b744d7e0e3c769e84bd7d9b2a655de6c Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 30 Nov 2023 14:48:55 +0100 Subject: [PATCH 58/72] Split object and subject query exectuion --- .../ual-extension-triple-store-migration.js | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 0e6aee587a..e36f50d0c4 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -20,7 +20,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { const oldBlockchainId = this.getOldBlockchainId(); const newBlockchainId = `${oldBlockchainId}:${chainId}`; - const chunkSize = 5000; + const chunkSize = 100000; const totalSubjectsQuery = ` SELECT (COUNT(*) AS ?totalObjects) @@ -30,6 +30,15 @@ class UalExtensionTripleStoreMigration extends BaseMigration { FILTER (STRSTARTS(STR(?s), "did:dkg:${oldBlockchainId}/")) } }`; + + const totalObjectsQuery = ` + SELECT (COUNT(*) AS ?totalObjects) + WHERE { + ?s ?p ?o . + FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "${oldBlockchainId}")) + } + + `; const updateSubjectQuery = ` WITH DELETE { @@ -78,7 +87,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { )[1], 10, ); - let offset = 0; + let offsetSubject = 0; if (totalSubjects !== 0) { do { // eslint-disable-next-line no-await-in-loop @@ -87,14 +96,31 @@ class UalExtensionTripleStoreMigration extends BaseMigration { updateSubjectQuery, ); + offsetSubject += chunkSize; + } while (offsetSubject < totalSubjects); + } + // eslint-disable-next-line no-await-in-loop + const totalObjectsResult = await this.tripleStoreService.select( + TRIPLE_STORE_REPOSITORIES[repository], + totalObjectsQuery, + ); + const totalObjects = parseInt( + totalObjectsResult[0].totalObjects.match( + /"(\d+)"\^\^http:\/\/www.w3.org\/2001\/XMLSchema#integer/, + )[1], + 10, + ); + let offsetObject = 0; + if (totalObjects !== 0) { + do { // eslint-disable-next-line no-await-in-loop await this.tripleStoreService.queryVoid( TRIPLE_STORE_REPOSITORIES[repository], updateObjectQuery, ); - offset += chunkSize; - } while (offset < totalSubjects); + offsetObject += chunkSize; + } while (offsetObject < totalObjects); } } } From 0602750b797c54f1039cffdef0072e1601023524 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 30 Nov 2023 17:16:03 +0100 Subject: [PATCH 59/72] Fix objcet update query, reduce batch size and add logging --- .../ual-extension-triple-store-migration.js | 78 ++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index e36f50d0c4..bedef2ff7e 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -20,7 +20,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { const oldBlockchainId = this.getOldBlockchainId(); const newBlockchainId = `${oldBlockchainId}:${chainId}`; - const chunkSize = 100000; + const chunkSize = 10000; const totalSubjectsQuery = ` SELECT (COUNT(*) AS ?totalObjects) @@ -70,7 +70,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { SELECT ?s ?p ?o WHERE { ?s ?p ?o . - FILTER(STRENDS(STR(?p), "blockchain")) + FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "${oldBlockchainId}")) } LIMIT ${chunkSize} } @@ -87,6 +87,9 @@ class UalExtensionTripleStoreMigration extends BaseMigration { )[1], 10, ); + this.logger.debug( + `Total number of triple store subjects that will be updated: ${totalSubjects} in repositroy: ${repository}.`, + ); let offsetSubject = 0; if (totalSubjects !== 0) { do { @@ -97,7 +100,13 @@ class UalExtensionTripleStoreMigration extends BaseMigration { ); offsetSubject += chunkSize; + this.logger.debug( + `Number of subjects updated: ${offsetSubject} in repository ${repository}`, + ); } while (offsetSubject < totalSubjects); + this.logger.debug( + `Finalised triple store subject update in repository: ${repository}.`, + ); } // eslint-disable-next-line no-await-in-loop const totalObjectsResult = await this.tripleStoreService.select( @@ -111,6 +120,9 @@ class UalExtensionTripleStoreMigration extends BaseMigration { 10, ); let offsetObject = 0; + this.logger.debug( + `Total number of triple store object that will be updated: ${totalObjects} in repositroy: ${repository}.`, + ); if (totalObjects !== 0) { do { // eslint-disable-next-line no-await-in-loop @@ -120,9 +132,71 @@ class UalExtensionTripleStoreMigration extends BaseMigration { ); offsetObject += chunkSize; + this.logger.debug( + `Number of objects updated: ${offsetObject} in repository ${repository}`, + ); } while (offsetObject < totalObjects); + this.logger.debug( + `Finalised triple store object update in repository: ${repository}.`, + ); } } + for (const repository in TRIPLE_STORE_REPOSITORIES) { + const countOldSujbectQuerry = `SELECT (COUNT(*) AS ?count) + WHERE { + ?s ?p ?o . + FILTER (STRSTARTS(STR(?s), "did:dkg:otp/")) + }`; + // eslint-disable-next-line no-await-in-loop + const countOldSujbectResult = await this.tripleStoreModuleManager.select( + this.repositoryImplementations[repository], + TRIPLE_STORE_REPOSITORIES[repository], + countOldSujbectQuerry, + ); + const countNewSujbectQuerry = `SELECT (COUNT(*) AS ?count) + WHERE { + ?s ?p ?o . + FILTER (STRSTARTS(STR(?s), "did:dkg:otp:2160/")) + }`; + // eslint-disable-next-line no-await-in-loop + const countNewSujbectQuerryResult = await this.tripleStoreModuleManager.select( + this.repositoryImplementations[repository], + TRIPLE_STORE_REPOSITORIES[repository], + countNewSujbectQuerry, + ); + + const countOldObjectsQuery = `SELECT (COUNT(*) AS ?count) + WHERE { + ?s ?p ?o . + FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "otp")) + }`; + // eslint-disable-next-line no-await-in-loop + const countOldObjectsQueryResult = await this.tripleStoreModuleManager.select( + this.repositoryImplementations[repository], + TRIPLE_STORE_REPOSITORIES[repository], + countOldObjectsQuery, + ); + const countNewObjectQuery = `SELECT (COUNT(*) AS ?count) + WHERE { + ?s ?p ?o . + FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "otp:2160")) + }`; + // eslint-disable-next-line no-await-in-loop + const countNewObjectQueryResult = await this.tripleStoreModuleManager.select( + this.repositoryImplementations[repository], + TRIPLE_STORE_REPOSITORIES[repository], + countNewObjectQuery, + ); + this.logger.debug( + `Report for UAL extentsion triple store migragrion on repository: ${repository}. Old subject count: ${JSON.stringify( + countOldSujbectResult, + )}. New subject count: ${JSON.stringify( + countNewSujbectQuerryResult, + )}. Old object count: ${JSON.stringify( + countOldObjectsQueryResult, + )}. New object count: ${JSON.stringify(countNewObjectQueryResult)}.`, + ); + } } getOldBlockchainId() { From 77929f21b6b0184bdfc30ccc2b44d8c64c0638f3 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 30 Nov 2023 17:18:14 +0100 Subject: [PATCH 60/72] Version bumb --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 04b8a57868..ba07d53327 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix2", "description": "OTNode V6", "main": "index.js", "type": "module", From 0ba52da710e82832e220be4a2f79e0fe7ab88dcc Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Thu, 30 Nov 2023 17:23:14 +0100 Subject: [PATCH 61/72] Package-lock update --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 00070a5fe9..41cb17e537 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix.1", + "version": "6.1.0+hotfix2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0+hotfix.1", + "version": "6.1.0+hotfix2", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", From fa36391b43a4f9662c024dea28f63d485def633a Mon Sep 17 00:00:00 2001 From: NZT48 Date: Thu, 30 Nov 2023 18:23:11 +0100 Subject: [PATCH 62/72] Disable statistics for ual triple store migration --- package-lock.json | 4 +- package.json | 2 +- .../ual-extension-triple-store-migration.js | 112 +++++++++--------- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/package-lock.json b/package-lock.json index 41cb17e537..ed7ab17522 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix2", + "version": "6.1.0+hotfix3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0+hotfix2", + "version": "6.1.0+hotfix3", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index ba07d53327..96be5f5c0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix2", + "version": "6.1.0+hotfix3", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index bedef2ff7e..32821b6973 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -141,62 +141,62 @@ class UalExtensionTripleStoreMigration extends BaseMigration { ); } } - for (const repository in TRIPLE_STORE_REPOSITORIES) { - const countOldSujbectQuerry = `SELECT (COUNT(*) AS ?count) - WHERE { - ?s ?p ?o . - FILTER (STRSTARTS(STR(?s), "did:dkg:otp/")) - }`; - // eslint-disable-next-line no-await-in-loop - const countOldSujbectResult = await this.tripleStoreModuleManager.select( - this.repositoryImplementations[repository], - TRIPLE_STORE_REPOSITORIES[repository], - countOldSujbectQuerry, - ); - const countNewSujbectQuerry = `SELECT (COUNT(*) AS ?count) - WHERE { - ?s ?p ?o . - FILTER (STRSTARTS(STR(?s), "did:dkg:otp:2160/")) - }`; - // eslint-disable-next-line no-await-in-loop - const countNewSujbectQuerryResult = await this.tripleStoreModuleManager.select( - this.repositoryImplementations[repository], - TRIPLE_STORE_REPOSITORIES[repository], - countNewSujbectQuerry, - ); - - const countOldObjectsQuery = `SELECT (COUNT(*) AS ?count) - WHERE { - ?s ?p ?o . - FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "otp")) - }`; - // eslint-disable-next-line no-await-in-loop - const countOldObjectsQueryResult = await this.tripleStoreModuleManager.select( - this.repositoryImplementations[repository], - TRIPLE_STORE_REPOSITORIES[repository], - countOldObjectsQuery, - ); - const countNewObjectQuery = `SELECT (COUNT(*) AS ?count) - WHERE { - ?s ?p ?o . - FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "otp:2160")) - }`; - // eslint-disable-next-line no-await-in-loop - const countNewObjectQueryResult = await this.tripleStoreModuleManager.select( - this.repositoryImplementations[repository], - TRIPLE_STORE_REPOSITORIES[repository], - countNewObjectQuery, - ); - this.logger.debug( - `Report for UAL extentsion triple store migragrion on repository: ${repository}. Old subject count: ${JSON.stringify( - countOldSujbectResult, - )}. New subject count: ${JSON.stringify( - countNewSujbectQuerryResult, - )}. Old object count: ${JSON.stringify( - countOldObjectsQueryResult, - )}. New object count: ${JSON.stringify(countNewObjectQueryResult)}.`, - ); - } + // for (const repository in TRIPLE_STORE_REPOSITORIES) { + // const countOldSujbectQuerry = `SELECT (COUNT(*) AS ?count) + // WHERE { + // ?s ?p ?o . + // FILTER (STRSTARTS(STR(?s), "did:dkg:otp/")) + // }`; + // // eslint-disable-next-line no-await-in-loop + // const countOldSujbectResult = await this.tripleStoreModuleManager.select( + // this.repositoryImplementations[repository], + // TRIPLE_STORE_REPOSITORIES[repository], + // countOldSujbectQuerry, + // ); + // const countNewSujbectQuerry = `SELECT (COUNT(*) AS ?count) + // WHERE { + // ?s ?p ?o . + // FILTER (STRSTARTS(STR(?s), "did:dkg:otp:2160/")) + // }`; + // // eslint-disable-next-line no-await-in-loop + // const countNewSujbectQuerryResult = await this.tripleStoreModuleManager.select( + // this.repositoryImplementations[repository], + // TRIPLE_STORE_REPOSITORIES[repository], + // countNewSujbectQuerry, + // ); + // + // const countOldObjectsQuery = `SELECT (COUNT(*) AS ?count) + // WHERE { + // ?s ?p ?o . + // FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "otp")) + // }`; + // // eslint-disable-next-line no-await-in-loop + // const countOldObjectsQueryResult = await this.tripleStoreModuleManager.select( + // this.repositoryImplementations[repository], + // TRIPLE_STORE_REPOSITORIES[repository], + // countOldObjectsQuery, + // ); + // const countNewObjectQuery = `SELECT (COUNT(*) AS ?count) + // WHERE { + // ?s ?p ?o . + // FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "otp:2160")) + // }`; + // // eslint-disable-next-line no-await-in-loop + // const countNewObjectQueryResult = await this.tripleStoreModuleManager.select( + // this.repositoryImplementations[repository], + // TRIPLE_STORE_REPOSITORIES[repository], + // countNewObjectQuery, + // ); + // this.logger.debug( + // `Report for UAL extentsion triple store migragrion on repository: ${repository}. Old subject count: ${JSON.stringify( + // countOldSujbectResult, + // )}. New subject count: ${JSON.stringify( + // countNewSujbectQuerryResult, + // )}. Old object count: ${JSON.stringify( + // countOldObjectsQueryResult, + // )}. New object count: ${JSON.stringify(countNewObjectQueryResult)}.`, + // ); + // } } getOldBlockchainId() { From b5443c66c3dbfdf24ac33f9e997a26465f136f0f Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Fri, 1 Dec 2023 16:31:47 +0100 Subject: [PATCH 63/72] Feature/add blockchains to nodeinfo (#2819) * Add blockchains to node info * Move getBlockchainsNodeInfo logic to send telemetry command --------- Co-authored-by: djordjekovac --- src/commands/common/send-telemetry-command.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/commands/common/send-telemetry-command.js b/src/commands/common/send-telemetry-command.js index ada1aab635..6a9ea0ce09 100644 --- a/src/commands/common/send-telemetry-command.js +++ b/src/commands/common/send-telemetry-command.js @@ -30,15 +30,27 @@ class SendTelemetryCommand extends Command { try { const events = (await this.getUnpublishedEvents()) || []; + const blockchainsNodeInfo = []; + const implementations = this.blockchainModuleManager.getImplementationNames(); + for (const implementation of implementations) { + const blockchainInfo = { + blockchain_id: implementation, + // eslint-disable-next-line no-await-in-loop + identity_id: await this.blockchainModuleManager.getIdentityId(implementation), + operational_wallet: this.blockchainModuleManager.getPublicKey(implementation), + management_wallet: + this.blockchainModuleManager.getManagementKey(implementation), + }; + blockchainsNodeInfo.push(blockchainInfo); + } const nodeData = { version: pjson.version, identity: this.networkModuleManager.getPeerId().toB58String(), hostname: this.config.hostname, - operational_wallet: this.blockchainModuleManager.getPublicKey(), - management_wallet: this.blockchainModuleManager.getManagementKey(), triple_store: this.config.modules.tripleStore.defaultImplementation, auto_update_enabled: this.config.modules.autoUpdater.enabled, multiaddresses: this.networkModuleManager.getMultiaddrs(), + blockchains: blockchainsNodeInfo, }; const isDataSuccessfullySent = await this.telemetryModuleManager.sendTelemetryData( nodeData, From 4f4d21324680a006ce4beafa30c2c7364ce016ea Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar <71610423+u-hubar@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:06:25 +0100 Subject: [PATCH 64/72] Added blockchain id to the telemetry events and db table, added migration to add new blockchainId column (#2820) * Added blockchain id to the telemetry events and db table, added migration to add new blockchainId column * Reverted back name of the migration file, added blockchainId insert to 'event' table in the operationaldb * Added blockchain_id column to the event table, fixed migration * Enabled sharding table migration --------- Co-authored-by: djordjekovac --- ot-node.js | 1 + package-lock.json | 4 +-- package.json | 2 +- src/commands/command.js | 7 +++-- src/commands/common/validate-asset-command.js | 12 +++++++- .../local-store/local-store-command.js | 5 +++- .../protocols/common/epoch-check-command.js | 29 ++++++++++++------- .../protocols/common/find-nodes-command.js | 3 ++ .../common/handle-protocol-message-command.js | 4 +-- .../protocol-schedule-messages-command.js | 6 +++- .../protocols/common/submit-commit-command.js | 3 ++ .../protocols/common/submit-proofs-command.js | 7 ++++- .../v1.0.0/v1-0-0-handle-get-init-command.js | 2 ++ .../v1-0-0-handle-get-request-command.js | 2 ++ .../get/sender/get-assertion-id-command.js | 11 +++++-- .../protocols/get/sender/local-get-command.js | 26 ++++++++++++----- .../v1-0-0-handle-store-init-command.js | 2 ++ .../v1-0-0-handle-store-request-command.js | 4 +++ .../publish-schedule-messages-command.js | 1 + .../sender/publish-validate-asset-command.js | 9 ++++-- .../receiver/submit-update-commit-command.js | 3 ++ .../v1-0-0-handle-update-init-command.js | 2 ++ .../v1-0-0-handle-update-request-command.js | 2 ++ .../sender/update-validate-asset-command.js | 9 ++++-- src/commands/query/query-command.js | 5 +++- .../http-api/v0/get-http-api-controller-v0.js | 8 ++++- .../v0/local-store-http-api-controller-v0.js | 1 + .../v0/publish-http-api-controller-v0.js | 17 ++++++----- .../v0/query-http-api-controller-v0.js | 1 + .../v0/update-http-api-controller-v0.js | 17 ++++++----- src/migration/migration-executor.js | 2 +- .../20231201140100-event-add-blockchain-id.js | 9 ++++++ .../implementation/sequelize/models/event.js | 1 + .../repositories/event-repository.js | 3 +- .../repository/repository-module-manager.js | 2 ++ src/service/get-service.js | 3 ++ src/service/operation-id-service.js | 16 ++++++++-- src/service/operation-service.js | 7 +++-- src/service/publish-service.js | 9 +++++- src/service/update-service.js | 9 +++++- test/unit/mock/operation-id-service-mock.js | 8 ++++- test/unit/service/get-service.test.js | 2 ++ test/unit/service/publish-service.test.js | 4 +++ test/unit/service/update-service.test.js | 4 +++ 44 files changed, 222 insertions(+), 62 deletions(-) create mode 100644 src/modules/repository/implementation/sequelize/migrations/20231201140100-event-add-blockchain-id.js diff --git a/ot-node.js b/ot-node.js index 43f8434230..3595e5495d 100644 --- a/ot-node.js +++ b/ot-node.js @@ -321,6 +321,7 @@ class OTNode { telemetryModuleManager.listenOnEvents((eventData) => { repositoryModuleManager.createEventRecord( eventData.operationId, + eventData.blockchainId, eventData.lastEvent, eventData.timestamp, eventData.value1, diff --git a/package-lock.json b/package-lock.json index ed7ab17522..866582ee23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix3", + "version": "6.1.0+hotfix4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0+hotfix3", + "version": "6.1.0+hotfix4", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index 96be5f5c0e..b33f4bb124 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix3", + "version": "6.1.0+hotfix4", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/commands/command.js b/src/commands/command.js index 164c1f73e0..c2d3596ba6 100644 --- a/src/commands/command.js +++ b/src/commands/command.js @@ -24,8 +24,8 @@ class Command { * @param err */ async recover(command, err) { - const { operationId } = command.data; - await this.handleError(operationId, err.message, this.errorType, true); + const { operationId, blockchain } = command.data; + await this.handleError(operationId, blockchain, err.message, this.errorType, true); return Command.empty(); } @@ -115,11 +115,12 @@ class Command { * @param markFailed - Update operation status to failed * @returns {*} */ - async handleError(operationId, errorMessage, errorName, markFailed) { + async handleError(operationId, blockchain, errorMessage, errorName, markFailed) { this.logger.error(`Command error (${errorName}): ${errorMessage}`); if (markFailed) { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.FAILED, errorMessage, errorName, diff --git a/src/commands/common/validate-asset-command.js b/src/commands/common/validate-asset-command.js index 317a45cdb6..ec25cd8c01 100644 --- a/src/commands/common/validate-asset-command.js +++ b/src/commands/common/validate-asset-command.js @@ -32,6 +32,7 @@ class ValidateAssetCommand extends Command { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.VALIDATE_ASSET_START, ); @@ -59,6 +60,7 @@ class ValidateAssetCommand extends Command { if (blockchainAssertionId !== cachedData.public.assertionId) { await this.handleError( operationId, + blockchain, `Invalid assertion id for asset ${ual}. Received value from blockchain: ${blockchainAssertionId}, received value from request: ${cachedData.public.assertionId}`, this.errorType, true, @@ -83,13 +85,20 @@ class ValidateAssetCommand extends Command { cachedData.private.assertionId, ); } catch (error) { - await this.handleError(operationId, error.message, this.errorType, true); + await this.handleError( + operationId, + blockchain, + error.message, + this.errorType, + true, + ); return Command.empty(); } } await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.VALIDATE_ASSET_END, ); return this.continueSequence( @@ -103,6 +112,7 @@ class ValidateAssetCommand extends Command { const ual = this.ualService.deriveUAL(blockchain, contract, tokenId); await this.handleError( operationId, + blockchain, `Max retry count for command: ${command.name} reached! Unable to validate ual: ${ual}`, this.errorType, true, diff --git a/src/commands/local-store/local-store-command.js b/src/commands/local-store/local-store-command.js index 5bf84abc00..4a0aa82b31 100644 --- a/src/commands/local-store/local-store-command.js +++ b/src/commands/local-store/local-store-command.js @@ -34,6 +34,7 @@ class LocalStoreCommand extends Command { try { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.LOCAL_STORE.LOCAL_STORE_START, ); @@ -104,15 +105,17 @@ class LocalStoreCommand extends Command { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.LOCAL_STORE.LOCAL_STORE_END, ); await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.COMPLETED, ); } catch (e) { - await this.handleError(operationId, e.message, this.errorType, true); + await this.handleError(operationId, blockchain, e.message, this.errorType, true); return Command.empty(); } diff --git a/src/commands/protocols/common/epoch-check-command.js b/src/commands/protocols/common/epoch-check-command.js index a1024ded62..ba10b2d825 100644 --- a/src/commands/protocols/common/epoch-check-command.js +++ b/src/commands/protocols/common/epoch-check-command.js @@ -6,6 +6,7 @@ import { TRANSACTION_CONFIRMATIONS, OPERATION_ID_STATUS, ERROR_TYPE, + NODE_ENVIRONMENTS, } from '../../../constants/constants.js'; import MigrationExecutor from '../../../migration/migration-executor.js'; @@ -28,7 +29,11 @@ class EpochCheckCommand extends Command { 'ualExtensionTripleStoreMigration', this.fileService, ); - if (!migrationExecuted) { + if ( + process.env.NODE_ENV !== NODE_ENVIRONMENTS.DEVELOPMENT && + process.env.NODE_ENV !== NODE_ENVIRONMENTS.TEST && + !migrationExecuted + ) { this.logger.info( 'Epoch check command will be postponed until ual extension triple store migration is completed', ); @@ -36,12 +41,15 @@ class EpochCheckCommand extends Command { } this.logger.info('Starting epoch check command'); const operationId = this.operationIdService.generateId(); - this.operationIdService.emitChangeEvent( - OPERATION_ID_STATUS.COMMIT_PROOF.EPOCH_CHECK_START, - operationId, - ); + await Promise.all( this.blockchainModuleManager.getImplementationNames().map(async (blockchain) => { + this.operationIdService.emitChangeEvent( + OPERATION_ID_STATUS.COMMIT_PROOF.EPOCH_CHECK_START, + operationId, + blockchain, + ); + const commitWindowDurationPerc = await this.blockchainModuleManager.getCommitWindowDurationPerc(blockchain); const proofWindowDurationPerc = @@ -84,12 +92,13 @@ class EpochCheckCommand extends Command { r0, ), ]); - }), - ); - this.operationIdService.emitChangeEvent( - OPERATION_ID_STATUS.COMMIT_PROOF.EPOCH_CHECK_END, - operationId, + this.operationIdService.emitChangeEvent( + OPERATION_ID_STATUS.COMMIT_PROOF.EPOCH_CHECK_END, + operationId, + blockchain, + ); + }), ); return Command.repeat(); diff --git a/src/commands/protocols/common/find-nodes-command.js b/src/commands/protocols/common/find-nodes-command.js index 400a0a6ef5..0ff49fc4ee 100644 --- a/src/commands/protocols/common/find-nodes-command.js +++ b/src/commands/protocols/common/find-nodes-command.js @@ -48,6 +48,7 @@ class FindNodesCommand extends Command { if (closestNodes.length < minAckResponses) { this.handleError( operationId, + blockchain, `Unable to find enough nodes for ${operationId}. Minimum number of nodes required: ${minAckResponses}`, this.errorType, true, @@ -68,6 +69,7 @@ class FindNodesCommand extends Command { async findNodes(blockchainId, keyword, operationId, hashFunctionId) { await this.operationIdService.updateOperationIdStatus( operationId, + blockchainId, OPERATION_ID_STATUS.FIND_NODES_START, ); const r2 = await this.blockchainModuleManager.getR2(blockchainId); @@ -87,6 +89,7 @@ class FindNodesCommand extends Command { await this.operationIdService.updateOperationIdStatus( operationId, + blockchainId, OPERATION_ID_STATUS.FIND_NODES_END, ); diff --git a/src/commands/protocols/common/handle-protocol-message-command.js b/src/commands/protocols/common/handle-protocol-message-command.js index 79400fda6e..92b7966697 100644 --- a/src/commands/protocols/common/handle-protocol-message-command.js +++ b/src/commands/protocols/common/handle-protocol-message-command.js @@ -225,9 +225,9 @@ class HandleProtocolMessageCommand extends Command { } async handleError(errorMessage, command) { - const { operationId, remotePeerId, keywordUuid, protocol } = command.data; + const { operationId, blockchain, remotePeerId, keywordUuid, protocol } = command.data; - await super.handleError(operationId, errorMessage, this.errorType, true); + await super.handleError(operationId, blockchain, errorMessage, this.errorType, true); await this.networkModuleManager.sendMessageResponse( protocol, remotePeerId, diff --git a/src/commands/protocols/common/protocol-schedule-messages-command.js b/src/commands/protocols/common/protocol-schedule-messages-command.js index bc9d1af115..c29b66559d 100644 --- a/src/commands/protocols/common/protocol-schedule-messages-command.js +++ b/src/commands/protocols/common/protocol-schedule-messages-command.js @@ -26,7 +26,11 @@ class ProtocolScheduleMessagesCommand extends Command { const currentBatchLeftoverNodes = batchSize < leftoverNodes.length ? leftoverNodes.slice(batchSize) : []; - await this.operationIdService.updateOperationIdStatus(operationId, this.startEvent); + await this.operationIdService.updateOperationIdStatus( + operationId, + blockchain, + this.startEvent, + ); this.logger.debug( `Trying to ${this.operationService.getOperationName()} to batch of ${ diff --git a/src/commands/protocols/common/submit-commit-command.js b/src/commands/protocols/common/submit-commit-command.js index 1151062811..d2782ad680 100644 --- a/src/commands/protocols/common/submit-commit-command.js +++ b/src/commands/protocols/common/submit-commit-command.js @@ -42,6 +42,7 @@ class SubmitCommitCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_COMMIT_START, operationId, + blockchain, agreementId, epoch, ); @@ -65,6 +66,7 @@ class SubmitCommitCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_COMMIT_END, operationId, + blockchain, agreementId, epoch, ); @@ -143,6 +145,7 @@ class SubmitCommitCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_COMMIT_END, operationId, + blockchain, agreementId, epoch, ); diff --git a/src/commands/protocols/common/submit-proofs-command.js b/src/commands/protocols/common/submit-proofs-command.js index 832e8a6461..27467c1cf9 100644 --- a/src/commands/protocols/common/submit-proofs-command.js +++ b/src/commands/protocols/common/submit-proofs-command.js @@ -48,6 +48,7 @@ class SubmitProofsCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.CALCULATE_PROOFS_START, operationId, + blockchain, agreementId, epoch, ); @@ -70,7 +71,7 @@ class SubmitProofsCommand extends Command { const errorMessage = `Assertion with id: ${assertionId} not found in the triple store.`; this.logger.trace(errorMessage); - await this.handleError(operationId, errorMessage, this.errorType, true); + await this.handleError(operationId, blockchain, errorMessage, this.errorType, true); return Command.empty(); } @@ -84,6 +85,7 @@ class SubmitProofsCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.CALCULATE_PROOFS_END, operationId, + blockchain, agreementId, epoch, ); @@ -91,6 +93,7 @@ class SubmitProofsCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_PROOFS_START, operationId, + blockchain, agreementId, epoch, ); @@ -112,6 +115,7 @@ class SubmitProofsCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_PROOFS_END, operationId, + blockchain, agreementId, epoch, ); @@ -192,6 +196,7 @@ class SubmitProofsCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_PROOFS_END, operationId, + blockchain, agreementId, epoch, ); diff --git a/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-init-command.js b/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-init-command.js index 8dbef0a104..475a9c2b3c 100644 --- a/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-init-command.js +++ b/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-init-command.js @@ -23,6 +23,7 @@ class HandleGetInitCommand extends HandleProtocolMessageCommand { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.GET.ASSERTION_EXISTS_LOCAL_START, ); @@ -64,6 +65,7 @@ class HandleGetInitCommand extends HandleProtocolMessageCommand { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.GET.ASSERTION_EXISTS_LOCAL_END, ); diff --git a/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-request-command.js b/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-request-command.js index 576dbe8a5a..8bf5f5b3a6 100644 --- a/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-request-command.js +++ b/src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-request-command.js @@ -23,6 +23,7 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand { const { operationId, blockchain, contract, tokenId, assertionId, state } = commandData; await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.GET.GET_REMOTE_START, ); @@ -61,6 +62,7 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.GET.GET_REMOTE_END, ); diff --git a/src/commands/protocols/get/sender/get-assertion-id-command.js b/src/commands/protocols/get/sender/get-assertion-id-command.js index cf40c8d681..b4773ce456 100644 --- a/src/commands/protocols/get/sender/get-assertion-id-command.js +++ b/src/commands/protocols/get/sender/get-assertion-id-command.js @@ -23,6 +23,7 @@ class GetAssertionIdCommand extends Command { if (state === ZERO_BYTES32) { await this.handleError( operationId, + blockchain, `The provided state: ${state}. State hash cannot be 0x0.`, this.errorType, ); @@ -47,6 +48,7 @@ class GetAssertionIdCommand extends Command { ) { await this.handleError( operationId, + blockchain, `The provided state: ${state} does not exist on the ${blockchain} blockchain, ``within contract: ${contract}, for the Knowledge Asset with tokenId: ${tokenId}.`, this.errorType, ); @@ -78,8 +80,13 @@ class GetAssertionIdCommand extends Command { return this.continueSequence({ ...command.data, state, assertionId }, command.sequence); } - async handleError(operationId, errorMessage, errorType) { - await this.operationService.markOperationAsFailed(operationId, errorMessage, errorType); + async handleError(operationId, blockchain, errorMessage, errorType) { + await this.operationService.markOperationAsFailed( + operationId, + blockchain, + errorMessage, + errorType, + ); } /** diff --git a/src/commands/protocols/get/sender/local-get-command.js b/src/commands/protocols/get/sender/local-get-command.js index 8d64f8186e..f510115010 100644 --- a/src/commands/protocols/get/sender/local-get-command.js +++ b/src/commands/protocols/get/sender/local-get-command.js @@ -28,6 +28,7 @@ class LocalGetCommand extends Command { const { operationId, blockchain, contract, tokenId, assertionId, state } = command.data; await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.GET.GET_LOCAL_START, ); @@ -90,25 +91,36 @@ class LocalGetCommand extends Command { } if (response?.assertion?.length) { - await this.operationService.markOperationAsCompleted(operationId, response, [ - OPERATION_ID_STATUS.GET.GET_LOCAL_END, - OPERATION_ID_STATUS.GET.GET_END, - OPERATION_ID_STATUS.COMPLETED, - ]); + await this.operationService.markOperationAsCompleted( + operationId, + blockchain, + response, + [ + OPERATION_ID_STATUS.GET.GET_LOCAL_END, + OPERATION_ID_STATUS.GET.GET_END, + OPERATION_ID_STATUS.COMPLETED, + ], + ); return Command.empty(); } await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.GET.GET_LOCAL_END, ); return this.continueSequence(command.data, command.sequence); } - async handleError(operationId, errorMessage, errorType) { - await this.operationService.markOperationAsFailed(operationId, errorMessage, errorType); + async handleError(operationId, blockchain, errorMessage, errorType) { + await this.operationService.markOperationAsFailed( + operationId, + blockchain, + errorMessage, + errorType, + ); } /** diff --git a/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-init-command.js b/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-init-command.js index 36cb8e407c..f699834f3b 100644 --- a/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-init-command.js +++ b/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-init-command.js @@ -16,6 +16,7 @@ class HandleStoreInitCommand extends HandleProtocolMessageCommand { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.VALIDATE_ASSET_REMOTE_START, ); @@ -31,6 +32,7 @@ class HandleStoreInitCommand extends HandleProtocolMessageCommand { this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.VALIDATE_ASSET_REMOTE_END, ); diff --git a/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-request-command.js b/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-request-command.js index 5e82bd6178..c7e7210694 100644 --- a/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-request-command.js +++ b/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-request-command.js @@ -36,6 +36,7 @@ class HandleStoreRequestCommand extends HandleProtocolMessageCommand { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.PUBLISH.VALIDATING_PUBLISH_ASSERTION_REMOTE_START, ); const assertionIds = await this.blockchainModuleManager.getAssertionIds( @@ -49,11 +50,13 @@ class HandleStoreRequestCommand extends HandleProtocolMessageCommand { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.PUBLISH.VALIDATING_PUBLISH_ASSERTION_REMOTE_END, ); await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.PUBLISH.PUBLISH_LOCAL_STORE_START, ); @@ -85,6 +88,7 @@ class HandleStoreRequestCommand extends HandleProtocolMessageCommand { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.PUBLISH.PUBLISH_LOCAL_STORE_END, ); diff --git a/src/commands/protocols/publish/sender/publish-schedule-messages-command.js b/src/commands/protocols/publish/sender/publish-schedule-messages-command.js index f5314aca85..4c4977a09e 100644 --- a/src/commands/protocols/publish/sender/publish-schedule-messages-command.js +++ b/src/commands/protocols/publish/sender/publish-schedule-messages-command.js @@ -102,6 +102,7 @@ class PublishScheduleMessagesCommand extends ProtocolScheduleMessagesCommand { if (validBids < minAckResponses) { await this.operationService.markOperationAsFailed( operationId, + blockchain, 'Unable to start publish, not enough nodes in neighbourhood satisfy the bid.', ERROR_TYPE.PUBLISH.PUBLISH_START_ERROR, ); diff --git a/src/commands/protocols/publish/sender/publish-validate-asset-command.js b/src/commands/protocols/publish/sender/publish-validate-asset-command.js index 4ff4edc453..764624a226 100644 --- a/src/commands/protocols/publish/sender/publish-validate-asset-command.js +++ b/src/commands/protocols/publish/sender/publish-validate-asset-command.js @@ -6,8 +6,13 @@ class PublishValidateAssetCommand extends ValidateAssetCommand { this.operationService = ctx.publishService; } - async handleError(operationId, errorMessage, errorType) { - await this.operationService.markOperationAsFailed(operationId, errorMessage, errorType); + async handleError(operationId, blockchain, errorMessage, errorType) { + await this.operationService.markOperationAsFailed( + operationId, + blockchain, + errorMessage, + errorType, + ); } /** diff --git a/src/commands/protocols/update/receiver/submit-update-commit-command.js b/src/commands/protocols/update/receiver/submit-update-commit-command.js index 7a6cbe098f..93bd576af1 100644 --- a/src/commands/protocols/update/receiver/submit-update-commit-command.js +++ b/src/commands/protocols/update/receiver/submit-update-commit-command.js @@ -46,6 +46,7 @@ class SubmitUpdateCommitCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_UPDATE_COMMIT_START, operationId, + blockchain, agreementId, epoch, ); @@ -67,6 +68,7 @@ class SubmitUpdateCommitCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_UPDATE_COMMIT_END, operationId, + blockchain, agreementId, epoch, ); @@ -136,6 +138,7 @@ class SubmitUpdateCommitCommand extends Command { this.operationIdService.emitChangeEvent( OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_UPDATE_COMMIT_END, operationId, + blockchain, agreementId, epoch, ); diff --git a/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-init-command.js b/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-init-command.js index 9882288b20..f26f862bea 100644 --- a/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-init-command.js +++ b/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-init-command.js @@ -18,6 +18,7 @@ class HandleUpdateInitCommand extends HandleProtocolMessageCommand { commandData; await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.VALIDATE_ASSET_REMOTE_START, ); @@ -42,6 +43,7 @@ class HandleUpdateInitCommand extends HandleProtocolMessageCommand { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.VALIDATE_ASSET_REMOTE_END, ); return validationResult; diff --git a/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-request-command.js b/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-request-command.js index 0429b3c1f3..c02ae88649 100644 --- a/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-request-command.js +++ b/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-request-command.js @@ -39,6 +39,7 @@ class HandleUpdateRequestCommand extends HandleProtocolMessageCommand { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.UPDATE.VALIDATING_UPDATE_ASSERTION_REMOTE_START, ); @@ -112,6 +113,7 @@ class HandleUpdateRequestCommand extends HandleProtocolMessageCommand { await Promise.all(scheduleCommandsPromises); await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.UPDATE.VALIDATING_UPDATE_ASSERTION_REMOTE_END, ); return { messageType: NETWORK_MESSAGE_TYPES.RESPONSES.ACK, messageData: {} }; diff --git a/src/commands/protocols/update/sender/update-validate-asset-command.js b/src/commands/protocols/update/sender/update-validate-asset-command.js index 581f3cf671..867a6729a7 100644 --- a/src/commands/protocols/update/sender/update-validate-asset-command.js +++ b/src/commands/protocols/update/sender/update-validate-asset-command.js @@ -6,8 +6,13 @@ class UpdateValidateAssetCommand extends ValidateAssetCommand { this.operationService = ctx.updateService; } - async handleError(operationId, errorMessage, errorType) { - await this.operationService.markOperationAsFailed(operationId, errorMessage, errorType); + async handleError(operationId, blockchain, errorMessage, errorType) { + await this.operationService.markOperationAsFailed( + operationId, + blockchain, + errorMessage, + errorType, + ); } /** diff --git a/src/commands/query/query-command.js b/src/commands/query/query-command.js index 68860027ec..d75acf8dc0 100644 --- a/src/commands/query/query-command.js +++ b/src/commands/query/query-command.js @@ -27,6 +27,7 @@ class QueryCommand extends Command { await this.operationIdService.updateOperationIdStatus( operationId, + null, OPERATION_ID_STATUS.QUERY.QUERY_START, ); try { @@ -47,6 +48,7 @@ class QueryCommand extends Command { await this.operationIdService.updateOperationIdStatus( operationId, + null, OPERATION_ID_STATUS.QUERY.QUERY_END, ); @@ -54,10 +56,11 @@ class QueryCommand extends Command { await this.operationIdService.updateOperationIdStatus( operationId, + null, OPERATION_ID_STATUS.COMPLETED, ); } catch (e) { - await this.handleError(operationId, e.message, this.errorType, true); + await this.handleError(operationId, null, e.message, this.errorType, true); } return Command.empty(); diff --git a/src/controllers/http-api/v0/get-http-api-controller-v0.js b/src/controllers/http-api/v0/get-http-api-controller-v0.js index f743fb48a6..3114e49955 100644 --- a/src/controllers/http-api/v0/get-http-api-controller-v0.js +++ b/src/controllers/http-api/v0/get-http-api-controller-v0.js @@ -25,6 +25,7 @@ class GetController extends BaseController { await this.operationIdService.updateOperationIdStatus( operationId, + null, OPERATION_ID_STATUS.GET.GET_INIT_START, ); @@ -38,6 +39,9 @@ class GetController extends BaseController { OPERATION_STATUS.IN_PROGRESS, ); + let blockchain; + let contract; + let tokenId; try { const { id } = req.body; @@ -45,7 +49,7 @@ class GetController extends BaseController { throw Error('Requested id is not a UAL.'); } - const { blockchain, contract, tokenId } = this.ualService.resolveUAL(id); + ({ blockchain, contract, tokenId } = this.ualService.resolveUAL(id)); const isValidUal = await this.validationService.validateUal( blockchain, @@ -84,6 +88,7 @@ class GetController extends BaseController { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.GET.GET_INIT_END, ); } catch (error) { @@ -91,6 +96,7 @@ class GetController extends BaseController { await this.operationService.markOperationAsFailed( operationId, + blockchain, 'Unable to get data, Failed to process input data!', ERROR_TYPE.GET.GET_ROUTE_ERROR, ); diff --git a/src/controllers/http-api/v0/local-store-http-api-controller-v0.js b/src/controllers/http-api/v0/local-store-http-api-controller-v0.js index fb94771785..06b6e0385a 100644 --- a/src/controllers/http-api/v0/local-store-http-api-controller-v0.js +++ b/src/controllers/http-api/v0/local-store-http-api-controller-v0.js @@ -20,6 +20,7 @@ class LocalStoreController extends BaseController { await this.operationIdService.updateOperationIdStatus( operationId, + null, OPERATION_ID_STATUS.LOCAL_STORE.LOCAL_STORE_INIT_END, ); diff --git a/src/controllers/http-api/v0/publish-http-api-controller-v0.js b/src/controllers/http-api/v0/publish-http-api-controller-v0.js index 91cce81b6b..dd132f8eac 100644 --- a/src/controllers/http-api/v0/publish-http-api-controller-v0.js +++ b/src/controllers/http-api/v0/publish-http-api-controller-v0.js @@ -17,12 +17,20 @@ class PublishController extends BaseController { } async handleRequest(req, res) { + const { assertion, assertionId, blockchain, contract, tokenId } = req.body; + const hashFunctionId = req.body.hashFunctionId ?? CONTENT_ASSET_HASH_FUNCTION_ID; + + this.logger.info( + `Received asset with assertion id: ${assertionId}, blockchain: ${blockchain}, hub contract: ${contract}, token id: ${tokenId}`, + ); + const operationId = await this.operationIdService.generateOperationId( OPERATION_ID_STATUS.PUBLISH.PUBLISH_START, ); await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.PUBLISH.PUBLISH_INIT_START, ); @@ -32,6 +40,7 @@ class PublishController extends BaseController { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.PUBLISH.PUBLISH_INIT_END, ); await this.repositoryModuleManager.createOperationRecord( @@ -41,13 +50,6 @@ class PublishController extends BaseController { ); try { - const { assertion, assertionId, blockchain, contract, tokenId } = req.body; - const hashFunctionId = req.body.hashFunctionId ?? CONTENT_ASSET_HASH_FUNCTION_ID; - - this.logger.info( - `Received asset with assertion id: ${assertionId}, blockchain: ${blockchain}, hub contract: ${contract}, token id: ${tokenId}`, - ); - await this.operationIdService.cacheOperationIdData(operationId, { public: { assertion, @@ -91,6 +93,7 @@ class PublishController extends BaseController { await this.operationService.markOperationAsFailed( operationId, + blockchain, 'Unable to publish data, Failed to process input data!', ERROR_TYPE.PUBLISH.PUBLISH_ROUTE_ERROR, ); diff --git a/src/controllers/http-api/v0/query-http-api-controller-v0.js b/src/controllers/http-api/v0/query-http-api-controller-v0.js index 0a66186e38..79e2455734 100644 --- a/src/controllers/http-api/v0/query-http-api-controller-v0.js +++ b/src/controllers/http-api/v0/query-http-api-controller-v0.js @@ -22,6 +22,7 @@ class QueryController extends BaseController { await this.operationIdService.updateOperationIdStatus( operationId, + null, OPERATION_ID_STATUS.QUERY.QUERY_INIT_END, ); diff --git a/src/controllers/http-api/v0/update-http-api-controller-v0.js b/src/controllers/http-api/v0/update-http-api-controller-v0.js index 17ecfffcb7..104677a889 100644 --- a/src/controllers/http-api/v0/update-http-api-controller-v0.js +++ b/src/controllers/http-api/v0/update-http-api-controller-v0.js @@ -17,12 +17,20 @@ class UpdateController extends BaseController { } async handleRequest(req, res) { + const { assertion, assertionId, blockchain, contract, tokenId } = req.body; + const hashFunctionId = req.body.hashFunctionId ?? CONTENT_ASSET_HASH_FUNCTION_ID; + + this.logger.info( + `Received asset with assertion id: ${assertionId}, blockchain: ${blockchain}, hub contract: ${contract}, token id: ${tokenId}`, + ); + const operationId = await this.operationIdService.generateOperationId( OPERATION_ID_STATUS.UPDATE.UPDATE_START, ); await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.UPDATE.UPDATE_INIT_START, ); @@ -32,6 +40,7 @@ class UpdateController extends BaseController { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.UPDATE.UPDATE_INIT_END, ); @@ -42,13 +51,6 @@ class UpdateController extends BaseController { ); try { - const { assertion, assertionId, blockchain, contract, tokenId } = req.body; - const hashFunctionId = req.body.hashFunctionId ?? CONTENT_ASSET_HASH_FUNCTION_ID; - - this.logger.info( - `Received asset with assertion id: ${assertionId}, blockchain: ${blockchain}, hub contract: ${contract}, token id: ${tokenId}`, - ); - await this.operationIdService.cacheOperationIdData(operationId, { public: { assertion, @@ -85,6 +87,7 @@ class UpdateController extends BaseController { await this.operationService.markOperationAsFailed( operationId, + blockchain, 'Unable to update data, Failed to process input data!', ERROR_TYPE.UPDATE.UPDATE_ROUTE_ERROR, ); diff --git a/src/migration/migration-executor.js b/src/migration/migration-executor.js index 7d5399dce5..c639c10b47 100644 --- a/src/migration/migration-executor.js +++ b/src/migration/migration-executor.js @@ -28,7 +28,7 @@ class MigrationExecutor { const validationModuleManager = container.resolve('validationModuleManager'); const migration = new PullBlockchainShardingTableMigration( - 'pullShardingTableMigrationV612', + 'pullShardingTableMigrationV613', logger, config, repositoryModuleManager, diff --git a/src/modules/repository/implementation/sequelize/migrations/20231201140100-event-add-blockchain-id.js b/src/modules/repository/implementation/sequelize/migrations/20231201140100-event-add-blockchain-id.js new file mode 100644 index 0000000000..c785da1e05 --- /dev/null +++ b/src/modules/repository/implementation/sequelize/migrations/20231201140100-event-add-blockchain-id.js @@ -0,0 +1,9 @@ +export async function up({ context: { queryInterface, Sequelize } }) { + await queryInterface.addColumn('event', 'blockchain_id', { + type: Sequelize.STRING, + }); +} + +export async function down({ context: { queryInterface } }) { + await queryInterface.removeColumn('event', 'blockchain_id'); +} diff --git a/src/modules/repository/implementation/sequelize/models/event.js b/src/modules/repository/implementation/sequelize/models/event.js index 77de650a78..d4f8b4db45 100644 --- a/src/modules/repository/implementation/sequelize/models/event.js +++ b/src/modules/repository/implementation/sequelize/models/event.js @@ -8,6 +8,7 @@ export default (sequelize, DataTypes) => { autoIncrement: true, }, operationId: DataTypes.UUID, + blockchainId: DataTypes.STRING, name: DataTypes.STRING, timestamp: DataTypes.STRING, value1: DataTypes.TEXT, diff --git a/src/modules/repository/implementation/sequelize/repositories/event-repository.js b/src/modules/repository/implementation/sequelize/repositories/event-repository.js index ba2a618b6f..276f83ce52 100644 --- a/src/modules/repository/implementation/sequelize/repositories/event-repository.js +++ b/src/modules/repository/implementation/sequelize/repositories/event-repository.js @@ -11,9 +11,10 @@ class EventRepository { this.model = models.event; } - async createEventRecord(operationId, name, timestamp, value1, value2, value3) { + async createEventRecord(operationId, blockchainId, name, timestamp, value1, value2, value3) { return this.model.create({ operationId, + blockchainId, name, timestamp, value1, diff --git a/src/modules/repository/repository-module-manager.js b/src/modules/repository/repository-module-manager.js index 66ac6171c0..0a58b7570a 100644 --- a/src/modules/repository/repository-module-manager.js +++ b/src/modules/repository/repository-module-manager.js @@ -206,6 +206,7 @@ class RepositoryModuleManager extends BaseModuleManager { async createEventRecord( operationId, + blockchainId, name, timestamp, value1 = null, @@ -214,6 +215,7 @@ class RepositoryModuleManager extends BaseModuleManager { ) { return this.getRepository('event').createEventRecord( operationId, + blockchainId, name, timestamp, value1, diff --git a/src/service/get-service.js b/src/service/get-service.js index af8ef60b8c..97c26ecc0c 100644 --- a/src/service/get-service.js +++ b/src/service/get-service.js @@ -26,6 +26,7 @@ class GetService extends OperationService { async processResponse(command, responseStatus, responseData) { const { operationId, + blockchain, numberOfFoundNodes, leftoverNodes, keyword, @@ -64,6 +65,7 @@ class GetService extends OperationService { ) { await this.markOperationAsCompleted( operationId, + blockchain, { assertion: responseData.nquads }, this.completedStatuses, ); @@ -80,6 +82,7 @@ class GetService extends OperationService { ); await this.markOperationAsCompleted( operationId, + blockchain, { message: 'Unable to find assertion on the network!', }, diff --git a/src/service/operation-id-service.js b/src/service/operation-id-service.js index 3e714c2a75..8331c067ea 100644 --- a/src/service/operation-id-service.js +++ b/src/service/operation-id-service.js @@ -38,9 +38,11 @@ class OperationIdService { async updateOperationIdStatusWithValues( operationId, + blockchain, status, value1 = null, value2 = null, + value3 = null, timestamp = Date.now(), ) { const response = { @@ -48,12 +50,18 @@ class OperationIdService { timestamp, }; - this.emitChangeEvent(status, operationId, value1, value2, null, timestamp); + this.emitChangeEvent(status, operationId, blockchain, value1, value2, value3, timestamp); await this.repositoryModuleManager.updateOperationIdRecord(response, operationId); } - async updateOperationIdStatus(operationId, status, errorMessage = null, errorType = null) { + async updateOperationIdStatus( + operationId, + blockchain, + status, + errorMessage = null, + errorType = null, + ) { const response = { status, }; @@ -64,7 +72,7 @@ class OperationIdService { await this.removeOperationIdCache(operationId); } - this.emitChangeEvent(status, operationId, errorMessage, errorType); + this.emitChangeEvent(status, operationId, blockchain, errorMessage, errorType); await this.repositoryModuleManager.updateOperationIdRecord(response, operationId); } @@ -72,6 +80,7 @@ class OperationIdService { emitChangeEvent( status, operationId, + blockchainId = null, value1 = null, value2 = null, value3 = null, @@ -82,6 +91,7 @@ class OperationIdService { const eventData = { lastEvent: status, operationId, + blockchainId, timestamp, value1, value2, diff --git a/src/service/operation-service.js b/src/service/operation-service.js index 13f4d64285..c2897d7222 100644 --- a/src/service/operation-service.js +++ b/src/service/operation-service.js @@ -59,7 +59,7 @@ class OperationService { return keywordsStatuses; } - async markOperationAsCompleted(operationId, responseData, endStatuses) { + async markOperationAsCompleted(operationId, blockchain, responseData, endStatuses) { this.logger.info(`Finalizing ${this.operationName} for operationId: ${operationId}`); await this.repositoryModuleManager.updateOperationStatus( @@ -74,11 +74,11 @@ class OperationService { for (const status of endStatuses) { // eslint-disable-next-line no-await-in-loop - await this.operationIdService.updateOperationIdStatus(operationId, status); + await this.operationIdService.updateOperationIdStatus(operationId, blockchain, status); } } - async markOperationAsFailed(operationId, message, errorType) { + async markOperationAsFailed(operationId, blockchain, message, errorType) { this.logger.info(`${this.operationName} for operationId: ${operationId} failed.`); await this.repositoryModuleManager.updateOperationStatus( @@ -89,6 +89,7 @@ class OperationService { await this.operationIdService.updateOperationIdStatus( operationId, + blockchain, OPERATION_ID_STATUS.FAILED, message, errorType, diff --git a/src/service/publish-service.js b/src/service/publish-service.js index 12b16edbf2..197efc4fb5 100644 --- a/src/service/publish-service.js +++ b/src/service/publish-service.js @@ -27,6 +27,7 @@ class PublishService extends OperationService { async processResponse(command, responseStatus, responseData, errorMessage = null) { const { operationId, + blockchain, numberOfFoundNodes, leftoverNodes, keyword, @@ -71,7 +72,12 @@ class PublishService extends OperationService { } } if (allCompleted) { - await this.markOperationAsCompleted(operationId, null, this.completedStatuses); + await this.markOperationAsCompleted( + operationId, + blockchain, + null, + this.completedStatuses, + ); this.logResponsesSummary(completedNumber, failedNumber); this.logger.info( `${this.operationName} with operation id: ${operationId} with status: ${ @@ -86,6 +92,7 @@ class PublishService extends OperationService { if (leftoverNodes.length === 0) { await this.markOperationAsFailed( operationId, + blockchain, 'Not replicated to enough nodes!', this.errorType, ); diff --git a/src/service/update-service.js b/src/service/update-service.js index 758e4de96d..496f71e74d 100644 --- a/src/service/update-service.js +++ b/src/service/update-service.js @@ -27,6 +27,7 @@ class UpdateService extends OperationService { async processResponse(command, responseStatus, responseData, errorMessage = null) { const { operationId, + blockchain, numberOfFoundNodes, leftoverNodes, keyword, @@ -71,7 +72,12 @@ class UpdateService extends OperationService { } } if (allCompleted) { - await this.markOperationAsCompleted(operationId, null, this.completedStatuses); + await this.markOperationAsCompleted( + operationId, + blockchain, + null, + this.completedStatuses, + ); this.logResponsesSummary(completedNumber, failedNumber); this.logger.info( `${this.operationName} with operation id: ${operationId} with status: ${ @@ -86,6 +92,7 @@ class UpdateService extends OperationService { if (leftoverNodes.length === 0) { await this.markOperationAsFailed( operationId, + blockchain, 'Not replicated to enough nodes!', this.errorType, ); diff --git a/test/unit/mock/operation-id-service-mock.js b/test/unit/mock/operation-id-service-mock.js index 75adb55f42..7e7a728857 100644 --- a/test/unit/mock/operation-id-service-mock.js +++ b/test/unit/mock/operation-id-service-mock.js @@ -5,7 +5,13 @@ class OperationIdServiceMock { cacheOperationIdData(operationId, data) {} - async updateOperationIdStatus(operationId, status, errorMessage = null, errorType = null) { + async updateOperationIdStatus( + operationId, + blockchain, + status, + errorMessage = null, + errorType = null, + ) { await this.repositoryModuleManager.updateOperationIdRecord( { status, diff --git a/test/unit/service/get-service.test.js b/test/unit/service/get-service.test.js index d990d457e2..44c6324a3a 100644 --- a/test/unit/service/get-service.test.js +++ b/test/unit/service/get-service.test.js @@ -42,6 +42,7 @@ describe('Get service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [], keyword: 'origintrail', @@ -77,6 +78,7 @@ describe('Get service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [1, 2, 3, 4], keyword: 'origintrail', diff --git a/test/unit/service/publish-service.test.js b/test/unit/service/publish-service.test.js index fad7dc6adf..9fb976320c 100644 --- a/test/unit/service/publish-service.test.js +++ b/test/unit/service/publish-service.test.js @@ -45,6 +45,7 @@ describe('Publish service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [], keyword: 'origintrail', @@ -74,6 +75,7 @@ describe('Publish service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [], keyword: 'origintrail', @@ -100,6 +102,7 @@ describe('Publish service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [], keyword: 'origintrail', @@ -126,6 +129,7 @@ describe('Publish service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [1, 2, 3, 4], keyword: 'origintrail', diff --git a/test/unit/service/update-service.test.js b/test/unit/service/update-service.test.js index 46409a8566..40b8ad8336 100644 --- a/test/unit/service/update-service.test.js +++ b/test/unit/service/update-service.test.js @@ -46,6 +46,7 @@ describe('Update service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [], keyword: 'origintrail', @@ -75,6 +76,7 @@ describe('Update service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [], keyword: 'origintrail', @@ -101,6 +103,7 @@ describe('Update service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [], keyword: 'origintrail', @@ -127,6 +130,7 @@ describe('Update service test', async () => { { data: { operationId: '5195d01a-b437-4aae-b388-a77b9fa715f1', + blockchain: 'hardhat', numberOfFoundNodes: 1, leftoverNodes: [1, 2, 3, 4], keyword: 'origintrail', From c68ab460f2615bf7fceae8578a427adf06bb2298 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar <71610423+u-hubar@users.noreply.github.com> Date: Tue, 5 Dec 2023 14:34:37 +0100 Subject: [PATCH 65/72] Added missing awaits to 'retryFinished' and 'handleError' functions (#2822) * Added missing awaits to 'retryFinished' and 'handleError' functions * Wrapped retryFinished message into Error object * Added latest error message to the log when max retries has been reached for commits/proofs * Added error field to the command, updated retryFinished functions * Fixed command error assigment during retry * Removed error object from command, added error message * Fixed message assignment for commit/proof commands * Fixed 'handleError' call for SendTelemetryCommand * Added check if there was a new finalized state before sending commits/proofs * Change local network setup readme * Add line after paragraph heading * Remove lines * Removed END events emitting for commits/proofs when we don't want command to be executed in order not to count it as successful execution * Only support node v16 * Remove Apache Jena * Add .env setup to main readme * Remove PRIVATE_KEY from env --------- Co-authored-by: Mihajlo Pavlovic Co-authored-by: djordjekovac --- README.md | 73 +++++++++++++------ package-lock.json | 4 +- package.json | 2 +- src/commands/cleaners/cleaner-command.js | 4 +- .../cleaners/operation-id-cleaner-command.js | 4 +- src/commands/command-executor.js | 9 ++- src/commands/command.js | 4 +- src/commands/common/dial-peers-command.js | 4 +- src/commands/common/otnode-update-command.js | 12 +-- src/commands/common/send-telemetry-command.js | 12 +-- .../protocols/common/epoch-check-command.js | 4 +- .../protocols/common/find-nodes-command.js | 2 +- .../common/protocol-message-command.js | 4 +- .../protocols/common/submit-commit-command.js | 56 +++++++++----- .../protocols/common/submit-proofs-command.js | 57 ++++++++++----- .../v1-0-0-handle-store-init-command.js | 2 +- .../receiver/submit-update-commit-command.js | 22 +++--- .../v1-0-0-handle-update-init-command.js | 2 +- tools/local-network-setup/README.md | 52 ++++++------- 19 files changed, 199 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index c4fd787499..97ea3aaf27 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -___ +---
@@ -50,7 +50,7 @@ ___ -___ +---
@@ -60,6 +60,7 @@ ___ ### **What is the Decentralized Knowledge Graph?** +
@@ -69,17 +70,19 @@ ___
OriginTrail Decentralized Knowledge Graph (DKG), hosted on the OriginTrail Decentralized Network (ODN) as trusted knowledge infrastructure, is shared global Knowledge Graph of Knowledge Assets. Running on the basis of the permissionless multi-chain OriginTrail protocol, it combines blockchains and knowledge graph technology to enable trusted AI applications based on key W3C standards. +
### **The OriginTrail DKG Architecture** +
-The OriginTrail tech stack is a three layer structure, consisting of the multi-chain consensus layer (OriginTrail layer 1, running on multiple blockchains), the Decentralized Knowledge Graph layer (OriginTrail Layer 2, hosted on the ODN) and Trusted Knowledge applications in the application layer. +The OriginTrail tech stack is a three layer structure, consisting of the multi-chain consensus layer (OriginTrail layer 1, running on multiple blockchains), the Decentralized Knowledge Graph layer (OriginTrail Layer 2, hosted on the ODN) and Trusted Knowledge applications in the application layer.
DKG Architecture @@ -87,13 +90,15 @@ The OriginTrail tech stack is a three layer structure, consisting of the multi-c Further, the architecture differentiates between **the public, replicated knowledge graph** shared by all network nodes according to the protocol, and **private Knowledge graphs** hosted separately by each of the OriginTrail nodes. -**Anyone can run an OriginTrail node and become part of the ODN, contributing to the network capacity and hosting the OriginTrail DKG. The OriginTrail node is the ultimate data service for data and knowledge intensive Web3 applications and is used as the key backbone for trusted AI applications (see https://chatdkg.ai)** +**Anyone can run an OriginTrail node and become part of the ODN, contributing to the network capacity and hosting the OriginTrail DKG. The OriginTrail node is the ultimate data service for data and knowledge intensive Web3 applications and is used as the key backbone for trusted AI applications (see https://chatdkg.ai)** +
### **What is a Knowledge Asset?** +
@@ -105,14 +110,16 @@ Further, the architecture differentiates between **the public, replicated knowle **Knowledge Asset is the new, AI‑ready resource for the Internet** Knowledge Assets are verifiable containers of structured knowledge that live on the OriginTrail DKG and provide: -- **Discoverability - UAL is the new URL**. Uniform Asset Locators (UALs, based on the W3C Decentralized Identifiers) are a new Web3 knowledge identifier (extensions of the Uniform Resource Locators - URLs) which identify a specific piece of knowledge and make it easy to find and connect with other Knowledge Assets. -- **Ownership - NFTs enable ownership**. Each Knowledge Asset contains an NFT token that enables ownership, knowledge asset administration and market mechanisms. -- **Verifiability - On-chain information origin and verifiable trail**. The blockchain tech increases trust, security, transparency, and the traceability of information. + +- **Discoverability - UAL is the new URL**. Uniform Asset Locators (UALs, based on the W3C Decentralized Identifiers) are a new Web3 knowledge identifier (extensions of the Uniform Resource Locators - URLs) which identify a specific piece of knowledge and make it easy to find and connect with other Knowledge Assets. +- **Ownership - NFTs enable ownership**. Each Knowledge Asset contains an NFT token that enables ownership, knowledge asset administration and market mechanisms. +- **Verifiability - On-chain information origin and verifiable trail**. The blockchain tech increases trust, security, transparency, and the traceability of information. By their nature, Knowledge Assets are semantic resources (following the W3C Semantic Web set of standards), and through their symbolic representations inherently AI ready. See more at https://chatdkg.ai
**Discover Knowledge Assets with the DKG Explorer:** +
@@ -144,7 +151,6 @@ By their nature, Knowledge Assets are semantic resources (following the W3C Sema
-

(back to top)

@@ -152,16 +158,17 @@ By their nature, Knowledge Assets are semantic resources (following the W3C Sema ## 🚀 Getting Started -___ +--- ### Prerequisites
-- **NodeJS** >= 16.0.0 -- **npm** >= 8.0.0 +- **NodeJS** >= 16.0.0 +- **npm** >= 8.0.0 + +--- -___
### Local Network Setup @@ -169,19 +176,36 @@ ___
First, clone the repo: + ```bash git clone https://github.com/OriginTrail/ot-node.git cd ot-node ``` Install dependencies using `npm`: + ```bash npm install ``` +Create the .env file inside the "ot-node" directory: + +```bash +nano .env +``` + +and paste the following content inside (save and close): + +```bash +NODE_ENV=development +RPC_ENDPOINT_BC1=http://localhost:8545 +RPC_ENDPOINT_BC2=http://localhost:9545 +``` + Run the Triple Store. To use default Triple Store (`blazegraph`), download the exec file and run it with the following command in the separate process: + ```bash java -server -Xmx4g -jar blazegraph.jar ``` @@ -189,11 +213,13 @@ java -server -Xmx4g -jar blazegraph.jar Then, depending on the OS, use one of the scripts in order to run the local network with provided number of nodes (minimal amount of nodes should be 12): **MacOS** + ```bash bash ./tools/local-network-setup/setup-macos-environment.sh --nodes=12 ``` -___ +--- +
### DKG Node Setup @@ -202,7 +228,8 @@ ___ In order to run a DKG node on the **Testnet** or **Mainnet**, please read the official documentation: https://docs.origintrail.io/decentralized-knowledge-graph-layer-2/node-setup-instructions/setup-instructions-dockerless -___ +--- +
### Build on DKG @@ -217,13 +244,15 @@ From an architectural standpoint, the SDK libraries are application interfaces i The OriginTrail SDK libraries are being built in various languages by the team and the community, as listed below: -- dkg.js - JavaScript SDK implementation - - [Github repository](https://github.com/OriginTrail/dkg.js) - - [Documentation](https://docs.origintrail.io/decentralized-knowledge-graph-layer-2/dkg-sdk/dkg-v6-js-client) -- dkg.py - Python SDK implementation - - [Github repository](https://github.com/OriginTrail/dkg.py) - - [Documentation](https://docs.origintrail.io/decentralized-knowledge-graph-layer-2/dkg-sdk/dkg-v6-py-client) -___ + +- dkg.js - JavaScript SDK implementation + - [Github repository](https://github.com/OriginTrail/dkg.js) + - [Documentation](https://docs.origintrail.io/decentralized-knowledge-graph-layer-2/dkg-sdk/dkg-v6-js-client) +- dkg.py - Python SDK implementation + - [Github repository](https://github.com/OriginTrail/dkg.py) + - [Documentation](https://docs.origintrail.io/decentralized-knowledge-graph-layer-2/dkg-sdk/dkg-v6-py-client) + +---

(back to top)

@@ -282,4 +311,4 @@ Don't forget to give the project a star! Thanks again! -___ +--- diff --git a/package-lock.json b/package-lock.json index 866582ee23..62c80d8216 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix4", + "version": "6.1.0+hotfix5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0+hotfix4", + "version": "6.1.0+hotfix5", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index b33f4bb124..6702909a8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix4", + "version": "6.1.0+hotfix5", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/commands/cleaners/cleaner-command.js b/src/commands/cleaners/cleaner-command.js index 38dc0685f2..3f78485ddb 100644 --- a/src/commands/cleaners/cleaner-command.js +++ b/src/commands/cleaners/cleaner-command.js @@ -66,8 +66,8 @@ class CleanerCommand extends Command { * @param command * @param error */ - async recover(command, error) { - this.logger.warn(`Failed to clean operational db data: error: ${error.message}`); + async recover(command) { + this.logger.warn(`Failed to clean operational db data: error: ${command.message}`); return Command.repeat(); } } diff --git a/src/commands/cleaners/operation-id-cleaner-command.js b/src/commands/cleaners/operation-id-cleaner-command.js index d1816e7d4c..0d41a8e9bb 100644 --- a/src/commands/cleaners/operation-id-cleaner-command.js +++ b/src/commands/cleaners/operation-id-cleaner-command.js @@ -54,8 +54,8 @@ class OperationIdCleanerCommand extends Command { * @param command * @param error */ - async recover(command, error) { - this.logger.warn(`Failed to clean operation ids table: error: ${error.message}`); + async recover(command) { + this.logger.warn(`Failed to clean operation ids table: error: ${command.message}`); return Command.repeat(); } diff --git a/src/commands/command-executor.js b/src/commands/command-executor.js index 776483f56e..5f2e36f057 100644 --- a/src/commands/command-executor.js +++ b/src/commands/command-executor.js @@ -293,6 +293,7 @@ class CommandExecutor { status: COMMAND_STATUS.PENDING, data: command.data, retries: command.retries - 1, + message: command.message, }); const period = command.period ?? 0; const delay = command.delay ?? 0; @@ -311,7 +312,7 @@ class CommandExecutor { * @return {Promise} * @private */ - async _handleError(command, handler, err) { + async _handleError(command, handler, error) { if (command.retries > 0) { await this._update(command, { retries: command.retries - 1, @@ -323,10 +324,10 @@ class CommandExecutor { try { await this._update(command, { status: COMMAND_STATUS.FAILED, - message: err.message, + message: error.message, }); - this.logger.warn(`Error in command: ${command.name}, error: ${err.message}`); - return await handler.recover(command, err); + this.logger.warn(`Error in command: ${command.name}, error: ${error.message}`); + return await handler.recover(command); } catch (e) { this.logger.warn(`Failed to recover command ${command.name} and ID ${command.id}`); } diff --git a/src/commands/command.js b/src/commands/command.js index c2d3596ba6..5e1f0735f9 100644 --- a/src/commands/command.js +++ b/src/commands/command.js @@ -23,9 +23,9 @@ class Command { * @param command * @param err */ - async recover(command, err) { + async recover(command) { const { operationId, blockchain } = command.data; - await this.handleError(operationId, blockchain, err.message, this.errorType, true); + await this.handleError(operationId, blockchain, command.message, this.errorType, true); return Command.empty(); } diff --git a/src/commands/common/dial-peers-command.js b/src/commands/common/dial-peers-command.js index 41a728f342..61631e0a0d 100644 --- a/src/commands/common/dial-peers-command.js +++ b/src/commands/common/dial-peers-command.js @@ -37,8 +37,8 @@ class DialPeersCommand extends Command { * @param command * @param error */ - async recover(command, error) { - this.logger.warn(`Failed to dial peers: error: ${error.message}`); + async recover(command) { + this.logger.warn(`Failed to dial peers: error: ${command.message}`); return Command.repeat(); } diff --git a/src/commands/common/otnode-update-command.js b/src/commands/common/otnode-update-command.js index 46b391bd71..b5a34c26da 100644 --- a/src/commands/common/otnode-update-command.js +++ b/src/commands/common/otnode-update-command.js @@ -51,20 +51,20 @@ class OtnodeUpdateCommand extends Command { } else { this.logger.info('Your node is running on the latest version!'); } - } catch (e) { - await this.handleError(e); + } catch (error) { + await this.handleError(error.message); } return Command.repeat(); } - async recover(command, err) { - await this.handleError(err); + async recover(command) { + await this.handleError(command.message); return Command.repeat(); } - async handleError(error) { - this.logger.error(`Error in update command: ${error}. ${error.stack}`); + async handleError(errorMessage) { + this.logger.error(`Error in update command: ${errorMessage}`); } /** diff --git a/src/commands/common/send-telemetry-command.js b/src/commands/common/send-telemetry-command.js index 6a9ea0ce09..949e6fb532 100644 --- a/src/commands/common/send-telemetry-command.js +++ b/src/commands/common/send-telemetry-command.js @@ -59,20 +59,20 @@ class SendTelemetryCommand extends Command { if (isDataSuccessfullySent && events?.length > 0) { await this.removePublishedEvents(events); } - } catch (e) { - await this.handleError(e); + } catch (error) { + await this.handleError(error.message); } return Command.repeat(); } - async recover(command, err) { - await this.handleError(err); + async recover(command) { + await this.handleError(command.message); return Command.repeat(); } - async handleError(error) { - this.logger.error(`Error in send telemetry command: ${error}. ${error.stack}`); + async handleError(errorMessage) { + this.logger.error(`Error in send telemetry command: ${errorMessage}`); } /** diff --git a/src/commands/protocols/common/epoch-check-command.js b/src/commands/protocols/common/epoch-check-command.js index ba10b2d825..d8da892f21 100644 --- a/src/commands/protocols/common/epoch-check-command.js +++ b/src/commands/protocols/common/epoch-check-command.js @@ -370,8 +370,8 @@ class EpochCheckCommand extends Command { * @param command * @param error */ - async recover(command, error) { - this.logger.warn(`Failed to execute ${command.name}; Error: ${error.message}`); + async recover(command) { + this.logger.warn(`Failed to execute ${command.name}. Error: ${command.message}`); return Command.repeat(); } diff --git a/src/commands/protocols/common/find-nodes-command.js b/src/commands/protocols/common/find-nodes-command.js index 0ff49fc4ee..bf9e204301 100644 --- a/src/commands/protocols/common/find-nodes-command.js +++ b/src/commands/protocols/common/find-nodes-command.js @@ -46,7 +46,7 @@ class FindNodesCommand extends Command { ); if (closestNodes.length < minAckResponses) { - this.handleError( + await this.handleError( operationId, blockchain, `Unable to find enough nodes for ${operationId}. Minimum number of nodes required: ${minAckResponses}`, diff --git a/src/commands/protocols/common/protocol-message-command.js b/src/commands/protocols/common/protocol-message-command.js index 7e3c2a0424..b0ee5c48b9 100644 --- a/src/commands/protocols/common/protocol-message-command.js +++ b/src/commands/protocols/common/protocol-message-command.js @@ -78,12 +78,12 @@ class ProtocolMessageCommand extends Command { return Command.empty(); } - async recover(command, err) { + async recover(command) { const { node, operationId, keyword } = command.data; const keywordUuid = uuidv5(keyword, uuidv5.URL); this.networkModuleManager.removeCachedSession(operationId, keywordUuid, node.id); - await this.markResponseAsFailed(command, err.message); + await this.markResponseAsFailed(command, command.message); return Command.empty(); } diff --git a/src/commands/protocols/common/submit-commit-command.js b/src/commands/protocols/common/submit-commit-command.js index d2782ad680..124e985231 100644 --- a/src/commands/protocols/common/submit-commit-command.js +++ b/src/commands/protocols/common/submit-commit-command.js @@ -48,6 +48,24 @@ class SubmitCommitCommand extends Command { ); } + const assertionIds = await this.blockchainModuleManager.getAssertionIds( + blockchain, + contract, + tokenId, + ); + + // If update for new state is already finalized (and node haven't processed the event yet), don't send commit for the older state + if (stateIndex < assertionIds.length - 1) { + this.logger.trace( + `Knowledge Asset was updated, not sending Commit for the Service Agreement with the ID: ${agreementId}, ` + + `Blockchain: ${blockchain}, Contract: ${contract}, Token ID: ${tokenId}, ` + + `Keyword: ${keyword}, Hash function ID: ${hashFunctionId}, Epoch: ${epoch}, ` + + `State Index: ${stateIndex}, Operation ID: ${operationId}`, + ); + + return Command.empty(); + } + // this can happen in case node has already submitted update commit const alreadySubmitted = await this.commitAlreadySubmitted( blockchain, @@ -63,14 +81,6 @@ class SubmitCommitCommand extends Command { `State Index: ${stateIndex}, Operation ID: ${operationId}`, ); - this.operationIdService.emitChangeEvent( - OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_COMMIT_END, - operationId, - blockchain, - agreementId, - epoch, - ); - return Command.empty(); } @@ -122,7 +132,10 @@ class SubmitCommitCommand extends Command { newGasPrice = null; } - Object.assign(command.data, { gasPrice: newGasPrice }); + Object.assign(command, { + data: { ...command.data, gasPrice: newGasPrice }, + message: error.message, + }); return Command.retry(); } @@ -130,6 +143,14 @@ class SubmitCommitCommand extends Command { let msgBase; if (txSuccess) { msgBase = 'Successfully executed'; + + this.operationIdService.emitChangeEvent( + OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_COMMIT_END, + operationId, + blockchain, + agreementId, + epoch, + ); } else { msgBase = 'Node has already submitted commit. Finishing'; } @@ -142,14 +163,6 @@ class SubmitCommitCommand extends Command { `Retry number: ${COMMAND_RETRIES.SUBMIT_COMMIT - command.retries + 1}`, ); - this.operationIdService.emitChangeEvent( - OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_COMMIT_END, - operationId, - blockchain, - agreementId, - epoch, - ); - return Command.empty(); } @@ -172,7 +185,14 @@ class SubmitCommitCommand extends Command { } async retryFinished(command) { - this.recover(command, `Max retry count for command: ${command.name} reached!`); + const { blockchain, operationId } = command.data; + await this.handleError( + operationId, + blockchain, + `Max retries has been reached! Latest Error Message: ${command.message}`, + this.errorType, + true, + ); } /** diff --git a/src/commands/protocols/common/submit-proofs-command.js b/src/commands/protocols/common/submit-proofs-command.js index 27467c1cf9..462d51fb27 100644 --- a/src/commands/protocols/common/submit-proofs-command.js +++ b/src/commands/protocols/common/submit-proofs-command.js @@ -98,6 +98,25 @@ class SubmitProofsCommand extends Command { epoch, ); } + + const assertionIds = await this.blockchainModuleManager.getAssertionIds( + blockchain, + contract, + tokenId, + ); + + // If update for new state is already finalized (and node haven't processed the event yet), don't send commit for the older state + if (stateIndex < assertionIds.length - 1) { + this.logger.trace( + `Knowledge Asset was updated, not sending Proof for the Service Agreement with the ID: ${agreementId}, ` + + `Blockchain: ${blockchain}, Contract: ${contract}, Token ID: ${tokenId}, ` + + `Keyword: ${keyword}, Hash function ID: ${hashFunctionId}, Epoch: ${epoch}, ` + + `State Index: ${stateIndex}, Operation ID: ${operationId}`, + ); + + return Command.empty(); + } + const alreadySubmitted = await this.proofAlreadySubmitted( blockchain, agreementId, @@ -112,14 +131,6 @@ class SubmitProofsCommand extends Command { `State Index: ${stateIndex}, Operation ID: ${operationId}`, ); - this.operationIdService.emitChangeEvent( - OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_PROOFS_END, - operationId, - blockchain, - agreementId, - epoch, - ); - return Command.empty(); } @@ -173,7 +184,10 @@ class SubmitProofsCommand extends Command { newGasPrice = null; } - Object.assign(command.data, { gasPrice: newGasPrice }); + Object.assign(command, { + data: { ...command.data, gasPrice: newGasPrice }, + message: error.message, + }); return Command.retry(); } @@ -181,6 +195,14 @@ class SubmitProofsCommand extends Command { let msgBase; if (txSuccess) { msgBase = 'Successfully executed'; + + this.operationIdService.emitChangeEvent( + OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_PROOFS_END, + operationId, + blockchain, + agreementId, + epoch, + ); } else { msgBase = 'Node has already sent proof. Finishing'; } @@ -193,14 +215,6 @@ class SubmitProofsCommand extends Command { `Retry number: ${COMMAND_RETRIES.SUBMIT_PROOFS - command.retries + 1}`, ); - this.operationIdService.emitChangeEvent( - OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_PROOFS_END, - operationId, - blockchain, - agreementId, - epoch, - ); - return Command.empty(); } @@ -223,7 +237,14 @@ class SubmitProofsCommand extends Command { } async retryFinished(command) { - this.recover(command, `Max retry count for command: ${command.name} reached!`); + const { blockchain, operationId } = command.data; + await this.handleError( + operationId, + blockchain, + `Max retries has been reached! Latest Error Message: ${command.message}`, + this.errorType, + true, + ); } /** diff --git a/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-init-command.js b/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-init-command.js index f699834f3b..d9c529ffe8 100644 --- a/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-init-command.js +++ b/src/commands/protocols/publish/receiver/v1.0.0/v1-0-0-handle-store-init-command.js @@ -41,7 +41,7 @@ class HandleStoreInitCommand extends HandleProtocolMessageCommand { async retryFinished(command) { const { operationId } = command.data; - this.handleError( + await this.handleError( `Retry count for command: ${command.name} reached! Unable to validate data for operation id: ${operationId}`, command, ); diff --git a/src/commands/protocols/update/receiver/submit-update-commit-command.js b/src/commands/protocols/update/receiver/submit-update-commit-command.js index 93bd576af1..e253372f87 100644 --- a/src/commands/protocols/update/receiver/submit-update-commit-command.js +++ b/src/commands/protocols/update/receiver/submit-update-commit-command.js @@ -65,14 +65,6 @@ class SubmitUpdateCommitCommand extends Command { `Epoch: ${epoch}, Operation ID: ${operationId}`, ); - this.operationIdService.emitChangeEvent( - OPERATION_ID_STATUS.COMMIT_PROOF.SUBMIT_UPDATE_COMMIT_END, - operationId, - blockchain, - agreementId, - epoch, - ); - return Command.empty(); } @@ -121,7 +113,10 @@ class SubmitUpdateCommitCommand extends Command { newGasPrice = null; } - Object.assign(command.data, { gasPrice: newGasPrice }); + Object.assign(command, { + data: { ...command.data, gasPrice: newGasPrice }, + message: error.message, + }); return Command.retry(); } @@ -152,7 +147,14 @@ class SubmitUpdateCommitCommand extends Command { } async retryFinished(command) { - this.recover(command, `Max retry count for command: ${command.name} reached!`); + const { blockchain, operationId } = command.data; + await this.handleError( + operationId, + blockchain, + `Max retries has been reached! Latest Error Message: ${command.message}`, + this.errorType, + true, + ); } /** diff --git a/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-init-command.js b/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-init-command.js index f26f862bea..ca0c1720ab 100644 --- a/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-init-command.js +++ b/src/commands/protocols/update/receiver/v1.0.0/v1-0-0-handle-update-init-command.js @@ -63,7 +63,7 @@ class HandleUpdateInitCommand extends HandleProtocolMessageCommand { async retryFinished(command) { const { operationId } = command.data; - this.handleError( + await this.handleError( `Retry count for command: ${command.name} reached! Unable to validate data for operation id: ${operationId}`, command, ); diff --git a/tools/local-network-setup/README.md b/tools/local-network-setup/README.md index 26cbf046e9..3280d62671 100644 --- a/tools/local-network-setup/README.md +++ b/tools/local-network-setup/README.md @@ -1,21 +1,16 @@ -DKG local network setup tool -======================== +# DKG local network setup tool -This tool will help you set up a local DKG v6 network running with the Ganache blockchain. It is useful for development and testing purposes and is used internally by the OriginTrail core developers. +This tool will help you set up a local DKG v6 network running with the Hardhat blockchain. It is useful for development and testing purposes and is used internally by the OriginTrail core developers.
- **Note: This tool is an internal tool used by the OriginTrail team and thus is developed for our workflow, meaning that it currently only supports MacOS**, but we encourage you to adapt it for your workflow as well. +# Prerequisites -Prerequisites -============= - -* An installed and running triplestore (graph database) - * We recommend testing with GraphDB. In order to download GraphDB, please visit their official [website](https://graphdb.ontotext.com/). Alternatively other triple stores can be used (Blazegraph, Apache Jena and other RDF native graph databases) -* An installed and running MySQL server -* You should have installed npm and Node.js (v16) or higher - +- An installed and running triplestore (graph database) + - We recommend testing with Blazegraph. In order to download Blazegraph, please visit their official [website](https://blazegraph.com/). Alternatively other triple stores can be used (GraphBD or and other RDF native graph databases) +- An installed and running MySQL server +- You should have installed npm and Node.js (v16) # Setup instructions @@ -23,56 +18,58 @@ In order to run the local network you fist need to clone the "ot-node" repositor
## 1. CLONE OT-NODE REPOSITORY & INSTALL DEPENDENCIES + After cloning the **ot-node** repository, please checkout to "v6/develop" branch and install dependencies by running: + ```bash git clone https://github.com/OriginTrail/ot-node.git && cd ot-node/ && npm install && cd .. ``` +
### 2.2 Create the .env file inside the "ot-node" directory: + ```bash nano .env ``` + and paste the following content inside (save and close): + ```bash NODE_ENV=development RPC_ENDPOINT_BC1=http://localhost:8545 RPC_ENDPOINT_BC2=http://localhost:9545 -PRIVATE_KEY=02b39cac1532bef9dba3e36ec32d3de1e9a88f1dda597d3ac6e2130aed9adc4e ``` -**Note:** The private key above is used ONLY for convenience and SHOULD be changed to a secure key when used in production. If you are connecting to rinkeby testnet network you need to provide valid RPC_ENDPOINT + +**Note:** The private key above is used ONLY for convenience and SHOULD be changed to a secure key when used in production.
## 3. START THE LOCAL NETWORK ## Specifying the number of nodes -You can specify to run anywhere between one and ten nodes with the `--nodes` parameter. -**Note:** All nodes assume MySQL username root and no password. To change the MySQL login information update the .dh_origintrail_noderc template file sequelize-repository config object with your username and password
+You can specify to run anywhere between one and twenty nodes with the `--nodes` parameter. + +**Note:** All nodes assume MySQL username root and no password. To change the MySQL login information update the .origintrail_noderc template file sequelize-repository config object with your username and password
The first node will be named `bootstrap`, while subsequent nodes will be named `dh1, dh2, ...`.
```bash bash ./tools/local-network-setup/setup-macos-environment.sh --nodes=6 ``` -**Note:** With the above command, we will start ganache instance, deploy contracts, deploy a 6 nodes network (1 bootstrap and 5 subsequent nodes)
+ +**Note:** With the above command, we will start two hardhat instances, deploy contracts, deploy a 6 nodes network (1 bootstrap and 5 subsequent nodes)
## Specifying the blockchain network + You can specify the blockchain network you want to connect to with `--network` parameter. Available networks: -- ganache - default network -- rinkeby - ETH testnet network -```bash -bash ./tools/local-network-setup/setup-macos-environment.sh --network=rinkeby -``` -**Note:** In order to run on rinkeby network you must provide Rinkeby ETH Testnet tokens to the wallets. Minimum of 3 Rinkeby ETH tokens is required for contract deployment. Wallet used for contracts deployment is the one you defined in .env file. Additionally, you need to send minimum of 1 Rinkeby ETH token to the wallets specified in file: ./tools/local-network-setup/keys.json. -
-Contribution -============ +- hardhat - default network -OriginTrail is an open source project. We happily invite you to join us in our mission of building decentralized knowledge graph - we're excited for your contributions! Join us in discord to meet the dev community +# Contribution +OriginTrail is an open source project. We happily invite you to join us in our mission of building decentralized knowledge graph - we're excited for your contributions! Join us in discord to meet the dev community ### Useful links @@ -85,4 +82,3 @@ OriginTrail is an open source project. We happily invite you to join us in our m [OriginTrail Telegram Group](https://t.me/origintrail) [OriginTrail Twitter](https://twitter.com/origin_trail) - From f35aafb57a32f950aea7fa5f1aa09ea0c9ad6713 Mon Sep 17 00:00:00 2001 From: djordjekovac Date: Wed, 6 Dec 2023 12:43:56 +0100 Subject: [PATCH 66/72] Added masking of RPC url, fixed bug with blockfetching for chiado (#2828) --- package-lock.json | 4 ++-- package.json | 2 +- .../blockchain/implementation/web3-service.js | 19 +++++++++++++++---- .../20233011121700-remove-blockchain-info.js | 10 ++++++++++ .../blockchain-event-listener-service.js | 2 +- 5 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 src/modules/repository/implementation/sequelize/migrations/20233011121700-remove-blockchain-info.js diff --git a/package-lock.json b/package-lock.json index 62c80d8216..aa896dff36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix5", + "version": "6.1.0+hotfix6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0+hotfix5", + "version": "6.1.0+hotfix6", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index 6702909a8e..ed32cc903f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix5", + "version": "6.1.0+hotfix6", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/modules/blockchain/implementation/web3-service.js b/src/modules/blockchain/implementation/web3-service.js index dd0472aee6..4e41f9b2cd 100644 --- a/src/modules/blockchain/implementation/web3-service.js +++ b/src/modules/blockchain/implementation/web3-service.js @@ -114,9 +114,13 @@ class Web3Service { stallTimeout: RPC_PROVIDER_STALL_TIMEOUT, }); - this.logger.debug(`Connected to the blockchain RPC: ${rpcEndpoint}.`); + this.logger.debug( + `Connected to the blockchain RPC: ${this.maskRpcUrl(rpcEndpoint)}.`, + ); } catch (e) { - this.logger.warn(`Unable to connect to the blockchain RPC: ${rpcEndpoint}.`); + this.logger.warn( + `Unable to connect to the blockchain RPC: ${this.maskRpcUrl(rpcEndpoint)}.`, + ); } } @@ -214,7 +218,7 @@ class Web3Service { ); this.logger.debug( `${functionName}(${inputs}) ${method} has failed; Error: ${decodedErrorData}; ` + - `RPC: ${info.backend.provider.connection.url}.`, + `RPC: ${this.maskRpcUrl(info.backend.provider.connection.url)}.`, ); } else if (info.backend.result !== undefined) { let message = `${functionName}(${inputs}) ${method} has been successfully executed; `; @@ -234,7 +238,7 @@ class Web3Service { } } - message += `RPC: ${info.backend.provider.connection.url}.`; + message += `RPC: ${this.maskRpcUrl(info.backend.provider.connection.url)}.`; this.logger.debug(message); } @@ -242,6 +246,13 @@ class Web3Service { }); } + maskRpcUrl(url) { + if (url.includes('apiKey')) { + return url.split('apiKey')[0]; + } + return url; + } + initializeAssetStorageContract(assetStorageAddress) { this.assetStorageContracts[assetStorageAddress.toLowerCase()] = new ethers.Contract( assetStorageAddress, diff --git a/src/modules/repository/implementation/sequelize/migrations/20233011121700-remove-blockchain-info.js b/src/modules/repository/implementation/sequelize/migrations/20233011121700-remove-blockchain-info.js new file mode 100644 index 0000000000..f1128be5fd --- /dev/null +++ b/src/modules/repository/implementation/sequelize/migrations/20233011121700-remove-blockchain-info.js @@ -0,0 +1,10 @@ +const chiadoBlockchainId = 'gnosis:10200'; + +export async function up({ context: { queryInterface } }) { + await queryInterface.sequelize.query(` + delete from blockchain where blockchain_id='${chiadoBlockchainId}' + `); +} + +// eslint-disable-next-line no-empty-function +export async function down() {} diff --git a/src/service/blockchain-event-listener-service.js b/src/service/blockchain-event-listener-service.js index ea8f9611e4..6e3f2a9d84 100644 --- a/src/service/blockchain-event-listener-service.js +++ b/src/service/blockchain-event-listener-service.js @@ -47,7 +47,7 @@ class BlockchainEventListenerService { process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT || process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST; - const currentBlock = await this.blockchainModuleManager.getBlockNumber(); + const currentBlock = await this.blockchainModuleManager.getBlockNumber(blockchainId); const syncContractEventsPromises = [ this.getContractEvents( blockchainId, From 387927f24affc38c707ddaf637ef208ea700258a Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Wed, 6 Dec 2023 14:37:52 +0100 Subject: [PATCH 67/72] Version update --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index aa896dff36..96ed40c12e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix6", + "version": "6.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0+hotfix6", + "version": "6.1.0", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index ed32cc903f..04b8a57868 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix6", + "version": "6.1.0", "description": "OTNode V6", "main": "index.js", "type": "module", From fda2a6f7067170628863474e8b59b6af4da2799d Mon Sep 17 00:00:00 2001 From: djordjekovac Date: Wed, 13 Dec 2023 12:28:08 +0100 Subject: [PATCH 68/72] Updated ual extension migration (#2833) * Updated ual extension migration, update insert and reactin on state finalized event * Fix queries * Updated query for migration * Fixed insert new triple query * Removed old migrations, updated broken query * Version updated --------- Co-authored-by: Mihajlo Pavlovic --- ot-node.js | 45 ---- package-lock.json | 4 +- package.json | 2 +- .../ual-extension-triple-store-migration.js | 203 ++++-------------- src/service/triple-store-service.js | 25 ++- src/service/ual-service.js | 9 + 6 files changed, 73 insertions(+), 215 deletions(-) diff --git a/ot-node.js b/ot-node.js index 3595e5495d..e2e59b0224 100644 --- a/ot-node.js +++ b/ot-node.js @@ -28,14 +28,6 @@ class OTNode { await this.checkForUpdate(); await this.removeUpdateFile(); - await MigrationExecutor.executeTripleStoreUserConfigurationMigration( - this.logger, - this.config, - ); - await MigrationExecutor.executeTelemetryModuleUserConfigurationMigration( - this.logger, - this.config, - ); await MigrationExecutor.executeUalExtensionUserConfigurationMigration( this.logger, this.config, @@ -57,43 +49,6 @@ class OTNode { await this.initializeModules(); - await MigrationExecutor.executePullShardingTableMigration( - this.container, - this.logger, - this.config, - ); - await MigrationExecutor.executePrivateAssetsMetadataMigration( - this.container, - this.logger, - this.config, - ); - await MigrationExecutor.executeRemoveAgreementStartEndTimeMigration( - this.container, - this.logger, - this.config, - ); - await MigrationExecutor.executeMarkOldBlockchainEventsAsProcessedMigration( - this.container, - this.logger, - this.config, - ); - await MigrationExecutor.executeTripleStoreMetadataMigration( - this.container, - this.logger, - this.config, - ); - await MigrationExecutor.executeServiceAgreementsMetadataMigration( - this.container, - this.logger, - this.config, - ); - await MigrationExecutor.executeRemoveOldEpochCommandsMigration( - this.container, - this.logger, - this.config, - ); - await MigrationExecutor.executePendingStorageMigration(this.logger, this.config); - await this.createProfiles(); await this.initializeCommandExecutor(); diff --git a/package-lock.json b/package-lock.json index 96ed40c12e..ab6d56fcda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix1", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index 04b8a57868..c4cbb948af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix1", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 32821b6973..93b1eb43c7 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -1,3 +1,4 @@ +/* eslint-disable no-await-in-loop */ import BaseMigration from './base-migration.js'; import { TRIPLE_STORE_REPOSITORIES } from '../constants/constants.js'; @@ -22,181 +23,53 @@ class UalExtensionTripleStoreMigration extends BaseMigration { const chunkSize = 10000; - const totalSubjectsQuery = ` - SELECT (COUNT(*) AS ?totalObjects) - WHERE { - GRAPH { - ?s ?p ?o . - FILTER (STRSTARTS(STR(?s), "did:dkg:${oldBlockchainId}/")) - } - }`; - - const totalObjectsQuery = ` - SELECT (COUNT(*) AS ?totalObjects) - WHERE { - ?s ?p ?o . - FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "${oldBlockchainId}")) - } - - `; - const updateSubjectQuery = ` - WITH - DELETE { - ?s ?p ?o - } - INSERT { - ?newSubject ?p ?o - } - WHERE { - { - SELECT ?s ?p ?o (IRI(REPLACE(STR(?s), "${oldBlockchainId}", "${newBlockchainId}")) AS ?newSubject) - WHERE { - ?s ?p ?o . - FILTER (STRSTARTS(STR(?s), "did:dkg:${oldBlockchainId}/")) - } - LIMIT ${chunkSize} - } - } - `; - const updateObjectQuery = ` - WITH - DELETE { - ?s ?p ?o - } - INSERT { - ?s ?p "${newBlockchainId}" . - } - WHERE { - SELECT ?s ?p ?o - WHERE { - ?s ?p ?o . - FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "${oldBlockchainId}")) - } - LIMIT ${chunkSize} - } - `; for (const repository in TRIPLE_STORE_REPOSITORIES) { - // eslint-disable-next-line no-await-in-loop - const totalSubjectsResult = await this.tripleStoreService.select( + const getUalListQuery = ` + PREFIX schema: + SELECT DISTINCT ?subject ?object + WHERE { + ?subject schema:assertion ?object . + }`; + + const ualList = await this.tripleStoreService.select( TRIPLE_STORE_REPOSITORIES[repository], - totalSubjectsQuery, - ); - const totalSubjects = parseInt( - totalSubjectsResult[0].totalObjects.match( - /"(\d+)"\^\^http:\/\/www.w3.org\/2001\/XMLSchema#integer/, - )[1], - 10, + getUalListQuery, ); - this.logger.debug( - `Total number of triple store subjects that will be updated: ${totalSubjects} in repositroy: ${repository}.`, + + this.logger.info( + `Ual extension triple store migration: found ${ualList.length} distinct UALs in ${repository}`, ); - let offsetSubject = 0; - if (totalSubjects !== 0) { - do { - // eslint-disable-next-line no-await-in-loop - await this.tripleStoreService.queryVoid( - TRIPLE_STORE_REPOSITORIES[repository], - updateSubjectQuery, - ); - offsetSubject += chunkSize; - this.logger.debug( - `Number of subjects updated: ${offsetSubject} in repository ${repository}`, - ); - } while (offsetSubject < totalSubjects); - this.logger.debug( - `Finalised triple store subject update in repository: ${repository}.`, - ); + const newTriples = []; + for (const { subject: ual, object: assertionId } of ualList) { + let newUal; + if (ual.includes(newBlockchainId)) { + newUal = ual.replace(newBlockchainId, oldBlockchainId); + } else { + newUal = ual.replace(oldBlockchainId, newBlockchainId); + } + newTriples.push(`<${newUal}> schema:assertion <${assertionId}>`); } - // eslint-disable-next-line no-await-in-loop - const totalObjectsResult = await this.tripleStoreService.select( - TRIPLE_STORE_REPOSITORIES[repository], - totalObjectsQuery, - ); - const totalObjects = parseInt( - totalObjectsResult[0].totalObjects.match( - /"(\d+)"\^\^http:\/\/www.w3.org\/2001\/XMLSchema#integer/, - )[1], - 10, - ); - let offsetObject = 0; - this.logger.debug( - `Total number of triple store object that will be updated: ${totalObjects} in repositroy: ${repository}.`, - ); - if (totalObjects !== 0) { - do { - // eslint-disable-next-line no-await-in-loop - await this.tripleStoreService.queryVoid( - TRIPLE_STORE_REPOSITORIES[repository], - updateObjectQuery, - ); - offsetObject += chunkSize; - this.logger.debug( - `Number of objects updated: ${offsetObject} in repository ${repository}`, - ); - } while (offsetObject < totalObjects); - this.logger.debug( - `Finalised triple store object update in repository: ${repository}.`, + while (newTriples.length) { + const triplesForInsert = newTriples.splice(0, chunkSize); + const insertQuery = ` + PREFIX schema: + INSERT DATA { + GRAPH { + ${triplesForInsert.join(' .\n')} + } + }`; + await this.tripleStoreService.queryVoid( + TRIPLE_STORE_REPOSITORIES[repository], + insertQuery, + ); + this.logger.info( + `Inserted ${triplesForInsert.length} triples, left for insert: ${newTriples.length} repository: ${repository}`, ); } + this.logger.info(`Finished processing of UALs in repository: ${repository}`); } - // for (const repository in TRIPLE_STORE_REPOSITORIES) { - // const countOldSujbectQuerry = `SELECT (COUNT(*) AS ?count) - // WHERE { - // ?s ?p ?o . - // FILTER (STRSTARTS(STR(?s), "did:dkg:otp/")) - // }`; - // // eslint-disable-next-line no-await-in-loop - // const countOldSujbectResult = await this.tripleStoreModuleManager.select( - // this.repositoryImplementations[repository], - // TRIPLE_STORE_REPOSITORIES[repository], - // countOldSujbectQuerry, - // ); - // const countNewSujbectQuerry = `SELECT (COUNT(*) AS ?count) - // WHERE { - // ?s ?p ?o . - // FILTER (STRSTARTS(STR(?s), "did:dkg:otp:2160/")) - // }`; - // // eslint-disable-next-line no-await-in-loop - // const countNewSujbectQuerryResult = await this.tripleStoreModuleManager.select( - // this.repositoryImplementations[repository], - // TRIPLE_STORE_REPOSITORIES[repository], - // countNewSujbectQuerry, - // ); - // - // const countOldObjectsQuery = `SELECT (COUNT(*) AS ?count) - // WHERE { - // ?s ?p ?o . - // FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "otp")) - // }`; - // // eslint-disable-next-line no-await-in-loop - // const countOldObjectsQueryResult = await this.tripleStoreModuleManager.select( - // this.repositoryImplementations[repository], - // TRIPLE_STORE_REPOSITORIES[repository], - // countOldObjectsQuery, - // ); - // const countNewObjectQuery = `SELECT (COUNT(*) AS ?count) - // WHERE { - // ?s ?p ?o . - // FILTER(STRENDS(STR(?p), "blockchain") && STRENDS(STR(?o), "otp:2160")) - // }`; - // // eslint-disable-next-line no-await-in-loop - // const countNewObjectQueryResult = await this.tripleStoreModuleManager.select( - // this.repositoryImplementations[repository], - // TRIPLE_STORE_REPOSITORIES[repository], - // countNewObjectQuery, - // ); - // this.logger.debug( - // `Report for UAL extentsion triple store migragrion on repository: ${repository}. Old subject count: ${JSON.stringify( - // countOldSujbectResult, - // )}. New subject count: ${JSON.stringify( - // countNewSujbectQuerryResult, - // )}. Old object count: ${JSON.stringify( - // countOldObjectsQueryResult, - // )}. New object count: ${JSON.stringify(countNewObjectQueryResult)}.`, - // ); - // } } getOldBlockchainId() { diff --git a/src/service/triple-store-service.js b/src/service/triple-store-service.js index 92a2799dc3..085acb8f19 100644 --- a/src/service/triple-store-service.js +++ b/src/service/triple-store-service.js @@ -47,12 +47,23 @@ class TripleStoreService { keyword, }); + const oldUalConnection = await formatAssertion({ + '@context': SCHEMA_CONTEXT, + '@id': this.ualService.getUalWithoutChainId(ual, blockchain), + assertion: { '@id': `assertion:${assertionId}` }, + }); + await Promise.all([ this.tripleStoreModuleManager.insertAssetAssertionMetadata( this.repositoryImplementations[repository], repository, currentAssetNquads.join('\n'), ), + this.tripleStoreModuleManager.insertAssetAssertionMetadata( + this.repositoryImplementations[repository], + repository, + oldUalConnection.join('\n'), + ), this.tripleStoreModuleManager.insertAssertion( this.repositoryImplementations[repository], repository, @@ -179,6 +190,11 @@ class TripleStoreService { repository, ual, ); + await this.tripleStoreModuleManager.deleteAssetMetadata( + this.repositoryImplementations[repository], + repository, + this.ualService.getUalWithoutChainId(ual, blockchain), + ); // Delete assertions that were linked only to this Knowledge Asset for (const linkedAssertionId of linkedAssertionIds) { @@ -212,8 +228,13 @@ class TripleStoreService { repository, assertionId, ); - - return this.dataService.parseBindings(bindings); + const count = this.dataService.parseBindings(bindings); + if (count > 1) { + // since 6.1.0 in asset metadata we are storing two triples connected to assertion id + // using 2 formats of ual - so we can expect that this query returns 2 triples per asset + return Math.round(count / 2); + } + return count; } async getAssertion(repository, assertionId) { diff --git a/src/service/ual-service.js b/src/service/ual-service.js index b6e4cd10db..f3f2b35266 100644 --- a/src/service/ual-service.js +++ b/src/service/ual-service.js @@ -100,6 +100,15 @@ class UALService { [contract, firstAssertionId], ); } + + getUalWithoutChainId(ual, blockchain) { + const blockchainParts = blockchain.split(':'); + + if (ual.includes(blockchain)) { + return ual.replace(blockchain, blockchainParts[0]); + } + return ual; + } } export default UALService; From a9bcb7529045f4688e39afa0b51aaa96acf810cd Mon Sep 17 00:00:00 2001 From: djordjekovac Date: Wed, 13 Dec 2023 16:15:54 +0100 Subject: [PATCH 69/72] Updated handling of already processed uals, resolved issue with blank nodes in triple store (#2836) --- package-lock.json | 4 ++-- package.json | 2 +- .../ual-extension-triple-store-migration.js | 16 ++++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index ab6d56fcda..96ed40c12e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix1", + "version": "6.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0+hotfix1", + "version": "6.1.0", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index c4cbb948af..04b8a57868 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix1", + "version": "6.1.0", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 93b1eb43c7..5c17eb2c6d 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -42,13 +42,17 @@ class UalExtensionTripleStoreMigration extends BaseMigration { const newTriples = []; for (const { subject: ual, object: assertionId } of ualList) { - let newUal; - if (ual.includes(newBlockchainId)) { - newUal = ual.replace(newBlockchainId, oldBlockchainId); - } else { - newUal = ual.replace(oldBlockchainId, newBlockchainId); + if (assertionId.startsWith('assertion:')) { + let newUal; + if (ual.includes(newBlockchainId)) { + newUal = ual.replace(newBlockchainId, oldBlockchainId); + } else { + newUal = ual.replace(oldBlockchainId, newBlockchainId); + } + if (!ualList.some((element) => element.subject === newUal)) { + newTriples.push(`<${newUal}> schema:assertion <${assertionId}>`); + } } - newTriples.push(`<${newUal}> schema:assertion <${assertionId}>`); } while (newTriples.length) { From 4fc3542ecf506e6d715fa3480f9f48eb5a9c152d Mon Sep 17 00:00:00 2001 From: Djordje Kovacevic Date: Wed, 13 Dec 2023 16:42:33 +0100 Subject: [PATCH 70/72] Migration updated --- package-lock.json | 4 ++-- package.json | 2 +- src/migration/ual-extension-triple-store-migration.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 96ed40c12e..41cb17e537 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix2", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index 04b8a57868..ba07d53327 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0", + "version": "6.1.0+hotfix2", "description": "OTNode V6", "main": "index.js", "type": "module", diff --git a/src/migration/ual-extension-triple-store-migration.js b/src/migration/ual-extension-triple-store-migration.js index 5c17eb2c6d..4709c6133b 100644 --- a/src/migration/ual-extension-triple-store-migration.js +++ b/src/migration/ual-extension-triple-store-migration.js @@ -39,7 +39,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { this.logger.info( `Ual extension triple store migration: found ${ualList.length} distinct UALs in ${repository}`, ); - + const subjectsSet = new Set(ualList.map((item) => item.subject)); const newTriples = []; for (const { subject: ual, object: assertionId } of ualList) { if (assertionId.startsWith('assertion:')) { @@ -49,7 +49,7 @@ class UalExtensionTripleStoreMigration extends BaseMigration { } else { newUal = ual.replace(oldBlockchainId, newBlockchainId); } - if (!ualList.some((element) => element.subject === newUal)) { + if (!subjectsSet.has(newUal)) { newTriples.push(`<${newUal}> schema:assertion <${assertionId}>`); } } From c7a0136a34cd0d2f85262071ac50c2743b541c77 Mon Sep 17 00:00:00 2001 From: Mihajlo Pavlovic Date: Wed, 20 Dec 2023 09:40:36 +0100 Subject: [PATCH 71/72] Add Gnsosi hub contract (#2839) --- config/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.json b/config/config.json index a7e8345980..fed029d00b 100644 --- a/config/config.json +++ b/config/config.json @@ -743,7 +743,7 @@ "enabled": false, "package": "./blockchain/implementation/gnosis/gnosis-service.js", "config": { - "hubContractAddress": "", + "hubContractAddress": "0xbEF14fc04F870c2dD65c13Df4faB6ba01A9c746b", "gasPriceOracleLink": "https://api.gnosisscan.io/api?module=proxy&action=eth_gasPrice", "rpcEndpoints": ["https://rpc.gnosischain.com/"] } From 4bdd1c09cb5f17bcb2fb8ee9667452bbabda82b5 Mon Sep 17 00:00:00 2001 From: djordjekovac Date: Wed, 20 Dec 2023 09:41:17 +0100 Subject: [PATCH 72/72] Version updated (#2840) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 41cb17e537..96ed40c12e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix2", + "version": "6.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "origintrail_node", - "version": "6.1.0+hotfix2", + "version": "6.1.0", "license": "ISC", "dependencies": { "@comunica/query-sparql": "^2.4.3", diff --git a/package.json b/package.json index ba07d53327..04b8a57868 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "origintrail_node", - "version": "6.1.0+hotfix2", + "version": "6.1.0", "description": "OTNode V6", "main": "index.js", "type": "module",