skalenetwork / filestorage

SKALE filestorage extension to EVM
GNU Affero General Public License v3.0
20 stars 3 forks source link

Add role based access control to Filestorage predeployed #68

Closed sync-by-unito[bot] closed 2 years ago

sync-by-unito[bot] commented 3 years ago

Currentl schain owner has 2 administrative functionality:

  1. Allocate space for new users
  2. Upgrade filestorage functionality

With multisig we need to give permission for (2) to separate account and Marionette contract and for (1) only for Marionette contract. For this purpose need to implement accessControl for Filestorage.sol

tx.origin needs to be changed with msg.sender to support control by smart contract

┆Issue is synchronized with this Jira Task

sync-by-unito[bot] commented 2 years ago

➤ Dmytro Nazarenko commented:

Blocked by SKALE-4592

sync-by-unito[bot] commented 2 years ago

➤ Automation for Jira commented:

Corresponding Pull Request https://github.com/skalenetwork/filestorage/pull/73

sync-by-unito[bot] commented 2 years ago

➤ Automation for Jira commented:

Corresponding Pull Request https://github.com/skalenetwork/filestorage/pull/76

sync-by-unito[bot] commented 2 years ago

➤ Automation for Jira commented:

Corresponding Pull Request https://github.com/skalenetwork/filestorage/pull/77

sync-by-unito[bot] commented 2 years ago

➤ Automation for Jira commented:

Corresponding Pull Request https://github.com/skalenetwork/filestorage/pull/78

sync-by-unito[bot] commented 2 years ago

➤ Dmytro Nazarenko commented:

Test:

  1. Schain owner can allocate storage for addresses

  2. Non-Schain owner can’t allocate storage

  3. Schain owner can grant ALLOCATOR_ROLE for other address and it can allocate space for addresses

sync-by-unito[bot] commented 2 years ago

➤ Oleksandr Salamatov commented:

Verified skaled: 3.10.0-develop.0

grant with DEFAULT_ADMIN_ROLE [(/)]

Oleksandr-Laptop% npx msig submitTransaction -a 1 FileStorage grantRole 0x68bf109b95a5c15fb2bb99041323c27d15f8675e11bf7420a1cd6ad64c394f46 0xd2c5b39B4e735C17612Bb5a08FD024ccc5dBCb23 --------------EVENTS-------------- Submission(3) Confirmation(0x1026467C91fdA40aCc7e6935d1E52f67274FD669,3) Execution(3)

Gas used: 369128 Tx hash: 0x5396e51cb587a399fa61b92a0e74da638678ffc335ebe84eb04fd5871af445a0grant without DEFAULT_ADMIN_ROLE [(/)]

