Skip to content

Commit

Permalink
Merge branch 'main' into Linea-mono
Browse files Browse the repository at this point in the history
  • Loading branch information
huperts authored Jan 7, 2025
2 parents 379a693 + 624c877 commit 502f504
Show file tree
Hide file tree
Showing 113 changed files with 2,894 additions and 886 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coordinator-build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ concurrency:

jobs:
build-and-publish:
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-med
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-large
name: Coordinator build
env:
COMMIT_TAG: ${{ inputs.commit_tag }}
Expand All @@ -78,7 +78,7 @@ jobs:
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 #v4.2.1
- name: Build dist
run: |
./gradlew coordinator:app:installDist --no-daemon
./gradlew coordinator:app:installDist
- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}
uses: docker/login-action@v3
Expand Down
21 changes: 14 additions & 7 deletions .husky/pre-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ const FILE_EXTENSION_FILTERS = {
[FILE_EXTENSION.SOLIDITY]: "\.sol$",
};

// File extension => script in package.json to run
// File extension => script in package.json to run for linting
const FILE_EXTENSION_LINTING_COMMAND = {
[FILE_EXTENSION.TYPESCRIPT]: "pnpm run lint:ts:fix",
[FILE_EXTENSION.SOLIDITY]: "pnpm run lint:sol:fix",
};

// File extension => script in package.json to run for documentation generation
const FILE_EXTENSION_DOCUMENTATION_UPDATING_COMMAND = {
[FILE_EXTENSION.SOLIDITY]: "pnpm run solidity:docgen",
};

// Project => Path in monorepo
const FOLDER_PATH = {
[FOLDER.BRIDGEUI]: "bridge-ui/",
Expand Down Expand Up @@ -95,7 +100,8 @@ function main() {
process.exit(1);
}
const changedFileExtensions = getChangedFileExtensions(folder);
executeLinting(folder, changedFileExtensions);
executeCommand(folder, changedFileExtensions, FILE_EXTENSION_LINTING_COMMAND);
executeCommand(folder, changedFileExtensions, FILE_EXTENSION_DOCUMENTATION_UPDATING_COMMAND);
}

updateGitIndex();
Expand Down Expand Up @@ -180,14 +186,15 @@ function getChangedFileExtensions(_folder) {
}

