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