Commit dd4bf9cd authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #3862 from ethereum-optimism/vm-bound

Update forge-std and use bound instead of vm.assume
parents 29cee901 f49b71d5
---
'@eth-optimism/indexer': patch
'@eth-optimism/contracts-bedrock': patch
'@eth-optimism/contracts-periphery': patch
---
Updated forge-std version
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
pragma solidity 0.8.15; pragma solidity 0.8.15;
/* Testing utilities */ /* Testing utilities */
import { Test } from "forge-std/Test.sol"; import { Test, StdUtils } from "forge-std/Test.sol";
import { L2OutputOracle } from "../L1/L2OutputOracle.sol"; import { L2OutputOracle } from "../L1/L2OutputOracle.sol";
import { L2ToL1MessagePasser } from "../L2/L2ToL1MessagePasser.sol"; import { L2ToL1MessagePasser } from "../L2/L2ToL1MessagePasser.sol";
import { L1StandardBridge } from "../L1/L1StandardBridge.sol"; import { L1StandardBridge } from "../L1/L1StandardBridge.sol";
......
...@@ -4,7 +4,7 @@ pragma solidity 0.8.15; ...@@ -4,7 +4,7 @@ pragma solidity 0.8.15;
import { CommonTest, Portal_Initializer } from "./CommonTest.t.sol"; import { CommonTest, Portal_Initializer } from "./CommonTest.t.sol";
import { CrossDomainOwnable } from "../L2/CrossDomainOwnable.sol"; import { CrossDomainOwnable } from "../L2/CrossDomainOwnable.sol";
import { AddressAliasHelper } from "../vendor/AddressAliasHelper.sol"; import { AddressAliasHelper } from "../vendor/AddressAliasHelper.sol";
import { Vm } from "forge-std/Vm.sol"; import { Vm, VmSafe } from "forge-std/Vm.sol";
import { Bytes32AddressLib } from "@rari-capital/solmate/src/utils/Bytes32AddressLib.sol"; import { Bytes32AddressLib } from "@rari-capital/solmate/src/utils/Bytes32AddressLib.sol";
contract XDomainSetter is CrossDomainOwnable { contract XDomainSetter is CrossDomainOwnable {
...@@ -62,11 +62,11 @@ contract CrossDomainOwnableThroughPortal_Test is Portal_Initializer { ...@@ -62,11 +62,11 @@ contract CrossDomainOwnableThroughPortal_Test is Portal_Initializer {
// Simulate the operation of the `op-node` by parsing data // Simulate the operation of the `op-node` by parsing data
// from logs // from logs
Vm.Log[] memory logs = vm.getRecordedLogs(); VmSafe.Log[] memory logs = vm.getRecordedLogs();
// Only 1 log emitted // Only 1 log emitted
assertEq(logs.length, 1); assertEq(logs.length, 1);
Vm.Log memory log = logs[0]; VmSafe.Log memory log = logs[0];
// It is the expected topic // It is the expected topic
bytes32 topic = log.topics[0]; bytes32 topic = log.topics[0];
......
...@@ -21,19 +21,20 @@ contract Hashing_Test is CommonTest { ...@@ -21,19 +21,20 @@ contract Hashing_Test is CommonTest {
} }
function test_hashCrossDomainMessage_differential( function test_hashCrossDomainMessage_differential(
uint256 _nonce, uint240 _nonce,
uint16 _version,
address _sender, address _sender,
address _target, address _target,
uint256 _value, uint256 _value,
uint256 _gasLimit, uint256 _gasLimit,
bytes memory _data bytes memory _data
) external { ) external {
// Discard any fuzz tests with an invalid version // Ensure the version is valid
(, uint16 version) = Encoding.decodeVersionedNonce(_nonce); uint16 version = uint16(bound(uint256(_version), 0, 1));
vm.assume(version < 2); uint256 nonce = Encoding.encodeVersionedNonce(_nonce, version);
bytes32 _hash = ffi.hashCrossDomainMessage( bytes32 _hash = ffi.hashCrossDomainMessage(
_nonce, nonce,
_sender, _sender,
_target, _target,
_value, _value,
...@@ -42,7 +43,7 @@ contract Hashing_Test is CommonTest { ...@@ -42,7 +43,7 @@ contract Hashing_Test is CommonTest {
); );
bytes32 hash = Hashing.hashCrossDomainMessage( bytes32 hash = Hashing.hashCrossDomainMessage(
_nonce, nonce,
_sender, _sender,
_target, _target,
_value, _value,
......
...@@ -711,17 +711,18 @@ contract OptimismPortal_FinalizeWithdrawal_Test is Portal_Initializer { ...@@ -711,17 +711,18 @@ contract OptimismPortal_FinalizeWithdrawal_Test is Portal_Initializer {
uint256 _gasLimit, uint256 _gasLimit,
bytes memory _data bytes memory _data
) external { ) external {
vm.assume(_target != address(op)); // Cannot call the optimism portal. // Cannot call the optimism portal
vm.assume(_value < 200_000_000 ether); // Total ETH supply is currently ~120M ETH. vm.assume(_target != address(op));
vm.assume(_gasLimit < 50_000_000); // Total ETH supply is currently about 120M ETH.
uint256 value = bound(_value, 0, 200_000_000 ether);
uint256 _nonce = messagePasser.nonce(); uint256 gasLimit = bound(_gasLimit, 0, 50_000_000);
uint256 nonce = messagePasser.nonce();
Types.WithdrawalTransaction memory _tx = Types.WithdrawalTransaction({ Types.WithdrawalTransaction memory _tx = Types.WithdrawalTransaction({
nonce: _nonce, nonce: nonce,
sender: _sender, sender: _sender,
target: _target, target: _target,
value: _value, value: value,
gasLimit: _gasLimit, gasLimit: gasLimit,
data: _data data: _data
}); });
( (
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
"dotenv": "^16.0.0", "dotenv": "^16.0.0",
"ds-test": "https://github.com/dapphub/ds-test.git#9310e879db8ba3ea6d5c6489a579118fd264a3f5", "ds-test": "https://github.com/dapphub/ds-test.git#9310e879db8ba3ea6d5c6489a579118fd264a3f5",
"ethereum-waffle": "^3.0.0", "ethereum-waffle": "^3.0.0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#f18682b2874fc57d7c80a511fed0b35ec4201ffa", "forge-std": "https://github.com/foundry-rs/forge-std.git#5bafa16b4a6aa67c503d96294be846a22a6f6efb",
"glob": "^7.1.6", "glob": "^7.1.6",
"hardhat-deploy": "^0.11.4", "hardhat-deploy": "^0.11.4",
"solhint": "^3.3.7", "solhint": "^3.3.7",
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
"ds-test": "https://github.com/dapphub/ds-test.git#9310e879db8ba3ea6d5c6489a579118fd264a3f5", "ds-test": "https://github.com/dapphub/ds-test.git#9310e879db8ba3ea6d5c6489a579118fd264a3f5",
"ethereum-waffle": "^3.4.4", "ethereum-waffle": "^3.4.4",
"ethers": "^5.7.0", "ethers": "^5.7.0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#f18682b2874fc57d7c80a511fed0b35ec4201ffa", "forge-std": "https://github.com/foundry-rs/forge-std.git#5bafa16b4a6aa67c503d96294be846a22a6f6efb",
"hardhat": "^2.9.6", "hardhat": "^2.9.6",
"hardhat-deploy": "^0.11.10", "hardhat-deploy": "^0.11.10",
"hardhat-gas-reporter": "^1.0.8", "hardhat-gas-reporter": "^1.0.8",
......
...@@ -9405,9 +9405,9 @@ forever-agent@~0.6.1: ...@@ -9405,9 +9405,9 @@ forever-agent@~0.6.1:
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=
"forge-std@https://github.com/foundry-rs/forge-std.git#f18682b2874fc57d7c80a511fed0b35ec4201ffa": "forge-std@https://github.com/foundry-rs/forge-std.git#5bafa16b4a6aa67c503d96294be846a22a6f6efb":
version "0.0.0" version "1.0.0"
resolved "https://github.com/foundry-rs/forge-std.git#f18682b2874fc57d7c80a511fed0b35ec4201ffa" resolved "https://github.com/foundry-rs/forge-std.git#5bafa16b4a6aa67c503d96294be846a22a6f6efb"
form-data@^2.2.0: form-data@^2.2.0:
version "2.5.1" version "2.5.1"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment