Commit 4f1ebd2d authored by ben-chain's avatar ben-chain

add back EVM precompiles, l2 gas burn, max l2 tx size

parent 869dba6d
...@@ -17,6 +17,13 @@ import { OVM_BaseQueue } from "./OVM_BaseQueue.sol"; ...@@ -17,6 +17,13 @@ import { OVM_BaseQueue } from "./OVM_BaseQueue.sol";
*/ */
contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueue, Lib_AddressResolver { contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueue, Lib_AddressResolver {
/*************************************************
* Contract Variables: Transaction Restrinctions *
*************************************************/
uint constant MAX_ROLLUP_TX_SIZE = 10000;
uint constant L2_GAS_DISCOUNT_DIVISOR = 10;
/******************************************* /*******************************************
* Contract Variables: Contract References * * Contract Variables: Contract References *
*******************************************/ *******************************************/
...@@ -58,6 +65,15 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu ...@@ -58,6 +65,15 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu
override override
public public
{ {
require(
_data.length <= MAX_ROLLUP_TX_SIZE,
"Transaction exceeds maximum rollup data size."
);
uint gasToConsume = _gasLimit/L2_GAS_DISCOUNT_DIVISOR;
// The methodId for consumeAllGasProvided() is 0xfd4cbdd9.
address(this).call{gas: gasToConsume}(hex"fd4cbdd9");
Lib_OVMCodec.QueueElement memory element = Lib_OVMCodec.QueueElement({ Lib_OVMCodec.QueueElement memory element = Lib_OVMCodec.QueueElement({
timestamp: block.timestamp, timestamp: block.timestamp,
batchRoot: keccak256(abi.encodePacked( batchRoot: keccak256(abi.encodePacked(
...@@ -85,4 +101,21 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu ...@@ -85,4 +101,21 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu
_dequeue(); _dequeue();
} }
/***************************************
* External Functions: Gas Consumption *
***************************************/
/**
* Consumes all gas provided.
* Note: this is an external function, but is only called by self.
*/
function consumeAllGasProvided()
external
{
assembly {
invalid()
}
}
} }
...@@ -31,7 +31,7 @@ const makeQueueElements = (count: number): any => { ...@@ -31,7 +31,7 @@ const makeQueueElements = (count: number): any => {
return [...Array(count)].map((el, idx) => { return [...Array(count)].map((el, idx) => {
return { return {
target: NON_ZERO_ADDRESS, target: NON_ZERO_ADDRESS,
gasLimit: idx, gasLimit: idx + 30_000,
data: DUMMY_BYTES32[0], data: DUMMY_BYTES32[0],
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment