Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
48fcc27
RLP Writing of eip1559 tx
thedarkjester Mar 27, 2025
0f92c40
remove restriction
thedarkjester Mar 27, 2025
525a2bb
reset with pnpm i
thedarkjester Mar 27, 2025
6246a46
use better variable name
thedarkjester Mar 28, 2025
20f1e67
rename and add NatSpec
thedarkjester Mar 28, 2025
0700c43
finish test coverage and split helper file
thedarkjester Mar 28, 2025
3086421
compute totalLen in assembly 2k gas save
thedarkjester Mar 28, 2025
065c66d
reuse memory variable for consistency
thedarkjester Mar 28, 2025
f3cf95d
add larger calldata test
thedarkjester Mar 28, 2025
7309379
support access lists
thedarkjester Mar 29, 2025
49b806a
use standard naming conventions
thedarkjester Mar 29, 2025
93ff836
let the compile control increments
thedarkjester Mar 31, 2025
5f42ca2
support signed ints
thedarkjester Mar 31, 2025
11f13e8
use binary search from kyzooghost
thedarkjester Apr 4, 2025
b5aedad
use better naming and remove duplicate pointer
thedarkjester Apr 4, 2025
e94da4f
Merge branch 'main' into feat/817-rlp-tx-writer
thedarkjester Apr 4, 2025
9cf3261
Merge branch 'main' into feat/817-rlp-tx-writer
thedarkjester Apr 4, 2025
54d5b2f
standardise _flatten with assembly
thedarkjester Apr 4, 2025
efcd93e
initial workings for the forced tx gateway
thedarkjester Apr 8, 2025
b78c8fe
move to more appropriate spot
thedarkjester Apr 8, 2025
1fa199e
use correct folders
thedarkjester Apr 8, 2025
267b551
add finalization logic
thedarkjester Apr 9, 2025
9821c44
use new structure for smuggling test
thedarkjester Apr 9, 2025
7422fd8
use correct function in test
thedarkjester Apr 9, 2025
e48bc39
deduplicate forced transactions
thedarkjester Apr 9, 2025
1193dd2
uncheck next forced tx number
thedarkjester Apr 10, 2025
0e5e55a
Merge branch 'main' into feat/tx-gateway
thedarkjester Apr 10, 2025
ad6c80e
use all fields for setFallbackOperator
thedarkjester Apr 10, 2025
8bef6f2
constructor tests and more coverage
thedarkjester Apr 10, 2025
87fcfa9
cover reinitialization in tests
thedarkjester Apr 10, 2025
942148c
placeholder for new public input fields
thedarkjester Apr 10, 2025
a683e3d
extra fields for expected public input reading
thedarkjester Apr 10, 2025
40f8693
[Feat] Edits for feat/tx-gateway branch (#881)
kyzooghost Apr 22, 2025
440989c
order functions correctly for readability
thedarkjester Apr 22, 2025
df8a4e5
adjust naming for state field retrieval
thedarkjester Apr 23, 2025
5e0801b
add NatSpec comment on mcopy
thedarkjester Apr 23, 2025
e732623
cover less than block on ftx submission
thedarkjester Apr 23, 2025
4cb1503
add censorship resistance check
thedarkjester Apr 24, 2025
661804e
Merge branch 'main' into feat/tx-gateway
thedarkjester Apr 25, 2025
e51deaf
use better naming for missing tx error
thedarkjester Apr 28, 2025
d5146e4
cover ftx race condition
thedarkjester Apr 28, 2025
4c06f21
cover ftx race condition
thedarkjester Apr 28, 2025
2d1bc37
Merge branch 'main' into feat/tx-gateway
thedarkjester Apr 28, 2025
cfe915c
simplify event signature - 1200 gas saved
thedarkjester Apr 29, 2025
5aea262
Merge branch 'main' into feat/tx-gateway
thedarkjester May 1, 2025
4569c55
Merge branch 'main' into feat/tx-gateway
thedarkjester May 9, 2025
b158098
set memory length correctly
thedarkjester May 13, 2025
575f8f1
Merge branch 'main' into feat/tx-gateway
thedarkjester May 13, 2025
a43276e
bump to 0.8.30
thedarkjester May 13, 2025
355e59a
remove pointless space
thedarkjester May 13, 2025
6e0f0b8
Merge branch 'main' into feat/tx-gateway
thedarkjester May 16, 2025
7a95ad0
Merge branch 'main' into feat/tx-gateway
thedarkjester May 20, 2025
7978bd5
coordinator: update compressor binaries (#1029)
fluentcrafter May 20, 2025
e10060c
fix: fix layerswap modal issue on mobile (#1027)
viphan007 May 20, 2025
7c0e6d3
feat(spot): adds spot-instance mode (#1031)
AlexandreBelling May 20, 2025
df150f4
chore: update favicon (#1011)
viphan007 May 21, 2025
6d3a2ca
Besu packgae update sequencer version (#1026)
fluentcrafter May 21, 2025
71139df
coordinator: improve blob libs loading (#1033)
fluentcrafter May 21, 2025
6228d64
[Fix] codecov-external-pr (#961)
kyzooghost May 22, 2025
a45f8b2
update shomei plugin mode
FlorianHuc May 22, 2025
c19be48
[Fix] Explicitly set commit tags from git commits to 7 characters for…
kyzooghost May 22, 2025
4e51238
feat: remove l2-node in e2e test and make it to run in local stack op…
jonesho May 22, 2025
4e53d6d
Prover limit update proposal for beta-2.0 (#936)
AlexandreBelling May 24, 2025
cfa819d
Prover/beta v2 release (#1043)
AlexandreBelling May 26, 2025
4098f9b
fix: set hardfork to prague for hardhar test (#1046)
VGau May 26, 2025
919b868
fix(log): remove extranous units (#1048)
julien-marchand May 26, 2025
258a9a4
Prover: the controller skips waiting for the sub-process to yield on …
AlexandreBelling May 27, 2025
c17b076
[Feat] Merge linea-sequencer plugin repo into monorepo (#1041)
kyzooghost May 28, 2025
ccc9067
fix(prover): fix constraints assignment patch for the lookup-insertio…
AlexandreBelling May 28, 2025
5fd560f
[Chore] Bump solc version and override L2 contracts (#1051)
thedarkjester May 28, 2025
c59a7f7
[Chore] Tweak contracts post Aderyn run (#1062)
thedarkjester May 28, 2025
2d7b40b
feat: add doc for l1 dynamic gas pricing mechanism (#1056)
jonesho May 29, 2025
abc4c4d
bug(state-manager): fix issue with insertion filter missing in the in…
bogdanbear May 30, 2025
f3574fc
use common variable name for plonk verifier name (#1071)
thedarkjester Jun 2, 2025
55d2a4f
Fixing gradle cache (#1078)
Filter94 Jun 2, 2025
752d54f
[Feat] CSP Header for BridgeUI (#963)
kyzooghost Jun 2, 2025
a44b21a
fix: update blob compressor lib + update dependencies + use tsup (#976)
VGau Jun 2, 2025
dd47e0c
[Feat] Upgrade Spotless from 6.16 to 6.25 (Breaking change) (#1068)
kyzooghost Jun 2, 2025
f484a88
Pinned setup-gradle version (#1081)
Filter94 Jun 3, 2025
907a0e2
feat: added shomei-frontend linea_getProof e2e test (#1077)
jonesho Jun 3, 2025
6e4e29f
[WIP - Tech Debt] Typescript config cleanup (#1073)
kyzooghost Jun 3, 2025
5b49656
Prover: Prepare the setup for 5.1.2 (#1070)
AlexandreBelling Jun 3, 2025
4065845
Workflow to publish all jvm-libs with default version 0.0.<timestamp>…
gauravahuja Jun 3, 2025
4004581
[Fix] Remove targetExclude from Java linting config (#1085)
kyzooghost Jun 3, 2025
8f247da
Fix/bump next and axios versions as per Dependabot (#1091)
kyzooghost Jun 4, 2025
00e17b1
Merge branch 'main' into feat/tx-gateway
thedarkjester Jun 4, 2025
0561f8f
add function back
thedarkjester Jun 4, 2025
9f23f22
format fix
thedarkjester Jun 4, 2025
1a0ffd6
Merge branch 'main' into feat/tx-gateway
thedarkjester Jun 5, 2025
5df3b9a
Merge branch 'main' into feat/tx-gateway
thedarkjester Jun 6, 2025
4edae33
Merge branch 'main' into feat/tx-gateway
thedarkjester Jun 6, 2025
555b5fe
Merge branch 'main' into feat/tx-gateway
thedarkjester Jun 17, 2025
595e9ea
chore: migrate project to Kotlin 2.0.0 and fix null-safety in tests (…
VolodymyrBg Jun 17, 2025
a7e77a0
chore(deps): update dependencies (#1164)
alainncls Jun 17, 2025
50e778b
fix: added test fixtures dependencies for linea-contract-clients (#1166)
jonesho Jun 17, 2025
75d716d
Chore: Update Tracer to beta-v3.1-rc5 (#1165)
fab-10 Jun 17, 2025
125ca8a
fix: update bridge ui next js image config (#1171)
VGau Jun 17, 2025
d0467de
chore: switch to Consensys fork of Tuweni and update it to 2.7.0 (#1074)
fab-10 Jun 17, 2025
42e4c8a
Feat/1076 refactor and allow overriding (#1079)
thedarkjester Jun 17, 2025
415d404
[linea-sequencer-plugin] Block blob tx (#1150)
kyzooghost Jun 18, 2025
a609207
add intercom to csp whitelist (#1177)
kyzooghost Jun 18, 2025
9afe13e
chore: added test fixtures dependencies in kotlin-common-conventions …
jonesho Jun 18, 2025
f69ec87
Merge branch 'main' into feat/tx-gateway
thedarkjester Jun 18, 2025
9c4311f
fighting merge issues
thedarkjester Jun 18, 2025
4a4b0eb
Merge branch 'main' into feat/tx-gateway
thedarkjester Jul 3, 2025
834cae5
Merge branch 'main' into feat/tx-gateway
thedarkjester Jul 3, 2025
11b4d0c
minor tweaks for gas
thedarkjester Jul 3, 2025
ff7541d
revert breaking code
thedarkjester Jul 3, 2025
b41930e
Merge branch 'main' into feat/tx-gateway
thedarkjester Jul 17, 2025
2fa44d8
switch to mimc for hashing unsigned payload
thedarkjester Jul 21, 2025
3b80d77
Merge branch 'main' into feat/tx-gateway
thedarkjester Nov 3, 2025
a69bef5
Merge branch 'main' into feat/tx-gateway
thedarkjester Nov 7, 2025
83cb697
missing test fix
thedarkjester Nov 7, 2025
4339a70
Merge branch 'main' into feat/tx-gateway
thedarkjester Nov 10, 2025
591b9db
Merge branch 'main' into feat/tx-gateway
thedarkjester Nov 14, 2025
bf3e7b8
use require, fix tests and scope files correctly
thedarkjester Nov 14, 2025
d9e7842
allow overriding of forced transaction
thedarkjester Nov 14, 2025
cfec0ac
dev comment
thedarkjester Nov 14, 2025
2276867
wip
thedarkjester Nov 24, 2025
0ea466e
add deny functionality
thedarkjester Nov 24, 2025
de00300
cleanup deny list feature
thedarkjester Nov 25, 2025
37d0f6d
better naming and natspec
thedarkjester Nov 25, 2025
a052353
missed file
thedarkjester Nov 25, 2025
0d53ae0
rename to address filter
thedarkjester Nov 26, 2025
7b2f62a
Merge branch 'main' into feat/tx-gateway
thedarkjester Nov 27, 2025
b51fc07
deploy scripts address filter
thedarkjester Nov 27, 2025
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
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { tryVerifyContract, getDeployedContractAddress, getRequiredEnvVar } from "../common/helpers";
import { tryVerifyContract, getRequiredEnvVar } from "../common/helpers";
import { ethers, upgrades } from "hardhat";
import { RollupRevenueVault__factory } from "contracts/typechain-types";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments } = hre;

const func: DeployFunction = async function () {
const contractName = "RollupRevenueVault";
const existingContractAddress = await getDeployedContractAddress(contractName, deployments);

// RollupRevenueVault DEPLOYED AS UPGRADEABLE PROXY
if (!existingContractAddress) {
console.log(`Deploying initial version, NB: the address will be saved if env SAVE_ADDRESS=true.`);
} else {
console.log(`Deploying new version, NB: ${existingContractAddress} will be overwritten if env SAVE_ADDRESS=true.`);
}

const proxyAddress = getRequiredEnvVar("ROLLUP_REVENUE_VAULT_ADDRESS");

Expand Down
19 changes: 2 additions & 17 deletions contracts/deploy/19_deploy_L1LineaTokenBurner.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import {
getRequiredEnvVar,
getDeployedContractAddress,
LogContractDeployment,
tryVerifyContractWithConstructorArgs,
} from "../common/helpers";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments } = hre;
import { getRequiredEnvVar, LogContractDeployment, tryVerifyContractWithConstructorArgs } from "../common/helpers";

const func: DeployFunction = async function () {
const contractName = "L1LineaTokenBurner";
const existingContractAddress = await getDeployedContractAddress(contractName, deployments);

const messageService = getRequiredEnvVar("LINEA_TOKEN_BURNER_MESSAGE_SERVICE");
const lineaToken = getRequiredEnvVar("LINEA_TOKEN_BURNER_LINEA_TOKEN");

if (!existingContractAddress) {
console.log(`Deploying initial version, NB: the address will be saved if env SAVE_ADDRESS=true.`);
} else {
console.log(`Deploying new version, NB: ${existingContractAddress} will be overwritten if env SAVE_ADDRESS=true.`);
}

const factory = await ethers.getContractFactory(contractName);
const contract = await factory.deploy(messageService, lineaToken);

Expand Down
19 changes: 2 additions & 17 deletions contracts/deploy/20_deploy_V3DexSwapAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import {
getRequiredEnvVar,
getDeployedContractAddress,
LogContractDeployment,
tryVerifyContractWithConstructorArgs,
} from "../common/helpers";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments } = hre;
import { getRequiredEnvVar, LogContractDeployment, tryVerifyContractWithConstructorArgs } from "../common/helpers";

const func: DeployFunction = async function () {
const contractName = "V3DexSwapAdapter";
const existingContractAddress = await getDeployedContractAddress(contractName, deployments);

const router = getRequiredEnvVar("V3_DEX_SWAP_ADAPTER_ROUTER");
const wethToken = getRequiredEnvVar("V3_DEX_SWAP_ADAPTER_WETH_TOKEN");
const lineaToken = getRequiredEnvVar("V3_DEX_SWAP_ADAPTER_LINEA_TOKEN");
const poolTickSpacing = getRequiredEnvVar("V3_DEX_SWAP_ADAPTER_POOL_TICK_SPACING");

if (!existingContractAddress) {
console.log(`Deploying initial version, NB: the address will be saved if env SAVE_ADDRESS=true.`);
} else {
console.log(`Deploying new version, NB: ${existingContractAddress} will be overwritten if env SAVE_ADDRESS=true.`);
}

const factory = await ethers.getContractFactory(contractName);
const contract = await factory.deploy(router, wethToken, lineaToken, poolTickSpacing);

Expand Down
26 changes: 26 additions & 0 deletions contracts/deploy/21_deploy_AddressFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { LogContractDeployment, getRequiredEnvVar, tryVerifyContractWithConstructorArgs } from "../common/helpers";

const func: DeployFunction = async function () {
const contractName = "AddressFilter";

const lineaRollupSecurityCouncil = getRequiredEnvVar("LINEA_ROLLUP_SECURITY_COUNCIL");
const filteredAddresses = getRequiredEnvVar("ADDRESS_FILTER_FILTERED_ADDRESSES").split(",");

const factory = await ethers.getContractFactory(contractName);
const contract = await factory.deploy(lineaRollupSecurityCouncil, filteredAddresses);

await LogContractDeployment(contractName, contract);
const contractAddress = await contract.getAddress();

const args = [lineaRollupSecurityCouncil, filteredAddresses];
await tryVerifyContractWithConstructorArgs(
contractAddress,
"src/rollup/forcedTransactions/AddressFilter.sol:AddressFilter",
args,
);
};

export default func;
func.tags = ["AddressFilter"];
47 changes: 47 additions & 0 deletions contracts/deploy/22_deploy_ForcedTransactionGateway.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { LogContractDeployment, getRequiredEnvVar, tryVerifyContractWithConstructorArgs } from "../common/helpers";

const func: DeployFunction = async function () {
const contractName = "ForcedTransactionGateway";

const lineaRollupAddress = getRequiredEnvVar("LINEA_ROLLUP_ADDRESS");
const destinationChainId = getRequiredEnvVar("FORCED_TRANSACTION_GATEWAY_L2_CHAIN_ID");
const l2BlockBuffer = getRequiredEnvVar("FORCED_TRANSACTION_GATEWAY_L2_BLOCK_BUFFER");
const maxGasLimit = getRequiredEnvVar("FORCED_TRANSACTION_GATEWAY_MAX_GAS_LIMIT");
const maxInputLengthBuffer = getRequiredEnvVar("FORCED_TRANSACTION_GATEWAY_MAX_INPUT_LENGTH_BUFFER");
const defaultAdmin = getRequiredEnvVar("LINEA_ROLLUP_SECURITY_COUNCIL");
const addressFilter = getRequiredEnvVar("FORCED_TRANSACTION_ADDRESS_FILTER");

const factory = await ethers.getContractFactory(contractName);
const contract = await factory.deploy(
lineaRollupAddress,
destinationChainId,
l2BlockBuffer,
maxGasLimit,
maxInputLengthBuffer,
defaultAdmin,
addressFilter,
);

await LogContractDeployment(contractName, contract);
const contractAddress = await contract.getAddress();

const args = [
lineaRollupAddress,
destinationChainId,
l2BlockBuffer,
maxGasLimit,
maxInputLengthBuffer,
defaultAdmin,
addressFilter,
];
await tryVerifyContractWithConstructorArgs(
contractAddress,
"src/rollup/forcedTransactions/ForcedTransactionGateway.sol:ForcedTransactionGateway",
args,
);
};

export default func;
func.tags = ["ForcedTransactionGateway"];
75 changes: 75 additions & 0 deletions contracts/src/_testing/unit/libraries/Eip1559RlpEncoder.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: Apache-2.0

/**
* @title Library for RLP Encoding EIP-1559 transactions.
* @author ConsenSys Software Inc.
* @custom:security-contact [email protected]
*/
pragma solidity ^0.8.30;

import { RlpEncoder } from "../../../libraries/RlpEncoder.sol";

/**
* @title Library for RLP Encoding a type 2 EIP-1559 transactions.
* @author ConsenSys Software Inc.
* @custom:security-contact [email protected]
*/
library Eip1559RlpEncoder {
/**
* @notice Supporting data for encoding an EIP-1559 transaction.
* @dev NB: ChainId is not on the struct to allow flexibility by the consuming contract.
* @dev NB: Access lists is assumed empty and does not appear here.
* @dev nonce The sender's nonce.
* @dev maxPriorityFeePerGas The max priority fee the user will pay.
* @dev maxFeePerGas The max fee per gas the user will pay.
* @dev gasLimit The limit of gas that the user is prepared to spend.
* @dev input The calldata input for the transaction.
* @dev accessList The access list used.
* @dev yParity The yParity in the signature.
* @dev r The r in the signature.
* @dev s The s in the signature.
*/
struct Eip1559Transaction {
uint256 nonce;
uint256 maxPriorityFeePerGas;
uint256 maxFeePerGas;
uint256 gasLimit;
address to;
uint256 value;
bytes input;
RlpEncoder.AccessList[] accessList;
uint8 yParity;
uint256 r;
uint256 s;
}

/**
* @notice Internal function that encodes bytes correctly with length data.
* @param _chainId The chainId to encode with.
* @param _transaction The EIP-1559 transaction excluding chainId.
* @return rlpEncodedTransaction The RLP encoded transaction for submitting.
* @return transactionHash The expected transaction hash.
*/
function _encodeEip1559Transaction(
uint256 _chainId,
Eip1559Transaction memory _transaction
) internal pure returns (bytes memory rlpEncodedTransaction, bytes32 transactionHash) {
bytes[] memory fields = new bytes[](12);

fields[0] = RlpEncoder._encodeUint(_chainId);
fields[1] = RlpEncoder._encodeUint(_transaction.nonce);
fields[2] = RlpEncoder._encodeUint(_transaction.maxPriorityFeePerGas);
fields[3] = RlpEncoder._encodeUint(_transaction.maxFeePerGas);
fields[4] = RlpEncoder._encodeUint(_transaction.gasLimit);
fields[5] = RlpEncoder._encodeAddress(_transaction.to);
fields[6] = RlpEncoder._encodeUint(_transaction.value);
fields[7] = RlpEncoder._encodeBytes(_transaction.input);
fields[8] = RlpEncoder._encodeAccessList(_transaction.accessList);
fields[9] = RlpEncoder._encodeUint(_transaction.yParity);
fields[10] = RlpEncoder._encodeUint(_transaction.r);
fields[11] = RlpEncoder._encodeUint(_transaction.s);

rlpEncodedTransaction = abi.encodePacked(hex"02", RlpEncoder._encodeList(fields));
transactionHash = keccak256(rlpEncodedTransaction);
}
}
18 changes: 18 additions & 0 deletions contracts/src/_testing/unit/libraries/TestEip1559RlpEncoder.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.30;

import { Eip1559RlpEncoder } from "./Eip1559RlpEncoder.sol";

contract TestEip1559RlpEncoder {
uint256 chainId;

constructor(uint256 _chainId) {
chainId = _chainId;
}

function encodeEip1559Transaction(
Eip1559RlpEncoder.Eip1559Transaction calldata _transaction
) external view returns (bytes memory rlpEncodedTransaction, bytes32 transactionHash) {
(rlpEncodedTransaction, transactionHash) = Eip1559RlpEncoder._encodeEip1559Transaction(chainId, _transaction);
}
}
18 changes: 18 additions & 0 deletions contracts/src/_testing/unit/libraries/TestRlpEncoder.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.30;

import { RlpEncoder } from "../../../libraries/RlpEncoder.sol";

contract TestRlpEncoder {
function encodeBool(bool _boolIn) external pure returns (bytes memory encodedBytes) {
return RlpEncoder._encodeBool(_boolIn);
}

function encodeString(string memory _stringIn) external pure returns (bytes memory encodedBytes) {
return RlpEncoder._encodeString(_stringIn);
}

function encodeInt(int _intIn) external pure returns (bytes memory encodedBytes) {
return RlpEncoder._encodeInt(_intIn);
}
}
28 changes: 25 additions & 3 deletions contracts/src/_testing/unit/rollup/TestLineaRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
pragma solidity 0.8.30;

import { LineaRollup } from "../../../rollup/LineaRollup.sol";
import { FinalizedStateHashing } from "../../../libraries/FinalizedStateHashing.sol";

/// @custom:oz-upgrades-unsafe-allow missing-initializer
contract TestLineaRollup is LineaRollup {
function setFallbackOperatorAddress(address _fallbackOperator) external {
function setFallbackOperatorManually(address _fallbackOperator) external {
fallbackOperator = _fallbackOperator;
}

Expand Down Expand Up @@ -41,7 +42,28 @@ contract TestLineaRollup is LineaRollup {
blobShnarfExists[_shnarf] = _finalBlockNumber;
}

function setLastFinalizedState(uint256 _messageNumber, bytes32 _rollingHash, uint256 _timestamp) external {
currentFinalizedState = _computeLastFinalizedState(_messageNumber, _rollingHash, _timestamp);
function setLastFinalizedStateV6(uint256 _messageNumber, bytes32 _rollingHash, uint256 _timestamp) external {
currentFinalizedState = FinalizedStateHashing._computeLastFinalizedState(_messageNumber, _rollingHash, _timestamp);
}

function setLastFinalizedState(
uint256 _messageNumber,
bytes32 _rollingHash,
uint256 _forcedTransactionNumber,
bytes32 _forcedTransactionRollingHash,
uint256 _timestamp
) external {
currentFinalizedState = FinalizedStateHashing._computeLastFinalizedState(
_messageNumber,
_rollingHash,
_forcedTransactionNumber,
_forcedTransactionRollingHash,
_timestamp
);
}

function setForcedTransactionBlockNumber(uint256 _blockNumber) external {
uint256 currentForcedTxNumber = nextForcedTransactionNumber++;
forcedTransactionL2BlockNumbers[currentForcedTxNumber] = _blockNumber;
}
}
5 changes: 5 additions & 0 deletions contracts/src/interfaces/IGenericErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ interface IGenericErrors {
* @dev Thrown when a parameter is the zero hash.
*/
error ZeroHashNotAllowed();

/**
* @dev Thrown when a parameter is zero.
*/
error ZeroValueNotAllowed();
}
58 changes: 58 additions & 0 deletions contracts/src/libraries/FinalizedStateHashing.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: Apache-2.0

/**
* @title Library for computing the last finalized state on L1.
* @author ConsenSys Software Inc.
* @custom:security-contact [email protected]
*/
pragma solidity ^0.8.30;

library FinalizedStateHashing {
/**
* @notice Internal function to compute and save the finalization state.
* @dev Using assembly this way is cheaper gas wise.
* @param _messageNumber Is the last L2 computed L1 message number in the finalization.
* @param _messageRollingHash Is the last L2 computed L1 rolling hash in the finalization.
* @param _forcedTransactionNumber Is the last processed forced transaction on L2's number.
* @param _messageRollingHash Is the last processed forced transaction on L2's rolling hash.
* @param _timestamp The final timestamp in the finalization.
*/
function _computeLastFinalizedState(
uint256 _messageNumber,
bytes32 _messageRollingHash,
uint256 _forcedTransactionNumber,
bytes32 _forcedTransactionRollingHash,
uint256 _timestamp
) internal pure returns (bytes32 hashedFinalizationState) {
assembly {
let mPtr := mload(0x40)
mstore(mPtr, _messageNumber)
mstore(add(mPtr, 0x20), _messageRollingHash)
mstore(add(mPtr, 0x40), _forcedTransactionNumber)
mstore(add(mPtr, 0x60), _forcedTransactionRollingHash)
mstore(add(mPtr, 0x80), _timestamp)
hashedFinalizationState := keccak256(mPtr, 0xa0)
}
}

/**
* @notice Internal function to compute and save the finalization state.
* @dev Using assembly this way is cheaper gas wise.
* @param _messageNumber Is the last L2 computed L1 message number in the finalization.
* @param _rollingHash Is the last L2 computed L1 rolling hash in the finalization.
* @param _timestamp The final timestamp in the finalization.
*/
function _computeLastFinalizedState(
uint256 _messageNumber,
bytes32 _rollingHash,
uint256 _timestamp
) internal pure returns (bytes32 hashedFinalizationState) {
assembly {
let mPtr := mload(0x40)
mstore(mPtr, _messageNumber)
mstore(add(mPtr, 0x20), _rollingHash)
mstore(add(mPtr, 0x40), _timestamp)
hashedFinalizationState := keccak256(mPtr, 0x60)
}
}
}
Loading
Loading