Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bd550e8
feat: L1Sequencer history + SequencerVerifier + deploy fix
Mar 26, 2026
4e51151
feat: P2P security test framework (build-malicious + p2p-test)
Mar 26, 2026
515d295
fix: p2p security test script improvements
Mar 26, 2026
8e13d7e
fix: sequencer key + L1 initializeHistory in devnet setup
Mar 27, 2026
f8c5788
fix: T-06 blocksync main path + Phase 0 precondition checks
Mar 27, 2026
04acf4f
feat: L1Sequencer unit tests + bindings regen + verifier retry backoff
Mar 27, 2026
d3493fd
refactor: rename Solidity struct SequencerRecord -> HistoryRecord
Mar 27, 2026
d02d69d
refactor: remove CONSENSUS_SWITCH_HEIGHT flag, read upgrade height fr…
Mar 30, 2026
9014457
revert: restore docker-compose-4nodes.yml to main state
Apr 16, 2026
af30743
fix: swap ServerSuffrage iota so Nonvoter=0 (safer zero value)
Apr 8, 2026
51cdfcb
feat: Sequencer HA V2 — Raft-based high availability for single seque…
Apr 9, 2026
5360350
feat: add NewL2BlockV2 support in executor + RetryableClient
Apr 16, 2026
9916a91
feat: mark block hash and NextL1MsgIndex errors as non-retryable
Apr 17, 2026
9b5fd23
fix: ensure L1 syncer is initialized for post-upgrade sequencer nodes…
Apr 28, 2026
9ab9f9d
feature: optimize ha test script & docker file
Apr 30, 2026
56d8869
fix: harden BlockFSM.Apply and increase blockCh buffer
May 7, 2026
7b9324b
chore: bump go-ethereum and tendermint to feat/sequencer-optimize branch
May 8, 2026
8f4c5ee
chore: pin go-ethereum to 56deb7072 across all modules
May 9, 2026
a64bbfd
deps: bump tendermint to v0.0.0-20260515043308-c6f7e21e4b14
May 15, 2026
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
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
################## update dependencies ####################
ETHEREUM_SUBMODULE_COMMIT_OR_TAG := morph-v2.2.2
ETHEREUM_TARGET_VERSION := morph-v2.2.2
TENDERMINT_TARGET_VERSION := v0.3.7
ETHEREUM_SUBMODULE_COMMIT_OR_TAG := 56deb7072ae467a12a850815c7a5c09b7c2782ba
ETHEREUM_TARGET_VERSION := v0.0.0-20260508105911-56deb7072ae4
TENDERMINT_TARGET_VERSION := v0.0.0-20260515043308-c6f7e21e4b14


ETHEREUM_MODULE_NAME := github.com/morph-l2/go-ethereum
Expand Down
236 changes: 201 additions & 35 deletions bindings/bindings/l1sequencer.go

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions bindings/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module morph-l2/bindings

go 1.24.0

replace github.com/tendermint/tendermint => github.com/morph-l2/tendermint v0.3.7
replace github.com/tendermint/tendermint => github.com/morph-l2/tendermint v0.0.0-20260515043308-c6f7e21e4b14

require github.com/morph-l2/go-ethereum v1.10.14-0.20260506071313-045be0fdc7ca
require github.com/morph-l2/go-ethereum v0.0.0-20260508105911-56deb7072ae4

