-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue related to chain cloning (#564)
* preliminary commit * optimization bug fix * add base block context * fix cheatcode bugs, add prevrandao, and deprecate difficulty * revert version number * fix optimization mode bug * update solc version in CI * update solc version again * fix context management * fix context bug and improve logging while shrinking * enable fork mode when --rpc-url is specified * update documentation * last update * i genuinely hate prettier * update docs
- Loading branch information
Showing
32 changed files
with
278 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package types | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
// BaseBlockContext stores block-level information (e.g. block.number or block.timestamp) when the block is first | ||
// created. We need to store these values because cheatcodes like warp or roll will directly modify the block header. | ||
// We use these values during the cloning process to ensure that execution semantics are maintained while still | ||
// allowing the cheatcodes to function as expected. We could expand this struct to hold additional values | ||
// (e.g. difficulty) but we will ere to add values only as necessary. | ||
type BaseBlockContext struct { | ||
// Number represents the block number of the block when it was first created. | ||
Number *big.Int | ||
// Time represents the timestamp of the block when it was first created. | ||
Time uint64 | ||
// BaseFee represents the base fee of the block when it was first created. | ||
BaseFee *big.Int | ||
// Coinbase represents the coinbase of the block when it was first created. | ||
Coinbase common.Address | ||
} | ||
|
||
// NewBaseBlockContext returns a new BaseBlockContext with the provided parameters. | ||
func NewBaseBlockContext(number uint64, time uint64, baseFee *big.Int, coinbase common.Address) *BaseBlockContext { | ||
return &BaseBlockContext{ | ||
Number: new(big.Int).SetUint64(number), | ||
Time: time, | ||
BaseFee: new(big.Int).Set(baseFee), | ||
Coinbase: coinbase, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# `prevrandao` | ||
|
||
## Description | ||
|
||
The `prevrandao` cheatcode updates the `block.prevrandao`. | ||
|
||
## Example | ||
|
||
```solidity | ||
// Obtain our cheat code contract reference. | ||
IStdCheats cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); | ||
// Change value and verify. | ||
cheats.prevrandao(bytes32(uint256(42))); | ||
assert(block.prevrandao == 42); | ||
``` | ||
|
||
## Function Signature | ||
|
||
```solidity | ||
function prevrandao(bytes32) external; | ||
``` |
Oops, something went wrong.