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
c1b06a35
Unverified
Commit
c1b06a35
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): Only save transactionHash for queueElements
parent
8487adb9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
38 deletions
+22
-38
CanonicalTransactionChain.sol
...ntracts/contracts/L1/rollup/CanonicalTransactionChain.sol
+12
-28
deposit.gas.spec.ts
...contracts/test/contracts/L1/messaging/deposit.gas.spec.ts
+2
-2
CanonicalTransactionChain.gas.spec.ts
...contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts
+2
-2
CanonicalTransactionChain.spec.ts
...est/contracts/L1/rollup/CanonicalTransactionChain.spec.ts
+6
-6
No files found.
packages/contracts/contracts/L1/rollup/CanonicalTransactionChain.sol
View file @
c1b06a35
...
@@ -53,7 +53,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -53,7 +53,7 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
***************/
***************/
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;
bytes32
[] queueElements;
/***************
/***************
...
@@ -195,10 +195,15 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -195,10 +195,15 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
public
public
view
view
returns (
returns (
Lib_OVMCodec.QueueElement memory
_element
Lib_OVMCodec.QueueElement memory
)
)
{
{
return queueElements[_index];
bytes32 transactionHash = queueElements[_index];
return Lib_OVMCodec.QueueElement({
transactionHash: transactionHash,
timestamp: 0,
blockNumber: 0
});
}
}
/**
/**
...
@@ -303,14 +308,9 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -303,14 +308,9 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
)
)
);
);
queueElements.push(
queueElements.push(transactionHash);
Lib_OVMCodec.QueueElement({
transactionHash: transactionHash,
timestamp: uint40(block.timestamp),
blockNumber: uint40(block.number)
})
);
uint256 queueIndex = queueElements.length - 1;
uint256 queueIndex = queueElements.length - 1;
emit TransactionEnqueued(
emit TransactionEnqueued(
sender,
sender,
_target,
_target,
...
@@ -389,24 +389,8 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
...
@@ -389,24 +389,8 @@ contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressRes
// Generate the required metadata that we need to append this batch
// Generate the required metadata that we need to append this batch
uint40 numQueuedTransactions = totalElementsToAppend - numSequencerTransactions;
uint40 numQueuedTransactions = totalElementsToAppend - numSequencerTransactions;
uint40 blockTimestamp;
uint40 blockTimestamp = uint40(curContext.timestamp);
uint40 blockNumber;
uint40 blockNumber = uint40(curContext.blockNumber);
if (curContext.numSubsequentQueueTransactions == 0) {
// The last element is a sequencer tx, therefore pull timestamp and block number from
// the last context.
blockTimestamp = uint40(curContext.timestamp);
blockNumber = uint40(curContext.blockNumber);
} else {
// The last element is a queue tx, therefore pull timestamp and block number from the
// queue element.
// curContext.numSubsequentQueueTransactions > 0 which means that we've processed at
// least one queue element. We increment nextQueueIndex after processing each queue
// element, so the index of the last element we processed is nextQueueIndex - 1.
Lib_OVMCodec.QueueElement memory lastElement = queueElements[nextQueueIndex - 1];
blockTimestamp = lastElement.timestamp;
blockNumber = lastElement.blockNumber;
}
// Cache the previous blockhash to ensure all transaction data can be retrieved efficiently.
// Cache the previous blockhash to ensure all transaction data can be retrieved efficiently.
_appendBatch(
_appendBatch(
...
...
packages/contracts/test/contracts/L1/messaging/deposit.gas.spec.ts
View file @
c1b06a35
...
@@ -146,7 +146,7 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
...
@@ -146,7 +146,7 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
const
receipt
=
await
res
.
wait
()
const
receipt
=
await
res
.
wait
()
const
gasUsed
=
receipt
.
gasUsed
.
toNumber
()
const
gasUsed
=
receipt
.
gasUsed
.
toNumber
()
console
.
log
(
'
- Gas used:
'
,
gasUsed
)
console
.
log
(
'
- Gas used:
'
,
gasUsed
)
expectApprox
(
gasUsed
,
116
_003
,
{
expectApprox
(
gasUsed
,
95
_017
,
{
absoluteUpperDeviation
:
500
,
absoluteUpperDeviation
:
500
,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
// contracts are too efficient, consider updating the target value!
...
@@ -173,7 +173,7 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
...
@@ -173,7 +173,7 @@ describe('[GAS BENCHMARK] Depositing via the standard bridge', () => {
const
receipt
=
await
res
.
wait
()
const
receipt
=
await
res
.
wait
()
const
gasUsed
=
receipt
.
gasUsed
.
toNumber
()
const
gasUsed
=
receipt
.
gasUsed
.
toNumber
()
console
.
log
(
'
- Gas used:
'
,
gasUsed
)
console
.
log
(
'
- Gas used:
'
,
gasUsed
)
expectApprox
(
gasUsed
,
1
63
_844
,
{
expectApprox
(
gasUsed
,
1
42
_858
,
{
absoluteUpperDeviation
:
500
,
absoluteUpperDeviation
:
500
,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
// contracts are too efficient, consider updating the target value!
...
...
packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.gas.spec.ts
View file @
c1b06a35
...
@@ -293,7 +293,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
...
@@ -293,7 +293,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
console
.
log
(
'
Benchmark complete.
'
)
console
.
log
(
'
Benchmark complete.
'
)
expectApprox
(
gasUsed
,
1
87
_081
,
{
expectApprox
(
gasUsed
,
1
66
_094
,
{
absoluteUpperDeviation
:
500
,
absoluteUpperDeviation
:
500
,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
// contracts are too efficient, consider updating the target value!
...
@@ -314,7 +314,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
...
@@ -314,7 +314,7 @@ describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
console
.
log
(
'
Benchmark complete.
'
)
console
.
log
(
'
Benchmark complete.
'
)
expectApprox
(
gasUsed
,
1
26
_700
,
{
expectApprox
(
gasUsed
,
1
05
_713
,
{
absoluteUpperDeviation
:
500
,
absoluteUpperDeviation
:
500
,
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// Assert a lower bound of 1% reduction on gas cost. If your tests are breaking because your
// contracts are too efficient, consider updating the target value!
// contracts are too efficient, consider updating the target value!
...
...
packages/contracts/test/contracts/L1/rollup/CanonicalTransactionChain.spec.ts
View file @
c1b06a35
...
@@ -301,8 +301,8 @@ describe('CanonicalTransactionChain', () => {
...
@@ -301,8 +301,8 @@ describe('CanonicalTransactionChain', () => {
)
)
).
to
.
deep
.
include
({
).
to
.
deep
.
include
({
transactionHash
,
transactionHash
,
timestamp
,
timestamp
:
0
,
blockNumber
,
blockNumber
:
0
,
})
})
})
})
}
}
...
@@ -345,8 +345,8 @@ describe('CanonicalTransactionChain', () => {
...
@@ -345,8 +345,8 @@ describe('CanonicalTransactionChain', () => {
)
)
).
to
.
deep
.
include
({
).
to
.
deep
.
include
({
transactionHash
,
transactionHash
,
timestamp
,
timestamp
:
0
,
blockNumber
,
blockNumber
:
0
,
})
})
})
})
}
}
...
@@ -388,8 +388,8 @@ describe('CanonicalTransactionChain', () => {
...
@@ -388,8 +388,8 @@ describe('CanonicalTransactionChain', () => {
)
)
).
to
.
deep
.
include
({
).
to
.
deep
.
include
({
transactionHash
,
transactionHash
,
timestamp
,
timestamp
:
0
,
blockNumber
,
blockNumber
:
0
,
})
})
})
})
}
}
...
...
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