Skip to content

Commit

Permalink
contracts-bedrock: forge-std v1.8.1 (#10161)
Browse files Browse the repository at this point in the history
* contracts-bedrock: forge-std v1.8.1

Updates to latest `forge-std` release to get access to the latest
cheatcodes with a nice API.

https://github.com/foundry-rs/forge-std/releases/tag/v1.8.1

* contracts-bedrock: fix warnings

* lint: fix

* contracts-bedrock: fix compiler

* lint: fix

* snapshots: update

* contracts-bedrock: make deploy config safe + expect safe mem

* gas-snapshot
  • Loading branch information
tynes authored Apr 17, 2024
1 parent dcc4fb3 commit 05ab396
Show file tree
Hide file tree
Showing 77 changed files with 263 additions and 259 deletions.
22 changes: 11 additions & 11 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 356410)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2954595)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 549189)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4061165)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 450338)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3496087)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 59803)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92930)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68390)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 69043)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155559)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 356411)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2954596)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 549198)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4061174)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 450326)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3496075)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 59809)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92951)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68398)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 69062)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155567)
9 changes: 5 additions & 4 deletions packages/contracts-bedrock/scripts/DeployConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import { stdJson } from "forge-std/StdJson.sol";
import { Executables } from "scripts/Executables.sol";
import { Chains } from "scripts/Chains.sol";

// Global constant for the `useFaultProofs` slot in the DeployConfig contract, which can be overridden in the testing
// environment.
bytes32 constant USE_FAULT_PROOFS_SLOT = bytes32(uint256(63));

/// @title DeployConfig
/// @notice Represents the configuration required to deploy the system. It is expected
/// to read the file from JSON. A future improvement would be to have fallback
Expand Down Expand Up @@ -180,6 +176,11 @@ contract DeployConfig is Script {
usePlasma = _usePlasma;
}

/// @notice Allow the `useFaultProofs` config to be overridden in testing environments
function setUseFaultProofs(bool _useFaultProofs) public {
useFaultProofs = _useFaultProofs;
}

function _getBlockByTag(string memory _tag) internal returns (bytes32) {
string[] memory cmd = new string[](3);
cmd[0] = Executables.bash;
Expand Down
9 changes: 0 additions & 9 deletions packages/contracts-bedrock/scripts/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Script } from "forge-std/Script.sol";
import { Artifacts } from "scripts/Artifacts.s.sol";
import { Config } from "scripts/Config.sol";
import { DeployConfig } from "scripts/DeployConfig.s.sol";
import { USE_FAULT_PROOFS_SLOT } from "scripts/DeployConfig.s.sol";

