alastria / alastriaID-truffle-contracts

Alastria ID truffle Smart Contracts
MIT License
2 stars 5 forks source link

Check if the Upgradeability functionality works in the Smart Contracts in the T network #34

Closed VictorNS69 closed 2 years ago

VictorNS69 commented 3 years ago

Check if the Upgradeability functionality works in the Smart Contracts in the T network.

For this task, it is needed to perform the following steps:

  1. Check the actual data in the Smart Contracts (DIDs, roles, public keys and hashes)
  2. Run the update_logic script.
    • Note: If the script does not work, we should fix it.
  3. Execute the examples to test the persistence of the data (DIDs, roles, public keys and hashes)
Anthares101 commented 3 years ago

I tried to execute just that script but i got this:

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

Starting migrations...
======================
> Network name:    'red-t-identity-admin'
> Network id:      83584648538
> Block gas limit: 700000000 (0x29b92700)

6_update_logic.js
=================

Error:  *** Deployment Failed ***

"Eidas" has no address. Has it been deployed?

    at Object.link (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/deployer/src/linker.js:29:1)
    at /home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/deployer/src/actions/link.js:5:1
    at Migration._deploy (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:68:1)
    at Migration._load (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:55:1)
    at Migration.run (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:171:1)
    at Object.runMigrations (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at runMigrations (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:264:1)
    at /home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:231:1
Truffle v5.1.53 (core: 5.1.53)
Node v12.18.2
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! alastria-identity@1.0.0 updateRedT: `truffle migrate --f 6 --to 6 --network=red-t-identity-admin`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the alastria-identity@1.0.0 updateRedT script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/anthares/.npm/_logs/2021-07-05T09_57_31_630Z-debug.log

Is it necessary to execute the rest of the scripts in order to execute this @VictorNS69 ?

VictorNS69 commented 3 years ago

Hi!

I made some changes in the script (https://github.com/alastria/alastriaID-truffle-contracts/commit/eae5812e2ed637278ec456844dc8a50a9d69cf20). These changes worked locally, so you can work on the branch I created, along with the T network.

I still have some questions about this script. Maybe @nefera606 can answer some of them.

  1. At the moment, neither Eidas, nor AlastriaIdentityIssuer, nor AlastriaIdentityServiceProvider are being deployed. What happens if we need to iterate any of them?
  2. Do we want to create another json file with the updated address or we just overwrite the actual one (addresses.json)?
  3. If only one of the contracts is modified, they will all be deployed again, right? Is this the way you want it to work?

Also, I'm not sure if all the changes I made are correct, so please @nefera606 do not hesitate to tell me which aspects we need to correct.

Anthares101 commented 3 years ago

Mmmm looks like the node is having problems:

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

Starting migrations...
======================
> Network name:    'red-t-identity-admin'
> Network id:      83584648538
> Block gas limit: 699999958 (0x29b926d6)

6_update_logic.js
=================
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
  code: -32603,
  message: 'socket hang up',
  data: { originalError: { code: 'ECONNRESET' } },
  stack: 'Error: socket hang up\n' +
    '    at connResetException (internal/errors.js:609:14)\n' +
    '    at Socket.socketOnEnd (_http_client.js:453:23)\n' +
    '    at Socket.emit (events.js:327:22)\n' +
    '    at endReadableNT (_stream_readable.js:1221:12)\n' +
    '    at processTicksAndRejections (internal/process/task_queues.js:84:21)'
})
    at Web3ProviderEngine.emit (events.js:304:17)
    at /home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/@trufflesuite/web3-provider-engine/index.js:57:14
    at afterRequest (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/@trufflesuite/web3-provider-engine/index.js:151:21)
    at /home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/@trufflesuite/web3-provider-engine/index.js:176:21
    at /home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/@trufflesuite/web3-provider-engine/index.js:238:9
    at /home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/async/internal/once.js:12:16
    at replenish (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/async/internal/eachOfLimit.js:61:25)
    at /home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/async/internal/eachOfLimit.js:71:9
    at eachLimit (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/async/eachLimit.js:43:36)
    at /home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/async/internal/doLimit.js:9:16
    at end (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/@trufflesuite/web3-provider-engine/index.js:217:5)
    at Request._callback (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/@trufflesuite/web3-provider-engine/subproviders/rpc.js:36:21)
    at self.callback (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/request/request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.onRequestError (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/request/request.js:877:8)
    at ClientRequest.emit (events.js:327:22)
    at Socket.socketOnEnd (_http_client.js:453:9)
    at Socket.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Anthares101 commented 3 years ago

Ok after the node is up this is the result:

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

Starting migrations...
======================
> Network name:    'red-t-identity-admin'
> Network id:      83584648538
> Block gas limit: 699999958 (0x29b926d6)

6_update_logic.js
=================

Error: Eidas has not been deployed to detected network (network/artifact mismatch)
    at Object.checkNetworkArtifactMatch (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/contract/lib/utils/index.js:249:1)
    at Function.deployed (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:84:1)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at module.exports (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/migrations/6_update_logic.js:36:3)
    at Migration._deploy (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:73:1)
    at Migration._load (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:55:1)
    at Migration.run (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:171:1)
    at Object.runMigrations (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at runMigrations (/home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:264:1)
    at /home/anthares/Projects/alastria/alastriaID-truffle-contracts/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:231:1
nefera606 commented 3 years ago

Could be a problem with the inheritance from the Eidas lib, let us review the Eidas update logic in the script

VictorNS69 commented 3 years ago

We have also detected that it works on my computer, but not on @anthares101's computer. What can this be due to? I did the previous deployments, is that why?

Anthares101 commented 3 years ago

I was able to execute the process with no errors in my computer but looks like the contracts are not getting updated. The process i followed:

  1. npm run compile
  2. npm run migrateToRedT
  3. npm run initRedT
  4. git checkout addresses.json
  5. npm run updateRedT

Im not sure about step 4, maybe im not supposed to do that but i understood that was necessary to avoid problems.

Anthares101 commented 3 years ago

After some @VictorNS69 feedback looks like i was updating a non upgradable contract (Upsi :sweat_smile: ) so i tried again modifying the AlastriaPublicKeyRegistry this time. I edited this function to return just a fixed string instead of the public key:

function getCurrentPublicKey(address subject) view public validAddress(subject) returns (string memory) {
    if (publicKeyList[subject].length > 0) {
        return publicKeyList[subject][publicKeyList[subject].length - 1];
    } else {
        return "";
    }
}
function getCurrentPublicKey(address subject) view public validAddress(subject) returns (string memory) {
    return "Hellojusttesting";
}

After this change i did the upgrade process:

  1. npm run compile
  2. npm run migrateToRedT
  3. npm run initRedT
  4. git checkout addresses.json
  5. npm run updateRedT

And tested the function with the examples:

node 1.getSubject1CurrentPublicKey.js                                                                                                                                              
RESULT -----> Hellojusttesting

I reverted the changes to the contract, upgrade it again and tested the same example one more time:

node 1.getSubject1CurrentPublicKey.js                                                                                                                                              
RESULT -----> 2e507af01167c98a6accc0cd46ab2a256dd6b6c69ec1c0c28f80fb62e1f7d70233768b0c58dbbdac1fc358b8141c075a520483cf9779e4ea98d13df2833f3767

So looks like everything is working as it should

VictorNS69 commented 3 years ago

That's a good test for me!

@nefera606 do you think we need to test something more deeper? Or maybe we can close this issue and mark it as complete?

PS: very good job @anthares101

VictorNS69 commented 2 years ago

The evidences have been deemed sufficient and we therefore close this issue.