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

Add isSequencer mapping to SequencerInbox #1424

Merged
merged 5 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions contracts/src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -154,6 +156,14 @@ interface ISequencerInbox is IDelayedMessageProvider {
*/
function invalidateKeysetHash(bytes32 ksHash) external;

/**
* @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
*/
function setIsSequencer(address addr, bool isSequencer_) external;

// ---------- initializer ----------

function initialize(IBridge bridge_, MaxTimeVariation calldata maxTimeVariation_) external;
Expand Down
8 changes: 8 additions & 0 deletions contracts/src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,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;
}
Expand Down Expand Up @@ -450,6 +452,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;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/storage/SequencerInbox.dot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ rankdir=LR
color=black
arrowhead=open
node [shape=record, style=filled, fillcolor=gray95 fontname="Courier New"]
3 [label="SequencerInbox \<\<Contract\>\>\n | {{ slot| 0 | 1 | 2 | 3 | 4-7 | 8 } | { type: \<inherited contract\>.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 \<\<Contract\>\>\n | {{ slot| 0 | 1 | 2 | 3 | 4-7 | 8 | 9 } | { type: \<inherited contract\>.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 \<\<Struct\>\>\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) }}}"]

Expand Down