Skip to content

Commit

Permalink
contracts-bedrock: add useInterop flag (#10433)
Browse files Browse the repository at this point in the history
* bedrock-devnet: add useInterop flag

* op-chain-ops: add useInterop flag

* op-node: add useInterop flag to config

* contracts-bedrock: add useInterop flag to DeployConfig

* contracts-bedrock: add useInterop flag to Predeploy's getName

* contracts-bedrock: add useInterop flag to L2Genesis

* contracts-bedrock: add useInterop flag to Predeploy's test

* contracts-bedrock: add useInterop flag to CommonTest

* contracts-bedrock: add useInterop flag to Setup

* Revert "op-chain-ops: add useInterop flag"

This reverts commit 83c63cc.

* Revert "op-node: add useInterop flag to config"

This reverts commit c3617f9.

* Revert "bedrock-devnet: add useInterop flag"

This reverts commit 858257c.

* contracts-bedrock: use L1Block in Predeploys for L1BlockInterop

* contracts-bedrock: update gas-snapshot

* op-chain-ops: add UseInterop flag to genesis DeployConfig

* contracts-bedrock: remove useInterop argument in Predeploys

* op-chain-ops: make UseInterop flag optional

Co-Authored-By: protolambda <proto@protolambda.com>

---------

Co-authored-by: protolambda <proto@protolambda.com>
  • Loading branch information
0xfuturistic and protolambda committed May 7, 2024
1 parent 66ec96b commit fc45866
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
3 changes: 3 additions & 0 deletions op-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ type DeployConfig struct {

// When Cancun activates. Relative to L1 genesis.
L1CancunTimeOffset *hexutil.Uint64 `json:"l1CancunTimeOffset,omitempty"`

// UseInterop is a flag that indicates if the system is using interop
UseInterop bool `json:"useInterop,omitempty"`
}

// Copy will deeply copy the DeployConfig. This does a JSON roundtrip to copy
Expand Down
18 changes: 9 additions & 9 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: 369398)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967433)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 562077)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4074053)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467008)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512757)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72627)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369443)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967411)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 562055)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4074098)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467053)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512735)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72672)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68453)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68945)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155567)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68923)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155612)
9 changes: 9 additions & 0 deletions packages/contracts-bedrock/scripts/DeployConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ contract DeployConfig is Script {
bool public useCustomGasToken;
address public customGasTokenAddress;

bool public useInterop;

function read(string memory _path) public {
console.log("DeployConfig: reading file %s", _path);
try vm.readFile(_path) returns (string memory data) {
Expand Down Expand Up @@ -151,6 +153,8 @@ contract DeployConfig is Script {

useCustomGasToken = _readOr(_json, "$.useCustomGasToken", false);
customGasTokenAddress = _readOr(_json, "$.customGasTokenAddress", address(0));

useInterop = _readOr(_json, "$.useInterop", false);
}

function l1StartingBlockTag() public returns (bytes32) {
Expand Down Expand Up @@ -191,6 +195,11 @@ contract DeployConfig is Script {
useFaultProofs = _useFaultProofs;
}

/// @notice Allow the `useInterop` config to be overridden in testing environments
function setUseInterop(bool _useInterop) public {
useInterop = _useInterop;
}

/// @notice Allow the `fundDevAccounts` config to be overridden.
function setFundDevAccounts(bool _fundDevAccounts) public {
fundDevAccounts = _fundDevAccounts;
Expand Down
14 changes: 14 additions & 0 deletions packages/contracts-bedrock/test/setup/CommonTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ contract CommonTest is Test, Setup, Events {
bool usePlasmaOverride;
bool useFaultProofs;
address customGasToken;
bool useInteropOverride;

function setUp() public virtual override {
alice = makeAddr("alice");
Expand All @@ -40,6 +41,9 @@ contract CommonTest is Test, Setup, Events {
if (customGasToken != address(0)) {
deploy.cfg().setUseCustomGasToken(customGasToken);
}
if (useInteropOverride) {
deploy.cfg().setUseInterop(true);
}

vm.etch(address(ffi), vm.getDeployedCode("FFIInterface.sol:FFIInterface"));
vm.label(address(ffi), "FFIInterface");
Expand Down Expand Up @@ -135,4 +139,14 @@ contract CommonTest is Test, Setup, Events {

customGasToken = _token;
}

function enableInterop() public {
// 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.
if (!(alice == address(0) && bob == address(0))) {
revert("CommonTest: Cannot enable interop after deployment. Consider overriding `setUp`.");
}

useInteropOverride = true;
}
}

0 comments on commit fc45866

Please sign in to comment.