Skip to content

Commit

Permalink
Merge pull request #3533 from OriginTrail/chore/integrate-w-new-contr…
Browse files Browse the repository at this point in the history
…acts

Integration w new contracts, changes in local script + installer + node
  • Loading branch information
brkagithub authored Dec 18, 2024
2 parents ac97fcf + cf9c1a3 commit 4400e65
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 50 deletions.
10 changes: 3 additions & 7 deletions installer/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,8 @@ install_node() {
read -p "$(print_color $YELLOW "Enter your EVM management wallet address : ")" EVM_MANAGEMENT_WALLET
print_color $GREEN "✅ EVM management wallet address : $EVM_MANAGEMENT_WALLET"

read -p "$(print_color $YELLOW "Enter your profile shares token name : ")" SHARES_TOKEN_NAME
print_color $GREEN "✅ Profile shares token name : $SHARES_TOKEN_NAME"

read -p "$(print_color $YELLOW "Enter your profile shares token symbol : ")" SHARES_TOKEN_SYMBOL
print_color $GREEN "✅ Profile shares token symbol : $SHARES_TOKEN_SYMBOL"
read -p "$(print_color $YELLOW "Enter your profile node name : ")" NODE_NAME
print_color $GREEN "✅ Profile shares token name : $NODE_NAME"

validate_operator_fees $blockchain

Expand All @@ -389,8 +386,7 @@ install_node() {
"config": {
"operationalWallets": $EVM_OP_WALLET_KEYS,
"evmManagementWalletPublicKey": "$EVM_MANAGEMENT_WALLET",
"sharesTokenName": "$SHARES_TOKEN_NAME",
"sharesTokenSymbol": "$SHARES_TOKEN_SYMBOL",
"nodeName": "$NODE_NAME",
"operatorFee": $OPERATOR_FEE,
"rpcEndpoints": ["$RPC_ENDPOINT"]
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/set-stake.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function setStake(
TRANSACTION_POLLING_TIMEOUT_MILLIS,
);
// TODO: Add ABI instead of hard-coded function definition
tx = await stakingContract['addStake(uint72,uint96)'](identityId, stakeWei, {
tx = await stakingContract['stake(uint72,uint96)'](identityId, stakeWei, {
gasPrice: gasPrice ? gasPrice * 100 : undefined,
gasLimit: 3_000_000,
});
Expand Down
4 changes: 2 additions & 2 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ export const ABIs = {
ParametersStorage: require('dkg-evm-module/abi/ParametersStorage.json'),
Profile: require('dkg-evm-module/abi/Profile.json'),
ProfileStorage: require('dkg-evm-module/abi/ProfileStorage.json'),
ShardingTable: require('dkg-evm-module/abi/ShardingTableV2.json'),
ShardingTableStorage: require('dkg-evm-module/abi/ShardingTableStorageV2.json'),
ShardingTable: require('dkg-evm-module/abi/ShardingTable.json'),
ShardingTableStorage: require('dkg-evm-module/abi/ShardingTableStorage.json'),
ParanetsRegistry: require('dkg-evm-module/abi/ParanetsRegistry.json'),
ParanetKnowledgeAssetsRegistry: require('dkg-evm-module/abi/ParanetKnowledgeAssetsRegistry.json'),
};
Expand Down
4 changes: 2 additions & 2 deletions src/modules/blockchain/blockchain-module-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ class BlockchainModuleManager extends BaseModuleManager {
// ]);
// }

async getKnowledgeCollectionPublisher(
async getLatestMerkleRootPublisher(
blockchain,
assetStorageContractAddress,
knowledgeCollectionId,
) {
return this.callImplementationFunction(blockchain, 'getKnowledgeCollectionPublisher', [
return this.callImplementationFunction(blockchain, 'getLatestMerkleRootPublisher', [
assetStorageContractAddress,
knowledgeCollectionId,
]);
Expand Down
13 changes: 5 additions & 8 deletions src/modules/blockchain/implementation/web3-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ class Web3Service {
}

async createProfile(peerId) {
if (!this.config.sharesTokenName || !this.config.sharesTokenSymbol) {
if (!this.config.nodeName) {
throw new Error(
'Missing sharesTokenName and sharesTokenSymbol in blockchain configuration. Please add it and start the node again.',
'Missing nodeName in blockchain configuration. Please add it and start the node again.',
);
}

Expand All @@ -492,18 +492,15 @@ class Web3Service {
[
this.getManagementKey(),
this.getPublicKeys().slice(1),
this.config.nodeName,
ethers.utils.hexlify(ethers.utils.toUtf8Bytes(peerId)),
this.config.sharesTokenName,
this.config.sharesTokenSymbol,
this.config.operatorFee,
],
null,
this.operationalWallets[0],
);
this.logger.info(
`Profile created with name: ${this.config.sharesTokenName} and symbol: ${
this.config.sharesTokenSymbol
}, wallet: ${
`Profile created with name: ${this.config.nodeName}, wallet: ${
this.operationalWallets[0].address
}, on blockchain ${this.getBlockchainId()}`,
);
Expand Down Expand Up @@ -925,7 +922,7 @@ class Web3Service {
// return this.callContractFunction(assetStorageContractInstance, 'ownerOf', [tokenId]);
// }

async getKnowledgeCollectionPublisher(assetStorageContractAddress, knowledgeCollectionId) {
async getLatestMerkleRootPublisher(assetStorageContractAddress, knowledgeCollectionId) {
const assetStorageContractInstance =
this.assetStorageContracts[assetStorageContractAddress.toString().toLowerCase()];
if (!assetStorageContractInstance)
Expand Down
2 changes: 1 addition & 1 deletion src/service/validation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ValidationService {

let isValid = true;
try {
const result = await this.blockchainModuleManager.getKnowledgeCollectionPublisher(
const result = await this.blockchainModuleManager.getLatestMerkleRootPublisher(
blockchain,
contract,
tokenId,
Expand Down
27 changes: 4 additions & 23 deletions test/bdd/steps/lib/local-blockchain.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { readFile } from 'fs/promises';
import { exec, execSync } from 'child_process';

const Hub = JSON.parse((await readFile('node_modules/dkg-evm-module/abi/Hub.json')).toString());
const HubController = JSON.parse(
(await readFile('node_modules/dkg-evm-module/abi/HubController.json')).toString(),
);
const ParametersStorage = JSON.parse(
(await readFile('node_modules/dkg-evm-module/abi/ParametersStorage.json')).toString(),
);
Expand Down Expand Up @@ -79,22 +76,6 @@ class LocalBlockchain {
this.hubContract = new ethers.Contract(hubContractAddress, Hub, wallet);

await this.provider.ready;
const hubControllerAddress = await this.hubContract.owner();
this.HubControllerContract = new ethers.Contract(
hubControllerAddress,
HubController,
wallet,
);

const parametersStorageAddress = await this.hubContract.getContractAddress(
'ParametersStorage',
);
this.ParametersStorageInterface = new ethers.utils.Interface(ParametersStorage);

await this.setParametersStorageParams(
parametersStorageAddress,
testParametersStorageParams,
);
}

async stop() {
Expand All @@ -118,7 +99,7 @@ class LocalBlockchain {
[params[parameter]],
);
// eslint-disable-next-line no-await-in-loop
await this.HubControllerContract.forwardCall(parametersStorageAddress, encodedData);
await this.hubContract.forwardCall(parametersStorageAddress, encodedData);
}
}

Expand All @@ -128,7 +109,7 @@ class LocalBlockchain {
const parametersStorageAddress = await this.hubContract.getContractAddress(
'ParametersStorage',
);
await this.HubControllerContract.forwardCall(parametersStorageAddress, encodedData);
await this.hubContract.forwardCall(parametersStorageAddress, encodedData);
}

async setR1(r1) {
Expand All @@ -137,7 +118,7 @@ class LocalBlockchain {
const parametersStorageAddress = await this.hubContract.getContractAddress(
'ParametersStorage',
);
await this.HubControllerContract.forwardCall(parametersStorageAddress, encodedData);
await this.hubContract.forwardCall(parametersStorageAddress, encodedData);
}

async setFinalizationCommitsNumber(commitsNumber) {
Expand All @@ -149,7 +130,7 @@ class LocalBlockchain {
const parametersStorageAddress = await this.hubContract.getContractAddress(
'ParametersStorage',
);
await this.HubControllerContract.forwardCall(parametersStorageAddress, encodedData);
await this.hubContract.forwardCall(parametersStorageAddress, encodedData);
}
}

Expand Down
3 changes: 1 addition & 2 deletions tools/local-network-setup/generate-config-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ function generateBlockchainConfig(templateBlockchainConfig, nodeIndex) {
],
evmManagementWalletPublicKey: publicKeysManagementWallet[nodeIndex + 1],
evmManagementWalletPrivateKey: privateKeysManagementWallet[nodeIndex + 1],
sharesTokenName: `LocalNode${nodeIndex + 1}`,
sharesTokenSymbol: `LN${nodeIndex + 1}`,
nodeName: `LocalNode${nodeIndex + 1}`,
};

// TODO: Don't use string
Expand Down
4 changes: 2 additions & 2 deletions tools/local-network-setup/setup-linux-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ then
echo ================================
echo ====== Starting hardhat1 ======
echo ================================
sh -c "cd $pathToOtNode && node tools/local-network-setup/run-local-blockchain.js 8545 :v2" &
sh -c "cd $pathToOtNode && node tools/local-network-setup/run-local-blockchain.js 8545 " &
echo Waiting for hardhat to start and contracts deployment

echo ================================
echo ====== Starting hardhat 2 ======
echo ================================
sh -c "cd $pathToOtNode && node tools/local-network-setup/run-local-blockchain.js 9545 :v2" &
sh -c "cd $pathToOtNode && node tools/local-network-setup/run-local-blockchain.js 9545 " &
echo Waiting for hardhat to start and contracts deployment
fi

Expand Down
4 changes: 2 additions & 2 deletions tools/local-network-setup/setup-macos-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ then

osascript -e "tell app \"Terminal\"
do script \"cd $pathToOtNode
node tools/local-network-setup/run-local-blockchain.js 8545 :v2\"
node tools/local-network-setup/run-local-blockchain.js 8545 \"
end tell"
echo Waiting for hardhat to start and contracts deployment

Expand All @@ -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 \"
end tell"
echo Waiting for hardhat to start and contracts deployment
fi
Expand Down

0 comments on commit 4400e65

Please sign in to comment.