Commit f63d3f37 authored by clabby's avatar clabby

Bump `forge-std` / update to `InvariantTest`

gas snapshot
parent 14c535cc
......@@ -92,10 +92,10 @@ L1ERC721Bridge_Test:test_finalizeBridgeERC721_notFromRemoteMessenger_reverts() (
L1ERC721Bridge_Test:test_finalizeBridgeERC721_notViaLocalMessenger_reverts() (gas: 16093)
L1ERC721Bridge_Test:test_finalizeBridgeERC721_selfToken_reverts() (gas: 17593)
L1ERC721Bridge_Test:test_finalizeBridgeERC721_succeeds() (gas: 323814)
L1StandardBridge_DepositERC20To_Test:test_depositERC20To_succeeds() (gas: 575962)
L1StandardBridge_DepositERC20To_Test:test_depositERC20To_succeeds() (gas: 575959)
L1StandardBridge_DepositERC20_Test:test_depositERC20_succeeds() (gas: 573786)
L1StandardBridge_DepositERC20_TestFail:test_depositERC20_notEoa_reverts() (gas: 22320)
L1StandardBridge_DepositETHTo_Test:test_depositETHTo_succeeds() (gas: 324724)
L1StandardBridge_DepositETHTo_Test:test_depositETHTo_succeeds() (gas: 324712)
L1StandardBridge_DepositETH_Test:test_depositETH_succeeds() (gas: 367539)
L1StandardBridge_DepositETH_TestFail:test_depositETH_notEoa_reverts() (gas: 40780)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_incorrectValue_reverts() (gas: 34207)
......@@ -159,7 +159,7 @@ L2OutputOracleTest:test_proposeL2Output_unexpectedBlockNumber_reverts() (gas: 28
L2OutputOracleTest:test_proposeL2Output_unmatchedBlockhash_reverts() (gas: 29446)
L2OutputOracleTest:test_proposeL2Output_wrongFork_reverts() (gas: 29005)
L2OutputOracleTest:test_proposeWithBlockhashAndHeight_succeeds() (gas: 95296)
L2OutputOracleUpgradeable_Test:test_initValuesOnProxy_succeeds() (gas: 26096)
L2OutputOracleUpgradeable_Test:test_initValuesOnProxy_succeeds() (gas: 26093)
L2OutputOracleUpgradeable_Test:test_initializeImpl_alreadyInitialized_reverts() (gas: 15149)
L2OutputOracleUpgradeable_Test:test_initializeProxy_alreadyInitialized_reverts() (gas: 20131)
L2OutputOracleUpgradeable_Test:test_upgrading_succeeds() (gas: 180413)
......@@ -169,7 +169,7 @@ L2StandardBridge_Test:test_finalizeBridgeETH_sendToSelf_reverts() (gas: 23838)
L2StandardBridge_Test:test_finalizeDeposit_succeeds() (gas: 89396)
L2StandardBridge_Test:test_initialize_succeeds() (gas: 10537)
L2StandardBridge_Test:test_receive_succeeds() (gas: 131905)
L2StandardBridge_Test:test_withdrawTo_succeeds() (gas: 344670)
L2StandardBridge_Test:test_withdrawTo_succeeds() (gas: 344660)
L2StandardBridge_Test:test_withdraw_insufficientValue_reverts() (gas: 19630)
L2StandardBridge_Test:test_withdraw_notEOA_reverts() (gas: 251798)
L2StandardBridge_Test:test_withdraw_succeeds() (gas: 343975)
......@@ -183,7 +183,7 @@ LegacyERC20ETH_Test:test_decreaseAllowance_doesNotExist_reverts() (gas: 10679)
LegacyERC20ETH_Test:test_increaseAllowance_doesNotExist_reverts() (gas: 10689)
LegacyERC20ETH_Test:test_metadata_succeeds() (gas: 15414)
LegacyERC20ETH_Test:test_mint_doesNotExist_reverts() (gas: 10649)
LegacyERC20ETH_Test:test_transferFrom_doesNotExist_reverts() (gas: 12887)
LegacyERC20ETH_Test:test_transferFrom_doesNotExist_reverts() (gas: 12890)
LegacyERC20ETH_Test:test_transfer_doesNotExist_reverts() (gas: 10733)
LegacyMessagePasser_Test:test_passMessageToL1_succeeds() (gas: 34518)
MerkleTrie_Test:test_get_corruptedProof_reverts() (gas: 5713)
......@@ -244,32 +244,32 @@ OptimismMintableERC721Factory_Test:test_createOptimismMintableERC721_zeroRemoteT
OptimismPortalUpgradeable_Test:test_initialize_cannotInitImpl_reverts() (gas: 10791)
OptimismPortalUpgradeable_Test:test_initialize_cannotInitProxy_reverts() (gas: 15833)
OptimismPortalUpgradeable_Test:test_params_initValuesOnProxy_succeeds() (gas: 16011)
OptimismPortalUpgradeable_Test:test_upgradeToAndCall_upgrading_succeeds() (gas: 180457)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputRootChanges_reverts() (gas: 198764)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 201083)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 39656)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalProofNotOldEnough_reverts() (gas: 196128)
OptimismPortalUpgradeable_Test:test_upgradeToAndCall_upgrading_succeeds() (gas: 180481)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputRootChanges_reverts() (gas: 198758)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 201077)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 39650)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalProofNotOldEnough_reverts() (gas: 196122)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onInsufficientGas_reverts() (gas: 196954)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onRecentWithdrawal_reverts() (gas: 176842)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReentrancy_reverts() (gas: 235400)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReplay_reverts() (gas: 236906)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_provenWithdrawalHash_succeeds() (gas: 228587)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_provenWithdrawalHash_succeeds() (gas: 228581)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_targetFails_fails() (gas: 8797746687696163638)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_timestampLessThanL2OracleStart_reverts() (gas: 192852)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_timestampLessThanL2OracleStart_reverts() (gas: 192846)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onInvalidOutputRootProof_reverts() (gas: 83498)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onInvalidWithdrawalProof_reverts() (gas: 135224)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onSelfCall_reverts() (gas: 50732)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onInvalidWithdrawalProof_reverts() (gas: 135223)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onSelfCall_reverts() (gas: 50752)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_replayProveChangedOutputRoot_succeeds() (gas: 275173)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_replayProve_reverts() (gas: 188130)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_validWithdrawalProof_succeeds() (gas: 178317)
OptimismPortal_Test:test_constructor_succeeds() (gas: 17277)
OptimismPortal_Test:test_depositTransaction_contractCreation_reverts() (gas: 14267)
OptimismPortal_Test:test_depositTransaction_contractCreation_reverts() (gas: 14273)
OptimismPortal_Test:test_depositTransaction_createWithZeroValueForContract_succeeds() (gas: 76662)
OptimismPortal_Test:test_depositTransaction_createWithZeroValueForEOA_succeeds() (gas: 77029)
OptimismPortal_Test:test_depositTransaction_noValueContract_succeeds() (gas: 76681)
OptimismPortal_Test:test_depositTransaction_noValueEOA_succeeds() (gas: 77198)
OptimismPortal_Test:test_depositTransaction_withEthValueAndContractContractCreation_succeeds() (gas: 83664)
OptimismPortal_Test:test_depositTransaction_withEthValueAndEOAContractCreation_succeeds() (gas: 75862)
OptimismPortal_Test:test_depositTransaction_withEthValueAndEOAContractCreation_succeeds() (gas: 75871)
OptimismPortal_Test:test_depositTransaction_withEthValueFromContract_succeeds() (gas: 83389)
OptimismPortal_Test:test_depositTransaction_withEthValueFromEOA_succeeds() (gas: 84133)
OptimismPortal_Test:test_isOutputFinalized_succeeds() (gas: 119474)
......@@ -282,9 +282,9 @@ Proxy_Test:test_implementation_zeroAddressCaller_succeeds() (gas: 14707)
Proxy_Test:test_ownerKey_succeeds() (gas: 19081)
Proxy_Test:test_ownerProxyCall_notAdmin_succeeds() (gas: 34637)
Proxy_Test:test_proxyCallToImp_notAdmin_succeeds() (gas: 29985)
Proxy_Test:test_upgradeToAndCall_functionDoesNotExist_reverts() (gas: 104517)
Proxy_Test:test_upgradeToAndCall_isPayable_succeeds() (gas: 53707)
Proxy_Test:test_upgradeToAndCall_succeeds() (gas: 125155)
Proxy_Test:test_upgradeToAndCall_functionDoesNotExist_reverts() (gas: 104520)
Proxy_Test:test_upgradeToAndCall_isPayable_succeeds() (gas: 53719)
Proxy_Test:test_upgradeToAndCall_succeeds() (gas: 125167)
Proxy_Test:test_upgradeTo_clashingFunctionSignatures_succeeds() (gas: 101359)
ProxyAdmin_Test:test_chugsplashChangeProxyAdmin_succeeds() (gas: 35586)
ProxyAdmin_Test:test_chugsplashGetProxyAdmin_succeeds() (gas: 15675)
......@@ -302,7 +302,7 @@ ProxyAdmin_Test:test_erc1967GetProxyImplementation_succeeds() (gas: 52049)
ProxyAdmin_Test:test_erc1967UpgradeAndCall_succeeds() (gas: 78940)
ProxyAdmin_Test:test_erc1967Upgrade_succeeds() (gas: 50034)
ProxyAdmin_Test:test_isUpgrading_succeeds() (gas: 19431)
ProxyAdmin_Test:test_onlyOwner_notOwner_reverts() (gas: 22760)
ProxyAdmin_Test:test_onlyOwner_notOwner_reverts() (gas: 22745)
ProxyAdmin_Test:test_owner_succeeds() (gas: 9738)
ProxyAdmin_Test:test_proxyType_succeeds() (gas: 20511)
ProxyAdmin_Test:test_setAddressManager_notOwner_reverts() (gas: 10600)
......
pragma solidity 0.8.15;
import { L2OutputOracle } from "../../L1/L2OutputOracle.sol";
import { L2ToL1MessagePasser } from "../../L2/L2ToL1MessagePasser.sol";
import { Predeploys } from "../../libraries/Predeploys.sol";
import { Test } from "forge-std/Test.sol";
contract L2OutputOracle_Invariants is Test {
// Global
address multisig = address(512);
// Test target
L2OutputOracle oracle;
L2ToL1MessagePasser messagePasser =
L2ToL1MessagePasser(payable(Predeploys.L2_TO_L1_MESSAGE_PASSER));
// Constructor arguments
address internal proposer = 0x000000000000000000000000000000000000AbBa;
address internal owner = 0x000000000000000000000000000000000000ACDC;
uint256 internal submissionInterval = 1800;
uint256 internal l2BlockTime = 2;
uint256 internal startingBlockNumber = 200;
uint256 internal startingTimestamp = 1000;
// Test data
uint256 initL1Time;
// Advance the evm's time to meet the L2OutputOracle's requirements for proposeL2Output
function warpToProposeTime(uint256 _nextBlockNumber) public {
vm.warp(oracle.computeL2Timestamp(_nextBlockNumber) + 1);
}
function setUp() public virtual {
// By default the first block has timestamp and number zero, which will cause underflows
// in the tests, so we'll move forward to these block values.
initL1Time = startingTimestamp + 1;
vm.warp(initL1Time);
vm.roll(startingBlockNumber);
// Deploy the L2OutputOracle and transfer owernship to the proposer
oracle = new L2OutputOracle(
submissionInterval,
l2BlockTime,
startingBlockNumber,
startingTimestamp,
proposer,
owner
);
import { InvariantTest } from "forge-std/InvariantTest.sol";
import { L2OutputOracle_Initializer } from "../CommonTest.t.sol";
contract L2OutputOracle_MonotonicBlockNumIncrease_Invariant is
InvariantTest,
L2OutputOracle_Initializer
{
function setUp() public override {
super.setUp();
// Set the target contract to the oracle proxy
targetContract(address(oracle));
// Set the target sender to the proposer
targetSender(address(proposer));
// Set the target selector for `proposeL2Output`
// `proposeL2Output` is the only function we care about, as it is the only function
// that can modify the `l2Outputs` array in the oracle.
bytes4[] memory selectors = new bytes4[](1);
selectors[0] = oracle.proposeL2Output.selector;
FuzzSelector memory selector = FuzzSelector({
addr: address(oracle),
selectors: selectors
});
targetSelector(selector);
}
/**
* INVARIANT: The block number of the output root proposals should monotonically increase.
* @custom:invariant The block number of the output root proposals should monotonically
* increase.
*
* When a new output is submitted, it should never be allowed to correspond to a block number
* that is less than the current output.
* When a new output is submitted, it should never be allowed to correspond to a block
* number that is less than the current output.
*/
function invariant_monotonicBlockNumIncrease() external {
// Current state of the L2OutputOracle
uint256 nextNumber = oracle.nextBlockNumber();
uint256 previousNumber = oracle.latestBlockNumber();
// Warp to the time that we can propose the next L2 output
warpToProposeTime(nextNumber);
// Propose a mock output
vm.prank(proposer);
oracle.proposeL2Output(bytes32(uint256(1)), nextNumber, 0, 0);
// Ensure that the output was proposed with the correct block number
assertEq(oracle.latestBlockNumber(), nextNumber);
// Ensure that the latest block number always monotonically increases
assertTrue(nextNumber >= previousNumber);
}
/**
* INVARIANT: The block number of the output root proposals should monotonically increase.
*
* When a new output is submitted, it should never be allowed to correspond to a block number
* that is less than the current output.
*
* This is a stripped version of `invariant_monotonicBlockNumIncrease` that gives foundry's
* invariant fuzzer less context.
*/
function invariant_monotonicBlockNumIncrease_stripped() external {
// Assert that the block number of proposals must monotonically increase.
assertTrue(oracle.nextBlockNumber() >= oracle.latestBlockNumber());
}
......
pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { InvariantTest } from "forge-std/InvariantTest.sol";
import { StdAssertions } from "forge-std/StdAssertions.sol";
import { SystemConfig } from "../../L1/SystemConfig.sol";
contract SystemConfig_Invariant is Test {
SystemConfig config;
contract SystemConfig_GasLimitLowerBound_Invariant is InvariantTest, StdAssertions {
SystemConfig public config;
function setUp() public {
config = new SystemConfig({
_owner: address(this),
_owner: address(0xbeef),
_overhead: 2100,
_scalar: 1000000,
_batcherHash: bytes32(hex"abcd"),
_gasLimit: 8_000_000,
_unsafeBlockSigner: address(1)
});
// Set the target contract to the `config`
targetContract(address(config));
// Set the target sender to the `config`'s owner (0xbeef)
targetSender(address(0xbeef));
// Set the target selector for `setGasLimit`
// `setGasLimit` is the only function we care about, as it is the only function
// that can modify the gas limit within the SystemConfig.
bytes4[] memory selectors = new bytes4[](1);
selectors[0] = config.setGasLimit.selector;
FuzzSelector memory selector = FuzzSelector({
addr: address(config),
selectors: selectors
});
targetSelector(selector);
}
/**
* INVARIANT: The gas limit of the `SystemConfig` contract can never be lower
* @custom:invariant The gas limit of the `SystemConfig` contract can never be lower
* than the hard-coded lower bound.
*/
function invariant_gasLimitLowerBound() external {
......
......@@ -77,7 +77,7 @@
"dotenv": "^16.0.0",
"ds-test": "https://github.com/dapphub/ds-test.git#9310e879db8ba3ea6d5c6489a579118fd264a3f5",
"ethereum-waffle": "^3.0.0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#5bafa16b4a6aa67c503d96294be846a22a6f6efb",
"forge-std": "https://github.com/foundry-rs/forge-std.git#53331f4cb2e313466f72440f3e73af048c454d02",
"glob": "^7.1.6",
"hardhat-deploy": "^0.11.4",
"solhint": "^3.3.7",
......
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