-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: force
prevrandao
on Moonbeam networks (#9489)
* chore: force prevrandao * add test for fix * fix forge fmt --------- Co-authored-by: zerosnacks <[email protected]> Co-authored-by: zerosnacks <[email protected]>
- Loading branch information
1 parent
a4de7e8
commit c161c7c
Showing
4 changed files
with
44 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity ^0.8.18; | ||
|
||
import "ds-test/test.sol"; | ||
import "cheats/Vm.sol"; | ||
|
||
// https://github.com/foundry-rs/foundry/issues/4232 | ||
contract Issue4232Test is DSTest { | ||
Vm constant vm = Vm(HEVM_ADDRESS); | ||
|
||
function testFork() public { | ||
// Smoke test, worked previously as well | ||
vm.createSelectFork("sepolia", 7215400); | ||
vm.assertFalse(block.prevrandao == 0); | ||
|
||
// Would previously fail with: | ||
// [FAIL: backend: failed while inspecting; header validation error: `prevrandao` not set; `prevrandao` not set; ] setUp() (gas: 0) | ||
// | ||
// Related fix: | ||
// Moonbeam | Moonbase | Moonriver | MoonbeamDev => { | ||
// if env.block.prevrandao.is_none() { | ||
// // <https://github.com/foundry-rs/foundry/issues/4232> | ||
// env.block.prevrandao = Some(B256::random()); | ||
// } | ||
// } | ||
// | ||
// Note: public RPC node used for `moonbeam` discards state quickly so we need to fork against the latest block | ||
vm.createSelectFork("moonbeam"); | ||
vm.assertFalse(block.prevrandao == 0); | ||
} | ||
} |