rooch icon indicating copy to clipboard operation
rooch copied to clipboard

Simple on-chain Random Number

Open jolestar opened this issue 2 years ago • 4 comments

seed = hash(tx_accumulator_root + now_milliseconds + sender::address + sender_account::sequence_number)

When users send transactions, they are not sure of the accumulator order of their transactions, so there is a certain level of randomness.

Refs

  • https://github.com/movefuns/movefuns/blob/main/starcoin/sources/PseudoRandom.move

jolestar avatar Sep 08 '23 07:09 jolestar

I'll take a look and resolve for this issue.

How do we calculate tx_accumulator_root? Do we get it in TransactionSequenceInfo from rooch db and hash it using move lang? Should we write it one in .move file? Cuz I didn't see there's a struct for tx_accumulator_root in move.

We need to put it into the TxContext and do some refactoring.

For simpler, we can maintain a random number sequence number in Move.

jolestar avatar Oct 19 '23 01:10 jolestar

We need to put it into the TxContext and do some refactoring.

For simpler, we can maintain a random number sequence number in Move.

Progress: #1052

The TransactionSequenceInfo already in the TxContext

https://github.com/rooch-network/rooch/blob/021a8ba0a88a255e14341e6e73c2b370a582a6ef/frameworks/rooch-framework/sources/transaction_validator.move#L130

jolestar avatar Jul 16 '24 11:07 jolestar

The TransactionSequenceInfo already in the TxContext

https://github.com/rooch-network/rooch/blob/021a8ba0a88a255e14341e6e73c2b370a582a6ef/frameworks/rooch-framework/sources/transaction_validator.move#L130

Okay. Got it.

rooch/frameworks/rooch-framework/sources/transaction_validator.move

This function quotes from rooch_framework. Are we supposed to import rooch_framework move dependencies in MoveosStdlib toml pkg?

rooch/frameworks/rooch-framework/sources/transaction_validator.move

This function quotes from rooch_framework. Are we supposed to import rooch_framework move dependencies in MoveosStdlib toml pkg?

Put the simple random module in the rooch_framework.

jolestar avatar Jul 22 '24 01:07 jolestar