/// @title Deployer
/// @author tynes
Expand All @@ -18,18 +17,10 @@ abstract contract Deployer is Script, Artifacts {
function setUp() public virtual override {
Artifacts.setUp();

// Load the `useFaultProofs` slot value prior to etching the DeployConfig's bytecode and reading the deploy
// config file. If this slot has already been set, it will override the preference in the deploy config.
bytes32 useFaultProofsOverride = vm.load(address(cfg), USE_FAULT_PROOFS_SLOT);

vm.etch(address(cfg), vm.getDeployedCode("DeployConfig.s.sol:DeployConfig"));
vm.label(address(cfg), "DeployConfig");
vm.allowCheatcodes(address(cfg));
cfg.read(Config.deployConfigPath());

if (useFaultProofsOverride != 0) {
vm.store(address(cfg), USE_FAULT_PROOFS_SLOT, useFaultProofsOverride);
}
}

/// @notice Returns the name of the deployment script. Children contracts
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-bedrock/scripts/fpac/FPACOPS.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ contract FPACOPS is Deploy, StdAssertions {
}

/// @notice Checks that the deployed system is configured correctly.
function postDeployAssertions(address _proxyAdmin, address _systemOwnerSafe) internal {
function postDeployAssertions(address _proxyAdmin, address _systemOwnerSafe) internal view {
Types.ContractSet memory contracts = _proxiesUnstrict();
contracts.OptimismPortal2 = mustGetAddress("OptimismPortal2");

Expand Down
50 changes: 25 additions & 25 deletions packages/contracts-bedrock/snapshots/state-diff/Kontrol-Deploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000000e"
"slot": "0x000000000000000000000000000000000000000000000000000000000000000f"
}
],
"value": 0
Expand Down Expand Up @@ -1413,7 +1413,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000000e"
"slot": "0x000000000000000000000000000000000000000000000000000000000000000f"
}
],
"value": 0
Expand Down Expand Up @@ -1962,7 +1962,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000000d"
"slot": "0x000000000000000000000000000000000000000000000000000000000000000e"
}
],
"value": 0
Expand All @@ -1988,7 +1988,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000003a"
"slot": "0x000000000000000000000000000000000000000000000000000000000000003b"
}
],
"value": 0
Expand All @@ -2014,7 +2014,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000003b"
"slot": "0x000000000000000000000000000000000000000000000000000000000000003c"
}
],
"value": 0
Expand Down Expand Up @@ -2397,7 +2397,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000000d"
"slot": "0x000000000000000000000000000000000000000000000000000000000000000e"
}
],
"value": 0
Expand Down Expand Up @@ -2475,7 +2475,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000003a"
"slot": "0x000000000000000000000000000000000000000000000000000000000000003b"
}
],
"value": 0
Expand Down Expand Up @@ -2553,7 +2553,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000003b"
"slot": "0x000000000000000000000000000000000000000000000000000000000000003c"
}
],
"value": 0
Expand Down Expand Up @@ -3540,7 +3540,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000000e"
"slot": "0x000000000000000000000000000000000000000000000000000000000000000f"
}
],
"value": 0
Expand Down Expand Up @@ -6043,7 +6043,7 @@
"newValue": "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
"previousValue": "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000017"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000018"
}
],
"value": 0
Expand All @@ -6069,7 +6069,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000000d"
"slot": "0x000000000000000000000000000000000000000000000000000000000000000e"
}
],
"value": 0
Expand All @@ -6095,7 +6095,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000834",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000834",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000002b"
"slot": "0x000000000000000000000000000000000000000000000000000000000000002c"
}
],
"value": 0
Expand All @@ -6121,7 +6121,7 @@
"newValue": "0x00000000000000000000000000000000000000000000000000000000000f4240",
"previousValue": "0x00000000000000000000000000000000000000000000000000000000000f4240",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000002c"
"slot": "0x000000000000000000000000000000000000000000000000000000000000002d"
}
],
"value": 0
Expand All @@ -6147,7 +6147,7 @@
"newValue": "0x00000000000000000000000000000000000000000000000000000000017d7840",
"previousValue": "0x00000000000000000000000000000000000000000000000000000000017d7840",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000029"
"slot": "0x000000000000000000000000000000000000000000000000000000000000002a"
}
],
"value": 0
Expand All @@ -6173,7 +6173,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000015"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000016"
}
],
"value": 0
Expand All @@ -6199,7 +6199,7 @@
"newValue": "0x000000000000000000000000ff00000000000000000000000000000000000000",
"previousValue": "0x000000000000000000000000ff00000000000000000000000000000000000000",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000016"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000017"
}
],
"value": 0
Expand Down Expand Up @@ -6778,7 +6778,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000000d"
"slot": "0x000000000000000000000000000000000000000000000000000000000000000e"
}
],
"value": 0
Expand Down Expand Up @@ -6856,7 +6856,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000834",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000834",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000002b"
"slot": "0x000000000000000000000000000000000000000000000000000000000000002c"
}
],
"value": 0
Expand Down Expand Up @@ -6934,7 +6934,7 @@
"newValue": "0x00000000000000000000000000000000000000000000000000000000000f4240",
"previousValue": "0x00000000000000000000000000000000000000000000000000000000000f4240",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000002c"
"slot": "0x000000000000000000000000000000000000000000000000000000000000002d"
}
],
"value": 0
Expand Down Expand Up @@ -7012,7 +7012,7 @@
"newValue": "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
"previousValue": "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000017"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000018"
}
],
"value": 0
Expand Down Expand Up @@ -7090,7 +7090,7 @@
"newValue": "0x00000000000000000000000000000000000000000000000000000000017d7840",
"previousValue": "0x00000000000000000000000000000000000000000000000000000000017d7840",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000029"
"slot": "0x000000000000000000000000000000000000000000000000000000000000002a"
}
],
"value": 0
Expand Down Expand Up @@ -7168,7 +7168,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000015"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000016"
}
],
"value": 0
Expand Down Expand Up @@ -7246,7 +7246,7 @@
"newValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"previousValue": "0x0000000000000000000000000000000000000000000000000000000000000000",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000039"
"slot": "0x000000000000000000000000000000000000000000000000000000000000003a"
}
],
"value": 0
Expand Down Expand Up @@ -7324,7 +7324,7 @@
"newValue": "0x000000000000000000000000ff00000000000000000000000000000000000000",
"previousValue": "0x000000000000000000000000ff00000000000000000000000000000000000000",
"reverted": false,
"slot": "0x0000000000000000000000000000000000000000000000000000000000000016"
"slot": "0x0000000000000000000000000000000000000000000000000000000000000017"
}
],
"value": 0
Expand Down Expand Up @@ -11400,7 +11400,7 @@
"newValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"previousValue": "0x0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc",
"reverted": false,
"slot": "0x000000000000000000000000000000000000000000000000000000000000000e"
"slot": "0x000000000000000000000000000000000000000000000000000000000000000f"
}
],
"value": 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
}

