Commit 5a33924c authored by Karl Floersch's avatar Karl Floersch

Require all sequencer txs are processed

parent 2758b354
...@@ -322,6 +322,10 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba ...@@ -322,6 +322,10 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba
} }
} }
require(
theCalldataSize == nextSequencerTransactionPosition,
"Not all sequencer transactions were processed."
);
require( require(
transactionIndex == _totalElementsToAppend, transactionIndex == _totalElementsToAppend,
"Actual transaction index does not match expected total elements to append." "Actual transaction index does not match expected total elements to append."
......
...@@ -4,7 +4,6 @@ import { expect } from '../../../setup' ...@@ -4,7 +4,6 @@ import { expect } from '../../../setup'
import { ethers } from '@nomiclabs/buidler' import { ethers } from '@nomiclabs/buidler'
import { Signer, ContractFactory, Contract, BigNumber } from 'ethers' import { Signer, ContractFactory, Contract, BigNumber } from 'ethers'
import { TransactionResponse } from "@ethersproject/abstract-provider"; import { TransactionResponse } from "@ethersproject/abstract-provider";
import { FunctionFragment } from "@ethersproject/abi";
import { smockit, MockContract } from '@eth-optimism/smock' import { smockit, MockContract } from '@eth-optimism/smock'
import _ from 'lodash' import _ from 'lodash'
...@@ -19,8 +18,6 @@ import { ...@@ -19,8 +18,6 @@ import {
getEthTime, getEthTime,
getNextBlockNumber, getNextBlockNumber,
increaseEthTime, increaseEthTime,
// NON_NULL_BYTES32,
// ZERO_ADDRESS,
} from '../../../helpers' } from '../../../helpers'
import { defaultAbiCoder, keccak256 } from 'ethers/lib/utils' import { defaultAbiCoder, keccak256 } from 'ethers/lib/utils'
...@@ -33,33 +30,6 @@ interface sequencerBatchContext { ...@@ -33,33 +30,6 @@ interface sequencerBatchContext {
const ELEMENT_TEST_SIZES = [1, 2, 4, 8, 16] const ELEMENT_TEST_SIZES = [1, 2, 4, 8, 16]
const getQueueElementHash = (queueIndex: number): string => {
return getChainElementHash(false, queueIndex, 0, 0, '0x')
}
const getSequencerElementHash = (
timestamp: number,
blockNumber: number,
txData: string
): string => {
return getChainElementHash(true, 0, timestamp, blockNumber, txData)
}
const getChainElementHash = (
isSequenced: boolean,
queueIndex: number,
timestamp: number,
blockNumber: number,
txData: string
): string => {
return keccak256(
defaultAbiCoder.encode(
['bool', 'uint256', 'uint256', 'uint256', 'bytes'],
[isSequenced, queueIndex, timestamp, blockNumber, txData]
)
)
}
const getTransactionHash = ( const getTransactionHash = (
sender: string, sender: string,
target: string, target: string,
...@@ -81,17 +51,6 @@ const encodeQueueTransaction = ( ...@@ -81,17 +51,6 @@ const encodeQueueTransaction = (
) )
} }
const encodeTimestampAndBlockNumber = (
timestamp: number,
blockNumber: number
): string => {
return (
'0x' +
remove0x(BigNumber.from(blockNumber).toHexString()).padStart(54, '0') +
remove0x(BigNumber.from(timestamp).toHexString()).padStart(10, '0')
)
}
interface BatchContext { interface BatchContext {
numSequencedTransactions: number numSequencedTransactions: number
numSubsequentQueueTransactions: number numSubsequentQueueTransactions: number
...@@ -563,6 +522,26 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -563,6 +522,26 @@ describe('OVM_CanonicalTransactionChain', () => {
) )
}) })
it('should revert if not all sequencer transactions are processed', async () => {
await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain, {
transactions: ['0x1234', '0x1234'],
contexts: [
{
numSequencedTransactions: 0,
numSubsequentQueueTransactions: 0,
timestamp: 0,
blockNumber: 0,
},
],
shouldStartAtBatch: 0,
totalElementsToAppend: 1
}
)).to.be.revertedWith(
'Not all sequencer transactions were processed.'
)
})
it('should revert if not called by the sequencer', async () => { it('should revert if not called by the sequencer', async () => {
await expect( await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain.connect(signer), { appendSequencerBatch(OVM_CanonicalTransactionChain.connect(signer), {
......
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