Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fork mainnet at the specified block number but the timestamp is not matched with it #3186

Open
kl456123 opened this issue Jun 6, 2022 · 14 comments
Milestone

Comments

@kl456123
Copy link

kl456123 commented Jun 6, 2022

No description provided.

@kl456123
Copy link
Author

kl456123 commented Jun 6, 2022

now I have to specify chain.time manually before start forknet to force it

@davidmurdoch
Copy link
Member

What version of Ganache?

@kl456123
Copy link
Author

kl456123 commented Jun 6, 2022

What version of Ganache?

v7.1.0

@davidmurdoch
Copy link
Member

What command are you using?

@kl456123
Copy link
Author

kl456123 commented Jun 7, 2022

What command are you using?

use chain.time to set timestamp in options

@kl456123
Copy link
Author

kl456123 commented Jun 7, 2022

 const options = {                                                                                          
      fork: {                                                                                                  
        url: getUrl(swapParam.chainId),                                                                        
        blockNumber: swapParam.blockNumber,                                                                    
      },                                                                                                       
      wallet: { unlockedAccounts },                                                                                                                                               
      chain: {time},                                                                                               
    };

@davidmurdoch
Copy link
Member

How are you determining that the time is wrong?

@kl456123
Copy link
Author

kl456123 commented Jun 7, 2022

otherwise I will get revert due to timestamp checks

@kl456123
Copy link
Author

kl456123 commented Jun 7, 2022

This is the expiration check.

modifier isExpired(uint256 deadLine) {
    require(deadLine >= block.timestamp, "Route: expired");
     _;
}

@davidmurdoch
Copy link
Member

Ah, ganache uses your system time by default, even for forked blocks. We'll be adding a new option, miner.timestampIncrement, that will let you tell ganache how many seconds apart you want your blocks to be. Here is the PR for the feature: #3131

This got me thinking that when forking we really should probably always set the time to the for block's timestamp (unless the user set a different time). 🤔

@kl456123
Copy link
Author

kl456123 commented Jun 7, 2022

Ah, ganache uses your system time by default, even for forked blocks. We'll be adding a new option, miner.timestampIncrement, that will let you tell ganache how many seconds apart you want your blocks to be. Here is the PR for the feature: #3131

This got me thinking that when forking we really should probably always set the time to the for block's timestamp (unless the user set a different time). 🤔

Yep, If that, it will not make any more confusion.:smiley:

@StillFantastic
Copy link

Agree, it makes more sense to use forked blocks' timestamp

@cliffoo
Copy link

cliffoo commented Jul 7, 2022

#3131 is merged! Closing for Issue Maintenance. Thanks for opening this 🙂

@cliffoo cliffoo closed this as completed Jul 7, 2022
@davidmurdoch
Copy link
Member

Reopening as I do think it makes sense for the default behavior to be based off of the forked blocks timestamp. Though this might have to wait until Ganache v8.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Backlog
Development

No branches or pull requests

5 participants