Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
f96e0ba9
Unverified
Commit
f96e0ba9
authored
Oct 04, 2021
by
Maurelian
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(contracts): add prefix '_' to private storage var _nextQueueIndex
parent
fc7de380
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
CanonicalTransactionChain.sol
...ntracts/contracts/L1/rollup/CanonicalTransactionChain.sol
+21
-21
No files found.
packages/contracts/contracts/L1/rollup/CanonicalTransactionChain.sol
View file @
f96e0ba9
...
@@ -52,7 +52,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -52,7 +52,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
* Queue State *
* Queue State *
***************/
***************/
uint40 private nextQueueIndex; // index of the first queue element not yet included
uint40 private
_
nextQueueIndex; // index of the first queue element not yet included
Lib_OVMCodec.QueueElement[] queueElements;
Lib_OVMCodec.QueueElement[] queueElements;
...
@@ -151,7 +151,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -151,7 +151,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
uint40
uint40
)
)
{
{
return nextQueueIndex;
return
_
nextQueueIndex;
}
}
/**
/**
...
@@ -212,7 +212,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -212,7 +212,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
uint40
uint40
)
)
{
{
return uint40(queueElements.length) - nextQueueIndex;
return uint40(queueElements.length) -
_
nextQueueIndex;
}
}
/**
/**
...
@@ -363,10 +363,10 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -363,10 +363,10 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
// Counter for number of sequencer transactions appended so far.
// Counter for number of sequencer transactions appended so far.
uint32 numSequencerTransactions = 0;
uint32 numSequencerTransactions = 0;
// Cache the
nextQueueIndex
.
// Cache the
_nextQueueIndex storage variable to a temporary stack variable
.
// This is safe as long as nothing reads or writes to the
nextQueueIndex
// This is safe as long as nothing reads or writes to the
storage variable
//
storage variable until it is updated with the value from nextQueueIndexCached
.
//
until it is updated by the temp variable
.
uint40 nextQueueIndex
Cached =
nextQueueIndex;
uint40 nextQueueIndex
= _
nextQueueIndex;
BatchContext memory curContext;
BatchContext memory curContext;
for (uint32 i = 0; i < numContexts; i++) {
for (uint32 i = 0; i < numContexts; i++) {
...
@@ -379,11 +379,11 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -379,11 +379,11 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
numSequencerTransactions += uint32(curContext.numSequencedTransactions);
numSequencerTransactions += uint32(curContext.numSequencedTransactions);
// Now process any subsequent queue transactions.
// Now process any subsequent queue transactions.
nextQueueIndex
Cached
+= uint40(curContext.numSubsequentQueueTransactions);
nextQueueIndex += uint40(curContext.numSubsequentQueueTransactions);
}
}
require(
require(
nextQueueIndex
Cached
<= queueElements.length,
nextQueueIndex <= queueElements.length,
"Attempted to append more elements than are available in the queue."
"Attempted to append more elements than are available in the queue."
);
);
...
@@ -402,7 +402,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -402,7 +402,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
// curContext.numSubsequentQueueTransactions > 0 which means that we've processed at
// curContext.numSubsequentQueueTransactions > 0 which means that we've processed at
// least one queue element. We increment nextQueueIndex after processing each queue
// least one queue element. We increment nextQueueIndex after processing each queue
// element, so the index of the last element we processed is nextQueueIndex - 1.
// element, so the index of the last element we processed is nextQueueIndex - 1.
Lib_OVMCodec.QueueElement memory lastElement = queueElements[nextQueueIndex
Cached
- 1];
Lib_OVMCodec.QueueElement memory lastElement = queueElements[nextQueueIndex - 1];
blockTimestamp = lastElement.timestamp;
blockTimestamp = lastElement.timestamp;
blockNumber = lastElement.blockNumber;
blockNumber = lastElement.blockNumber;
...
@@ -418,13 +418,13 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -418,13 +418,13 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
);
);
emit SequencerBatchAppended(
emit SequencerBatchAppended(
nextQueueIndex
Cached
- numQueuedTransactions,
nextQueueIndex - numQueuedTransactions,
numQueuedTransactions,
numQueuedTransactions,
getTotalElements()
getTotalElements()
);
);
// Update the nextQueueIndex storage variable.
// Update the
_
nextQueueIndex storage variable.
nextQueueIndex = nextQueueIndexCached
;
_nextQueueIndex = nextQueueIndex
;
}
}
/**********************
/**********************
...
@@ -484,7 +484,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -484,7 +484,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
bytes27 extraData = batches().getGlobalMetadata();
bytes27 extraData = batches().getGlobalMetadata();
uint40 totalElements;
uint40 totalElements;
uint40 nextQueueI
d
x;
uint40 nextQueueI
nde
x;
uint40 lastTimestamp;
uint40 lastTimestamp;
uint40 lastBlockNumber;
uint40 lastBlockNumber;
...
@@ -492,7 +492,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -492,7 +492,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
assembly {
assembly {
extraData := shr(40, extraData)
extraData := shr(40, extraData)
totalElements := and(extraData, 0x000000000000000000000000000000000000000000000000000000FFFFFFFFFF)
totalElements := and(extraData, 0x000000000000000000000000000000000000000000000000000000FFFFFFFFFF)
nextQueueI
d
x := shr(40, and(extraData, 0x00000000000000000000000000000000000000000000FFFFFFFFFF0000000000))
nextQueueI
nde
x := shr(40, and(extraData, 0x00000000000000000000000000000000000000000000FFFFFFFFFF0000000000))
lastTimestamp := shr(80, and(extraData, 0x0000000000000000000000000000000000FFFFFFFFFF00000000000000000000))
lastTimestamp := shr(80, and(extraData, 0x0000000000000000000000000000000000FFFFFFFFFF00000000000000000000))
lastBlockNumber := shr(120, and(extraData, 0x000000000000000000000000FFFFFFFFFF000000000000000000000000000000))
lastBlockNumber := shr(120, and(extraData, 0x000000000000000000000000FFFFFFFFFF000000000000000000000000000000))
}
}
...
@@ -500,7 +500,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -500,7 +500,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
return (
return (
totalElements,
totalElements,
nextQueueI
d
x,
nextQueueI
nde
x,
lastTimestamp,
lastTimestamp,
lastBlockNumber
lastBlockNumber
);
);
...
@@ -509,14 +509,14 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -509,14 +509,14 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
/**
/**
* Encodes the batch context for the extra data.
* Encodes the batch context for the extra data.
* @param _totalElements Total number of elements submitted.
* @param _totalElements Total number of elements submitted.
* @param _nextQueueI
nde
x Index of the next queue element.
* @param _nextQueueI
d
x Index of the next queue element.
* @param _timestamp Timestamp for the last batch.
* @param _timestamp Timestamp for the last batch.
* @param _blockNumber Block number of the last batch.
* @param _blockNumber Block number of the last batch.
* @return Encoded batch context.
* @return Encoded batch context.
*/
*/
function _makeBatchExtraData(
function _makeBatchExtraData(
uint40 _totalElements,
uint40 _totalElements,
uint40 _nextQueueI
nde
x,
uint40 _nextQueueI
d
x,
uint40 _timestamp,
uint40 _timestamp,
uint40 _blockNumber
uint40 _blockNumber
)
)
...
@@ -529,7 +529,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -529,7 +529,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
bytes27 extraData;
bytes27 extraData;
assembly {
assembly {
extraData := _totalElements
extraData := _totalElements
extraData := or(extraData, shl(40, _nextQueueI
nde
x))
extraData := or(extraData, shl(40, _nextQueueI
d
x))
extraData := or(extraData, shl(80, _timestamp))
extraData := or(extraData, shl(80, _timestamp))
extraData := or(extraData, shl(120, _blockNumber))
extraData := or(extraData, shl(120, _blockNumber))
extraData := shl(40, extraData)
extraData := shl(40, extraData)
...
@@ -556,7 +556,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -556,7 +556,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
internal
internal
{
{
IChainStorageContainer batchesRef = batches();
IChainStorageContainer batchesRef = batches();
(uint40 totalElements, uint40 nextQueueI
d
x,,) = _getBatchExtraData();
(uint40 totalElements, uint40 nextQueueI
nde
x,,) = _getBatchExtraData();
Lib_OVMCodec.ChainBatchHeader memory header = Lib_OVMCodec.ChainBatchHeader({
Lib_OVMCodec.ChainBatchHeader memory header = Lib_OVMCodec.ChainBatchHeader({
batchIndex: batchesRef.length(),
batchIndex: batchesRef.length(),
...
@@ -577,7 +577,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -577,7 +577,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
bytes32 batchHeaderHash = Lib_OVMCodec.hashBatchHeader(header);
bytes32 batchHeaderHash = Lib_OVMCodec.hashBatchHeader(header);
bytes27 latestBatchContext = _makeBatchExtraData(
bytes27 latestBatchContext = _makeBatchExtraData(
totalElements + uint40(header.batchSize),
totalElements + uint40(header.batchSize),
nextQueueI
d
x + uint40(_numQueuedTransactions),
nextQueueI
nde
x + uint40(_numQueuedTransactions),
_timestamp,
_timestamp,
_blockNumber
_blockNumber
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment