-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[RFC] Add native function create_uuid #8401
Conversation
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.
you'll need move changes to be able to test it end to end
check how other native functions are tested, and potentially add a test there - i.e. that calling this on different transactions or multiple times in the same transaction, it gives different results.
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.
Cool stuff. Overall the code matches a lot of what I expected. Could we push this to an AIP quickly to discuss how we might migrate from the current account guid concept to the transaction guid?
Furthermore, it makes me wonder in what circumstances we might be blocked on really considering to use this. For example, events would still benefit from either aggregators or eliminating the sequence numbers all together. Objects could immediately make use of this. Though one could argue then the object could be further improved by eliminating the legacy GUID field from object core.
Added a unit test that creates 50 GUIDs in a transaction and verifies that all of them are unique. |
Another thing to contemplate. We already have a framework for defining GUIDs as an address plus an integer. Would it make more sense to follow that paradigm rather than define a new paradigm and have to port everything over? I'm a little stuck on the hassle it would be to introduce a new GUID type. |
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.
let's get alignment on what a proper next-gen guid is prior to landing this.
@@ -1,4 +1,7 @@ | |||
module aptos_framework::transaction_context { | |||
/// Return a globally unique identifier | |||
public native fun create_guid(): address; |
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.
Or provide get_tx_hash()
and guid_counter()
native functions, and implement the create_guid()
in Move
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.
If we go that route, then we can explore multiple solutions and leave it more to the user to dictate their preferred approach.
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.
Isn't it generally preferable to provide as simple interface as possible, and reduce the cognitive load on the smart contract developer? In terms of functionality, the developer would achieve the same with both the options, but the developer has to put more effort into how to construct GUIDs if we expose get_tx_hash
and guid_counter
without an additional benefit.
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 get_tx_hash
is helpful in many scenarios, guid_counter
may be just for the create_guid
. And I think the new_table_handle
is repeated with create_guid
; if we do not reuse the guid_counter
, it will produce the repeat table_handle
and guid
.
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.
@jolestar - more details on the choice : https://www.notion.so/aptoslabs/Move-Parallelism-for-MetaPixel-982afa7c10ca494fad235fd1aa4318f4?pvs=4#d87bb42cc7a648d39fa3e699a4fffd35
guid_counter is scoped separately, while table_handle isn't
if we introduce a new API I would use this as opportunity to call this UUID (instead of GUID), which is the much more common term used in other programming languages and libs. |
I have made a few changes in object.move to utilize the new |
Oh, btw, please make an effort to ensure that GUID hashes are domain separated from everything else in Rust and Move. See "Current domain-separation for hashing and signatures" in Notion. |
* Add create_token method in token.move * add deprecated flag to create_token_from_account * Add test case and rename to create * Add feature flag condition in test case * enabled feature flag in the unit test * Enabling auid feature flag in ambassador unit tests
@@ -83,6 +83,7 @@ spec aptos_framework::staking_config { | |||
} | |||
|
|||
spec calculate_and_save_latest_epoch_rewards_rate(): FixedPoint64 { | |||
pragma verify_duration_estimate = 120; |
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.
what is this for?
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.
Yesterday, I got some move prover test errors in Github actions. I think Junkil added this to fix those errors.
aptos-move/framework/aptos-framework/sources/transaction_context.move
Outdated
Show resolved
Hide resolved
} | ||
|
||
/// Return the transaction hash of the current transaction | ||
public native fun get_txn_hash(): vector<u8>; |
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.
even though we are not using it, does this need to be gated?
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 couldn't really think of a reason to gate it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
* Add native function create_guid * Append a constant to hash_arg * Add move test to verify uniqueness of guids * Charging gas for create_guid method * Add gas for create guid * Add create_guid to object.move * Change GUID to UUID * Change GUID to UUID in tests * Change GUID to UUID in tests * Add create_object method in object.move * Fix typo * Fix typo * fix trigger condition for build jobs * Add native_get_txn_hash * Add native_get_txn_hash * Deprecate the old create_object_from_object and create_object_from_account * Bumped the latest_gas_version to 10 * Bumped gas version to 10 * Changed gas feature version to 9 * Moved transaction hash hashing to authenticator.rs * Add documentation to create_uuid method * Use AuthenticationKey struct for create_uuid * Remove deprecated comment * Updatd comments in object.move * Changed create_uuid to use only one hash * Add create_unique_address function * Add drop, store capabilities to UUID * Resetting the create_object_from_account function * Add comment for create_object function * feature gating * deprecated tag * Add transaction context spec * Add a test case in transaction_context * Updated move test case * Add create_token method * Update test cases * rust lint * Changed comments * Remove create_token method * Add feature flag for test * fix a unit test * Fix unit test * moved unit test to object.move * changing uuid to auid * rust lint * Minor changes * Change uuid to auid in tests * Change uuid to auid in tests * changed name to generate_unique_address * Fixed the specs which timeout * Fixed a unit test * Shift test from e2e-move-tests to transaction_context.move * Add a comment in object.move * rust lint * Add create_token method in token.move (#8825) * Add create_token method in token.move * add deprecated flag to create_token_from_account * Add test case and rename to create * Add feature flag condition in test case * enabled feature flag in the unit test * Enabling auid feature flag in ambassador unit tests * Enable auid flag in an ambassador.move unit test * Changed gas cost * changed name from generate_unique_address to generate_auid_address * Updated a comment * Feature gate get_txn_hash * changing names in test cases --------- Co-authored-by: geekflyer <[email protected]> Co-authored-by: Junkil Park <[email protected]>
Description
Add native function
create_uuid
toNativeTransactionContext
. This function will create a universally unique identifier by hashingSessionId || uuid_counter
. These universally unique identifiers are helpful when assigning universally unique names for objects in Token V2 standard.