From 54cd6cc5e42ec6aa84db1ca1788efee6f9ac1f9a Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Mon, 9 Jan 2023 17:47:48 +0100 Subject: [PATCH 1/4] Add isSequencer mapping to SequencerInbox --- contracts/src/bridge/ISequencerInbox.sol | 9 +++++++++ contracts/src/bridge/SequencerInbox.sol | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/contracts/src/bridge/ISequencerInbox.sol b/contracts/src/bridge/ISequencerInbox.sol index d801dca356..35a9b34771 100644 --- a/contracts/src/bridge/ISequencerInbox.sol +++ b/contracts/src/bridge/ISequencerInbox.sol @@ -69,6 +69,8 @@ interface ISequencerInbox is IDelayedMessageProvider { function isBatchPoster(address) external view returns (bool); + function isSequencer(address) external view returns (bool); + struct DasKeySetInfo { bool isValidKeyset; uint64 creationBlock; @@ -154,6 +156,13 @@ interface ISequencerInbox is IDelayedMessageProvider { */ function invalidateKeysetHash(bytes32 ksHash) external; + /** + * @notice Updates whether an address is authorized to be a sequencer at the sequencer inbox + * @param addr the address + * @param isSequencer_ if the specified address should be authorized as a sequencer + */ + function setIsSequencer(address addr, bool isSequencer_) external; + // ---------- initializer ---------- function initialize(IBridge bridge_, MaxTimeVariation calldata maxTimeVariation_) external; diff --git a/contracts/src/bridge/SequencerInbox.sol b/contracts/src/bridge/SequencerInbox.sol index 5072359b09..62e7f1815b 100644 --- a/contracts/src/bridge/SequencerInbox.sol +++ b/contracts/src/bridge/SequencerInbox.sol @@ -53,6 +53,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox IOwnable public rollup; mapping(address => bool) public isBatchPoster; + mapping(address => bool) public isSequencer; ISequencerInbox.MaxTimeVariation public maxTimeVariation; mapping(bytes32 => DasKeySetInfo) public dasKeySetInfo; @@ -450,6 +451,12 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox emit OwnerFunctionCalled(3); } + /// @inheritdoc ISequencerInbox + function setIsSequencer(address addr, bool isSequencer_) external onlyRollupOwner { + isSequencer[addr] = isSequencer_; + emit OwnerFunctionCalled(4); + } + function isValidKeysetHash(bytes32 ksHash) external view returns (bool) { return dasKeySetInfo[ksHash].isValidKeyset; } From 7ac17e063cc5ce5551c7362a32f39fa1ac576813 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Mon, 9 Jan 2023 19:05:00 +0100 Subject: [PATCH 2/4] move the isSequencer field --- contracts/src/bridge/SequencerInbox.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/src/bridge/SequencerInbox.sol b/contracts/src/bridge/SequencerInbox.sol index 62e7f1815b..c95cd70b72 100644 --- a/contracts/src/bridge/SequencerInbox.sol +++ b/contracts/src/bridge/SequencerInbox.sol @@ -53,7 +53,6 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox IOwnable public rollup; mapping(address => bool) public isBatchPoster; - mapping(address => bool) public isSequencer; ISequencerInbox.MaxTimeVariation public maxTimeVariation; mapping(bytes32 => DasKeySetInfo) public dasKeySetInfo; @@ -65,6 +64,8 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox uint256 internal immutable deployTimeChainId = block.chainid; + mapping(address => bool) public isSequencer; + function _chainIdChanged() internal view returns (bool) { return deployTimeChainId != block.chainid; } From 3af18897ac698f799fac3109941bbcf46b361544 Mon Sep 17 00:00:00 2001 From: gzeon <95478735+gzeoneth@users.noreply.github.com> Date: Tue, 10 Jan 2023 05:42:03 +0900 Subject: [PATCH 3/4] chore: update SequencerInbox storage layout --- contracts/test/storage/SequencerInbox.dot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/test/storage/SequencerInbox.dot b/contracts/test/storage/SequencerInbox.dot index 81ca079da4..f9ea05abe5 100644 --- a/contracts/test/storage/SequencerInbox.dot +++ b/contracts/test/storage/SequencerInbox.dot @@ -4,7 +4,7 @@ rankdir=LR color=black arrowhead=open node [shape=record, style=filled, fillcolor=gray95 fontname="Courier New"] -3 [label="SequencerInbox \<\\>\n | {{ slot| 0 | 1 | 2 | 3 | 4-7 | 8 } | { type: \.variable (bytes) | { uint256: totalDelayedMessagesRead (32) } | { unallocated (12) | IBridge: bridge (20) } | { unallocated (12) | IOwnable: rollup (20) } | { mapping\(address=\>bool\): isBatchPoster (32) } | { <9> ISequencerInbox.MaxTimeVariation: maxTimeVariation (128) } | { <12> mapping\(bytes32=\>DasKeySetInfo\): dasKeySetInfo (32) }}}"] +3 [label="SequencerInbox \<\\>\n | {{ slot| 0 | 1 | 2 | 3 | 4-7 | 8 | 9 } | { type: \.variable (bytes) | { uint256: totalDelayedMessagesRead (32) } | { unallocated (12) | IBridge: bridge (20) } | { unallocated (12) | IOwnable: rollup (20) } | { mapping\(address=\>bool\): isBatchPoster (32) } | { <9> ISequencerInbox.MaxTimeVariation: maxTimeVariation (128) } | { <12> mapping\(bytes32=\>DasKeySetInfo\): dasKeySetInfo (32) } | { mapping\(address=\>bool\): isSequencer (32) }}}"] 1 [label="ISequencerInbox.MaxTimeVariation \<\\>\n | {{ slot| 4 | 5 | 6 | 7 } | { type: variable (bytes) | { uint256: MaxTimeVariation.delayBlocks (32) } | { uint256: MaxTimeVariation.futureBlocks (32) } | { uint256: MaxTimeVariation.delaySeconds (32) } | { uint256: MaxTimeVariation.futureSeconds (32) }}}"] From 9b48858f6e1b7422a9bc5494b433b7a30026b778 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Wed, 11 Jan 2023 23:35:50 +0100 Subject: [PATCH 4/4] update setIsSequencer comment --- contracts/src/bridge/ISequencerInbox.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/src/bridge/ISequencerInbox.sol b/contracts/src/bridge/ISequencerInbox.sol index 35a9b34771..994c7c0126 100644 --- a/contracts/src/bridge/ISequencerInbox.sol +++ b/contracts/src/bridge/ISequencerInbox.sol @@ -157,7 +157,8 @@ interface ISequencerInbox is IDelayedMessageProvider { function invalidateKeysetHash(bytes32 ksHash) external; /** - * @notice Updates whether an address is authorized to be a sequencer at the sequencer inbox + * @notice Updates whether an address is authorized to be a sequencer. + * @dev The IsSequencer information is used only off-chain by the nitro node to validate sequencer feed signer. * @param addr the address * @param isSequencer_ if the specified address should be authorized as a sequencer */