-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
@@ -120,11 +121,30 @@ public IEnumerable<ContractState> ListContracts(StoreView snapshot) | |||
return snapshot.Storages.Find(listContractsPrefix).Select(kvp => kvp.Value.GetInteroperable<ContractState>()); | |||
} | |||
|
|||
[ContractMethod(0, CallFlags.WriteStates | CallFlags.AllowNotify)] | |||
private ContractState CreateChild(ApplicationEngine engine, StackItem data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
{ | ||
using var sb = new ScriptBuilder(); | ||
sb.Emit(OpCode.ABORT); | ||
sb.EmitPush(sender); | ||
sb.EmitPush(script); | ||
sb.EmitPush(nefCheckSum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)