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
48cfb704
Commit
48cfb704
authored
Oct 12, 2020
by
Karl Floersch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add enqueue functionality
parent
7ab3f1a2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
28 deletions
+33
-28
OVM_CanonicalTransactionChain.sol
...stic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol
+24
-23
OVM_CanonicalTransactionChain.spec.ts
...contracts/OVM/chain/OVM_CanonicalTransactionChain.spec.ts
+9
-5
No files found.
packages/contracts/contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol
View file @
48cfb704
...
@@ -75,7 +75,8 @@ contract OVM_CanonicalTransactionChain is OVM_BaseChain, Lib_AddressResolver { /
...
@@ -75,7 +75,8 @@ contract OVM_CanonicalTransactionChain is OVM_BaseChain, Lib_AddressResolver { /
{
{
sequencerAddress = resolve("OVM_Sequencer");
sequencerAddress = resolve("OVM_Sequencer");
forceInclusionPeriodSeconds = _forceInclusionPeriodSeconds;
forceInclusionPeriodSeconds = _forceInclusionPeriodSeconds;
queue.init(100, 50, 0); // TODO: Update once we have arbitrary condition
queue.init(100, 50, 10000000000); // TODO: Update once we have arbitrary condition
batches.init(100, 50, 10000000000); // TODO: Update once we have arbitrary condition
}
}
...
@@ -100,7 +101,7 @@ contract OVM_CanonicalTransactionChain is OVM_BaseChain, Lib_AddressResolver { /
...
@@ -100,7 +101,7 @@ contract OVM_CanonicalTransactionChain is OVM_BaseChain, Lib_AddressResolver { /
_data.length <= MAX_ROLLUP_TX_SIZE,
_data.length <= MAX_ROLLUP_TX_SIZE,
"Transaction exceeds maximum rollup data size."
"Transaction exceeds maximum rollup data size."
);
);
require(_gasLimit >= 20000, "
Gas limit too low
.");
require(_gasLimit >= 20000, "
Layer 2 gas limit too low to enqueue
.");
// Consume l1 gas rate limit queued transactions
// Consume l1 gas rate limit queued transactions
uint gasToConsume = _gasLimit/L2_GAS_DISCOUNT_DIVISOR;
uint gasToConsume = _gasLimit/L2_GAS_DISCOUNT_DIVISOR;
...
@@ -110,35 +111,35 @@ contract OVM_CanonicalTransactionChain is OVM_BaseChain, Lib_AddressResolver { /
...
@@ -110,35 +111,35 @@ contract OVM_CanonicalTransactionChain is OVM_BaseChain, Lib_AddressResolver { /
i++; // TODO: Replace this dumb work with minting gas token. (not today)
i++; // TODO: Replace this dumb work with minting gas token. (not today)
}
}
// This struct shows the form of the queueElement but isn't how we store it
bytes32 batchRoot = keccak256(abi.encode(
// Lib_OVMCodec.QueueElement memory element = Lib_OVMCodec.QueueElement({
_target,
// timestamp: uint40(block.timestamp),
_gasLimit,
// blockNumber: uint32(block.number),
_data
// batchRoot: keccak256(abi.encodePacked(
));
// _target,
// bytes is left aligned, uint is right aligned - use this to encode them together
// _gasLimit,
bytes32 timestampAndBlockNumber = bytes32(bytes4(uint32(block.number))) | bytes32(uint256(uint40(block.timestamp)));
// _data
// bytes32 timestampAndBlockNumber = bytes32(bytes4(uint32(999))) | bytes32(uint256(uint40(777)));
// ))
queue.push2(batchRoot, timestampAndBlockNumber, bytes28(0));
// });
// bytes28 timestampBlockNumber = concat(timestamp, blockNumber)
// We need access to the timestamp and blocknumber for EVERY queue tx
// So we use push2 to push both the batchRoot and timestampAndBlocknumber
// This way we have all the info we need for calling appendSequencerMultiBatch
// queue.push2(batchRoot, timestampBlocknNumber);
}
}
// function getQueueIndex(uint queueIndex) {
function getQueueElement(uint queueIndex) public view returns(Lib_OVMCodec.QueueElement memory) {
// uint realIndex = queueIndex * 2;
uint32 trueIndex = uint32(queueIndex * 2);
// uint timestampBlockNumber = queueIndex * 2 + 1;
bytes32 batchRoot = queue.get(trueIndex);
// }
bytes32 timestampAndBlockNumber = queue.get(trueIndex + 1);
uint40 timestamp = uint40(uint256(timestampAndBlockNumber & 0x000000000000000000000000000000000000000000000000000000ffffffffff));
uint32 blockNumber = uint32(bytes4(timestampAndBlockNumber & 0xffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000));
return Lib_OVMCodec.QueueElement({
batchRoot: batchRoot,
timestamp: timestamp,
blockNumber: blockNumber
});
}
/****************************************
/****************************************
* Public Functions: Batch Manipulation *
* Public Functions: Batch Manipulation *
****************************************/
****************************************/
// TODO: allow the sequencer/users to append queue batches independently
// TODO: allow the sequencer/users to append queue batches independently
...
...
packages/contracts/test/contracts/OVM/chain/OVM_CanonicalTransactionChain.spec.ts
View file @
48cfb704
...
@@ -63,12 +63,16 @@ describe('OVM_CanonicalTransactionChain', () => {
...
@@ -63,12 +63,16 @@ describe('OVM_CanonicalTransactionChain', () => {
)
)
})
})
describe
(
'
appendSequencerMultiBatch
'
,
()
=>
{
describe
(
'
enqueue
'
,
()
=>
{
before
(()
=>
{
it
.
only
(
'
should store queued elements correctly
'
,
async
()
=>
{
Mock__OVM_L1ToL2TransactionQueue
.
smocked
.
size
.
will
.
return
.
with
(
0
)
await
OVM_CanonicalTransactionChain
.
enqueue
(
'
0x
'
+
'
01
'
.
repeat
(
20
),
25000
,
'
0x1234
'
)
Mock__OVM_L1ToL2TransactionQueue
.
smocked
.
dequeue
.
will
.
return
()
const
firstQueuedElement
=
await
OVM_CanonicalTransactionChain
.
getQueueElement
(
0
)
console
.
log
(
firstQueuedElement
)
})
})
})
it
(
'
should append a multi-batch with just one batch
'
,
async
()
=>
{
describe
(
'
appendSequencerMultiBatch
'
,
()
=>
{
it
(
'
should append a multi-batch with just one batch
'
,
async
()
=>
{
// Try out appending
// Try out appending
const
testBatchContext
:
sequencerBatchContext
=
{
const
testBatchContext
:
sequencerBatchContext
=
{
numSequencedTransactions
:
1
,
numSequencedTransactions
:
1
,
...
...
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