-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: support Uuid type and sha1_calculate API #145
Conversation
0.8.2 does not support wasm32 target.
The version of schemars dependency has been updated by uuid. Changes of regeneration following schemars update.
a15917c
to
e42ec38
Compare
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.
In general, LGTM!
I added some comments about the code.
tested the longest name and it requires a larger input. Optimize the format and re-edit to the limit.
Changed the input limit from 40bytes to 80bytes as needed.(avg 266ns -> 270ns) So the gas cost is similar. |
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.
LGTM
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.
LGTM!
Description
Closes #141
Support
Uuid
for a clear unique id type.Usually,
Uuidv4
is used the most, but v4 is based on random.So Use internally
Uuidv5
andNAMESPACE_OID
.The name is combined with
contract address
,block height
, andincrease-sequential(u16)
.Add
sha1
crypto native API.Uuidv5
uses internallysha1
.However, crypto-related calls in the contract usually cost expensive gas.
And As crypto function code is compiled into wasm code, there is a performance degradation compared to native.
So put a limit on the hash input, we can relax this later as needed.
Add the example contract '
voting-with-uuid
' for usage examples and gas consumption measurement.As per the table, the gas consumption increased by the using hash function.
This even includes the cost of
uuid.to_string()
in attributes. Excluding this, the actual cost of uuid is lower.Types of changes
Checklist