/**
* Execute linting command
* @param {FOLDER, FILE_EXTENSION[]}
* Execute command based on file extension
* @param {FOLDER, FILE_EXTENSION[], FILE_EXTENSION_LINTING_COMMAND | FILE_EXTENSION_DOCUMENTATION_UPDATING_COMMAND}
*/
function executeLinting(_folder, _changedFileExtensions) {
function executeCommand(_folder, _changedFileExtensions, _command) {
for (const fileExtension of _changedFileExtensions) {
const path = FOLDER_PATH[_folder];
const cmd = FILE_EXTENSION_LINTING_COMMAND[fileExtension];
console.log(`${fileExtension} change found in ${path}, linting...`);
const cmd = _command[fileExtension];
if (!cmd) return;
console.log(`${fileExtension} change found in ${path}, executing command ${cmd}`);
try {
// Execute command synchronously and stream output directly to the current stdout
execSync(`
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ deploy-token-bridge-l1:
RPC_URL=http:\\localhost:8445/ \
REMOTE_CHAIN_ID=1337 \
TOKEN_BRIDGE_L1=true \
TOKEN_BRIDGE_SECURITY_COUNCIL=0x90F79bf6EB2c4f870365E785982E1f101E93b906 \
L1_TOKEN_BRIDGE_SECURITY_COUNCIL=0x90F79bf6EB2c4f870365E785982E1f101E93b906 \
L2MESSAGESERVICE_ADDRESS=0xe537D669CA013d86EBeF1D64e40fC74CADC91987 \
LINEA_ROLLUP_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 \
npx ts-node local-deployments-artifacts/deployBridgedTokenAndTokenBridge.ts
Expand All @@ -124,7 +124,7 @@ deploy-token-bridge-l2:
RPC_URL=http:\\localhost:8545/ \
REMOTE_CHAIN_ID=31648428 \
TOKEN_BRIDGE_L1=false \
TOKEN_BRIDGE_SECURITY_COUNCIL=0xf17f52151EbEF6C7334FAD080c5704D77216b732 \
L2_TOKEN_BRIDGE_SECURITY_COUNCIL=0xf17f52151EbEF6C7334FAD080c5704D77216b732 \
L2MESSAGESERVICE_ADDRESS=0xe537D669CA013d86EBeF1D64e40fC74CADC91987 \
LINEA_ROLLUP_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 \
npx ts-node local-deployments-artifacts/deployBridgedTokenAndTokenBridge.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ repositories {
url "https://hyperledger.jfrog.io/artifactory/besu-maven/"
content { includeGroupAndSubgroups('org.hyperledger.besu') }
}
maven {
url "https://artifacts.consensys.net/public/linea-besu/maven/"
content {
includeGroupAndSubgroups('io.consensys')
}
}
maven {
url "https://artifacts.consensys.net/public/maven/maven/"
}
Expand Down
13 changes: 0 additions & 13 deletions contracts/abi/LineaRollupV6.0.abi
Original file line number Diff line number Diff line change
Expand Up @@ -983,19 +983,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "GENESIS_SHNARF",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "INBOX_STATUS_RECEIVED",
Expand Down
54 changes: 21 additions & 33 deletions contracts/contracts/LineaRollup.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.26;

import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { L1MessageService } from "./messageService/l1/L1MessageService.sol";
import { ZkEvmV2 } from "./ZkEvmV2.sol";
Expand All @@ -14,14 +13,7 @@ import { Utils } from "./lib/Utils.sol";
* @author ConsenSys Software Inc.
* @custom:security-contact security-report@linea.build
*/
contract LineaRollup is
Initializable,
AccessControlUpgradeable,
ZkEvmV2,
L1MessageService,
PermissionsManager,
ILineaRollup
{
contract LineaRollup is AccessControlUpgradeable, ZkEvmV2, L1MessageService, PermissionsManager, ILineaRollup {
using Utils for *;

/// @notice This is the ABI version and not the reinitialize version.
Expand All @@ -33,18 +25,6 @@ contract LineaRollup is
/// @notice The role required to set/remove proof verifiers by type.
bytes32 public constant VERIFIER_UNSETTER_ROLE = keccak256("VERIFIER_UNSETTER_ROLE");

/// @notice The default genesis shnarf using empty/default hashes and a default state.
bytes32 public constant GENESIS_SHNARF =
keccak256(
abi.encode(
EMPTY_HASH,
EMPTY_HASH,
0x072ead6777750dc20232d1cee8dc9a395c2d350df4bbaa5096c6f59b214dcecd,
EMPTY_HASH,
EMPTY_HASH
)
);

/// @dev Value indicating a shnarf exists.
uint256 internal constant SHNARF_EXISTS_DEFAULT_VALUE = 1;

Expand Down Expand Up @@ -122,6 +102,10 @@ contract LineaRollup is

__MessageService_init(_initializationData.rateLimitPeriodInSeconds, _initializationData.rateLimitAmountInWei);

if (_initializationData.defaultAdmin == address(0)) {
revert ZeroAddressNotAllowed();
}

/**
* @dev DEFAULT_ADMIN_ROLE is set for the security council explicitly,
* as the permissions init purposefully does not allow DEFAULT_ADMIN_ROLE to be set.
Expand All @@ -132,15 +116,26 @@ contract LineaRollup is

verifiers[0] = _initializationData.defaultVerifier;

if (_initializationData.fallbackOperator == address(0)) {
revert ZeroAddressNotAllowed();
}

fallbackOperator = _initializationData.fallbackOperator;
emit FallbackOperatorAddressSet(msg.sender, _initializationData.fallbackOperator);

currentL2BlockNumber = _initializationData.initialL2BlockNumber;
stateRootHashes[_initializationData.initialL2BlockNumber] = _initializationData.initialStateRootHash;

blobShnarfExists[GENESIS_SHNARF] = SHNARF_EXISTS_DEFAULT_VALUE;
bytes32 genesisShnarf = _computeShnarf(
EMPTY_HASH,
EMPTY_HASH,
_initializationData.initialStateRootHash,
EMPTY_HASH,
EMPTY_HASH
);

currentFinalizedShnarf = GENESIS_SHNARF;
blobShnarfExists[genesisShnarf] = SHNARF_EXISTS_DEFAULT_VALUE;
currentFinalizedShnarf = genesisShnarf;
currentFinalizedState = _computeLastFinalizedState(0, EMPTY_HASH, _initializationData.genesisTimestamp);
}

Expand Down Expand Up @@ -487,8 +482,7 @@ contract LineaRollup is
_finalizationData,
lastFinalizedShnarf,
finalShnarf,
lastFinalizedBlockNumber,
_finalizationData.endBlockNumber
lastFinalizedBlockNumber
);

_verifyProof(publicInput, _proofType, _aggregatedProof);
Expand All @@ -504,10 +498,6 @@ contract LineaRollup is
FinalizationDataV3 calldata _finalizationData,
uint256 _lastFinalizedBlock
) internal returns (bytes32 finalShnarf) {
if (_finalizationData.endBlockNumber <= _lastFinalizedBlock) {
revert FinalBlockNumberLessThanOrEqualToLastFinalizedBlock(_finalizationData.endBlockNumber, _lastFinalizedBlock);
}

_validateL2ComputedRollingHash(_finalizationData.l1RollingHashMessageNumber, _finalizationData.l1RollingHash);

if (
Expand Down Expand Up @@ -678,14 +668,12 @@ contract LineaRollup is
* @param _finalizationData The full finalization data.
* @param _finalShnarf The final shnarf in the finalization.
* @param _lastFinalizedBlockNumber The last finalized block number.
* @param _endBlockNumber End block number being finalized.
*/
function _computePublicInput(
FinalizationDataV3 calldata _finalizationData,
bytes32 _lastFinalizedShnarf,
bytes32 _finalShnarf,
uint256 _lastFinalizedBlockNumber,
uint256 _endBlockNumber
uint256 _lastFinalizedBlockNumber
) private pure returns (uint256 publicInput) {
assembly {
let mPtr := mload(0x40)
Expand All @@ -701,7 +689,7 @@ contract LineaRollup is
mstore(add(mPtr, 0x80), _lastFinalizedBlockNumber)

// _finalizationData.endBlockNumber
mstore(add(mPtr, 0xA0), _endBlockNumber)
calldatacopy(add(mPtr, 0xA0), add(_finalizationData, 0x20), 0x20)

/**
* _finalizationData.lastFinalizedL1RollingHash
Expand Down
5 changes: 2 additions & 3 deletions contracts/contracts/ZkEvmV2.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.26;

import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import { L1MessageServiceV1 } from "./messageService/l1/v1/L1MessageServiceV1.sol";
import { IZkEvmV2 } from "./interfaces/l1/IZkEvmV2.sol";
Expand All @@ -11,7 +10,7 @@ import { IPlonkVerifier } from "./interfaces/l1/IPlonkVerifier.sol";
* @author ConsenSys Software Inc.
* @custom:security-contact security-report@linea.build
*/
abstract contract ZkEvmV2 is Initializable, AccessControlUpgradeable, L1MessageServiceV1, IZkEvmV2 {
abstract contract ZkEvmV2 is AccessControlUpgradeable, L1MessageServiceV1, IZkEvmV2 {
uint256 internal constant MODULO_R = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

Expand Down Expand Up @@ -49,7 +48,7 @@ abstract contract ZkEvmV2 is Initializable, AccessControlUpgradeable, L1MessageS
}

(bool callSuccess, bytes memory result) = verifierToUse.call(
abi.encodeWithSelector(IPlonkVerifier.Verify.selector, _proof, publicInput)
abi.encodeCall(IPlonkVerifier.Verify, (_proof, publicInput))
);

if (!callSuccess) {
Expand Down
48 changes: 48 additions & 0 deletions contracts/contracts/interfaces/IPauseManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,29 @@ interface IPauseManager {
*/
event PauseTypeRoleSet(PauseType indexed pauseType, bytes32 indexed role);

/**
* @notice Emitted when a pause type and its associated role are updated in the `_PauseTypeRoles` mapping.
* @param pauseType The indexed type of pause.
* @param role The indexed role associated with the pause type.
* @param previousRole The indexed previously found role associated with the pause type.
*/
event PauseTypeRoleUpdated(PauseType indexed pauseType, bytes32 indexed role, bytes32 indexed previousRole);

/**
* @notice Emitted when an unpause type and its associated role are set in the `_unPauseTypeRoles` mapping.
* @param unPauseType The indexed type of unpause.
* @param role The indexed role associated with the unpause type.
*/
event UnPauseTypeRoleSet(PauseType indexed unPauseType, bytes32 indexed role);

/**
* @notice Emitted when an unpause type and its associated role are updated in the `_unPauseTypeRoles` mapping.
* @param unPauseType The indexed type of unpause.
* @param role The indexed role associated with the unpause type.
* @param previousRole The indexed previously found role associated with the unpause type.
*/
event UnPauseTypeRoleUpdated(PauseType indexed unPauseType, bytes32 indexed role, bytes32 indexed previousRole);

/**
* @dev Thrown when a specific pause type is paused.
*/
Expand All @@ -74,15 +90,27 @@ interface IPauseManager {
*/
error IsNotPaused(PauseType pauseType);

/**
* @dev Thrown when the unused paused type is used.
*/
error PauseTypeNotUsed();

/**
* @dev Thrown when trying to update a pause/unpause type role mapping to the existing role.
*/
error RolesNotDifferent();

/**
* @notice Pauses functionality by specific type.
* @dev Throws if UNUSED pause type is used.
* @dev Requires the role mapped in pauseTypeRoles for the pauseType.
* @param _pauseType The pause type value.
*/
function pauseByType(PauseType _pauseType) external;

/**
* @notice Unpauses functionality by specific type.
* @dev Throws if UNUSED pause type is used.
* @dev Requires the role mapped in unPauseTypeRoles for the pauseType.
* @param _pauseType The pause type value.
*/
Expand All @@ -94,4 +122,24 @@ interface IPauseManager {
* @return pauseTypeIsPaused Returns true if the pause type if paused, false otherwise.
*/
function isPaused(PauseType _pauseType) external view returns (bool pauseTypeIsPaused);

/**
* @notice Update the pause type role mapping.
* @dev Throws if UNUSED pause type is used.
* @dev Throws if role not different.
* @dev PAUSE_ALL_ROLE role is required to execute this function.
* @param _pauseType The pause type value to update.
* @param _newRole The role to update to.
*/
function updatePauseTypeRole(PauseType _pauseType, bytes32 _newRole) external;

/**
* @notice Update the unpause type role mapping.
* @dev Throws if UNUSED pause type is used.
* @dev Throws if role not different.
* @dev UNPAUSE_ALL_ROLE role is required to execute this function.
* @param _pauseType The pause type value to update.
* @param _newRole The role to update to.
*/
function updateUnpauseTypeRole(PauseType _pauseType, bytes32 _newRole) external;
}
5 changes: 0 additions & 5 deletions contracts/contracts/interfaces/l1/ILineaRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,6 @@ interface ILineaRollup {
*/
error FinalizationStateIncorrect(bytes32 expected, bytes32 value);

/**
* @dev Thrown when the final block number in finalization data is less than or equal to the last finalized block during finalization.
*/
error FinalBlockNumberLessThanOrEqualToLastFinalizedBlock(uint256 finalBlockNumber, uint256 lastFinalizedBlock);

/**
* @dev Thrown when the final block state equals the zero hash during finalization.
*/
Expand Down
Loading

0 comments on commit 502f504

Please sign in to comment.