Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop -> Master #4969

Merged
merged 48 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
b29e003
contracts-bedrock: fix setup chain in tests
tynes Feb 22, 2023
aa9c4d6
lint: fix
tynes Feb 22, 2023
8039995
contracts-bedrock: regenerate snapshot
tynes Feb 22, 2023
f6f8244
build(deps): bump golang.org/x/text from 0.3.7 to 0.3.8 in /op-exporter
dependabot[bot] Feb 23, 2023
2dca930
build(deps): bump golang.org/x/text from 0.3.7 to 0.3.8 in /indexer
dependabot[bot] Feb 23, 2023
0d7b69b
ci: Remove proxyd and indexer from changesets workflow
mslipper Feb 23, 2023
a6a14b7
Merge pull request #4938 from ethereum-optimism/fix/test-setup
mslipper Feb 23, 2023
11fceca
op-chain-ops: Fix misleading comment
maurelian Feb 23, 2023
a8b042b
contracts-bedrock: make the portal pausable
tynes Feb 18, 2023
996d1f1
bindings: regenerate
tynes Feb 18, 2023
249fcc7
contracts-bedrock: gas snapshot, natspec
tynes Feb 18, 2023
4144e69
contracts-bedrock: lint fix
tynes Feb 18, 2023
be8d68a
contracts-bedrock: better initialize
tynes Feb 18, 2023
41accd0
deployment: optimism portal with pausability
tynes Feb 18, 2023
0d0df07
contracts-bedrock: cleanup
tynes Feb 18, 2023
7be28f9
contracts-bedrock: cleanup fixes
tynes Feb 22, 2023
b296f5b
contracts-bedrock: remove deposit pausable
tynes Feb 22, 2023
820c230
contracts-bedrock: fix test names
tynes Feb 23, 2023
1a234df
op-node: regolith rollup config attribute
protolambda Feb 23, 2023
d328189
Merge pull request #4921 from ethereum-optimism/feat/portal-pausable
tynes Feb 23, 2023
19fd276
fix(migration-data): prevent query block from going past end
maurelian Feb 23, 2023
c084cd0
Merge pull request #4948 from ethereum-optimism/feat/remove-proxyd-in…
mslipper Feb 23, 2023
098e803
fix(ctb): Add correct prefix to errors
maurelian Feb 23, 2023
035391a
ci-builder: add changeset
tynes Feb 23, 2023
eab53ea
Merge pull request #4956 from ethereum-optimism/fix/ci-builder-changeset
mslipper Feb 23, 2023
dda861e
Merge pull request #4950 from ethereum-optimism/jm/fix-migrate-eth-co…
mslipper Feb 23, 2023
34e13a5
Merge pull request #4951 from ethereum-optimism/regolith-config
mslipper Feb 23, 2023
a01241f
Merge branch 'develop' into jm/fix-error-strings
mergify[bot] Feb 23, 2023
68e2b49
op-node: regolith fork systemtx change
protolambda Feb 23, 2023
fbe14d5
Merge pull request #4949 from ethereum-optimism/jm/fix-error-strings
mslipper Feb 23, 2023
5101faa
Merge pull request #4953 from ethereum-optimism/jm/fix-step
mslipper Feb 23, 2023
e9734a3
Merge pull request #4942 from ethereum-optimism/dependabot/go_modules…
tynes Feb 23, 2023
a596609
Create pretty-pants-beam.md
tynes Feb 23, 2023
0c1f45e
Merge pull request #4944 from ethereum-optimism/dependabot/go_modules…
tynes Feb 23, 2023
096d9c2
Merge pull request #4961 from ethereum-optimism/regolith-sys-deposits
mslipper Feb 23, 2023
49c57bc
op-e2e: Introduce l2_geth e2e test util
ajsutton Feb 23, 2023
dbf29ae
Merge pull request #4957 from ethereum-optimism/aj/l2geth-e2e
mergify[bot] Feb 24, 2023
edb1224
op-node: fix stale payload-ID in sequencer log
protolambda Feb 24, 2023
814b9a9
ci-devnet: increase sequencer time drift to 5 min of L1 blocks, seq w…
protolambda Feb 24, 2023
e928cc2
Merge pull request #4965 from ethereum-optimism/increase-devnet-params
mslipper Feb 24, 2023
e36ddb0
Merge pull request #4964 from ethereum-optimism/fix-sequencer-log
mslipper Feb 24, 2023
80f2271
Update foundry & forge-std
clabby Feb 24, 2023
471186c
fix(ctb): Remove duplicate onlyOtherBridge check
maurelian Feb 23, 2023
903052e
Merge pull request #4968 from ethereum-optimism/clabby/update-foundry
mergify[bot] Feb 24, 2023
04c12a8
Merge branch 'develop' into jm/remove-duplicate-check
mergify[bot] Feb 24, 2023
7b7a26c
Merge pull request #4952 from ethereum-optimism/jm/remove-duplicate-c…
mergify[bot] Feb 24, 2023
f9a0e80
fix(ctb): Use multiplication of divisors for more precision
maurelian Feb 23, 2023
aa67575
Merge pull request #4955 from ethereum-optimism/jm/fix-dbl-div
mergify[bot] Feb 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
404 changes: 388 additions & 16 deletions op-bindings/bindings/optimismportal.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions op-bindings/bindings/optimismportal_more.go

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions op-chain-ops/genesis/layer_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ func BuildL1DeveloperGenesis(config *DeployConfig) (*core.Genesis, error) {
if err != nil {
return nil, err
}
data, err = portalABI.Pack("initialize")
// Initialize the OptimismPortal without being paused
data, err = portalABI.Pack("initialize", false)
if err != nil {
return nil, fmt.Errorf("cannot abi encode initialize for OptimismPortal: %w", err)
}
Expand Down Expand Up @@ -290,9 +291,15 @@ func deployL1Contracts(config *DeployConfig, backend *backends.SimulatedBackend)
},
},
{
// The implementation of the OptimismPortal is deployed
// as being paused to prevent invalid usage of the network
// as only the proxy should be used
Name: "OptimismPortal",
Args: []interface{}{
predeploys.DevL2OutputOracleAddr,
config.FinalSystemOwner,
uint642Big(config.FinalizationPeriodSeconds),
true, // _paused
},
},
{
Expand Down Expand Up @@ -354,8 +361,10 @@ func l1Deployer(backend *backends.SimulatedBackend, opts *bind.TransactOpts, dep
_, tx, _, err = bindings.DeployOptimismPortal(
opts,
backend,
predeploys.DevL2OutputOracleAddr,
deployment.Args[0].(*big.Int),
deployment.Args[0].(common.Address),
deployment.Args[2].(*big.Int),
deployment.Args[1].(common.Address),
deployment.Args[3].(bool),
)
case "L1CrossDomainMessenger":
_, tx, _, err = bindings.DeployL1CrossDomainMessenger(
Expand Down
122 changes: 64 additions & 58 deletions packages/contracts-bedrock/.gas-snapshot

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/contracts-bedrock/.storage-layout
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
| l2Sender | address | 50 | 0 | 20 | contracts/L1/OptimismPortal.sol:OptimismPortal |
| finalizedWithdrawals | mapping(bytes32 => bool) | 51 | 0 | 32 | contracts/L1/OptimismPortal.sol:OptimismPortal |
| provenWithdrawals | mapping(bytes32 => struct OptimismPortal.ProvenWithdrawal) | 52 | 0 | 32 | contracts/L1/OptimismPortal.sol:OptimismPortal |
| paused | bool | 53 | 0 | 1 | contracts/L1/OptimismPortal.sol:OptimismPortal |

=======================
➡ contracts/L1/SystemConfig.sol:SystemConfig
Expand Down
76 changes: 70 additions & 6 deletions packages/contracts-bedrock/contracts/L1/OptimismPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
*/
L2OutputOracle public immutable L2_ORACLE;

/**
* @notice Address that has the ability to pause and unpause deposits and withdrawals.
*/
address public immutable GUARDIAN;

/**
* @notice Address of the L2 account which initiated a withdrawal in this transaction. If the
* of this variable is the default L2 sender address, then we are NOT inside of a call
Expand All @@ -75,6 +80,13 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
*/
mapping(bytes32 => ProvenWithdrawal) public provenWithdrawals;

/**
* @notice Determines if cross domain messaging is paused. When set to true,
* deposits and withdrawals are paused. This may be removed in the
* future.
*/
bool public paused;

/**
* @notice Emitted when a transaction is deposited from L1 to L2. The parameters of this event
* are read by the rollup node and used to derive deposit transactions on L2.
Expand Down Expand Up @@ -111,25 +123,74 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);

/**
* @custom:semver 1.0.0
* @notice Emitted when the pause is triggered.
*
* @param account Address of the account triggering the pause.
*/
event Paused(address account);

/**
* @notice Emitted when the pause is lifted.
*
* @param account Address of the account triggering the unpause.
*/
event Unpaused(address account);

/**
* @notice Reverts when paused.
*/
modifier whenNotPaused() {
require(paused == false, "OptimismPortal: paused");
_;
}

/**
* @custom:semver 1.1.0
*
* @param _l2Oracle Address of the L2OutputOracle contract.
* @param _guardian Address that can pause deposits and withdrawals.
* @param _finalizationPeriodSeconds Output finalization time in seconds.
* @param _paused Sets the contract's pausability state.
*/
constructor(L2OutputOracle _l2Oracle, uint256 _finalizationPeriodSeconds) Semver(1, 0, 0) {
constructor(
L2OutputOracle _l2Oracle,
uint256 _finalizationPeriodSeconds,
address _guardian,
bool _paused
) Semver(1, 1, 0) {
L2_ORACLE = _l2Oracle;
GUARDIAN = _guardian;
FINALIZATION_PERIOD_SECONDS = _finalizationPeriodSeconds;
initialize();
initialize(_paused);
}

/**
* @notice Initializer.
*/
function initialize() public initializer {
function initialize(bool _paused) public initializer {
l2Sender = Constants.DEFAULT_L2_SENDER;
paused = _paused;
__ResourceMetering_init();
}

/**
* @notice Pause deposits and withdrawals.
*/
function pause() external {
require(msg.sender == GUARDIAN, "OptimismPortal: only guardian can pause");
paused = true;
emit Paused(msg.sender);
}

/**
* @notice Unpause deposits and withdrawals.
*/
function unpause() external {
require(msg.sender == GUARDIAN, "OptimismPortal: only guardian can unpause");
paused = false;
emit Unpaused(msg.sender);
}

/**
* @notice Accepts value so that users can send ETH directly to this contract and have the
* funds be deposited to their address on L2. This is intended as a convenience
Expand Down Expand Up @@ -162,7 +223,7 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
uint256 _l2OutputIndex,
Types.OutputRootProof calldata _outputRootProof,
bytes[] calldata _withdrawalProof
) external {
) external whenNotPaused {
// Prevent users from creating a deposit transaction where this address is the message
// sender on L2. Because this is checked here, we do not need to check again in
// `finalizeWithdrawalTransaction`.
Expand Down Expand Up @@ -240,7 +301,10 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
*
* @param _tx Withdrawal transaction to finalize.
*/
function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external {
function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx)
external
whenNotPaused
{
// Make sure that the l2Sender has not yet been set. The l2Sender is set to a value other
// than the default value when a withdrawal transaction is being finalized. This check is
// a defacto reentrancy guard.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ contract SystemDictator is OwnableUpgradeable {
*/
L2OutputOracleDynamicConfig public l2OutputOracleDynamicConfig;

/**
* @notice Dynamic configuration for the OptimismPortal. Determines
* if the system should be paused when initialized.
*/
bool public optimismPortalDynamicConfig;

/**
* @notice Current step;
*/
Expand Down Expand Up @@ -160,14 +166,17 @@ contract SystemDictator is OwnableUpgradeable {
}

/**
* @notice Allows the owner to update dynamic L2OutputOracle config.
* @notice Allows the owner to update dynamic config.
*
* @param _l2OutputOracleDynamicConfig Dynamic L2OutputOracle config.
* @param _optimismPortalDynamicConfig Dynamic OptimismPortal config.
*/
function updateL2OutputOracleDynamicConfig(
L2OutputOracleDynamicConfig memory _l2OutputOracleDynamicConfig
function updateDynamicConfig(
L2OutputOracleDynamicConfig memory _l2OutputOracleDynamicConfig,
bool _optimismPortalDynamicConfig
) external onlyOwner {
l2OutputOracleDynamicConfig = _l2OutputOracleDynamicConfig;
optimismPortalDynamicConfig = _optimismPortalDynamicConfig;
dynamicConfigSet = true;
}

Expand Down Expand Up @@ -314,7 +323,7 @@ contract SystemDictator is OwnableUpgradeable {
config.globalConfig.proxyAdmin.upgradeAndCall(
payable(config.proxyAddressConfig.optimismPortalProxy),
address(config.implementationAddressConfig.optimismPortalImpl),
abi.encodeCall(OptimismPortal.initialize, ())
abi.encodeCall(OptimismPortal.initialize, (optimismPortalDynamicConfig))
);

// Upgrade the L1CrossDomainMessenger.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ contract EchidnaFuzzOptimismPortal {
bool internal failedToComplete;

constructor() {
portal = new OptimismPortal(L2OutputOracle(address(0)), 10);
portal = new OptimismPortal({
_l2Oracle: L2OutputOracle(address(0)),
_guardian: address(0),
_finalizationPeriodSeconds: 10,
_paused: false
});
}

// A test intended to identify any unexpected halting conditions
Expand Down
19 changes: 16 additions & 3 deletions packages/contracts-bedrock/contracts/test/CommonTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ contract L2OutputOracle_Initializer is CommonTest {
uint256 internal l2BlockTime = 2;
uint256 internal startingBlockNumber = 200;
uint256 internal startingTimestamp = 1000;
address guardian;

// Test data
uint256 initL1Time;
Expand All @@ -119,6 +120,8 @@ contract L2OutputOracle_Initializer is CommonTest {

function setUp() public virtual override {
super.setUp();
guardian = makeAddr("guardian");

// 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;
Expand Down Expand Up @@ -164,12 +167,17 @@ contract Portal_Initializer is L2OutputOracle_Initializer {
function setUp() public virtual override {
super.setUp();

opImpl = new OptimismPortal(oracle, 7 days);
opImpl = new OptimismPortal({
_l2Oracle: oracle,
_guardian: guardian,
_finalizationPeriodSeconds: 7 days,
_paused: true
});
Proxy proxy = new Proxy(multisig);
vm.prank(multisig);
proxy.upgradeToAndCall(
address(opImpl),
abi.encodeWithSelector(OptimismPortal.initialize.selector)
abi.encodeWithSelector(OptimismPortal.initialize.selector, false)
);
op = OptimismPortal(payable(address(proxy)));
}
Expand Down Expand Up @@ -223,7 +231,12 @@ contract Messenger_Initializer is L2OutputOracle_Initializer {
super.setUp();

// Deploy the OptimismPortal
op = new OptimismPortal(oracle, 7 days);
op = new OptimismPortal({
_l2Oracle: oracle,
_guardian: guardian,
_finalizationPeriodSeconds: 7 days,
_paused: false
});
vm.label(address(op), "OptimismPortal");

// Deploy the address manager
Expand Down
Loading