Commit 76beff3d authored by Maurelian's avatar Maurelian Committed by GitHub

test: Default to enabling fault proofs (#12489)

* test: Default to enabling fault proofs

* test: replace useFaultProofs with useLegacyContracts

Note that this does not modify the deploy config, which still uses the
same `useFaultProofs` flag. It simply modifies the state variables in
CommonTest

* chore: Update gas snapshot

* fix: enableLegacy on L2OO invariants

* feat: Add comment

* fix: enableLegacy on portal invariants

* fix: enableLegacy on Initializable.t.sol

* fix: enableLegacy on portal tests

* feat: follow convention of super.enable...()

* fix: Don't double enable
parent d8012e05
...@@ -4,12 +4,12 @@ GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchm ...@@ -4,12 +4,12 @@ GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchm
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099) GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099)
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531) GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597) GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369242) GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369344)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967382) GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967484)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564356) GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564462)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076571) GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076505)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467019) GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 466947)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512723) GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512651)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72621) GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72621)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973) GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68357) GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68357)
......
...@@ -17,7 +17,12 @@ import { Proxy } from "src/universal/Proxy.sol"; ...@@ -17,7 +17,12 @@ import { Proxy } from "src/universal/Proxy.sol";
import { L2OutputOracle } from "src/L1/L2OutputOracle.sol"; import { L2OutputOracle } from "src/L1/L2OutputOracle.sol";
import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol";
contract L2OutputOracle_constructor_Test is CommonTest { contract L2OutputOracle_TestBase is CommonTest {
function setUp() public override {
super.enableLegacyContracts();
super.setUp();
}
/// @dev Tests that constructor sets the initial values correctly. /// @dev Tests that constructor sets the initial values correctly.
function test_constructor_succeeds() external { function test_constructor_succeeds() external {
IL2OutputOracle oracleImpl = IL2OutputOracle(address(new L2OutputOracle())); IL2OutputOracle oracleImpl = IL2OutputOracle(address(new L2OutputOracle()));
...@@ -63,7 +68,7 @@ contract L2OutputOracle_constructor_Test is CommonTest { ...@@ -63,7 +68,7 @@ contract L2OutputOracle_constructor_Test is CommonTest {
} }
} }
contract L2OutputOracle_getter_Test is CommonTest { contract L2OutputOracle_getter_Test is L2OutputOracle_TestBase {
bytes32 proposedOutput1 = keccak256(abi.encode(1)); bytes32 proposedOutput1 = keccak256(abi.encode(1));
/// @dev Tests that `latestBlockNumber` returns the correct value. /// @dev Tests that `latestBlockNumber` returns the correct value.
...@@ -199,7 +204,7 @@ contract L2OutputOracle_getter_Test is CommonTest { ...@@ -199,7 +204,7 @@ contract L2OutputOracle_getter_Test is CommonTest {
} }
} }
contract L2OutputOracle_proposeL2Output_Test is CommonTest { contract L2OutputOracle_proposeL2Output_Test is L2OutputOracle_TestBase {
/// @dev Test that `proposeL2Output` succeeds for a valid input /// @dev Test that `proposeL2Output` succeeds for a valid input
/// and when a block hash and number are not specified. /// and when a block hash and number are not specified.
function test_proposeL2Output_proposeAnotherOutput_succeeds() public { function test_proposeL2Output_proposeAnotherOutput_succeeds() public {
...@@ -291,7 +296,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest { ...@@ -291,7 +296,7 @@ contract L2OutputOracle_proposeL2Output_Test is CommonTest {
} }
} }
contract L2OutputOracle_deleteOutputs_Test is CommonTest { contract L2OutputOracle_deleteOutputs_Test is L2OutputOracle_TestBase {
/// @dev Tests that `deleteL2Outputs` succeeds for a single output. /// @dev Tests that `deleteL2Outputs` succeeds for a single output.
function test_deleteOutputs_singleOutput_succeeds() external { function test_deleteOutputs_singleOutput_succeeds() external {
proposeAnotherOutput(); proposeAnotherOutput();
...@@ -405,7 +410,7 @@ contract L2OutputOracle_deleteOutputs_Test is CommonTest { ...@@ -405,7 +410,7 @@ contract L2OutputOracle_deleteOutputs_Test is CommonTest {
} }
} }
contract L2OutputOracleUpgradeable_Test is CommonTest { contract L2OutputOracleUpgradeable_Test is L2OutputOracle_TestBase {
/// @dev Tests that the proxy can be successfully upgraded. /// @dev Tests that the proxy can be successfully upgraded.
function test_upgrading_succeeds() external { function test_upgrading_succeeds() external {
Proxy proxy = Proxy(deploy.mustGetAddress("L2OutputOracleProxy")); Proxy proxy = Proxy(deploy.mustGetAddress("L2OutputOracleProxy"));
......
...@@ -34,6 +34,7 @@ contract OptimismPortal_Test is CommonTest { ...@@ -34,6 +34,7 @@ contract OptimismPortal_Test is CommonTest {
/// @notice Marked virtual to be overridden in /// @notice Marked virtual to be overridden in
/// test/kontrol/deployment/DeploymentSummary.t.sol /// test/kontrol/deployment/DeploymentSummary.t.sol
function setUp() public virtual override { function setUp() public virtual override {
super.enableLegacyContracts();
super.setUp(); super.setUp();
depositor = makeAddr("depositor"); depositor = makeAddr("depositor");
} }
...@@ -580,6 +581,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest { ...@@ -580,6 +581,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
// Use a constructor to set the storage vars above, so as to minimize the number of ffi calls. // Use a constructor to set the storage vars above, so as to minimize the number of ffi calls.
constructor() { constructor() {
super.enableLegacyContracts();
super.setUp(); super.setUp();
_defaultTx = Types.WithdrawalTransaction({ _defaultTx = Types.WithdrawalTransaction({
nonce: 0, nonce: 0,
......
...@@ -34,7 +34,6 @@ contract OptimismPortal2_Test is CommonTest { ...@@ -34,7 +34,6 @@ contract OptimismPortal2_Test is CommonTest {
address depositor; address depositor;
function setUp() public virtual override { function setUp() public virtual override {
super.enableFaultProofs();
super.setUp(); super.setUp();
// zero out contracts that should not be used // zero out contracts that should not be used
...@@ -436,7 +435,6 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest { ...@@ -436,7 +435,6 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
// Use a constructor to set the storage vars above, so as to minimize the number of ffi calls. // Use a constructor to set the storage vars above, so as to minimize the number of ffi calls.
constructor() { constructor() {
super.enableFaultProofs();
super.setUp(); super.setUp();
_defaultTx = Types.WithdrawalTransaction({ _defaultTx = Types.WithdrawalTransaction({
...@@ -1397,7 +1395,6 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest { ...@@ -1397,7 +1395,6 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
contract OptimismPortal2_Upgradeable_Test is CommonTest { contract OptimismPortal2_Upgradeable_Test is CommonTest {
function setUp() public override { function setUp() public override {
super.enableFaultProofs();
super.setUp(); super.setUp();
} }
...@@ -1443,7 +1440,6 @@ contract OptimismPortal2_ResourceFuzz_Test is CommonTest { ...@@ -1443,7 +1440,6 @@ contract OptimismPortal2_ResourceFuzz_Test is CommonTest {
uint256 constant MAX_GAS_LIMIT = 30_000_000; uint256 constant MAX_GAS_LIMIT = 30_000_000;
function setUp() public override { function setUp() public override {
super.enableFaultProofs();
super.setUp(); super.setUp();
} }
......
...@@ -311,7 +311,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init { ...@@ -311,7 +311,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init {
function setUp() public override { function setUp() public override {
token = new ERC20("Silly", "SIL"); token = new ERC20("Silly", "SIL");
super.enableCustomGasToken(address(token)); super.enableCustomGasToken(address(token));
super.enableFaultProofs();
super.setUp(); super.setUp();
} }
......
...@@ -18,7 +18,6 @@ contract DelayedWETH_Init is CommonTest { ...@@ -18,7 +18,6 @@ contract DelayedWETH_Init is CommonTest {
event Unwrap(address indexed src, uint256 wad); event Unwrap(address indexed src, uint256 wad);
function setUp() public virtual override { function setUp() public virtual override {
super.enableFaultProofs();
super.setUp(); super.setUp();
// Transfer ownership of delayed WETH to the test contract. // Transfer ownership of delayed WETH to the test contract.
......
...@@ -24,7 +24,6 @@ contract DisputeGameFactory_Init is CommonTest { ...@@ -24,7 +24,6 @@ contract DisputeGameFactory_Init is CommonTest {
event InitBondUpdated(GameType indexed gameType, uint256 indexed newBond); event InitBondUpdated(GameType indexed gameType, uint256 indexed newBond);
function setUp() public virtual override { function setUp() public virtual override {
super.enableFaultProofs();
super.setUp(); super.setUp();
fakeClone = new FakeClone(); fakeClone = new FakeClone();
......
...@@ -33,6 +33,7 @@ contract L2OutputOracle_MonotonicBlockNumIncrease_Invariant is CommonTest { ...@@ -33,6 +33,7 @@ contract L2OutputOracle_MonotonicBlockNumIncrease_Invariant is CommonTest {
L2OutputOracle_Proposer internal actor; L2OutputOracle_Proposer internal actor;
function setUp() public override { function setUp() public override {
super.enableLegacyContracts();
super.setUp(); super.setUp();
// Create a proposer actor. // Create a proposer actor.
......
...@@ -88,6 +88,7 @@ contract OptimismPortal_Invariant_Harness is CommonTest { ...@@ -88,6 +88,7 @@ contract OptimismPortal_Invariant_Harness is CommonTest {
Types.OutputRootProof internal _outputRootProof; Types.OutputRootProof internal _outputRootProof;
function setUp() public virtual override { function setUp() public virtual override {
super.enableLegacyContracts();
super.setUp(); super.setUp();
_defaultTx = Types.WithdrawalTransaction({ _defaultTx = Types.WithdrawalTransaction({
......
...@@ -96,7 +96,6 @@ contract OptimismPortal2_Invariant_Harness is CommonTest { ...@@ -96,7 +96,6 @@ contract OptimismPortal2_Invariant_Harness is CommonTest {
Types.OutputRootProof internal _outputRootProof; Types.OutputRootProof internal _outputRootProof;
function setUp() public virtual override { function setUp() public virtual override {
super.enableFaultProofs();
super.setUp(); super.setUp();
_defaultTx = Types.WithdrawalTransaction({ _defaultTx = Types.WithdrawalTransaction({
......
...@@ -32,7 +32,6 @@ contract DeputyGuardianModule_TestInit is CommonTest, SafeTestTools { ...@@ -32,7 +32,6 @@ contract DeputyGuardianModule_TestInit is CommonTest, SafeTestTools {
/// @dev Sets up the test environment /// @dev Sets up the test environment
function setUp() public virtual override { function setUp() public virtual override {
super.enableFaultProofs();
super.setUp(); super.setUp();
// Create a Safe with 10 owners // Create a Safe with 10 owners
......
...@@ -19,7 +19,7 @@ contract CommonTest is Test, Setup, Events { ...@@ -19,7 +19,7 @@ contract CommonTest is Test, Setup, Events {
FFIInterface constant ffi = FFIInterface(address(uint160(uint256(keccak256(abi.encode("optimism.ffi")))))); FFIInterface constant ffi = FFIInterface(address(uint160(uint256(keccak256(abi.encode("optimism.ffi"))))));
bool useAltDAOverride; bool useAltDAOverride;
bool useFaultProofs; bool useLegacyContracts;
address customGasToken; address customGasToken;
bool useInteropOverride; bool useInteropOverride;
...@@ -35,7 +35,8 @@ contract CommonTest is Test, Setup, Events { ...@@ -35,7 +35,8 @@ contract CommonTest is Test, Setup, Events {
if (useAltDAOverride) { if (useAltDAOverride) {
deploy.cfg().setUseAltDA(true); deploy.cfg().setUseAltDA(true);
} }
if (useFaultProofs) { // We default to fault proofs unless explicitly disabled by useLegacyContracts
if (!useLegacyContracts) {
deploy.cfg().setUseFaultProofs(true); deploy.cfg().setUseFaultProofs(true);
} }
if (customGasToken != address(0)) { if (customGasToken != address(0)) {
...@@ -109,14 +110,14 @@ contract CommonTest is Test, Setup, Events { ...@@ -109,14 +110,14 @@ contract CommonTest is Test, Setup, Events {
l2OutputOracle.proposeL2Output(proposedOutput2, nextBlockNumber, 0, 0); l2OutputOracle.proposeL2Output(proposedOutput2, nextBlockNumber, 0, 0);
} }
function enableFaultProofs() public { function enableLegacyContracts() public {
// Check if the system has already been deployed, based off of the heuristic that alice and bob have not been // Check if the system has already been deployed, based off of the heuristic that alice and bob have not been
// set by the `setUp` function yet. // set by the `setUp` function yet.
if (!(alice == address(0) && bob == address(0))) { if (!(alice == address(0) && bob == address(0))) {
revert("CommonTest: Cannot enable fault proofs after deployment. Consider overriding `setUp`."); revert("CommonTest: Cannot enable fault proofs after deployment. Consider overriding `setUp`.");
} }
useFaultProofs = true; useLegacyContracts = true;
} }
function enableAltDA() public { function enableAltDA() public {
...@@ -147,7 +148,6 @@ contract CommonTest is Test, Setup, Events { ...@@ -147,7 +148,6 @@ contract CommonTest is Test, Setup, Events {
revert("CommonTest: Cannot enable interop after deployment. Consider overriding `setUp`."); revert("CommonTest: Cannot enable interop after deployment. Consider overriding `setUp`.");
} }
useFaultProofs = true;
useInteropOverride = true; useInteropOverride = true;
} }
} }
...@@ -26,7 +26,7 @@ contract DeployVariations_Test is CommonTest { ...@@ -26,7 +26,7 @@ contract DeployVariations_Test is CommonTest {
/// @dev It should be possible to enable Fault Proofs with any mix of CGT and Alt-DA. /// @dev It should be possible to enable Fault Proofs with any mix of CGT and Alt-DA.
function testFuzz_enableFaultProofs(bool _enableCGT, bool _enableAltDa) public virtual { function testFuzz_enableFaultProofs(bool _enableCGT, bool _enableAltDa) public virtual {
enableAddOns(_enableCGT, _enableAltDa); enableAddOns(_enableCGT, _enableAltDa);
super.enableFaultProofs();
super.setUp(); super.setUp();
} }
...@@ -35,7 +35,7 @@ contract DeployVariations_Test is CommonTest { ...@@ -35,7 +35,7 @@ contract DeployVariations_Test is CommonTest {
function test_enableInteropAndFaultProofs(bool _enableCGT, bool _enableAltDa) public virtual { function test_enableInteropAndFaultProofs(bool _enableCGT, bool _enableAltDa) public virtual {
enableAddOns(_enableCGT, _enableAltDa); enableAddOns(_enableCGT, _enableAltDa);
super.enableInterop(); super.enableInterop();
super.enableFaultProofs();
super.setUp(); super.setUp();
} }
} }
...@@ -47,6 +47,7 @@ contract GasBenchMark_OptimismPortal is CommonTest { ...@@ -47,6 +47,7 @@ contract GasBenchMark_OptimismPortal is CommonTest {
// Use a constructor to set the storage vars above, so as to minimize the number of ffi calls. // Use a constructor to set the storage vars above, so as to minimize the number of ffi calls.
constructor() { constructor() {
super.enableLegacyContracts();
super.setUp(); super.setUp();
_defaultTx = Types.WithdrawalTransaction({ _defaultTx = Types.WithdrawalTransaction({
nonce: 0, nonce: 0,
...@@ -204,6 +205,7 @@ contract GasBenchMark_L2OutputOracle is CommonTest { ...@@ -204,6 +205,7 @@ contract GasBenchMark_L2OutputOracle is CommonTest {
uint256 nextBlockNumber; uint256 nextBlockNumber;
function setUp() public override { function setUp() public override {
super.enableLegacyContracts();
super.setUp(); super.setUp();
nextBlockNumber = l2OutputOracle.nextBlockNumber(); nextBlockNumber = l2OutputOracle.nextBlockNumber();
warpToProposeTime(nextBlockNumber); warpToProposeTime(nextBlockNumber);
......
...@@ -46,7 +46,7 @@ contract Initializer_Test is Bridge_Initializer { ...@@ -46,7 +46,7 @@ contract Initializer_Test is Bridge_Initializer {
function setUp() public override { function setUp() public override {
super.enableAltDA(); super.enableAltDA();
// Run the `Bridge_Initializer`'s `setUp()` function. super.enableLegacyContracts();
super.setUp(); super.setUp();
// Initialize the `contracts` array with the addresses of the contracts to test, the // Initialize the `contracts` array with the addresses of the contracts to test, the
......
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