Skip to content
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

bug: transactions for functions that use block.timestamp in require() statements incorrectly fails during gas estimate #1135

Open
swetshaw opened this issue May 30, 2024 · 2 comments
Labels
bug Inconsistencies or issues which will cause a problem for users or implementors.

Comments

@swetshaw
Copy link
Contributor

Bug Report

Kakarot RPC version:
0.6.16

Current behavior:

Transactions for functions that use block.timestamp in require() statements incorrectly fails during gas estimate. When passed a gasLimit (gas estimation step is skipped), the transactions go through.

Expected behavior:

The transactions should go through even when no gasLimit is sent along with the tx.

Steps to reproduce:

  1. Copy paste the following code in Remix
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract BlockTimestampDemo {
    uint256 public timestamp;
    mapping(address => uint256) public lastClaimTimes;
    uint256 cooldownDuration = 20;

    function claim() public {
        timestamp = block.timestamp;

        require(block.timestamp >= (lastClaimTimes[msg.sender] + cooldownDuration), "Claim too soon!");

        lastClaimTimes[msg.sender] = block.timestamp;
    }

    function getBlockNumber() public view  returns (uint256)  {
        return block.number;
    }
}
  1. Deploy the contract and call the claim() function. The transaction will be successful first time
  2. Call claim function again after 20 seconds (cooldown period), this time it should popup the following Gas estimation error message:
Screenshot 2024-05-29 at 6 38 31 PM
  1. Go ahead and click on Send Transaction, the transaction will go through
  2. Call claim() function again but this time pass gas manually. The transaction should go through this time as well.

Note: Make sure no new blocks are created or transaction executed in between steps 2 and 3 and in between step 4 and 5

@swetshaw swetshaw added the bug Inconsistencies or issues which will cause a problem for users or implementors. label May 30, 2024
@tcoratger
Copy link
Collaborator

@swetshaw is this one still relevant or not after all the updates?

@Eikix
Copy link
Member

Eikix commented Oct 2, 2024

What is the status of this @swetshaw?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Inconsistencies or issues which will cause a problem for users or implementors.
Projects
Status: 🆕 Backlog
Development

No branches or pull requests

3 participants