diff --git a/proxy/contracts/mainnet/MessageProxyForMainnet.sol b/proxy/contracts/mainnet/MessageProxyForMainnet.sol index e3cf29187..ec5eac130 100644 --- a/proxy/contracts/mainnet/MessageProxyForMainnet.sol +++ b/proxy/contracts/mainnet/MessageProxyForMainnet.sol @@ -218,6 +218,7 @@ contract MessageProxyForMainnet is SkaleManagerClient, MessageProxy, IMessagePro { uint256 gasTotal = gasleft(); bytes32 fromSchainHash = keccak256(abi.encodePacked(fromSchainName)); + require(isAgentAuthorized(fromSchainHash, msg.sender), "Agent is not authorized"); require(_checkSchainBalance(fromSchainHash), "Schain wallet has not enough funds"); require(connectedChains[fromSchainHash].inited, "Chain is not initialized"); require(messages.length <= MESSAGES_LENGTH, "Too many messages"); diff --git a/proxy/contracts/mainnet/SkaleManagerClient.sol b/proxy/contracts/mainnet/SkaleManagerClient.sol index b3dd002f7..5c4c0c830 100644 --- a/proxy/contracts/mainnet/SkaleManagerClient.sol +++ b/proxy/contracts/mainnet/SkaleManagerClient.sol @@ -71,4 +71,9 @@ contract SkaleManagerClient is Initializable, AccessControlEnumerableUpgradeable address skaleChainsInternal = contractManagerOfSkaleManager.getContract("SchainsInternal"); return ISchainsInternal(skaleChainsInternal).isOwnerAddress(sender, schainHash); } + + function isAgentAuthorized(bytes32 schainHash, address sender) public view override returns (bool) { + address skaleChainsInternal = contractManagerOfSkaleManager.getContract("SchainsInternal"); + return ISchainsInternal(skaleChainsInternal).isNodeAddressesInGroup(schainHash, sender); + } } diff --git a/proxy/contracts/test/TestNodes.sol b/proxy/contracts/test/TestNodes.sol index daeda8f0e..34f085fe7 100644 --- a/proxy/contracts/test/TestNodes.sol +++ b/proxy/contracts/test/TestNodes.sol @@ -26,6 +26,7 @@ pragma solidity 0.8.6; interface INodesTester { function createNode(address, Nodes.NodeCreationParams calldata params) external; function getNodeAddress(uint nodeIndex) external view returns (address); + function isNodeExist(address from, uint nodeIndex) external view returns (bool); } @@ -56,14 +57,21 @@ contract Nodes is INodesTester { string domainName; } + struct CreatedNodes { + mapping (uint => bool) isNodeExist; + uint numberOfNodes; + } + Node[] public nodes; + mapping (address => CreatedNodes) public nodeIndexes; + modifier checkNodeExists(uint nodeIndex) { _checkNodeIndex(nodeIndex); _; } - function createNode(address, NodeCreationParams calldata params) + function createNode(address from, NodeCreationParams calldata params) external override { nodes.push(Node({ @@ -78,6 +86,8 @@ contract Nodes is INodesTester { status: NodeStatus.Active, validatorId: 1337 })); + nodeIndexes[from].isNodeExist[nodes.length - 1] = true; + nodeIndexes[from].numberOfNodes++; } function getNodeAddress(uint nodeIndex) @@ -90,6 +100,16 @@ contract Nodes is INodesTester { return _publicKeyToAddress(nodes[nodeIndex].publicKey); } + function isNodeExist(address from, uint nodeIndex) + public + view + override + checkNodeExists(nodeIndex) + returns (bool) + { + return nodeIndexes[from].isNodeExist[nodeIndex]; + } + function _checkNodeIndex(uint nodeIndex) private view { require(nodeIndex < nodes.length, "Node with such index does not exist"); } diff --git a/proxy/contracts/test/TestSchainsInternal.sol b/proxy/contracts/test/TestSchainsInternal.sol index 27b12cd16..80960bfa2 100644 --- a/proxy/contracts/test/TestSchainsInternal.sol +++ b/proxy/contracts/test/TestSchainsInternal.sol @@ -39,6 +39,7 @@ interface ISchainsInternalTester { function isSchainExist(bytes32 schainHash) external view returns (bool); function getSchains() external view returns (bytes32[] memory); function getSchainName(bytes32 schainHash) external view returns (string memory); + function getNodesInGroup(bytes32 schainHash) external view returns (uint[] memory); } @@ -66,6 +67,8 @@ contract SchainsInternal is ISchainsInternalTester { bytes32[] public schainsAtSystem; + mapping (bytes32 => mapping (address => bool)) private _nodeAddressInSchain; + function addContractManager(address newContractManager) external override { contractManager = ContractManager(newContractManager); } @@ -89,17 +92,16 @@ contract SchainsInternal is ISchainsInternalTester { } function addNodesToSchainsGroups(bytes32 schainHash, uint[] memory nodes) external override { + Nodes nodesContract = Nodes(contractManager.getContract("Nodes")); schainsGroups[schainHash] = nodes; + for (uint i = 0; i < nodes.length; i++) { + address nodeAddress = nodesContract.getNodeAddress(nodes[i]); + _nodeAddressInSchain[schainHash][nodeAddress] = true; + } } function isNodeAddressesInGroup(bytes32 schainHash, address sender) external view override returns (bool) { - Nodes nodes = Nodes(contractManager.getContract("Nodes")); - for (uint i = 0; i < schainsGroups[schainHash].length; i++) { - if (nodes.getNodeAddress(schainsGroups[schainHash][i]) == sender) { - return true; - } - } - return true; + return _nodeAddressInSchain[schainHash][sender]; } function isOwnerAddress(address from, bytes32 schainHash) external view override returns (bool) { @@ -122,4 +124,13 @@ contract SchainsInternal is ISchainsInternalTester { { return schains[schainHash].name; } + + function getNodesInGroup(bytes32 schainHash) + external + view + override + returns (uint[] memory) + { + return schainsGroups[schainHash]; + } } diff --git a/proxy/gas/calculateGas.ts b/proxy/gas/calculateGas.ts index 4a85deba4..f621e9ac9 100644 --- a/proxy/gas/calculateGas.ts +++ b/proxy/gas/calculateGas.ts @@ -86,11 +86,11 @@ import { deployTokenManagerERC1155 } from "../test/utils/deploy/schain/tokenMana import { deployMessageProxyForSchain } from "../test/utils/deploy/schain/messageProxyForSchain"; import { deployMessages } from "../test/utils/deploy/messages"; -import { randomString, stringValue } from "../test/utils/helper"; +import { randomString, stringValue, getPublicKey } from "../test/utils/helper"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber, BytesLike } from "ethers"; +import { BigNumber, BytesLike, Wallet } from "ethers"; import { assert, expect } from "chai"; import { deployCommunityLocker } from "../test/utils/deploy/schain/communityLocker"; @@ -101,6 +101,8 @@ describe("Gas calculation", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let schainOwner: SignerWithAddress; + let richGuy: SignerWithAddress; + let nodeAddress: Wallet; let imaLinker: Linker; let depositBoxEth: DepositBoxEth; @@ -141,9 +143,17 @@ describe("Gas calculation", () => { const mainnetName = "Mainnet"; before(async () => { - [deployer, schainOwner, user] = await ethers.getSigners(); + [deployer, schainOwner, user, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); }) + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); + }); + beforeEach(async () => { // skale-manager mock preparation contractManager = await deployContractManager(contractManagerAddress); @@ -165,37 +175,32 @@ describe("Gas calculation", () => { await schainsInternal.connect(deployer).addContractManager(contractManager.address); await wallets.connect(deployer).addContractManager(contractManager.address); - const nodePublicKey: [BytesLike, BytesLike] = [ - "0x1122334455667788990011223344556677889900112233445566778899001122", - "0x1122334455667788990011223344556677889900112233445566778899001122" - ]; - // setup 16 nodes const nodeCreationParams = { port: 1337, nonce: 1337, ip: "0x12345678", publicIp: "0x12345678", - publicKey: nodePublicKey, + publicKey: getPublicKey(nodeAddress), name: "GasCalculationNode", domainName: "gascalculationnode.com" }; - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); // initialize schain and data await schainsInternal.connect(deployer).initializeSchain(schainName, schainOwner.address, 12345678, 12345678); @@ -565,7 +570,7 @@ describe("Gas calculation", () => { }; async function postIncomingMessages(startingCounter: number, arrayOfMessages: any, action: string) { - const res = await (await messageProxyForMainnet.connect(deployer).postIncomingMessages( + const res = await (await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, startingCounter, arrayOfMessages, diff --git a/proxy/migrations/deploySkaleManagerComponents.ts b/proxy/migrations/deploySkaleManagerComponents.ts index e1cad246d..680e49e2f 100644 --- a/proxy/migrations/deploySkaleManagerComponents.ts +++ b/proxy/migrations/deploySkaleManagerComponents.ts @@ -28,6 +28,8 @@ import { deployLibraries, getLinkedContractFactory } from "./tools/factory"; import { getAbi } from './tools/abi'; import { Manifest, hashBytecode } from "@openzeppelin/upgrades-core"; import { KeyStorageMock } from '../typechain/KeyStorageMock'; +import { Wallet } from 'ethers'; +import { getPublicKey, stringValue } from '../test/utils/helper'; export function getContractKeyInAbiFile(contract: string) { return contract.replace(/([a-z0-9])(?=[A-Z])/g, '$1_').toLowerCase(); @@ -114,6 +116,8 @@ async function main() { await schains.addContractManager( contractManager.address ); console.log("Add ContractManager address", contractManager.address, "as ContractManager to Contract Schains", schains.address, "\n"); + await schainsInternal.addContractManager( contractManager.address ); + console.log("Add ContractManager address", contractManager.address, "as ContractManager to Contract SchainsInternal", schainsInternal.address, "\n"); await wallets.addContractManager( contractManager.address ); console.log("Add ContractManager address", contractManager.address, "as ContractManager to Contract Wallets", wallets.address, "\n"); await contractManager.setContractsAddress( "Schains", schains.address ); @@ -128,8 +132,37 @@ async function main() { console.log("Set KeyStorage", keyStorage.address, "to ContractManager", contractManager.address, "\n"); await contractManager.setContractsAddress( "Nodes", nodes.address ); console.log("Set Nodes", nodes.address, "to ContractManager", contractManager.address, "\n"); + const nodeAddress1 = new Wallet(stringValue(process.env.PRIVATE_KEY_FOR_ETHEREUM)).connect(ethers.provider); + const nodeAddress2 = new Wallet(stringValue(process.env.PRIVATE_KEY_FOR_SCHAIN)).connect(ethers.provider); + await owner.sendTransaction({to: nodeAddress1.address, value: ethers.utils.parseEther("1")}); + await owner.sendTransaction({to: nodeAddress2.address, value: ethers.utils.parseEther("1")}); + + const nodeCreationParams1 = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress1), + name: "TestNode1", + domainName: "testnode1.com" + }; + const nodeCreationParams2 = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress1), + name: "TestNode2", + domainName: "testnode2.com" + }; + await nodes.connect(owner).createNode(nodeAddress1.address, nodeCreationParams1); + console.log("Create Node 0 with address", nodeAddress1.address, "\n"); + await nodes.connect(owner).createNode(nodeAddress2.address, nodeCreationParams2); + console.log("Create Node 1 with address", nodeAddress2.address, "\n"); await schainsInternal.initializeSchain( schainName, owner.address, 1, 1 ); console.log("Initialize Schain", schainName, "with address", owner.address, "\n"); + await schainsInternal.connect(owner).addNodesToSchainsGroups(stringValue(ethers.utils.id(schainName)), [0, 1]); + console.log("Add Nodes 0 and 1 to schain", schainName, "\n"); const BLSPublicKey = { x: { a: "8276253263131369565695687329790911140957927205765534740198480597854608202714", diff --git a/proxy/package.json b/proxy/package.json index e325c93fc..dd6b749c2 100644 --- a/proxy/package.json +++ b/proxy/package.json @@ -25,7 +25,7 @@ "@openzeppelin/contracts-upgradeable": "^4.3.2", "@openzeppelin/hardhat-upgrades": "^1.9.0", "@skalenetwork/etherbase-interfaces": "^0.0.1-develop.20", - "@skalenetwork/ima-interfaces": "1.0.0-develop.16", + "@skalenetwork/ima-interfaces": "1.0.0-develop.17", "@skalenetwork/skale-manager-interfaces": "1.0.0-develop.1", "axios": "^0.21.4", "dotenv": "^10.0.0", @@ -45,6 +45,7 @@ "@types/chai": "^4.2.12", "@types/chai-almost": "^1.0.1", "@types/chai-as-promised": "^7.1.3", + "@types/elliptic": "^6.4.14", "@types/minimist": "^1.2.0", "@types/mocha": "^8.2.2", "@types/sinon-chai": "^3.2.5", diff --git a/proxy/test/DepositBoxERC1155.ts b/proxy/test/DepositBoxERC1155.ts index c69a74d26..10860cc29 100644 --- a/proxy/test/DepositBoxERC1155.ts +++ b/proxy/test/DepositBoxERC1155.ts @@ -34,7 +34,7 @@ import { MessagesTester, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -47,7 +47,7 @@ import { deployDepositBoxERC1155 } from "./utils/deploy/mainnet/depositBoxERC115 import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -56,9 +56,10 @@ import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber } from "ethers"; +import { BigNumber, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -75,6 +76,8 @@ describe("DepositBoxERC1155", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxERC1155: DepositBoxERC1155; let contractManager: ContractManager; @@ -85,7 +88,15 @@ describe("DepositBoxERC1155", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -97,6 +108,17 @@ describe("DepositBoxERC1155", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC1155.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -354,7 +376,7 @@ describe("DepositBoxERC1155", () => { // execution // to avoid `Incorrect sender` error const balanceBefore = await getBalance(deployer.address); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -410,7 +432,7 @@ describe("DepositBoxERC1155", () => { // execution // to avoid `Incorrect sender` error const balanceBefore = await getBalance(deployer.address); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); diff --git a/proxy/test/DepositBoxERC20.ts b/proxy/test/DepositBoxERC20.ts index b70a11408..67d35b8a4 100644 --- a/proxy/test/DepositBoxERC20.ts +++ b/proxy/test/DepositBoxERC20.ts @@ -36,7 +36,7 @@ import { ERC20OnChain, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -49,7 +49,7 @@ import { deployDepositBoxERC20 } from "./utils/deploy/mainnet/depositBoxERC20"; import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -60,9 +60,10 @@ import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber } from "ethers"; +import { BigNumber, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -79,6 +80,8 @@ describe("DepositBoxERC20", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxERC20: DepositBoxERC20; let contractManager: ContractManager; @@ -89,7 +92,15 @@ describe("DepositBoxERC20", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -101,6 +112,17 @@ describe("DepositBoxERC20", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC20.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -298,7 +320,7 @@ describe("DepositBoxERC20", () => { await depositBoxERC20.connect(user).depositERC20(schainName, erc20.address, amount); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress, messageWithNotMintedToken], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress, messageWithNotMintedToken], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Given address is not a contract"); @@ -309,13 +331,13 @@ describe("DepositBoxERC20", () => { } const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 2, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 2, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); await depositBoxERC20.connect(user).depositERC20(schainName, erc20.address, amount); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 3, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 3, [message], sign); expect(BigNumber.from(await depositBoxERC20.transferredAmount(schainHash, erc20.address)).toString()).to.be.equal(BigNumber.from(0).toString()); (await erc20.balanceOf(user.address)).toString().should.be.equal((amount * 2).toString()); diff --git a/proxy/test/DepositBoxERC721.ts b/proxy/test/DepositBoxERC721.ts index d96364d64..d7108957a 100644 --- a/proxy/test/DepositBoxERC721.ts +++ b/proxy/test/DepositBoxERC721.ts @@ -34,7 +34,7 @@ import { MessagesTester, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -47,7 +47,7 @@ import { deployDepositBoxERC721 } from "./utils/deploy/mainnet/depositBoxERC721" import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -56,9 +56,10 @@ import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber } from "ethers"; +import { BigNumber, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -75,6 +76,8 @@ describe("DepositBoxERC721", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxERC721: DepositBoxERC721; let contractManager: ContractManager; @@ -85,7 +88,15 @@ describe("DepositBoxERC721", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -97,6 +108,17 @@ describe("DepositBoxERC721", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC721.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -276,7 +298,7 @@ describe("DepositBoxERC721", () => { await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721.address, tokenId); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -299,7 +321,7 @@ describe("DepositBoxERC721", () => { await erc721.connect(deployer).mint(deployer.address, tokenId); await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721.address, tokenId); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Given address is not a contract"); @@ -321,7 +343,7 @@ describe("DepositBoxERC721", () => { await erc721.connect(deployer).mint(deployer.address, tokenId); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Incorrect tokenId"); @@ -351,7 +373,7 @@ describe("DepositBoxERC721", () => { .depositERC721(schainName, erc721.address, tokenId); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); diff --git a/proxy/test/DepositBoxERC721WithMetadata.ts b/proxy/test/DepositBoxERC721WithMetadata.ts index 3304f30fe..98e80989b 100644 --- a/proxy/test/DepositBoxERC721WithMetadata.ts +++ b/proxy/test/DepositBoxERC721WithMetadata.ts @@ -34,7 +34,7 @@ import { MessagesTester, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -47,7 +47,7 @@ import { deployDepositBoxERC721WithMetadata } from "./utils/deploy/mainnet/depos import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -56,9 +56,10 @@ import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber } from "ethers"; +import { BigNumber, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -75,6 +76,8 @@ describe("DepositBoxERC721WithMetadata", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxERC721WithMetadata: DepositBoxERC721WithMetadata; let contractManager: ContractManager; @@ -85,7 +88,15 @@ describe("DepositBoxERC721WithMetadata", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -97,6 +108,17 @@ describe("DepositBoxERC721WithMetadata", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC721WithMetadata.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -282,7 +304,7 @@ describe("DepositBoxERC721WithMetadata", () => { await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721WithMetadata.address, tokenId); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -308,7 +330,7 @@ describe("DepositBoxERC721WithMetadata", () => { await erc721.connect(deployer).setTokenURI(tokenId, tokenURI); await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721WithMetadata.address, tokenId); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Given address is not a contract"); @@ -332,7 +354,7 @@ describe("DepositBoxERC721WithMetadata", () => { await erc721.connect(deployer).mint(deployer.address, tokenId); await erc721.connect(deployer).setTokenURI(tokenId, tokenURI); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Incorrect tokenId"); @@ -364,7 +386,7 @@ describe("DepositBoxERC721WithMetadata", () => { .depositERC721(schainName, erc721.address, tokenId); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); diff --git a/proxy/test/DepositBoxEth.ts b/proxy/test/DepositBoxEth.ts index 66a5d4ef6..c94071b76 100644 --- a/proxy/test/DepositBoxEth.ts +++ b/proxy/test/DepositBoxEth.ts @@ -37,7 +37,7 @@ import { ERC20OnChain, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -53,7 +53,7 @@ import { deployDepositBoxERC1155 } from "./utils/deploy/mainnet/depositBoxERC115 import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -63,9 +63,10 @@ import { deployFallbackEthTester } from "./utils/deploy/test/fallbackEthTester"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber, ContractTransaction } from "ethers"; +import { BigNumber, ContractTransaction, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -105,6 +106,8 @@ describe("DepositBoxEth", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxEth: DepositBoxEth; let contractManager: ContractManager; @@ -115,7 +118,15 @@ describe("DepositBoxEth", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -127,6 +138,17 @@ describe("DepositBoxEth", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxEth.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -170,7 +192,6 @@ describe("DepositBoxEth", () => { await depositBoxEth .connect(deployer) .deposit(schainName, { value: wei }); - // console.log("Gas for deposit:", tx.receipt.gasUsed); const lockAndDataBalance = await web3.eth.getBalance(depositBoxEth.address); // expectation @@ -261,8 +282,7 @@ describe("DepositBoxEth", () => { .rechargeUserWallet(schainName, user.address, { value: wei }); // execution - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); - // console.log(res.logs); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(res.events[0].args?.msgCounter.toString(), "0"); @@ -306,7 +326,7 @@ describe("DepositBoxEth", () => { .connect(user) .rechargeUserWallet(schainName, user.address, { value: wei }); // execution - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); @@ -351,7 +371,7 @@ describe("DepositBoxEth", () => { // to avoid `Incorrect sender` error // await lockAndDataForMainnet.setContract("MessageProxy", deployer); // execution - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); @@ -400,7 +420,7 @@ describe("DepositBoxEth", () => { .connect(deployer) .deposit(schainName, { value: wei }); // execution - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); @@ -451,7 +471,7 @@ describe("DepositBoxEth", () => { expect(BigNumber.from(await depositBoxEth.transferredAmount(schainHash)).toString()).to.be.equal(BigNumber.from(wei).toString()); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -504,7 +524,7 @@ describe("DepositBoxEth", () => { expect(BigNumber.from(await depositBoxEth.transferredAmount(schainHash)).toString()).to.be.equal(BigNumber.from(wei).mul(2).toString()); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -526,7 +546,7 @@ describe("DepositBoxEth", () => { const userBalanceBefore = await web3.eth.getBalance(user.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 1, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 1, [message], sign); expect(BigNumber.from(await web3.eth.getBalance(user.address)).toString()).to.equal(BigNumber.from(userBalanceBefore).add(BigNumber.from(wei)).toString()); expect(BigNumber.from(await depositBoxEth.approveTransfers(user.address)).toString()).to.equal(BigNumber.from(wei).toString()); @@ -580,7 +600,7 @@ describe("DepositBoxEth", () => { expect(BigNumber.from(await depositBoxEth.transferredAmount(schainHash)).toString()).to.be.equal(BigNumber.from(wei).mul(2).toString()); - await reimbursed(await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)); + await reimbursed(await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)); expect(BigNumber.from(await depositBoxEth.approveTransfers(fallbackEthTester.address)).toString()).to.equal(BigNumber.from(wei).toString()); @@ -599,7 +619,7 @@ describe("DepositBoxEth", () => { const userBalanceBefore = await web3.eth.getBalance(fallbackEthTester.address); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 1, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 1, [message], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); diff --git a/proxy/test/MessageProxy.ts b/proxy/test/MessageProxy.ts index 77ce09758..240eb29de 100644 --- a/proxy/test/MessageProxy.ts +++ b/proxy/test/MessageProxy.ts @@ -40,13 +40,13 @@ import { EtherbaseMock, SchainsInternal } from "../typechain/"; -import { randomString, stringToHex } from "./utils/helper"; +import { randomString, stringToHex, getPublicKey } from "./utils/helper"; import ABIReceiverMock = require("../artifacts/contracts/test/ReceiverMock.sol/ReceiverMock.json"); import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployDepositBoxEth } from "./utils/deploy/mainnet/depositBoxEth"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessageProxyCaller } from "./utils/deploy/test/messageProxyCaller"; @@ -59,6 +59,7 @@ import { assert, expect } from "chai"; import { MessageProxyForSchainTester } from "../typechain/MessageProxyForSchainTester"; import { deployMessageProxyForSchainTester } from "./utils/deploy/test/messageProxyForSchainTester"; import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; +import { createNode } from "./utils/skale-manager-utils/nodes"; chai.should(); chai.use((chaiAsPromised)); @@ -69,6 +70,8 @@ describe("MessageProxy", () => { let client: SignerWithAddress; let customer: SignerWithAddress; let agent: SignerWithAddress; + let richGuy: SignerWithAddress; + let nodeAddress: Wallet; let keyStorage: KeyStorageMock; let messageProxyForSchain: MessageProxyForSchainTester; @@ -95,7 +98,15 @@ describe("MessageProxy", () => { const Counter = 0; before(async () => { - [deployer, user, client, customer, agent] = await ethers.getSigners(); + [deployer, user, client, customer, agent, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); describe("MessageProxy for mainnet", async () => { @@ -247,6 +258,17 @@ describe("MessageProxy", () => { it("should post incoming messages", async () => { const startingCounter = 0; await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.registerExtraContract(schainName, communityPool.address); @@ -276,7 +298,7 @@ describe("MessageProxy", () => { // chain should be inited: await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -287,7 +309,7 @@ describe("MessageProxy", () => { await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -298,7 +320,7 @@ describe("MessageProxy", () => { await communityPool.connect(client).rechargeUserWallet(schainName, client.address, {value: amountWei.toString()}); await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -309,7 +331,104 @@ describe("MessageProxy", () => { await communityPool.connect(client).rechargeUserWallet(schainName, user.address, {value: amountWei.toString()}); await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) + .postIncomingMessages( + schainName, + startingCounter + 2, + outgoingMessages, + sign + ); + const incomingMessagesCounter = BigNumber.from( + await messageProxyForMainnet.getIncomingMessagesCounter(schainName)); + incomingMessagesCounter.should.be.deep.equal(BigNumber.from(4)); + }); + + it("should not post incoming messages with incorrect address", async () => { + const startingCounter = 0; + await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); + await setCommonPublicKey(contractManager, schainName); + await messageProxyForMainnet.registerExtraContract(schainName, communityPool.address); + await depositBox.addSchainContract(schainName, deployer.address); + const minTransactionGas = await communityPool.minTransactionGas(); + const amountWei = minTransactionGas.mul(gasPrice); + + const message1 = { + destinationContract: depositBox.address, + sender: deployer.address, + data: await messages.encodeTransferEthMessage(client.address, 0), + }; + + const message2 = { + destinationContract: depositBox.address, + sender: deployer.address, + data: await messages.encodeTransferEthMessage(customer.address, 7), + }; + + const outgoingMessages = [message1, message2]; + const sign = { + blsSignature: BlsSignature, + counter: Counter, + hashA: HashA, + hashB: HashB, + }; + + // chain should be inited: + await messageProxyForMainnet + .connect(nodeAddress) + .postIncomingMessages( + schainName, + startingCounter, + outgoingMessages, + sign + ).should.be.eventually.rejectedWith("Chain is not initialized"); + + await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); + + await messageProxyForMainnet + .connect(nodeAddress) + .postIncomingMessages( + schainName, + startingCounter, + Array(11).fill(message1), + sign + ).should.be.eventually.rejectedWith("Too many messages"); + + await communityPool.connect(client).rechargeUserWallet(schainName, client.address, {value: amountWei.toString()}); + + await messageProxyForMainnet + .connect(user) + .postIncomingMessages( + schainName, + startingCounter, + outgoingMessages, + sign + ).should.be.eventually.rejectedWith("Agent is not authorized"); + + await messageProxyForMainnet + .connect(nodeAddress) + .postIncomingMessages( + schainName, + startingCounter, + outgoingMessages, + sign + ); + + await communityPool.connect(client).rechargeUserWallet(schainName, user.address, {value: amountWei.toString()}); + + await messageProxyForMainnet + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter + 2, @@ -346,6 +465,17 @@ describe("MessageProxy", () => { it("should get incoming messages counter", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); const startingCounter = 0; @@ -381,7 +511,7 @@ describe("MessageProxy", () => { incomingMessagesCounter0.should.be.deep.equal(BigNumber.from(0)); await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -395,6 +525,17 @@ describe("MessageProxy", () => { it("should get outgoing messages counter", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); @@ -430,7 +571,7 @@ describe("MessageProxy", () => { }; await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -460,6 +601,17 @@ describe("MessageProxy", () => { it("should check gas limit issue", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); @@ -490,7 +642,7 @@ describe("MessageProxy", () => { expect(a.toNumber()).be.equal(0); const res = await (await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -506,6 +658,17 @@ describe("MessageProxy", () => { it("should slice revert message", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); @@ -537,7 +700,7 @@ describe("MessageProxy", () => { } await expect( messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -551,6 +714,17 @@ describe("MessageProxy", () => { it("should return panic error message", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); @@ -583,7 +757,7 @@ describe("MessageProxy", () => { } await expect( messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -866,7 +1040,7 @@ describe("MessageProxy", () => { // } // // chain should be inited: - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter, // outgoingMessages, @@ -877,14 +1051,14 @@ describe("MessageProxy", () => { // (await messageProxyForSchain.getIncomingMessagesCounter(schainName)).toNumber().should.be.equal(0); - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter, // outgoingMessages, // fakeSign // ).should.be.eventually.rejectedWith("Signature is not verified"); - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter + 1, // outgoingMessages, @@ -894,7 +1068,7 @@ describe("MessageProxy", () => { // (await messageProxyForSchain.getIncomingMessagesCounter(schainName)).toNumber().should.be.equal(0); - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter, // [message1, message1, message1, message1, message1, message1, message1, message1, message1, message1, message1], @@ -911,7 +1085,7 @@ describe("MessageProxy", () => { // hashB: "0x2fa5d1482af89ecda5b40d8b7ffbbebf066bc0f9e78f61e7122d5fd952d58dd6" // }; - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter, // outgoingMessages, diff --git a/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts b/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts index ec57298d6..f83cbbf34 100644 --- a/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts +++ b/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts @@ -84,11 +84,11 @@ import { deployTokenManagerERC721 } from "../utils/deploy/schain/tokenManagerERC import { deployMessageProxyForSchain } from "../utils/deploy/schain/messageProxyForSchain"; import { deployMessages } from "../utils/deploy/messages"; -import { randomString, stringValue } from "../utils/helper"; +import { randomString, stringValue, getPublicKey } from "../utils/helper"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber, BytesLike } from "ethers"; +import { BigNumber, BytesLike, Wallet } from "ethers"; import { assert, expect } from "chai"; import { deployCommunityLocker } from "../utils/deploy/schain/communityLocker"; @@ -99,6 +99,8 @@ describe("ERC721MintingFromSchainToMainnet", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let schainOwner: SignerWithAddress; + let richGuy: SignerWithAddress; + let nodeAddress: Wallet; let imaLinker: Linker; let communityPool: CommunityPool; @@ -125,7 +127,10 @@ describe("ERC721MintingFromSchainToMainnet", () => { const contractManagerAddress = "0x0000000000000000000000000000000000000000"; before(async () => { - [deployer, schainOwner, user] = await ethers.getSigners(); + [deployer, schainOwner, user, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); }) beforeEach(async () => { @@ -149,18 +154,13 @@ describe("ERC721MintingFromSchainToMainnet", () => { await schainsInternal.connect(deployer).addContractManager(contractManager.address); await wallets.connect(deployer).addContractManager(contractManager.address); - const nodePublicKey: [BytesLike, BytesLike] = [ - "0x1122334455667788990011223344556677889900112233445566778899001122", - "0x1122334455667788990011223344556677889900112233445566778899001122" - ]; - // setup 16 nodes const nodeCreationParams = { port: 1337, nonce: 1337, ip: "0x12345678", publicIp: "0x12345678", - publicKey: nodePublicKey, + publicKey: getPublicKey(nodeAddress), name: "ExtensionChainNode", domainName: "gascalculationnode.com" }; @@ -352,7 +352,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { hashB: HashB, }; - await messageProxyForMainnet.connect(deployer).postIncomingMessages( + await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -361,7 +361,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { await wallets.connect(deployer).rechargeSchainWallet(stringValue(schainNameHash), {value: "1000000000000000000"}); - const resPost = await (await messageProxyForMainnet.connect(deployer).postIncomingMessages( + const resPost = await (await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -395,7 +395,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { hashB: HashB, }; - await messageProxyForMainnet.connect(deployer).postIncomingMessages( + await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -404,7 +404,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { await wallets.connect(deployer).rechargeSchainWallet(stringValue(schainNameHash), {value: "1000000000000000000"}); - await expect(messageProxyForMainnet.connect(deployer).postIncomingMessages( + await expect(messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -436,7 +436,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { hashB: HashB, }; - await messageProxyForMainnet.connect(deployer).postIncomingMessages( + await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -445,7 +445,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { await wallets.connect(deployer).rechargeSchainWallet(stringValue(schainNameHash), {value: "1000000000000000000"}); - const resPost = await (await messageProxyForMainnet.connect(deployer).postIncomingMessages( + const resPost = await (await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], diff --git a/proxy/test/utils/helper.ts b/proxy/test/utils/helper.ts index 9ba199f6a..813dc856c 100644 --- a/proxy/test/utils/helper.ts +++ b/proxy/test/utils/helper.ts @@ -1,3 +1,9 @@ +import { Wallet, BytesLike, ethers } from "ethers"; + +import { ec } from "elliptic"; + +const secp256k1EC = new ec("secp256k1"); + // SPDX-License-Identifier: AGPL-3.0-only /** @@ -69,3 +75,8 @@ export function stringValue(value: string | null | undefined) { return ""; } } + +export function getPublicKey(wallet: Wallet): [BytesLike, BytesLike] { + const publicKey = secp256k1EC.keyFromPrivate(wallet.privateKey.slice(2)).getPublic(); + return [ethers.utils.hexlify(publicKey.getX().toBuffer()), ethers.utils.hexlify(publicKey.getY().toBuffer())] +} \ No newline at end of file diff --git a/proxy/test/utils/skale-manager-utils/contractManager.ts b/proxy/test/utils/skale-manager-utils/contractManager.ts index 0dc5a8ab9..45dc1d9cf 100644 --- a/proxy/test/utils/skale-manager-utils/contractManager.ts +++ b/proxy/test/utils/skale-manager-utils/contractManager.ts @@ -2,13 +2,6 @@ import { Wallet } from "@ethersproject/wallet"; import { ethers } from "hardhat"; import { ContractManager, KeyStorageMock, Nodes, Schains, SchainsInternal, SkaleVerifierMock, Wallets } from "../../../typechain"; -// const contractManager: ContractManagerContract = artifacts.require("./ContractManager"); -// const keyStorage: KeyStorageContract = artifacts.require("./KeyStorage"); -// const nodes: NodesContract = artifacts.require("./Nodes"); -// const schains: SchainsContract = artifacts.require("./Schains"); -// const schainsInternal: SchainsInternalContract = artifacts.require("./SchainsInternal"); -// const skaleVerifier: SkaleVerifierMockContract = artifacts.require("./SkaleVerifierMock"); -// const wallets: WalletsContract = artifacts.require("./Wallets"); const nameNodes = "Nodes"; const nameSchains = "Schains"; const nameSchainsInternal = "SchainsInternal"; @@ -38,6 +31,7 @@ export async function deployContractManager(contractManagerAddress: string) { } if (await instance.getContract(nameSchainsInternal) === "0x0000000000000000000000000000000000000000") { const schainsInternalInstance = await (await ethers.getContractFactory(nameSchainsInternal)).deploy() as SchainsInternal; + await schainsInternalInstance.addContractManager(instance.address); await instance.setContractsAddress(nameSchainsInternal, schainsInternalInstance.address); } if (await instance.getContract(nameSkaleVerifier) === "0x0000000000000000000000000000000000000000") { diff --git a/proxy/test/utils/skale-manager-utils/nodes.ts b/proxy/test/utils/skale-manager-utils/nodes.ts new file mode 100644 index 000000000..d0314a2f5 --- /dev/null +++ b/proxy/test/utils/skale-manager-utils/nodes.ts @@ -0,0 +1,26 @@ +import { ethers } from "hardhat"; +import { ContractManager, Nodes } from "../../../typechain"; +import { BytesLike } from "ethers"; + +const nameNodes = "Nodes"; + +type NodeCreationParams = { + port: number; + nonce: number; + ip: string; + publicIp: string; + publicKey: [BytesLike, BytesLike]; + name: string; + domainName: string; +} + +export async function createNode( + contractManager: ContractManager, + from: string, + nodeCreationParams: NodeCreationParams +) { + const nodesFactory = await ethers.getContractFactory(nameNodes); + const nodesAddres = await contractManager.getContract(nameNodes); + const nodes = nodesFactory.attach(nodesAddres) as Nodes; + await nodes.createNode(from, nodeCreationParams); +} diff --git a/proxy/test/utils/skale-manager-utils/schainsInternal.ts b/proxy/test/utils/skale-manager-utils/schainsInternal.ts index e744926e2..2ff58ba52 100644 --- a/proxy/test/utils/skale-manager-utils/schainsInternal.ts +++ b/proxy/test/utils/skale-manager-utils/schainsInternal.ts @@ -10,12 +10,23 @@ export async function initializeSchain( lifetime: number, deposit: number ) { - const schainsInternalFactory = await ethers.getContractFactory("SchainsInternal"); - const schainsInternalAddres = await contractManager.getContract("SchainsInternal"); + const schainsInternalFactory = await ethers.getContractFactory(nameSchainsInternal); + const schainsInternalAddres = await contractManager.getContract(nameSchainsInternal); const schainsInternal = schainsInternalFactory.attach(schainsInternalAddres) as SchainsInternal; await schainsInternal.initializeSchain(schainName, owner, lifetime, deposit); } +export async function addNodesToSchain( + contractManager: ContractManager, + schainName: string, + nodes: number[] +) { + const schainsInternalFactory = await ethers.getContractFactory(nameSchainsInternal); + const schainsInternalAddres = await contractManager.getContract(nameSchainsInternal); + const schainsInternal = schainsInternalFactory.attach(schainsInternalAddres) as SchainsInternal; + await schainsInternal.addNodesToSchainsGroups(ethers.utils.id(schainName), nodes); +} + export async function isSchainActive( contractManager: ContractManager, schainName: string diff --git a/proxy/yarn.lock b/proxy/yarn.lock index 948d77ce8..56b239b1a 100644 --- a/proxy/yarn.lock +++ b/proxy/yarn.lock @@ -757,10 +757,10 @@ resolved "https://registry.yarnpkg.com/@skalenetwork/etherbase-interfaces/-/etherbase-interfaces-0.0.1-develop.20.tgz#33f61e18d695fd47063aa39dce4df335d26b9528" integrity sha512-j3xnuQtOtjvjAoUMJgSUFxRa9/Egkg1RyA8r6PjcEb33VksE4LWLBy0PNFUFehLZv48595JROTcViGeXXwg5HQ== -"@skalenetwork/ima-interfaces@1.0.0-develop.16": - version "1.0.0-develop.16" - resolved "https://registry.yarnpkg.com/@skalenetwork/ima-interfaces/-/ima-interfaces-1.0.0-develop.16.tgz#9f79790c6e7eb960498f6930e978705f4ee60cc2" - integrity sha512-lsNonWKt3BLUlS7tk+w1Yp1o/07Bjj9Hr22zt0dzAqvRhCAB8ITBEeHlysXeQs60lE+bBqvmU/SRMdmMF/kliA== +"@skalenetwork/ima-interfaces@1.0.0-develop.17": + version "1.0.0-develop.17" + resolved "https://registry.yarnpkg.com/@skalenetwork/ima-interfaces/-/ima-interfaces-1.0.0-develop.17.tgz#e2650b43a056962e62127fe787577db96d9766d3" + integrity sha512-x1LEQF4dNklotJNCIRl4wfq9R6N8yeX0ZBe38yiBpKPgIX++R3pBF/gPl6HGK6l5xSp0bOQgzw59fzYdjnZP5A== dependencies: "@skalenetwork/skale-manager-interfaces" "^0.1.2" @@ -888,6 +888,13 @@ resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.22.tgz#47020d7e4cf19194d43b5202f35f75bd2ad35ce7" integrity sha512-tFfcE+DSTzWAgifkjik9AySNqIyNoYwmR+uecPwwD/XRNfvOjmC/FjCxpiUGDkDVDphPfCUecSQVFw+lN3M3kQ== +"@types/elliptic@^6.4.14": + version "6.4.14" + resolved "https://registry.yarnpkg.com/@types/elliptic/-/elliptic-6.4.14.tgz#7bbaad60567a588c1f08b10893453e6b9b4de48e" + integrity sha512-z4OBcDAU0GVwDTuwJzQCiL6188QvZMkvoERgcVjq0/mPM8jCfdwZ3x5zQEVoL9WCAru3aG5wl3Z5Ww5wBWn7ZQ== + dependencies: + "@types/bn.js" "*" + "@types/glob@^7.1.1": version "7.1.4" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.4.tgz#ea59e21d2ee5c517914cb4bc8e4153b99e566672"