-
Notifications
You must be signed in to change notification settings - Fork 102
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
Sync neo changes #391
Sync neo changes #391
Changes from 6 commits
4c2e79d
f5f161b
38e0590
9c8e7db
5379d41
7ad9b72
4448877
cc4cced
88fa514
6947047
c0db531
f4df31a
2ec0748
9894e83
821f834
057d5ba
9e79f27
af62c81
32905b6
1650325
afad1b1
425718f
ecdb308
0fafec4
0633281
3de92ed
9110b42
ba8a716
c496fe8
da701ad
2e4fc2c
1cfec66
e1eff81
560e161
0ef68d9
b7d657a
c75bb6b
a33b14b
d1d2300
0b9fd67
0c27e44
e3d02dc
5db20de
ad2d89e
c903184
882a721
bd4c246
8d0d298
493b278
15f9de1
8d1e266
0823a31
7992c3a
befe380
a572293
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,28 +64,15 @@ internal static string ConvType(TypeReference t) | |
return "Unknown:" + type; | ||
} | ||
|
||
public static string ComputeHash(byte[] script) | ||
{ | ||
var sha256 = System.Security.Cryptography.SHA256.Create(); | ||
byte[] hash256 = sha256.ComputeHash(script); | ||
var ripemd160 = new Neo.Cryptography.RIPEMD160Managed(); | ||
var hash = ripemd160.ComputeHash(hash256); | ||
|
||
StringBuilder sb = new StringBuilder(); | ||
sb.Append("0x"); | ||
for (int i = hash.Length - 1; i >= 0; i--) | ||
{ | ||
sb.Append(hash[i].ToString("x02")); | ||
} | ||
return sb.ToString(); | ||
} | ||
|
||
public static JObject Export(NeoModule module, byte[] script, Dictionary<int, int> addrConvTable) | ||
{ | ||
var outjson = new JObject(); | ||
|
||
//hash | ||
outjson["hash"] = ComputeHash(script); | ||
//name | ||
outjson["name"] = module.attributes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the https://github.com/neo-project/neo/pull/2024/files#diff-6a8fe6159fb062d52f619635b6c0e2123632e3a61acdc5f86b867da878af2e02R166, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I am not sure, maybe it's more appropriate to put the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
.Where(u => u.AttributeType.FullName == "Neo.SmartContract.Framework.ManifestNameAttribute") | ||
.Select(u => (string)u.ConstructorArguments.FirstOrDefault().Value) | ||
.FirstOrDefault() ?? ""; | ||
|
||
shargon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//functions | ||
var methods = new JArray(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace Neo.SmartContract.Framework | ||
{ | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] | ||
public class ManifestNameAttribute : Attribute | ||
erikzhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
public string Value { get; set; } | ||
|
||
public ManifestNameAttribute(string value) | ||
{ | ||
Value = value; | ||
} | ||
} | ||
} |
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.
@devhawk do you need the name in
debugExport
?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.
I need whatever unique identifier is used to identify the contract.
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.
Is there a design document describing how contract deploy and invoke is supposed to work now? I am all for having a stable contract identifier other than the script hash, though it's not clear what the new design is?
One question - Have we considered the impact on dynamic contract invocations scenarios. Using script hash to invoke a contract means that any calling contracts break when a dependent contract is updated. That is, I was calling a specific contract by script hash it will be obvious something has changed if that script hash is no longer valid. With a stable identifier, will it still be obvious if a dependent contract has made a backwards incompatible change?
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.
Hi @devhawk, thinking in this perspective you mentioned, it may be important to create a flag that says that the contract trust any update on the dynamic invoked contract.
For instance, most of the DeFi projects are relying on external dynamic invoked contracts. In this sense, consider the need of mutual update is something plausible.
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.
I would expect that dynamic invoke scenarios always require "mutual update" as you called it @vncoelho. I'm not sure it's a good idea to make the change less obvious. Right now, if you update your contract it breaks anyone who calls it since the hash changes. If we keep the hash, will that allow a developer to publish a malicious contract update w/o their users noticing?