Skip to content

Commit 1a720a6

Browse files
committed
skip relay proof in L1; update gas price through L1BlockContainer
1 parent ef7b403 commit 1a720a6

File tree

10 files changed

+45
-19
lines changed

10 files changed

+45
-19
lines changed

contracts/integration-test/L1BlockContainer.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ describe("L1BlockContainer", async () => {
134134
const whitelist = await Whitelist.deploy(deployer.address);
135135
await container.updateWhitelist(whitelist.address);
136136

137-
await expect(container.importBlockHeader(constants.HashZero, [], [])).to.revertedWith("Not whitelist sender");
137+
await expect(container.importBlockHeader(constants.HashZero, [], false)).to.revertedWith(
138+
"Not whitelisted sender"
139+
);
138140
});
139141

140142
it("should revert, when block hash mismatch", async () => {
@@ -146,7 +148,7 @@ describe("L1BlockContainer", async () => {
146148
test.stateRoot
147149
);
148150
const headerRLP = encodeHeader(test);
149-
await expect(container.importBlockHeader(test.parentHash, headerRLP, "0x")).to.revertedWith(
151+
await expect(container.importBlockHeader(test.parentHash, headerRLP, false)).to.revertedWith(
150152
"Block hash mismatch"
151153
);
152154
});
@@ -160,7 +162,7 @@ describe("L1BlockContainer", async () => {
160162
test.stateRoot
161163
);
162164
const headerRLP = encodeHeader(test);
163-
await expect(container.importBlockHeader(test.hash, concat([headerRLP, "0x00"]), "0x")).to.revertedWith(
165+
await expect(container.importBlockHeader(test.hash, concat([headerRLP, "0x00"]), false)).to.revertedWith(
164166
"Header RLP length mismatch"
165167
);
166168
});
@@ -174,7 +176,7 @@ describe("L1BlockContainer", async () => {
174176
test.stateRoot
175177
);
176178
const headerRLP = encodeHeader(test);
177-
await expect(container.importBlockHeader(test.hash, headerRLP, "0x")).to.revertedWith("Parent not imported");
179+
await expect(container.importBlockHeader(test.hash, headerRLP, false)).to.revertedWith("Parent not imported");
178180
});
179181

180182
it("should revert, when block height mismatch", async () => {
@@ -186,7 +188,7 @@ describe("L1BlockContainer", async () => {
186188
test.stateRoot
187189
);
188190
const headerRLP = encodeHeader(test);
189-
await expect(container.importBlockHeader(test.hash, headerRLP, "0x")).to.revertedWith("Block height mismatch");
191+
await expect(container.importBlockHeader(test.hash, headerRLP, false)).to.revertedWith("Block height mismatch");
190192
});
191193

192194
it("should revert, when parent block has larger timestamp", async () => {
@@ -198,7 +200,7 @@ describe("L1BlockContainer", async () => {
198200
test.stateRoot
199201
);
200202
const headerRLP = encodeHeader(test);
201-
await expect(container.importBlockHeader(test.hash, headerRLP, "0x")).to.revertedWith(
203+
await expect(container.importBlockHeader(test.hash, headerRLP, false)).to.revertedWith(
202204
"Parent block has larger timestamp"
203205
);
204206
});
@@ -213,7 +215,7 @@ describe("L1BlockContainer", async () => {
213215
);
214216
expect(await container.latestBlockHash()).to.eq(test.parentHash);
215217
const headerRLP = encodeHeader(test);
216-
await expect(container.importBlockHeader(test.hash, headerRLP, "0x"))
218+
await expect(container.importBlockHeader(test.hash, headerRLP, false))
217219
.to.emit(container, "ImportBlock")
218220
.withArgs(test.hash, test.blockHeight, test.blockTimestamp, test.baseFee, test.stateRoot);
219221
expect(await container.getStateRoot(test.hash)).to.eq(test.stateRoot);

contracts/src/L1/L1ScrollMessenger.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/securit
77
import { IScrollChain } from "./rollup/IScrollChain.sol";
88
import { IL1MessageQueue } from "./rollup/IL1MessageQueue.sol";
99
import { IL1ScrollMessenger } from "./IL1ScrollMessenger.sol";
10-
import { ScrollConstants } from "../libraries/ScrollConstants.sol";
10+
import { ScrollConstants } from "../libraries/constants/ScrollConstants.sol";
1111
import { IScrollMessenger } from "../libraries/IScrollMessenger.sol";
1212
import { ScrollMessengerBase } from "../libraries/ScrollMessengerBase.sol";
1313
import { WithdrawTrieVerifier } from "../libraries/verifier/WithdrawTrieVerifier.sol";
@@ -127,11 +127,14 @@ contract L1ScrollMessenger is PausableUpgradeable, ScrollMessengerBase, IL1Scrol
127127
{
128128
address _rollup = rollup;
129129
require(IScrollChain(_rollup).isBatchFinalized(_proof.batchHash), "Batch is not finalized");
130+
// @note skip verify for now
131+
/*
130132
bytes32 _messageRoot = IScrollChain(_rollup).getL2MessageRoot(_proof.batchHash);
131133
require(
132134
WithdrawTrieVerifier.verifyMerkleProof(_messageRoot, _xDomainCalldataHash, _nonce, _proof.merkleProof),
133135
"Invalid proof"
134136
);
137+
*/
135138
}
136139

137140
// @note This usually will never happen, just in case.

contracts/src/L2/L2ScrollMessenger.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IL1BlockContainer } from "./predeploys/IL1BlockContainer.sol";
1010
import { IL1GasPriceOracle } from "./predeploys/IL1GasPriceOracle.sol";
1111

1212
import { PatriciaMerkleTrieVerifier } from "../libraries/verifier/PatriciaMerkleTrieVerifier.sol";
13-
import { ScrollConstants } from "../libraries/ScrollConstants.sol";
13+
import { ScrollConstants } from "../libraries/constants/ScrollConstants.sol";
1414
import { IScrollMessenger } from "../libraries/IScrollMessenger.sol";
1515
import { ScrollMessengerBase } from "../libraries/ScrollMessengerBase.sol";
1616

contracts/src/L2/predeploys/IL1BlockContainer.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ interface IL1BlockContainer {
5454
/// @notice Import L1 block header to this contract.
5555
/// @param blockHash The hash of block.
5656
/// @param blockHeaderRLP The RLP encoding of L1 block.
57-
/// @param signature The ETH 2.0 signatures for the block header.
57+
/// @param updateGasPriceOracle Whether to update gas price oracle.
5858
function importBlockHeader(
5959
bytes32 blockHash,
6060
bytes calldata blockHeaderRLP,
61-
bytes calldata signature
61+
bool updateGasPriceOracle
6262
) external;
6363
}

contracts/src/L2/predeploys/IL1GasPriceOracle.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,12 @@ interface IL1GasPriceOracle {
4545
/// @param data Unsigned fully RLP-encoded transaction to get the L1 gas for.
4646
/// @return Amount of L1 gas used to publish the transaction.
4747
function getL1GasUsed(bytes memory data) external view returns (uint256);
48+
49+
/****************************
50+
* Public Mutated Functions *
51+
****************************/
52+
53+
/// @notice Allows whitelisted caller to modify the l1 base fee.
54+
/// @param _l1BaseFee New l1 base fee.
55+
function setL1BaseFee(uint256 _l1BaseFee) external;
4856
}

contracts/src/L2/predeploys/L1BlockContainer.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
pragma solidity ^0.8.0;
44

55
import { IL1BlockContainer } from "./IL1BlockContainer.sol";
6+
import { IL1GasPriceOracle } from "./IL1GasPriceOracle.sol";
67

78
import { OwnableBase } from "../../libraries/common/OwnableBase.sol";
89
import { IWhitelist } from "../../libraries/common/IWhitelist.sol";
10+
import { ScrollPredeploy } from "../../libraries/constants/ScrollPredeploy.sol";
911

1012
/// @title L1BlockContainer
1113
/// @notice This contract will maintain the list of blocks proposed in L1.
@@ -113,7 +115,7 @@ contract L1BlockContainer is OwnableBase, IL1BlockContainer {
113115
function importBlockHeader(
114116
bytes32 _blockHash,
115117
bytes calldata _blockHeaderRLP,
116-
bytes calldata
118+
bool _updateGasPriceOracle
117119
) external {
118120
// @todo remove this when ETH 2.0 signature verification is ready.
119121
{
@@ -279,6 +281,10 @@ contract L1BlockContainer is OwnableBase, IL1BlockContainer {
279281
metadata[_blockHash] = BlockMetadata(_height, _timestamp, _baseFee);
280282

281283
emit ImportBlock(_blockHash, _height, _timestamp, _baseFee, _stateRoot);
284+
285+
if (_updateGasPriceOracle) {
286+
IL1GasPriceOracle(ScrollPredeploy.L1_GAS_PRICE_ORACLE).setL1BaseFee(_baseFee);
287+
}
282288
}
283289

284290
/************************

contracts/src/L2/predeploys/L1GasPriceOracle.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ contract L1GasPriceOracle is OwnableBase, IL1GasPriceOracle {
9191
* Public Mutated Functions *
9292
****************************/
9393

94-
/// @notice Allows the owner to modify the l1 base fee.
95-
/// @param _l1BaseFee New l1 base fee.
96-
function setL1BaseFee(uint256 _l1BaseFee) external {
94+
/// @inheritdoc IL1GasPriceOracle
95+
function setL1BaseFee(uint256 _l1BaseFee) external override {
9796
require(whitelist.isSenderAllowed(msg.sender), "Not whitelisted sender");
9897

9998
l1BaseFee = _l1BaseFee;

contracts/src/libraries/ScrollMessengerBase.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ pragma solidity ^0.8.0;
55
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
66

77
import { IWhitelist } from "./common/IWhitelist.sol";
8+
import { ScrollConstants } from "./constants/ScrollConstants.sol";
89
import { IScrollMessenger } from "./IScrollMessenger.sol";
9-
import { ScrollConstants } from "./ScrollConstants.sol";
1010

1111
abstract contract ScrollMessengerBase is OwnableUpgradeable, IScrollMessenger {
1212
/**********

contracts/src/libraries/ScrollConstants.sol renamed to contracts/src/libraries/constants/ScrollConstants.sol

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,4 @@ pragma solidity ^0.8.0;
55
library ScrollConstants {
66
/// @notice The address of default cross chain message sender.
77
address internal constant DEFAULT_XDOMAIN_MESSAGE_SENDER = address(1);
8-
9-
/// @notice The minimum seconds needed to wait if we want to drop message.
10-
uint256 internal constant MIN_DROP_DELAY_DURATION = 7 days;
118
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.0;
4+
5+
library ScrollPredeploy {
6+
address internal constant L1_MESSAGE_QUEUE = 0x5300000000000000000000000000000000000000;
7+
8+
address internal constant L1_BLOCK_CONTAINER = 0x5300000000000000000000000000000000000001;
9+
10+
address internal constant L1_GAS_PRICE_ORACLE = 0x5300000000000000000000000000000000000002;
11+
}

0 commit comments

Comments
 (0)