require (
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
Expand Down Expand Up @@ -46,3 +46,5 @@ require (
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/morph-l2/go-ethereum => github.com/morph-l2/go-ethereum v0.0.0-20260508105911-56deb7072ae4
4 changes: 2 additions & 2 deletions bindings/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqky
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/morph-l2/go-ethereum v1.10.14-0.20260506071313-045be0fdc7ca h1:ogHsgxvm1wzyNKYDSAsIi0PJZeu9VhQECSL91X/KTWI=
github.com/morph-l2/go-ethereum v1.10.14-0.20260506071313-045be0fdc7ca/go.mod h1:nkVzHjQWCOjvukQW8ittlwX+Xz9gmVHrP7mUi7zoHTs=
github.com/morph-l2/go-ethereum v0.0.0-20260508105911-56deb7072ae4 h1:u8oa1NfdZu20Tq4QjKw5R5T9W6Pvjawq0KBKK53mHrk=
github.com/morph-l2/go-ethereum v0.0.0-20260508105911-56deb7072ae4/go.mod h1:nkVzHjQWCOjvukQW8ittlwX+Xz9gmVHrP7mUi7zoHTs=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
Expand Down
129 changes: 104 additions & 25 deletions contracts/contracts/l1/L1Sequencer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,134 @@ pragma solidity =0.8.24;
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

/// @title L1Sequencer
/// @notice L1 contract for managing the sequencer address.
/// The sequencer address can be updated by the owner (multisig recommended).
/// @notice L1 contract for managing sequencer address with history tracking.
/// Supports querying which sequencer was active at any given L2 block height.
contract L1Sequencer is OwnableUpgradeable {
// ============ Types ============

struct HistoryRecord {
uint64 startL2Block;
address sequencerAddr;
}

// ============ Storage ============

/// @notice Current sequencer address
address public sequencer;
/// @notice Ordered array of sequencer records (by startL2Block ascending).
/// sequencerHistory[0] is the first sequencer after PBFT → single-sequencer upgrade.
HistoryRecord[] public sequencerHistory;

/// @notice The L2 block height at which single-sequencer mode activates.
/// Set by initializeHistory(). Nodes read this to know when to switch consensus.
uint64 public activeHeight;

// ============ Events ============

/// @notice Emitted when sequencer is updated
event SequencerUpdated(address indexed oldSequencer, address indexed newSequencer);
event SequencerUpdated(
address indexed oldSequencer,
address indexed newSequencer,
uint64 startL2Block
);

// ============ Initializer ============

/// @notice Initialize the contract
/// @param _owner Contract owner (multisig recommended)
/// @param _initialSequencer Initial sequencer address (can be address(0) to set later)
function initialize(address _owner, address _initialSequencer) external initializer {
function initialize(address _owner) external initializer {
require(_owner != address(0), "invalid owner");

__Ownable_init();
_transferOwnership(_owner);

// Set initial sequencer if provided
if (_initialSequencer != address(0)) {
sequencer = _initialSequencer;
emit SequencerUpdated(address(0), _initialSequencer);
}
}

// ============ Admin Functions ============

/// @notice Update sequencer address (takes effect immediately)
/// @param newSequencer New sequencer address
function updateSequencer(address newSequencer) external onlyOwner {
require(newSequencer != address(0), "invalid sequencer");
require(newSequencer != sequencer, "same sequencer");
/// @notice Initialize sequencer history (called once before the L2 upgrade).
/// @param firstSequencer The first sequencer address after the upgrade.
/// @param upgradeL2Block The L2 block height where single-sequencer mode activates.
function initializeHistory(
address firstSequencer,
uint64 upgradeL2Block
) external onlyOwner {
require(sequencerHistory.length == 0, "already initialized");
require(firstSequencer != address(0), "invalid address");

sequencerHistory.push(HistoryRecord({
startL2Block: upgradeL2Block,
sequencerAddr: firstSequencer
}));
activeHeight = upgradeL2Block;

emit SequencerUpdated(address(0), firstSequencer, upgradeL2Block);
}

/// @notice Register a sequencer change at a future L2 block height.
/// The new sequencer is NOT active until startL2Block is reached.
/// @param newSequencer New sequencer address.
/// @param startL2Block L2 block height when the new sequencer takes over.
/// Must be strictly greater than the last record.
function updateSequencer(
address newSequencer,
uint64 startL2Block
) external onlyOwner {
require(newSequencer != address(0), "invalid address");
require(sequencerHistory.length > 0, "not initialized");
require(
startL2Block > sequencerHistory[sequencerHistory.length - 1].startL2Block,
"startL2Block must be greater than last record"
);

address oldSequencer = sequencer;
sequencer = newSequencer;
address oldSequencer = sequencerHistory[sequencerHistory.length - 1].sequencerAddr;

emit SequencerUpdated(oldSequencer, newSequencer);
sequencerHistory.push(HistoryRecord({
startL2Block: startL2Block,
sequencerAddr: newSequencer
}));

emit SequencerUpdated(oldSequencer, newSequencer, startL2Block);
}

// ============ View Functions ============

/// @notice Get current sequencer address
/// @notice Get the sequencer that was active at a given L2 block height.
/// @dev Binary search: O(log n).
function getSequencerAt(uint64 l2Height) external view returns (address) {
uint256 len = sequencerHistory.length;
require(len > 0, "no sequencer configured");

uint256 low = 0;
uint256 high = len - 1;
uint256 result = 0;

while (low <= high) {
uint256 mid = (low + high) / 2;
if (sequencerHistory[mid].startL2Block <= l2Height) {
result = mid;
if (mid == high) break;
low = mid + 1;
} else {
if (mid == 0) break;
high = mid - 1;
}
}

require(sequencerHistory[result].startL2Block <= l2Height, "no sequencer at height");
return sequencerHistory[result].sequencerAddr;
}

/// @notice Get the latest registered sequencer address (backward compat).
/// @dev If the latest record's startL2Block hasn't been reached yet,
/// this address is scheduled but not yet active.
function getSequencer() external view returns (address) {
return sequencer;
require(sequencerHistory.length > 0, "no sequencer configured");
return sequencerHistory[sequencerHistory.length - 1].sequencerAddr;
}

/// @notice Get the full sequencer history (for L2 node bulk sync at startup).
function getSequencerHistory() external view returns (HistoryRecord[] memory) {
return sequencerHistory;
}

/// @notice Get the number of sequencer history records.
function getSequencerHistoryLength() external view returns (uint256) {
return sequencerHistory.length;
}
}
Loading
Loading