-
Notifications
You must be signed in to change notification settings - Fork 273
Closed
Description
Describe the bug
I'm seeing an issue after the Titan upgrade where contracts that use random number generation in solidity are not working. The transaction gets submitted but never gets picked up by the blockchain or indexed. The cro value and gas seem to be taken out of the account though. I can't provide a tx hash since it is never indexed. This issue seems isolated to using a random number generation function in a contract from what I can tell. Potentially one of the properties off block?
Here is an example of a random number generation function that causes the issue:
function getRandomAvailableTokenId(address to, uint updatedNumAvailableTokens)
internal
returns (uint256)
{
uint256 randomNum = uint256(
keccak256(
abi.encode(
to,
tx.gasprice,
block.number,
block.timestamp,
block.difficulty,
blockhash(block.number - 1),
address(this),
updatedNumAvailableTokens
)
)
);
uint256 randomIndex = (randomNum % updatedNumAvailableTokens) + 1;
return getAvailableTokenAtIndex(randomIndex, updatedNumAvailableTokens + 1);
}```
**Expected behavior**
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
Any
**Smartphone (please complete the following information):**
Any
**Additional context**
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
No labels