Commit 9c0dc1fd authored by Karl Floersch's avatar Karl Floersch

Clean up gas burn & err msg

parent 5778931f
...@@ -65,17 +65,13 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu ...@@ -65,17 +65,13 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu
override override
public public
{ {
require(_gasLimit >= 20000, "Gas limit too low.");
require( require(
_data.length <= MAX_ROLLUP_TX_SIZE, _data.length <= MAX_ROLLUP_TX_SIZE,
"Transaction exceeds maximum rollup data size." "Transaction exceeds maximum rollup data size."
); );
uint gasToConsume = _gasLimit/L2_GAS_DISCOUNT_DIVISOR; require(_gasLimit >= 20000, "Gas limit too low.");
uint startingGas = gasleft();
uint i; consumeGas(_gasLimit/L2_GAS_DISCOUNT_DIVISOR);
while(startingGas - gasleft() > gasToConsume) {
i++; // TODO: Replace this dumb work with minting gas token.
}
Lib_OVMCodec.QueueElement memory element = Lib_OVMCodec.QueueElement({ Lib_OVMCodec.QueueElement memory element = Lib_OVMCodec.QueueElement({
timestamp: block.timestamp, timestamp: block.timestamp,
...@@ -99,7 +95,7 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu ...@@ -99,7 +95,7 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu
{ {
require( require(
msg.sender == ovmCanonicalTransactionChain, msg.sender == ovmCanonicalTransactionChain,
"Sender is not allowed to enqueue." "Sender is not allowed to dequeue."
); );
_dequeue(); _dequeue();
...@@ -112,13 +108,17 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu ...@@ -112,13 +108,17 @@ contract OVM_L1ToL2TransactionQueue is iOVM_L1ToL2TransactionQueue, OVM_BaseQueu
/** /**
* Consumes all gas provided. * Consumes all gas provided.
* Note: this is an external function, but is only called by self.
*/ */
function consumeAllGasProvided() function consumeGas
external (
uint gasToConsume
)
internal
{ {
assembly { uint startingGas = gasleft();
invalid() uint i;
while(startingGas - gasleft() > gasToConsume) {
i++; // TODO: Replace this dumb work with minting gas token.
} }
} }
} }
...@@ -37,7 +37,7 @@ const makeQueueElements = (count: number): any => { ...@@ -37,7 +37,7 @@ const makeQueueElements = (count: number): any => {
}) })
} }
describe('OVM_L1ToL2TransactionQueue', () => { describe.only('OVM_L1ToL2TransactionQueue', () => {
let signer: Signer let signer: Signer
before(async () => { before(async () => {
;[signer] = await ethers.getSigners() ;[signer] = await ethers.getSigners()
...@@ -98,7 +98,7 @@ describe('OVM_L1ToL2TransactionQueue', () => { ...@@ -98,7 +98,7 @@ describe('OVM_L1ToL2TransactionQueue', () => {
it('should revert', async () => { it('should revert', async () => {
await expect(OVM_L1ToL2TransactionQueue.dequeue()).to.be.revertedWith( await expect(OVM_L1ToL2TransactionQueue.dequeue()).to.be.revertedWith(
'Sender is not allowed to enqueue.' 'Sender is not allowed to dequeue.'
) )
}) })
}) })
......
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