Oleksandr-Laptop% npx msig submitTransaction -a 2 FileStorage grantRole 0x68bf109b95a5c15fb2bb99041323c27d15f8675e11bf7420a1cd6ad64c394f46 0xe09ea615c2dd742800437D1BC828853A6C171c04 Error: transaction failed (transactionHash="0x927f7ae1eb7d7cdcf45802ac67afb31100aba86f5eda5b8795d9fbe81ff410c4", transaction={"nonce":2,"gasPrice":{"type":"BigNumber","hex":"0x0186a0"},"gasLimit":{"type":"BigNumber","hex":"0x2dc6c0"},"to":"0xD244519000000000000000000000000000000000","value":{"type":"BigNumber","hex":"0x00"},"data":"0xc6427474000000000000000000000000d2c0deface0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e4b61d27f6000000000000000000000000d3002000000000000000000000000000000000d30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000442f2ff15d68bf109b95a5c15fb2bb99041323c27d15f8675e11bf7420a1cd6ad64c394f46000000000000000000000000e09ea615c2dd742800437d1bc828853a6c171c040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","chainId":1027672650474817,"v":2055345300949670,"r":"0x8f4f2a723fbad43b01839057b18bfb62684116955c96acade1ea3bbe9fbc3a53","s":"0x306226aad5bb4cdbbda8c016bc2346c95ca72dc6b9e56d8a8a1a6d8bd6aa2f39","from":"0xd2c5b39B4e735C17612Bb5a08FD024ccc5dBCb23","hash":"0x927f7ae1eb7d7cdcf45802ac67afb31100aba86f5eda5b8795d9fbe81ff410c4","type":null,"confirmations":0}, receipt={"to":"0xD244519000000000000000000000000000000000","from":"0xd2c5b39B4e735C17612Bb5a08FD024ccc5dBCb23","contractAddress":null,"transactionIndex":0,"gasUsed":{"type":"BigNumber","hex":"0x034ef0"},"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash":"0x4d38b7988b60c7f989e9f358e97b04da4f6838819295eebf80a5c1c25c881a83","transactionHash":"0x927f7ae1eb7d7cdcf45802ac67afb31100aba86f5eda5b8795d9fbe81ff410c4","logs":[],"blockNumber":89519,"confirmations":1,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x034ef0"},"status":0,"type":0,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.5.1) at Logger.makeError (/home/oleksandr/Work/multisigwallet-cli/node_modules/@ethersproject/logger/lib/index.js:199:21) at Logger.throwError (/home/oleksandr/Work/multisigwallet-cli/node_modules/@ethersproject/logger/lib/index.js:208:20) at JsonRpcProvider. (/home/oleksandr/Work/multisigwallet-cli/node_modules/@ethersproject/providers/lib/base-provider.js:1471:36) at step (/home/oleksandr/Work/multisigwallet-cli/node_modules/@ethersproject/providers/lib/base-provider.js:48:23) at Object.next (/home/oleksandr/Work/multisigwallet-cli/node_modules/@ethersproject/providers/lib/base-provider.js:29:53) at fulfilled (/home/oleksandr/Work/multisigwallet-cli/node_modules/@ethersproject/providers/lib/base-provider.js:20:58) at processTicksAndRejections (internal/process/task_queues.js:97:5) { reason: 'transaction failed', code: 'CALL_EXCEPTION', transactionHash: '0x927f7ae1eb7d7cdcf45802ac67afb31100aba86f5eda5b8795d9fbe81ff410c4', transaction: { nonce: 2, gasPrice: BigNumber { _hex: '0x0186a0', _isBigNumber: true }, gasLimit: BigNumber { _hex: '0x2dc6c0', _isBigNumber: true }, to: '0xD244519000000000000000000000000000000000', value: BigNumber { _hex: '0x00', _isBigNumber: true }, data: '0xc6427474000000000000000000000000d2c0deface0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e4b61d27f6000000000000000000000000d3002000000000000000000000000000000000d30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000442f2ff15d68bf109b95a5c15fb2bb99041323c27d15f8675e11bf7420a1cd6ad64c394f46000000000000000000000000e09ea615c2dd742800437d1bc828853a6c171c040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', chainId: 1027672650474817, v: 2055345300949670, r: '0x8f4f2a723fbad43b01839057b18bfb62684116955c96acade1ea3bbe9fbc3a53', s: '0x306226aad5bb4cdbbda8c016bc2346c95ca72dc6b9e56d8a8a1a6d8bd6aa2f39', from: '0xd2c5b39B4e735C17612Bb5a08FD024ccc5dBCb23', hash: '0x927f7ae1eb7d7cdcf45802ac67afb31100aba86f5eda5b8795d9fbe81ff410c4', type: null, confirmations: 0, wait: [Function] }, receipt: { to: '0xD244519000000000000000000000000000000000', from: '0xd2c5b39B4e735C17612Bb5a08FD024ccc5dBCb23', contractAddress: null, transactionIndex: 0, gasUsed: BigNumber { _hex: '0x034ef0', _isBigNumber: true }, logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', blockHash: '0x4d38b7988b60c7f989e9f358e97b04da4f6838819295eebf80a5c1c25c881a83', transactionHash: '0x927f7ae1eb7d7cdcf45802ac67afb31100aba86f5eda5b8795d9fbe81ff410c4', logs: [], blockNumber: 89519, confirmations: 1, cumulativeGasUsed: BigNumber { _hex: '0x034ef0', _isBigNumber: true }, status: 0, type: 0, byzantium: true } }Allocate with ALLOCATOR_ROLE [(/)]

await filestorage.reserveSpace("0xe09ea615c2dd742800437D1BC828853A6C171c04", 8192) { hash: '0x930202f489f8e9db7ab5651ac3298b380b0ebbf73d32ef1aab7d6d0f554e5af6', type: 0, accessList: null, blockHash: '0x08a3fbcdd179d3504be104fa51f6823aa6da820304989d894cbd2870d41fef9c', blockNumber: 89690, transactionIndex: 0, confirmations: 1, from: '0x1026467C91fdA40aCc7e6935d1E52f67274FD669', gasPrice: BigNumber { value: "100000" }, gasLimit: BigNumber { value: "62547" }, to: '0xD3002000000000000000000000000000000000d3', value: BigNumber { value: "0" }, nonce: 24, data: '0x1cfe4e3b000000000000000000000000e09ea615c2dd742800437d1bc828853a6c171c040000000000000000000000000000000000000000000000000000000000002000', creates: null, chainId: 0, wait: [Function] }

eth.getTransactionReceipt("0x930202f489f8e9db7ab5651ac3298b380b0ebbf73d32ef1aab7d6d0f554e5af6") { blockHash: "0x08a3fbcdd179d3504be104fa51f6823aa6da820304989d894cbd2870d41fef9c", blockNumber: 89690, contractAddress: null, cumulativeGasUsed: 61989, from: "0x1026467c91fda40acc7e6935d1e52f67274fd669", gasUsed: 61989, logs: [], logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", status: "0x1", to: "0xd3002000000000000000000000000000000000d3", transactionHash: "0x930202f489f8e9db7ab5651ac3298b380b0ebbf73d32ef1aab7d6d0f554e5af6", transactionIndex: 0 }Allocate without ALLOCATOR_ROLE [(/)]

await filestorage.reserveSpace("0xe09ea615c2dd742800437D1BC828853A6C171c04",8192) { hash: '0xe8d973b4750117851237a09a781f4f14dbdd4ebfc54eebeeb3c2df42eee949a5', type: 0, accessList: null, blockHash: '0x11bb66869a1825d67e7cca4d252aa32aa908f6ed681834c42e41987e03e69343', blockNumber: 89755, transactionIndex: 0, confirmations: 1, from: '0xe09ea615c2dd742800437D1BC828853A6C171c04', gasPrice: BigNumber { value: "100000" }, gasLimit: BigNumber { value: "50000000" }, to: '0xD3002000000000000000000000000000000000d3', value: BigNumber { value: "0" }, nonce: 0, data: '0x1cfe4e3b000000000000000000000000e09ea615c2dd742800437d1bc828853a6c171c040000000000000000000000000000000000000000000000000000000000002000', creates: null, chainId: 0, wait: [Function] }

eth.getTransactionReceipt("0xe8d973b4750117851237a09a781f4f14dbdd4ebfc54eebeeb3c2df42eee949a5") { blockHash: "0x11bb66869a1825d67e7cca4d252aa32aa908f6ed681834c42e41987e03e69343", blockNumber: 89755, contractAddress: null, cumulativeGasUsed: 26464, from: "0xe09ea615c2dd742800437d1bc828853a6c171c04", gasUsed: 26464, logs: [], logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", revertReason: "Caller is not allowed to reserve space", status: "0x0", to: "0xd3002000000000000000000000000000000000d3", transactionHash: "0xe8d973b4750117851237a09a781f4f14dbdd4ebfc54eebeeb3c2df42eee949a5", transactionIndex: 0 }