Copy Abi into nef file and use nef for scriptHash#1973
Copy Abi into nef file and use nef for scriptHash#1973
Conversation
|
@erikzhang please take a look, I included only the Abi, the manifest it was thought to be modified in order to add some rights, but the abi should be changed only if the script change. So how can the developer change the manifest before create the nef file? We can remove Abi from the manifest and add the Abi inside |
|
Any update? |
|
There is no way to compute the hash in the ABI. Maybe we should remove it. |
roman-khimov
left a comment
There was a problem hiding this comment.
If we're to go this route then maybe it's easier to put full manifest inside NEF, it'd simplify things a bit for deployment/updates and ContractState will have it too.
There is a more wild idea wrt #1961/#1964 though (or maybe that was meant by #1961 (comment)). Every deployed contract has an ID, storage is using that for keys since #1400, maybe it's time to use it also for invocations/verifications/addresses? We get contracts by hash in the following situations:
- to create a callback
- to perform a call
- to find witness script
- to create/update contract
- to return it to the script from
GetContractinterop - to check it for
IsStandardinterop - to check for existence in oracle contract
- to answer an RPC request
We delete them on update or destroy. Imagine all of the above use cases with an ID instead of a hash (for calls that would be 4-byte IDs, for witnesses 20-byte with lots of zeroes). The only problematic case I see is IsStandard, but even that is probably OK (and this patch breaks it too anyway).
Script (ABI/NEF/whatever) hash is also an address and contracts can receive some tokens to it, but NKuyBkoGdZZSLyPbJEetheRhMjezqzTxcW/NKuyBkoGdZZSLyPbJEetheRhMjezwhg9vh/NKuyBkoGdZZSLyPbJEetheRhMjf17rTWMC/etc are good enough for that purpose.
Collisions? Probably not that different to the current situation.
Maybe I'm missing something, but using IDs can also be an option and it will allow to keep scripts/abi/nefs as is.
Done, but we need it in manifest for check if it's a valid call so I moved it to Manifest. |
If you want to update only the manifest, for change rights, you will need a new script?
I like the idea of use the id instead of the hash in some cases (for optimization), but how it solves the main problem? |
I thought we're to change from script hash to NEF hash effectively (at least that's my interpretation of #1961 (comment)), thus change in the manifest changes the NEF and the hash. Am I missing something?
By the ability to differentiate script hashes from IDs? I mean regular scripts would have script hash as a signer, for example NTZJ91cwZWiad8uj8sLMF7X6j8Ed41Cim6 (41546d4fee9fe73744a08fc5055d76a88b17d853), this can't be contract ID, thus it must have a corresponding verification script attached and we won't look into the DB for it. Now NKuyBkoGdZZSLyPbJEetheRhMjezqzTxcW (0100000000000000000000000000000000000000) is the opposite, it can't be a hash (sure, technically it can, but good luck with that), so it must not have any verification script and we will take contract №1 to verify that. I know it sounds a bit fishy, but I can't find where this approach breaks. |
|
Then we need to remove ABI from manifest. |
I'll test this after neo-devpack-dotnet is updated. |
|
Please take a look to neo-project/neo-devpack-dotnet#378 |
Find CLI also should be modified: https://github.com/neo-project/neo-node/blob/90c7f396df2ac52c4ced880c433d286719e578ce/neo-cli/CLI/MainService.cs#L284 |
Did you use a nef file? |
|
@superboyiii It's a new generated nef file? Could you send me by discord your nef and manifest? |
|
|
Sure. I upload the whole project here so that you could find the issue clearly. https://packet.azureedge.net/neochain/neo3/neo-PR#1973.zip |
Yes, |
Yes, for me is |
|
@superboyiii I will wait for #2021 because maybe we choose a different fix |
Fine. But I think this feature might be included in the version after Preview4 because not much time left for release. Do you think it's OK? |
I think that it's the most important one in preview4 🤣 |
Then we have to delay Preview4 for several weeks. Only one week left.🤣 |
|
@superboyiii We only need to discuss #2021 and we can move foreward. |
|
This or #2021 are very invasive things, so independent of what's going to be the accepted solution it needs as much testing as we could provide. And preview4 is exactly for that, testing in a wider setting, so I'd rather wait a little, but settle this before preview4. |
|
Closed in favor of #2044 |
* Copy abi to nef Related: neo-project/neo#1973, neo-project/neo-devpack-dotnet#378 * Update neo-cli/CLI/MainService.cs * Fix deploy * fix contract hash (#680) * update to neo * Use helper * Clean usings Co-authored-by: Shargon <shargon@gmail.com> Co-authored-by: Vitor Nazário Coelho <vncoelho@gmail.com> Co-authored-by: Luchuan <luchuan@ngd.neo.org>



Related to #1961 (comment)
Produce changes in neo-project/proposals#121 (review)
Close #2002