/// @dev Tests that the proxy is initialized correctly.
function test_initialize_succeeds() external {
function test_initialize_succeeds() external view {
assertEq(address(l1CrossDomainMessenger.superchainConfig()), address(superchainConfig));
assertEq(address(l1CrossDomainMessenger.PORTAL()), address(optimismPortal));
assertEq(address(l1CrossDomainMessenger.portal()), address(optimismPortal));
Expand All @@ -46,7 +46,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
}

/// @dev Tests that the version can be decoded from the message nonce.
function test_messageVersion_succeeds() external {
function test_messageVersion_succeeds() external view {
(, uint16 version) = Encoding.decodeVersionedNonce(l1CrossDomainMessenger.messageNonce());
assertEq(version, l1CrossDomainMessenger.MESSAGE_VERSION());
}
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/test/L1/L1ERC721Bridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract L1ERC721Bridge_Test is Bridge_Initializer {
}

/// @dev Tests that the proxy is initialized with the correct values.
function test_initialize_succeeds() public {
function test_initialize_succeeds() public view {
assertEq(address(l1ERC721Bridge.MESSENGER()), address(l1CrossDomainMessenger));
assertEq(address(l1ERC721Bridge.messenger()), address(l1CrossDomainMessenger));
assertEq(address(l1ERC721Bridge.OTHER_BRIDGE()), Predeploys.L2_ERC721_BRIDGE);
Expand Down Expand Up @@ -316,7 +316,7 @@ contract L1ERC721Bridge_Test is Bridge_Initializer {
contract L1ERC721Bridge_Pause_Test is Bridge_Initializer {
/// @dev Verifies that the `paused` accessor returns the same value as the `paused` function of the
/// `superchainConfig`.
function test_paused_succeeds() external {
function test_paused_succeeds() external view {
assertEq(l1ERC721Bridge.paused(), superchainConfig.paused());
}

Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/test/L1/L1StandardBridge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ contract L1StandardBridge_Initialize_Test is Bridge_Initializer {
}

/// @dev Test that the initialize function sets the correct values.
function test_initialize_succeeds() external {
function test_initialize_succeeds() external view {
assertEq(address(l1StandardBridge.superchainConfig()), address(superchainConfig));
assertEq(address(l1StandardBridge.MESSENGER()), address(l1CrossDomainMessenger));
assertEq(address(l1StandardBridge.messenger()), address(l1CrossDomainMessenger));
Expand All @@ -58,7 +58,7 @@ contract L1StandardBridge_Initialize_Test is Bridge_Initializer {
contract L1StandardBridge_Pause_Test is Bridge_Initializer {
/// @dev Verifies that the `paused` accessor returns the same value as the `paused` function of the
/// `superchainConfig`.
function test_paused_succeeds() external {
function test_paused_succeeds() external view {
assertEq(l1StandardBridge.paused(), superchainConfig.paused());
}

Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-bedrock/test/L1/L2OutputOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ contract L2OutputOracle_getter_Test is CommonTest {
}

/// @dev Tests that `nextBlockNumber` returns the correct value.
function test_nextBlockNumber_succeeds() external {
function test_nextBlockNumber_succeeds() external view {
assertEq(
l2OutputOracle.nextBlockNumber(),
// The return value should match this arithmetic
Expand Down
Loading

0 comments on commit 05ab396

Please sign in to comment.