Commit 2afd1957 authored by Karl Floersch's avatar Karl Floersch Committed by GitHub

Merge pull request #10 from ethereum-optimism/fix/ctc_events

Fix ctc events
parents 9c4eb7f8 08bcdd21
...@@ -172,7 +172,16 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba ...@@ -172,7 +172,16 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba
queue.push2(transactionHash, timestampAndBlockNumber, bytes28(0)); queue.push2(transactionHash, timestampAndBlockNumber, bytes28(0));
emit QueueTransactionAppended(transaction, timestampAndBlockNumber); (, uint32 nextQueueIndex) = _getLatestBatchContext();
// TODO: Evaluate if we need timestamp
emit TransactionEnqueued(
msg.sender,
_target,
_gasLimit,
_data,
nextQueueIndex - 1,
block.timestamp
);
} }
/** /**
...@@ -203,7 +212,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba ...@@ -203,7 +212,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba
_numQueuedTransactions _numQueuedTransactions
); );
emit ChainBatchAppended( emit QueueBatchAppended(
nextQueueIndex - _numQueuedTransactions, nextQueueIndex - _numQueuedTransactions,
_numQueuedTransactions _numQueuedTransactions
); );
...@@ -271,6 +280,10 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba ...@@ -271,6 +280,10 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba
} }
} }
require(
numSequencerTransactionsProcessed == _transactions.length,
"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."
...@@ -283,7 +296,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba ...@@ -283,7 +296,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, OVM_Ba
numQueuedTransactions numQueuedTransactions
); );
emit ChainBatchAppended( emit SequencerBatchAppended(
nextQueueIndex - numQueuedTransactions, nextQueueIndex - numQueuedTransactions,
numQueuedTransactions numQueuedTransactions
); );
......
...@@ -17,12 +17,21 @@ interface iOVM_CanonicalTransactionChain is iOVM_BaseChain { ...@@ -17,12 +17,21 @@ interface iOVM_CanonicalTransactionChain is iOVM_BaseChain {
* Events * * Events *
**********/ **********/
event QueueTransactionAppended( event TransactionEnqueued(
bytes _transaction, address _l1TxOrigin,
bytes32 _timestampAndBlockNumber address _target,
uint256 _gasLimit,
bytes _data,
uint256 _queueIndex,
uint256 _timestamp
);
event QueueBatchAppended(
uint256 _startingQueueIndex,
uint256 _numQueueElements
); );
event ChainBatchAppended( event SequencerBatchAppended(
uint256 _startingQueueIndex, uint256 _startingQueueIndex,
uint256 _numQueueElements uint256 _numQueueElements
); );
......
...@@ -168,28 +168,14 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -168,28 +168,14 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
describe('with valid input parameters', () => { describe('with valid input parameters', () => {
it('should emit a QueueTransactionAppended event', async () => { it('should emit a TransactionEnqueued event', async () => {
const timestamp = (await getEthTime(ethers.provider)) + 100 const timestamp = (await getEthTime(ethers.provider)) + 100
const blockNumber = await getNextBlockNumber(ethers.provider)
await setEthTime(ethers.provider, timestamp) await setEthTime(ethers.provider, timestamp)
const encodedTimestampAndBlockNumber = encodeTimestampAndBlockNumber(
timestamp,
blockNumber
)
const encodedQueueTransaction = encodeQueueTransaction(
await signer.getAddress(),
target,
gasLimit,
data
)
await expect( await expect(
OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data)
) )
.to.emit(OVM_CanonicalTransactionChain, 'QueueTransactionAppended') .to.emit(OVM_CanonicalTransactionChain, 'TransactionEnqueued')
.withArgs(encodedQueueTransaction, encodedTimestampAndBlockNumber)
}) })
describe('when enqueing multiple times', () => { describe('when enqueing multiple times', () => {
...@@ -399,7 +385,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -399,7 +385,7 @@ describe('OVM_CanonicalTransactionChain', () => {
sequencer sequencer
).appendQueueBatch(1) ).appendQueueBatch(1)
) )
.to.emit(OVM_CanonicalTransactionChain, 'ChainBatchAppended') .to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended')
.withArgs(0, 1) .withArgs(0, 1)
}) })
}) })
...@@ -414,13 +400,13 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -414,13 +400,13 @@ describe('OVM_CanonicalTransactionChain', () => {
it('should be able to append a single element', async () => { it('should be able to append a single element', async () => {
await expect(OVM_CanonicalTransactionChain.appendQueueBatch(1)) await expect(OVM_CanonicalTransactionChain.appendQueueBatch(1))
.to.emit(OVM_CanonicalTransactionChain, 'ChainBatchAppended') .to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended')
.withArgs(0, 1) .withArgs(0, 1)
}) })
it(`should be able to append ${size} elements`, async () => { it(`should be able to append ${size} elements`, async () => {
await expect(OVM_CanonicalTransactionChain.appendQueueBatch(size)) await expect(OVM_CanonicalTransactionChain.appendQueueBatch(size))
.to.emit(OVM_CanonicalTransactionChain, 'ChainBatchAppended') .to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended')
.withArgs(0, size) .withArgs(0, size)
}) })
...@@ -611,7 +597,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -611,7 +597,7 @@ describe('OVM_CanonicalTransactionChain', () => {
size size
) )
) )
.to.emit(OVM_CanonicalTransactionChain, 'ChainBatchAppended') .to.emit(OVM_CanonicalTransactionChain, 'SequencerBatchAppended')
.withArgs(0, 0) .withArgs(0, 0)
}) })
}) })
...@@ -659,7 +645,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -659,7 +645,7 @@ describe('OVM_CanonicalTransactionChain', () => {
size * 2 size * 2
) )
) )
.to.emit(OVM_CanonicalTransactionChain, 'ChainBatchAppended') .to.emit(OVM_CanonicalTransactionChain, 'SequencerBatchAppended')
.withArgs(0, size) .withArgs(0, size)
}) })
}) })
...@@ -699,7 +685,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -699,7 +685,7 @@ describe('OVM_CanonicalTransactionChain', () => {
size + spacing size + spacing
) )
) )
.to.emit(OVM_CanonicalTransactionChain, 'ChainBatchAppended') .to.emit(OVM_CanonicalTransactionChain, 'SequencerBatchAppended')
.withArgs(0, spacing) .withArgs(0, spacing)
}) })
}) })
......
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