Simple on-chain Random Number
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
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.
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
The
TransactionSequenceInfoalready in the TxContexthttps://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.