Change smart contract hash computation#2240
Conversation
|
It'll work, but I'm still a little worried about these contracts having the same name. It'd be nice to get |
| } | ||
|
|
||
| [ContractMethod(0, CallFlags.WriteStates | CallFlags.AllowNotify)] | ||
| private ContractState CreateChild(ApplicationEngine engine, StackItem data) |
There was a problem hiding this comment.
We don't need to create this method, right? We can create a new child contract in contract/script directly, by this following way.
var contract = ContractManagement.GetContract(hash)
ContractManagement.Deploy(contract.nef, contract.manifest, data)
There was a problem hiding this comment.
The problem is that the sender of the transaction could be the same. Then it will generate the same hash.
There was a problem hiding this comment.
|
Now do we still need |
Agree it's a very specific case, and now it can be solved. |
This is the tricky part, because manifest is returned as a JSON string from |
Use |
Use #2237 to fix it? Create a new deploy method: |
|
Or create a new method, like |
I think that change the name it's easy with the json syscalls |
| sb.Emit(OpCode.ABORT); | ||
| sb.EmitPush(sender); | ||
| sb.EmitPush(script); | ||
| sb.EmitPush(nefCheckSum); |
There was a problem hiding this comment.
Shouldn`t the checksum be calculated?
| Assert.AreEqual("0xb8e95ff7b11c427c29355e3398722d97bd2ca069", Neo.SmartContract.Helper.GetContractHash(UInt160.Zero, nef.Script).ToString()); | ||
| Assert.AreEqual("0x435c467b8e15cb9b1474ad7ee817ffdcfededef9", Neo.SmartContract.Helper.GetContractHash(UInt160.Parse("0xa400ff00ff00ff00ff00ff00ff00ff00ff00ff01"), nef.Script).ToString()); | ||
| Assert.AreEqual("0x9b9628e4f1611af90e761eea8cc21372380c74b6", Neo.SmartContract.Helper.GetContractHash(UInt160.Zero, nef.CheckSum, "").ToString()); | ||
| Assert.AreEqual("0x66eec404d86b918d084e62a29ac9990e3b6f4286", Neo.SmartContract.Helper.GetContractHash(UInt160.Parse("0xa400ff00ff00ff00ff00ff00ff00ff00ff00ff01"), nef.CheckSum, "").ToString()); |
There was a problem hiding this comment.
Why are they called "" instead of Neo and Gas?
It allows to deploy the same NEF using one sender and get different contract hashes. See neo-project/neo#2240.
* CreateChild * Change to checkSum * Remove nonce * Change manifest to name * Remove new method * Clean changes
Close #2233
Idea comes from : #2233 (comment)