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
5bcd7c96
Commit
5bcd7c96
authored
Jun 25, 2021
by
Liam Horne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: rename Range to BlockRange
parent
e5383c30
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
39 deletions
+28
-39
batch-submitter.ts
...es/batch-submitter/src/batch-submitter/batch-submitter.ts
+2
-2
state-batch-submitter.ts
...ch-submitter/src/batch-submitter/state-batch-submitter.ts
+2
-2
tx-batch-submitter.ts
...batch-submitter/src/batch-submitter/tx-batch-submitter.ts
+24
-35
No files found.
packages/batch-submitter/src/batch-submitter/batch-submitter.ts
View file @
5bcd7c96
...
@@ -7,7 +7,7 @@ import { RollupInfo, sleep } from '@eth-optimism/core-utils'
...
@@ -7,7 +7,7 @@ import { RollupInfo, sleep } from '@eth-optimism/core-utils'
import
{
Logger
,
Metrics
}
from
'
@eth-optimism/common-ts
'
import
{
Logger
,
Metrics
}
from
'
@eth-optimism/common-ts
'
import
{
getContractFactory
}
from
'
old-contracts
'
import
{
getContractFactory
}
from
'
old-contracts
'
export
interface
Range
{
export
interface
Block
Range
{
start
:
number
start
:
number
end
:
number
end
:
number
}
}
...
@@ -65,7 +65,7 @@ export abstract class BatchSubmitter {
...
@@ -65,7 +65,7 @@ export abstract class BatchSubmitter {
endBlock
:
number
endBlock
:
number
):
Promise
<
TransactionReceipt
>
):
Promise
<
TransactionReceipt
>
public
abstract
_onSync
():
Promise
<
TransactionReceipt
>
public
abstract
_onSync
():
Promise
<
TransactionReceipt
>
public
abstract
_getBatchStartAndEnd
():
Promise
<
Range
>
public
abstract
_getBatchStartAndEnd
():
Promise
<
Block
Range
>
public
abstract
_updateChainInfo
():
Promise
<
void
>
public
abstract
_updateChainInfo
():
Promise
<
void
>
public
async
submitNextBatch
():
Promise
<
TransactionReceipt
>
{
public
async
submitNextBatch
():
Promise
<
TransactionReceipt
>
{
...
...
packages/batch-submitter/src/batch-submitter/state-batch-submitter.ts
View file @
5bcd7c96
...
@@ -12,7 +12,7 @@ import {
...
@@ -12,7 +12,7 @@ import {
import
{
Logger
,
Metrics
}
from
'
@eth-optimism/common-ts
'
import
{
Logger
,
Metrics
}
from
'
@eth-optimism/common-ts
'
/* Internal Imports */
/* Internal Imports */
import
{
Range
,
BatchSubmitter
}
from
'
.
'
import
{
Block
Range
,
BatchSubmitter
}
from
'
.
'
export
class
StateBatchSubmitter
extends
BatchSubmitter
{
export
class
StateBatchSubmitter
extends
BatchSubmitter
{
// TODO: Change this so that we calculate start = scc.totalElements() and end = ctc.totalElements()!
// TODO: Change this so that we calculate start = scc.totalElements() and end = ctc.totalElements()!
...
@@ -116,7 +116,7 @@ export class StateBatchSubmitter extends BatchSubmitter {
...
@@ -116,7 +116,7 @@ export class StateBatchSubmitter extends BatchSubmitter {
return
return
}
}
public
async
_getBatchStartAndEnd
():
Promise
<
Range
>
{
public
async
_getBatchStartAndEnd
():
Promise
<
Block
Range
>
{
this
.
logger
.
info
(
'
Getting batch start and end for state batch submitter...
'
)
this
.
logger
.
info
(
'
Getting batch start and end for state batch submitter...
'
)
const
startBlock
:
number
=
const
startBlock
:
number
=
(
await
this
.
chainContract
.
getTotalElements
()).
toNumber
()
+
(
await
this
.
chainContract
.
getTotalElements
()).
toNumber
()
+
...
...
packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts
View file @
5bcd7c96
...
@@ -21,7 +21,7 @@ import {
...
@@ -21,7 +21,7 @@ import {
AppendSequencerBatchParams
,
AppendSequencerBatchParams
,
}
from
'
../transaction-chain-contract
'
}
from
'
../transaction-chain-contract
'
import
{
Range
,
BatchSubmitter
}
from
'
.
'
import
{
Block
Range
,
BatchSubmitter
}
from
'
.
'
export
interface
AutoFixBatchOptions
{
export
interface
AutoFixBatchOptions
{
fixDoublePlayedDeposits
:
boolean
fixDoublePlayedDeposits
:
boolean
...
@@ -127,7 +127,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
...
@@ -127,7 +127,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
}
}
public
async
_onSync
():
Promise
<
TransactionReceipt
>
{
public
async
_onSync
():
Promise
<
TransactionReceipt
>
{
const
pendingQueueElements
=
await
this
.
chainContract
.
getNumPendingQueueElements
()
const
pendingQueueElements
=
await
this
.
chainContract
.
getNumPendingQueueElements
()
this
.
logger
.
debug
(
'
Got number of pending queue elements
'
,
{
this
.
logger
.
debug
(
'
Got number of pending queue elements
'
,
{
pendingQueueElements
,
pendingQueueElements
,
})
})
...
@@ -173,7 +174,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
...
@@ -173,7 +174,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
return
return
}
}
public
async
_getBatchStartAndEnd
():
Promise
<
Range
>
{
public
async
_getBatchStartAndEnd
():
Promise
<
Block
Range
>
{
this
.
logger
.
info
(
this
.
logger
.
info
(
'
Getting batch start and end for transaction batch submitter...
'
'
Getting batch start and end for transaction batch submitter...
'
)
)
...
@@ -228,10 +229,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
...
@@ -228,10 +229,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
return
return
}
}
const
[
const
[
batchParams
,
wasBatchTruncated
]
=
batchParams
,
await
this
.
_generateSequencerBatchParams
(
startBlock
,
endBlock
)
wasBatchTruncated
,
]
=
await
this
.
_generateSequencerBatchParams
(
startBlock
,
endBlock
)
const
batchSizeInBytes
=
encodeAppendSequencerBatch
(
batchParams
).
length
/
2
const
batchSizeInBytes
=
encodeAppendSequencerBatch
(
batchParams
).
length
/
2
this
.
logger
.
debug
(
'
Sequencer batch generated
'
,
{
this
.
logger
.
debug
(
'
Sequencer batch generated
'
,
{
batchSizeInBytes
,
batchSizeInBytes
,
...
@@ -390,11 +389,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
...
@@ -390,11 +389,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
}
}
let
isEqual
=
true
let
isEqual
=
true
const
[
const
[
queueEleHash
,
timestamp
,
blockNumber
]
=
queueEleHash
,
await
this
.
chainContract
.
getQueueElement
(
queueIndex
)
timestamp
,
blockNumber
,
]
=
await
this
.
chainContract
.
getQueueElement
(
queueIndex
)
// TODO: Verify queue element hash equality. The queue element hash can be computed with:
// TODO: Verify queue element hash equality. The queue element hash can be computed with:
// keccak256( abi.encode( msg.sender, _target, _gasLimit, _data))
// keccak256( abi.encode( msg.sender, _target, _gasLimit, _data))
...
@@ -458,19 +454,18 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
...
@@ -458,19 +454,18 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
for
(
const
ele
of
b
)
{
for
(
const
ele
of
b
)
{
// Look for skipped deposits
// Look for skipped deposits
while
(
true
)
{
while
(
true
)
{
const
pendingQueueElements
=
await
this
.
chainContract
.
getNumPendingQueueElements
()
const
pendingQueueElements
=
const
nextRemoteQueueElements
=
await
this
.
chainContract
.
getNextQueueIndex
()
await
this
.
chainContract
.
getNumPendingQueueElements
()
const
nextRemoteQueueElements
=
await
this
.
chainContract
.
getNextQueueIndex
()
const
totalQueueElements
=
const
totalQueueElements
=
pendingQueueElements
+
nextRemoteQueueElements
pendingQueueElements
+
nextRemoteQueueElements
// No more queue elements so we clearly haven't skipped anything
// No more queue elements so we clearly haven't skipped anything
if
(
nextQueueIndex
>=
totalQueueElements
)
{
if
(
nextQueueIndex
>=
totalQueueElements
)
{
break
break
}
}
const
[
const
[
queueEleHash
,
timestamp
,
blockNumber
]
=
queueEleHash
,
await
this
.
chainContract
.
getQueueElement
(
nextQueueIndex
)
timestamp
,
blockNumber
,
]
=
await
this
.
chainContract
.
getQueueElement
(
nextQueueIndex
)
if
(
timestamp
<
ele
.
timestamp
||
blockNumber
<
ele
.
blockNumber
)
{
if
(
timestamp
<
ele
.
timestamp
||
blockNumber
<
ele
.
blockNumber
)
{
this
.
logger
.
warn
(
'
Fixing skipped deposit
'
,
{
this
.
logger
.
warn
(
'
Fixing skipped deposit
'
,
{
...
@@ -506,10 +501,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
...
@@ -506,10 +501,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
const
fixMonotonicity
=
async
(
b
:
Batch
):
Promise
<
Batch
>
=>
{
const
fixMonotonicity
=
async
(
b
:
Batch
):
Promise
<
Batch
>
=>
{
this
.
logger
.
debug
(
'
Fixing monotonicity...
'
)
this
.
logger
.
debug
(
'
Fixing monotonicity...
'
)
// The earliest allowed timestamp/blockNumber is the last timestamp submitted on chain.
// The earliest allowed timestamp/blockNumber is the last timestamp submitted on chain.
const
{
const
{
lastTimestamp
,
lastBlockNumber
}
=
lastTimestamp
,
await
this
.
_getLastTimestampAndBlockNumber
()
lastBlockNumber
,
}
=
await
this
.
_getLastTimestampAndBlockNumber
()
let
earliestTimestamp
=
lastTimestamp
let
earliestTimestamp
=
lastTimestamp
let
earliestBlockNumber
=
lastBlockNumber
let
earliestBlockNumber
=
lastBlockNumber
this
.
logger
.
debug
(
'
Determined earliest timestamp and blockNumber
'
,
{
this
.
logger
.
debug
(
'
Determined earliest timestamp and blockNumber
'
,
{
...
@@ -525,16 +518,15 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
...
@@ -525,16 +518,15 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
// updateLatestTimestampAndBlockNumber is a helper which updates
// updateLatestTimestampAndBlockNumber is a helper which updates
// the latest timestamp and block number based on the pending queue elements.
// the latest timestamp and block number based on the pending queue elements.
const
updateLatestTimestampAndBlockNumber
=
async
()
=>
{
const
updateLatestTimestampAndBlockNumber
=
async
()
=>
{
const
pendingQueueElements
=
await
this
.
chainContract
.
getNumPendingQueueElements
()
const
pendingQueueElements
=
const
nextRemoteQueueElements
=
await
this
.
chainContract
.
getNextQueueIndex
()
await
this
.
chainContract
.
getNumPendingQueueElements
()
const
nextRemoteQueueElements
=
await
this
.
chainContract
.
getNextQueueIndex
()
const
totalQueueElements
=
const
totalQueueElements
=
pendingQueueElements
+
nextRemoteQueueElements
pendingQueueElements
+
nextRemoteQueueElements
if
(
nextQueueIndex
<
totalQueueElements
)
{
if
(
nextQueueIndex
<
totalQueueElements
)
{
const
[
const
[
queueEleHash
,
queueTimestamp
,
queueBlockNumber
]
=
queueEleHash
,
await
this
.
chainContract
.
getQueueElement
(
nextQueueIndex
)
queueTimestamp
,
queueBlockNumber
,
]
=
await
this
.
chainContract
.
getQueueElement
(
nextQueueIndex
)
latestTimestamp
=
queueTimestamp
latestTimestamp
=
queueTimestamp
latestBlockNumber
=
queueBlockNumber
latestBlockNumber
=
queueBlockNumber
}
else
{
}
else
{
...
@@ -652,11 +644,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
...
@@ -652,11 +644,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
queueIndex
:
number
,
queueIndex
:
number
,
queueElement
:
BatchElement
queueElement
:
BatchElement
):
Promise
<
BatchElement
>
{
):
Promise
<
BatchElement
>
{
const
[
const
[
queueEleHash
,
timestamp
,
blockNumber
]
=
queueEleHash
,
await
this
.
chainContract
.
getQueueElement
(
queueIndex
)
timestamp
,
blockNumber
,
]
=
await
this
.
chainContract
.
getQueueElement
(
queueIndex
)
if
(
if
(
timestamp
>
queueElement
.
timestamp
&&
timestamp
>
queueElement
.
timestamp
&&
...
...
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